// ==========================================================================
// Monitor.Cat — Layout Shell + Utilities
// ==========================================================================

@use 'tokens' as *;

.monitorcat-wrap {
  // ---------------------------------------------------------------------------
  // Page brand header
  // ---------------------------------------------------------------------------
  .mc-page-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1.25rem 2rem 0;
  }

  .mc-brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 1rem;
    background: linear-gradient(145deg, rgba($mc-primary-light, 0.98), rgba(255, 255, 255, 0.98));
    box-shadow: 0 8px 24px rgba($mc-primary, 0.18);
    flex-shrink: 0;
    overflow: hidden;

    img {
      width: 36px;
      height: 36px;
    }
  }

  .mc-brand-text {
    flex: 1;

    h1 {
      margin-bottom: 0;
      font-size: clamp(1.4rem, 2.5vw, 1.8rem);
    }

    p {
      margin: 0;
      color: $mc-text-light;
      font-size: 0.875rem;
    }
  }

  .mc-brand-version {
    align-self: flex-start;
    margin-right: 0;
    font-family: $mc-font-heading;
    font-size: 0.8125rem;
    font-weight: 500;
    color: $mc-lavender-strong;
    background: $mc-lavender-light;
    border: 1px solid rgba($mc-lavender, 0.2);
    padding: 5px 14px;
    border-radius: $mc-radius-pill;
    white-space: nowrap;
    letter-spacing: 0.02em;
  }

  // ---------------------------------------------------------------------------
  // Main content area
  // ---------------------------------------------------------------------------
  .mc-main {
    padding: 2rem;
  }

  // ---------------------------------------------------------------------------
  // Page header (module pages)
  // ---------------------------------------------------------------------------
  .mc-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
  }

  .mc-page-title-group {
    display: flex;
    align-items: center;
    gap: 0.875rem;

    h1 {
      margin-bottom: 0;
    }
  }

  .mc-page-subtitle {
    margin: 0.125rem 0 0;
    font-size: 0.9rem;
    color: var(--mc-text-medium, #6b7280);
    font-weight: 400;
  }

  .mc-page-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  // ---------------------------------------------------------------------------
  // Empty state
  // ---------------------------------------------------------------------------
  .mc-empty-state {
    margin-top: 2rem;
  }

  .mc-empty-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 3rem 2rem;

    h2 {
      font-size: 1.25rem;
      margin-bottom: 0.5rem;
    }

    p {
      max-width: 420px;
      margin-bottom: 0;
    }
  }

  .mc-empty-illustration {
    width: 120px;
    height: auto;
    margin-bottom: 1.25rem;
    opacity: 0.85;
  }

  // ---------------------------------------------------------------------------
  // Loading state
  // ---------------------------------------------------------------------------
  .mc-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem 2rem;
    text-align: center;
  }

  .mc-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid $mc-base-alt;
    border-top-color: $mc-primary;
    border-radius: 50%;
    animation: mc-spin 0.8s linear infinite;
  }

  @keyframes mc-spin {
    to { transform: rotate(360deg); }
  }

  // ---------------------------------------------------------------------------
  // Toast notifications
  // ---------------------------------------------------------------------------
  .mc-toast-container {
    position: fixed;
    top: 40px;
    right: 24px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
  }

  .mc-toast {
    padding: 0.875rem 1.25rem;
    border-radius: $mc-radius-input;
    font-family: $mc-font-body;
    font-size: 0.9375rem;
    font-weight: 500;
    box-shadow: $mc-shadow-card;
    opacity: 0;
    transform: translateX(24px);
    transition:
      opacity 0.35s $mc-ease-spring,
      transform 0.35s $mc-ease-spring;
    pointer-events: auto;
  }

  .mc-toast-visible {
    opacity: 1;
    transform: translateX(0);
  }

  .mc-toast-success {
    background: $mc-mint-light;
    color: $mc-mint-strong;
    border: 1px solid rgba($mc-mint-strong, 0.15);
  }

  .mc-toast-error {
    background: $mc-coral-light;
    color: $mc-coral-strong;
    border: 1px solid rgba($mc-coral-strong, 0.15);
  }

  .mc-toast-warning {
    background: $mc-primary-light;
    color: $mc-primary-hover;
    border: 1px solid rgba($mc-primary, 0.15);
  }

  .mc-toast-info {
    background: $mc-cyan-light;
    color: $mc-cyan-strong;
    border: 1px solid rgba($mc-cyan-strong, 0.15);
  }

  // ---------------------------------------------------------------------------
  // Container
  // ---------------------------------------------------------------------------
  .mc-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
  }

  // ---------------------------------------------------------------------------
  // CSS Grid — auto-fit
  // ---------------------------------------------------------------------------
  .mc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
  }

  // Fixed column grids
  .mc-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .mc-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }

  .mc-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
  }

  // Responsive collapse for fixed grids
  @media (max-width: 900px) {
    .mc-grid-3,
    .mc-grid-4 {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  @media (max-width: 600px) {
    .mc-grid-2,
    .mc-grid-3,
    .mc-grid-4 {
      grid-template-columns: 1fr;
    }
  }

  // ---------------------------------------------------------------------------
  // Flexbox utilities
  // ---------------------------------------------------------------------------
  .mc-flex {
    display: flex;
  }

  .mc-flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mc-flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .mc-flex-start {
    display: flex;
    align-items: center;
    justify-content: flex-start;
  }

  .mc-flex-col {
    display: flex;
    flex-direction: column;
  }

  .mc-flex-wrap {
    flex-wrap: wrap;
  }

  .mc-flex-1 {
    flex: 1;
  }

  .mc-items-center {
    align-items: center;
  }

  .mc-items-start {
    align-items: flex-start;
  }

  // ---------------------------------------------------------------------------
  // Gap utilities
  // ---------------------------------------------------------------------------
  .mc-gap-sm { gap: $mc-space-sm; }  // 0.75rem
  .mc-gap-md { gap: $mc-space-md; }  // 1.25rem
  .mc-gap-lg { gap: $mc-space-lg; }  // 2rem

  // ---------------------------------------------------------------------------
  // Margin utilities
  // ---------------------------------------------------------------------------
  .mc-mt-sm { margin-top: $mc-space-sm; }
  .mc-mt-md { margin-top: $mc-space-md; }
  .mc-mt-lg { margin-top: $mc-space-lg; }
  .mc-mt-xl { margin-top: $mc-space-xl; }

  .mc-mb-sm { margin-bottom: $mc-space-sm; }
  .mc-mb-md { margin-bottom: $mc-space-md; }
  .mc-mb-lg { margin-bottom: $mc-space-lg; }
  .mc-mb-xl { margin-bottom: $mc-space-xl; }

  .mc-mt-0 { margin-top: 0; }
  .mc-mb-0 { margin-bottom: 0; }

  // ---------------------------------------------------------------------------
  // Padding utilities
  // ---------------------------------------------------------------------------
  .mc-p-sm { padding: $mc-space-sm; }
  .mc-p-md { padding: $mc-space-md; }
  .mc-p-lg { padding: $mc-space-lg; }
  .mc-p-xl { padding: $mc-space-xl; }

  .mc-px-sm { padding-left: $mc-space-sm; padding-right: $mc-space-sm; }
  .mc-px-md { padding-left: $mc-space-md; padding-right: $mc-space-md; }
  .mc-px-lg { padding-left: $mc-space-lg; padding-right: $mc-space-lg; }

  .mc-py-sm { padding-top: $mc-space-sm; padding-bottom: $mc-space-sm; }
  .mc-py-md { padding-top: $mc-space-md; padding-bottom: $mc-space-md; }
  .mc-py-lg { padding-top: $mc-space-lg; padding-bottom: $mc-space-lg; }

  // ---------------------------------------------------------------------------
  // Width utilities
  // ---------------------------------------------------------------------------
  .mc-w-full { width: 100%; }
  .mc-w-auto { width: auto; }

  // ---------------------------------------------------------------------------
  // Responsive
  // ---------------------------------------------------------------------------
  @media (max-width: 768px) {
    .mc-main {
      padding: 1.25rem;
    }

    .mc-page-header {
      flex-direction: column;
      align-items: flex-start;
    }
  }
}
