/* MartinsTech Platform - Refined Design System v3.0 */
/* Design Tokens v3.0 - Maritime Precision */
/* Navy & Gold palette with refined, comfortable aesthetics */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Fira+Code:wght@400;500&display=swap');

:root {
  /* ========== BRAND COLORS ========== */

  /* Primary - Navy Blue (trust, depth, professionalism) */
  --navy-900: #001D3D;
  --navy-800: #002952;
  --navy-700: #003566;
  --navy-600: #004080;
  --navy-500: #0059B3;
  --navy-400: #3385CC;
  --navy-300: #66A3D9;
  --navy-200: #99C2E6;
  --navy-100: #CCE0F2;
  --navy-50: #E6F0F9;

  /* Accent - Gold (prestige, highlights, important actions) */
  --gold-600: #B8930F;
  --gold-500: #D4A51A;
  --gold-400: #F5CC00;
  --gold-300: #FFD633;
  --gold-200: #FFE066;
  --gold-100: #FFF0A3;
  --gold-50: #FFFBE6;

  /* ========== NEUTRAL PALETTE ========== */

  /* Warm grays with subtle blue undertone */
  --slate-950: #0C1222;
  --slate-900: #0F172A;
  --slate-800: #1E293B;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748B;
  --slate-400: #94A3B8;
  --slate-300: #CBD5E1;
  --slate-200: #E2E8F0;
  --slate-100: #F1F5F9;
  --slate-50: #F8FAFC;

  /* ========== SEMANTIC COLORS ========== */

  /* Success - Emerald (calm, positive) */
  --success-600: #059669;
  --success-500: #10B981;
  --success-400: #34D399;
  --success-100: #D1FAE5;

  /* Danger - Rose (clear but not aggressive) */
  --danger-600: #DC2626;
  --danger-500: #EF4444;
  --danger-400: #F87171;
  --danger-100: #FEE2E2;

  /* Warning - Amber (warm caution) */
  --warning-600: #D97706;
  --warning-500: #F59E0B;
  --warning-400: #FBBF24;
  --warning-100: #FEF3C7;

  /* Info - Sky (friendly information) */
  --info-600: #0284C7;
  --info-500: #0EA5E9;
  --info-400: #38BDF8;
  --info-100: #E0F2FE;

  /* ========== LIGHT MODE (DEFAULT) ========== */

  --color-bg: var(--slate-50);
  --color-bg-alt: #FFFFFF;
  --color-surface: #FFFFFF;
  --color-surface-raised: #FFFFFF;
  --color-surface-overlay: rgba(255, 255, 255, 0.95);

  --color-border: var(--slate-200);
  --color-border-subtle: var(--slate-100);
  --color-border-strong: var(--slate-300);

  --color-text-primary: var(--slate-900);
  --color-text-secondary: var(--slate-600);
  --color-text-muted: #6B7280;
  --color-text-inverse: #FFFFFF;

  /* Brand semantic mappings */
  --color-brand: var(--navy-700);
  --color-brand-light: var(--navy-50);
  --color-brand-hover: var(--navy-800);

  --color-accent: var(--gold-400);
  --color-accent-hover: var(--gold-500);
  --color-accent-subtle: var(--gold-50);

  --color-success: var(--success-500);
  --color-success-bg: var(--success-100);
  --color-danger: var(--danger-500);
  --color-danger-bg: var(--danger-100);
  --color-warning: var(--warning-500);
  --color-warning-bg: var(--warning-100);
  --color-info: var(--info-500);
  --color-info-bg: var(--info-100);
  --color-success-text: #047857;
  --color-danger-text: #B91C1C;
  --color-warning-text: #B45309;
  --color-info-text: #0369A1;

  /* ========== TYPOGRAPHY ========== */

  /* Font families - warm, modern, readable */
  --font-display: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Fira Code', 'SF Mono', 'Monaco', 'Consolas', monospace;

  /* Type scale - comfortable reading */
  --text-xs: 0.75rem;     /* 12px */
  --text-sm: 0.875rem;    /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  --text-3xl: 1.875rem;   /* 30px */
  --text-4xl: 2.25rem;    /* 36px */
  --text-5xl: 3rem;       /* 48px */

  /* Font weights */
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Line heights */
  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* Letter spacing */
  --tracking-tight: -0.025em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;

  /* ========== SPACING ========== */

  --space-0: 0;
  --space-0-5: 0.125rem;  /* 2px */
  --space-1: 0.25rem;     /* 4px */
  --space-1-5: 0.375rem;  /* 6px */
  --space-2: 0.5rem;      /* 8px */
  --space-2-5: 0.625rem;  /* 10px */
  --space-3: 0.75rem;     /* 12px */
  --space-3-5: 0.875rem;  /* 14px */
  --space-4: 1rem;        /* 16px */
  --space-5: 1.25rem;     /* 20px */
  --space-6: 1.5rem;      /* 24px */
  --space-7: 1.75rem;     /* 28px */
  --space-8: 2rem;        /* 32px */
  --space-9: 2.25rem;     /* 36px */
  --space-10: 2.5rem;     /* 40px */
  --space-12: 3rem;       /* 48px */
  --space-14: 3.5rem;     /* 56px */
  --space-16: 4rem;       /* 64px */
  --space-20: 5rem;       /* 80px */
  --space-24: 6rem;       /* 96px */

  /* ========== LAYOUT ========== */

  /* Border radius - refined, approachable */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  /* Border widths */
  --border-width: 1px;
  --border-width-2: 2px;

  /* Shadows - soft, layered, realistic */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.06);

  /* Focus ring — navy passes WCAG AA on all light backgrounds */
  --ring-width: 2px;
  --ring-offset: 2px;
  --ring-color: var(--navy-700);

  /* Missing variable aliases (referenced by apps) */
  --font-sans: var(--font-body);
  --text-md: 0.9375rem;    /* 15px - between sm and base */
  --ring-brand: 0 0 0 var(--ring-width) var(--color-brand);
  --color-bg-secondary: var(--color-bg-alt);
  --color-text-tertiary: var(--color-text-muted);

  /* Color scheme hint for browser-native controls */
  color-scheme: light;

  /* Container widths */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --container-2xl: 1536px;

  /* Z-index scale */
  --z-dropdown: 50;
  --z-sticky: 100;
  --z-fixed: 150;
  --z-modal-backdrop: 200;
  --z-modal: 250;
  --z-popover: 300;
  --z-tooltip: 400;
  --z-toast: 500;

  /* ========== ANIMATION ========== */

  /* Durations - comfortable, not rushed */
  --duration-75: 75ms;
  --duration-100: 100ms;
  --duration-150: 150ms;
  --duration-200: 200ms;
  --duration-300: 300ms;
  --duration-500: 500ms;

  /* Easing - smooth, natural motion */
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ========== DARK MODE ========== */

