/**
 * Foundation Design System
 * Warm Neutrals Theme - Calming, Professional Interface
 */

:root {
  /* ===== COLOR SYSTEM ===== */
  /* Sophisticated Slate Theme - Calm, Professional, Minimal */

  /* Primary Brand - Muted Slate Blue */
  --color-primary: #5C6B7A;
  --color-primary-dark: #465563;
  --color-primary-light: #7A8A99;
  --color-primary-hover: #4E5D6B;

  /* Sidebar - Dark Slate */
  --sidebar-gradient: linear-gradient(180deg, #2D3748 0%, #1A202C 100%);
  --sidebar-bg: #2D3748;
  --sidebar-text: rgba(255, 255, 255, 0.92);
  --sidebar-text-muted: rgba(255, 255, 255, 0.6);
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: rgba(255, 255, 255, 0.12);

  /* Backgrounds - Very Subtle, Clean */
  --color-bg-body: #F7F8FA;
  --color-bg-card: #FFFFFF;
  --color-bg-sidebar: #2D3748;
  --color-bg-muted: #F1F3F5;
  --color-bg-hover: #E9ECEF;
  --color-bg-input: #FFFFFF;
  --color-bg-header: #FFFFFF;

  /* Text - Neutral Slate */
  --color-text-primary: #1A202C;
  --color-text-secondary: #4A5568;
  --color-text-muted: #718096;
  --color-text-inverse: #FFFFFF;
  --color-text-link: #5C6B7A;

  /* Semantic - Success (Very Muted Sage) */
  --color-success: #6B8E6B;
  --color-success-light: #F0F5F0;
  --color-success-text: #4A6B4A;
  --color-success-hover: #5A7D5A;

  /* Semantic - Warning (Muted Amber - very subtle) */
  --color-warning: #B89B5A;
  --color-warning-light: #FAF6EE;
  --color-warning-text: #7A6B3D;
  --color-warning-hover: #A68B4A;

  /* Semantic - Danger (Muted Dusty Rose - NOT bright red) */
  --color-danger: #9B6B6B;
  --color-danger-light: #F8F2F2;
  --color-danger-text: #6B4A4A;
  --color-danger-hover: #8A5A5A;

  /* Semantic - Info (Muted Steel Blue) */
  --color-info: #6B7B8E;
  --color-info-light: #F0F3F5;
  --color-info-text: #4A5A6B;
  --color-info-hover: #5A6A7D;

  /* Borders - Subtle Gray */
  --color-border: #E2E8F0;
  --color-border-light: #EDF2F7;
  --color-border-focus: #5C6B7A;

  /* ===== SPACING SYSTEM (Spacious) ===== */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
  --spacing-3xl: 64px;

  /* ===== TYPOGRAPHY ===== */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-base: 14px;
  --font-size-md: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 28px;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.25;
  --line-height-base: 1.5;
  --line-height-relaxed: 1.75;

  /* ===== BORDER RADIUS ===== */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* ===== SHADOWS (Warm tint) ===== */
  --shadow-sm: 0 1px 3px rgba(45, 41, 38, 0.08);
  --shadow-md: 0 4px 12px rgba(45, 41, 38, 0.1);
  --shadow-lg: 0 8px 24px rgba(45, 41, 38, 0.12);
  --shadow-xl: 0 12px 36px rgba(45, 41, 38, 0.15);

  /* ===== TRANSITIONS ===== */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* ===== Z-INDEX SCALE ===== */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal-backdrop: 900;
  --z-modal: 1000;
  --z-toast: 1100;
  --z-tooltip: 1200;

  /* ===== LAYOUT ===== */
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 70px;
  --header-height: 60px;
  --content-max-width: 1400px;
}

/* ===== BASE STYLES ===== */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text-primary);
  background-color: var(--color-bg-body);
  margin: 0;
  padding: 0;
}

/* Form controls do not inherit the page font on their own — a bare <textarea>
   renders in the browser's monospace default, which is why notes fields looked
   like code next to the rest of the app. Only font-family is set here: leaving
   font-size to each control keeps existing layouts intact. Anything that wants
   a different face (a code or monospace field) still overrides it. */
textarea,
input,
select,
button {
  font-family: inherit;
}

/* ===== RESPONSIVE - Small MacBook Pro (13" / 1440px) ===== */
@media (max-width: 1440px) {
  :root {
    --spacing-lg: 20px;
    --spacing-xl: 28px;
    --spacing-2xl: 40px;
  }

  /* Auto-collapse sidebar hint — skip when pinned or not collapsed */
  .sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
  }

  /* Reduce content padding */
  .content-area {
    padding: var(--spacing-md);
  }

  .content-card {
    padding: var(--spacing-lg);
  }

  /* Reduce table cell padding */
  .data-table th,
  .data-table td {
    padding: var(--spacing-sm) var(--spacing-md);
  }

  /* Hide optional columns on small screens */
  .col-optional {
    display: none;
  }

  /* Stack form rows on small screens */
  .form-row {
    flex-direction: column;
  }

  /* Reduce modal max-width */
  .modal-container {
    max-width: 500px;
  }

  /* Adjust page header */
  .page-header h1 {
    font-size: var(--font-size-xl);
  }
}

/* ===== RESPONSIVE - Tablet and smaller ===== */
@media (max-width: 1024px) {
  :root {
    --spacing-lg: 16px;
    --spacing-xl: 24px;
  }

  /* Force sidebar collapsed on tablet — skip when pinned or hover-expanded */
  .sidebar.collapsed {
    width: var(--sidebar-collapsed-width) !important;
    min-width: var(--sidebar-collapsed-width) !important;
  }

  /* Stack header controls */
  .header-controls {
    flex-direction: column;
    align-items: stretch;
  }

  /* Full-width search on tablet */
  .global-search-container {
    max-width: none;
    margin: var(--spacing-sm) 0;
  }
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-muted);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* ===== UTILITY CLASSES ===== */
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-info { color: var(--color-info); }

.bg-body { background-color: var(--color-bg-body); }
.bg-card { background-color: var(--color-bg-card); }
.bg-muted { background-color: var(--color-bg-muted); }

/* Hide on small screens */
@media (max-width: 1440px) {
  .hide-small { display: none !important; }
}

/* Table responsive wrapper */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(var(--spacing-md) * -1);
  padding: 0 var(--spacing-md);
}

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Selection styling */
::selection {
  background-color: var(--color-primary-light);
  color: var(--color-text-inverse);
}