[data-theme="dark"] {
  --color-bg: var(--slate-950);
  --color-bg-alt: var(--slate-900);
  --color-surface: var(--slate-900);
  --color-surface-raised: var(--slate-800);
  --color-surface-overlay: rgba(15, 23, 42, 0.95);

  --color-border: var(--slate-700);
  --color-border-subtle: var(--slate-800);
  --color-border-strong: var(--slate-600);

  --color-text-primary: var(--slate-100);
  --color-text-secondary: var(--slate-400);
  --color-text-muted: #94A3B8;
  --color-text-inverse: var(--slate-900);

  --color-brand: var(--navy-400);
  --color-brand-light: var(--navy-900);
  --color-brand-hover: var(--navy-300);

  /* Gold stays bright in dark mode for visibility */
  --color-accent: var(--gold-400);
  --color-accent-hover: var(--gold-300);
  --color-accent-subtle: rgba(245, 204, 0, 0.1);

  /* Semantic colors adjusted for dark */
  --color-success: var(--success-400);
  --color-success-bg: rgba(16, 185, 129, 0.15);
  --color-danger: var(--danger-400);
  --color-danger-bg: rgba(239, 68, 68, 0.15);
  --color-warning: var(--warning-400);
  --color-warning-bg: rgba(245, 158, 11, 0.15);
  --color-info: var(--info-400);
  --color-info-bg: rgba(14, 165, 233, 0.15);
  --color-success-text: #34D399;
  --color-danger-text: #F87171;
  --color-warning-text: #FBBF24;
  --color-info-text: #38BDF8;

  /* Focus ring — gold passes WCAG AA on all dark backgrounds */
  --ring-color: var(--gold-400);
  --color-bg-secondary: var(--color-bg-alt);
  --color-text-tertiary: var(--color-text-muted);

  /* Color scheme hint for browser-native controls */
  color-scheme: dark;

  /* Shadows for dark mode - deeper, more prominent */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

/* ========== BASE RESET ========== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--duration-200) var(--ease-out),
              color var(--duration-200) var(--ease-out);
}

/* ========== TYPOGRAPHY ========== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-tight);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); font-weight: var(--weight-medium); }

p {
  margin-bottom: var(--space-4);
  color: var(--color-text-secondary);
}

a {
  color: var(--color-brand);
  text-decoration: none;
  transition: color var(--duration-150) var(--ease-out);
}

a:hover {
  color: var(--color-brand-hover);
  text-decoration: underline;
}

a:focus-visible {
  outline: var(--ring-width) solid var(--ring-color);
  outline-offset: var(--ring-offset);
  border-radius: var(--radius-sm);
}

strong, b {
  font-weight: var(--weight-semibold);
}

small {
  font-size: var(--text-sm);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background-color: var(--color-surface);
  padding: var(--space-0-5) var(--space-1-5);
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--color-border);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background-color: var(--color-surface);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: var(--border-width) solid var(--color-border);
  overflow-x: auto;
}

pre code {
  background: transparent;
  padding: 0;
  border: none;
  font-size: inherit;
}

/* ========== FORM ELEMENTS ========== */

input, textarea, select, button {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
  margin-bottom: var(--space-1-5);
}

::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

/* Focus states */
:focus-visible {
  outline: var(--ring-width) solid var(--ring-color);
  outline-offset: var(--ring-offset);
}

/* ========== ACCESSIBILITY ========== */

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* High contrast mode */
@media (prefers-contrast: more) {
  :root {
    --color-border: var(--slate-400);
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
  }
}

/* ========== SELECTION ========== */

::selection {
  background-color: var(--gold-200);
  color: var(--navy-900);
}

[data-theme="dark"] ::selection {
  background-color: var(--gold-500);
  color: var(--navy-900);
}

/* ========== SCROLLBAR ========== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg);
}

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

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

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) var(--color-bg);
}
