/* ============================================
   BASE.CSS — Design Tokens, Reset, Typography, Dark Mode
   Sistema de Manuais S2 Tech
   ============================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Colors - Light */
  --color-primary: #1a1d2e;
  --color-primary-light: #2a2d3e;
  --color-accent: #c9a84c;
  --color-accent-light: #dfc06a;
  --color-accent-dark: #a88a30;
  --color-bg: #f8f9fb;
  --color-surface: #ffffff;
  --color-surface-alt: #f0f1f5;
  --color-text: #1a1d2e;
  --color-text-secondary: #5a5d6e;
  --color-text-muted: #8a8d9e;
  --color-border: #e2e4ea;
  --color-border-light: #f0f1f5;

  /* Semantic Colors */
  --color-success: #22c55e;
  --color-success-bg: #f0fdf4;
  --color-success-border: #bbf7d0;
  --color-warning: #f59e0b;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;
  --color-danger: #ef4444;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;
  --color-info: #3b82f6;
  --color-info-bg: #eff6ff;
  --color-info-border: #bfdbfe;

  /* Typography */
  --font-heading: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;

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

  /* Spacing (8px grid) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Borders & Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;

  /* Z-index */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;

  /* Header */
  --header-height: 56px;
  --progress-height: 3px;
}

@media (min-width: 960px) {
  :root {
    --header-height: 64px;
  }
}

/* ---------- Dark Mode ---------- */
[data-theme="dark"] {
  --color-primary: #e2e4e9;
  --color-primary-light: #c8cad2;
  --color-bg: #0f1117;
  --color-surface: #1a1d27;
  --color-surface-alt: #22252f;
  --color-text: #e2e4e9;
  --color-text-secondary: #a0a3b1;
  --color-text-muted: #6b6e7e;
  --color-border: #2a2d3a;
  --color-border-light: #22252f;

  --color-success-bg: #052e16;
  --color-success-border: #166534;
  --color-warning-bg: #451a03;
  --color-warning-border: #92400e;
  --color-danger-bg: #450a0a;
  --color-danger-border: #991b1b;
  --color-info-bg: #172554;
  --color-info-border: #1e40af;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-primary: #e2e4e9;
    --color-primary-light: #c8cad2;
    --color-bg: #0f1117;
    --color-surface: #1a1d27;
    --color-surface-alt: #22252f;
    --color-text: #e2e4e9;
    --color-text-secondary: #a0a3b1;
    --color-text-muted: #6b6e7e;
    --color-border: #2a2d3a;
    --color-border-light: #22252f;

    --color-success-bg: #052e16;
    --color-success-border: #166534;
    --color-warning-bg: #451a03;
    --color-warning-border: #92400e;
    --color-danger-bg: #450a0a;
    --color-danger-border: #991b1b;
    --color-info-bg: #172554;
    --color-info-border: #1e40af;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + var(--progress-height) + var(--space-4));
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-light);
}

ul, ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--color-text);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

@media (min-width: 640px) {
  h1 { font-size: var(--text-4xl); }
  h2 { font-size: var(--text-3xl); }
  h3 { font-size: var(--text-2xl); }
}

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

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

/* ---------- Focus Visible ---------- */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Selection ---------- */
::selection {
  background-color: var(--color-accent);
  color: var(--color-primary);
}

/* ---------- Skip to Content ---------- */
.skip-link {
  position: fixed;
  top: -100%;
  left: var(--space-4);
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent);
  color: var(--color-primary);
  font-weight: var(--font-semibold);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 8px;
}

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

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

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

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

.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 640px) {
  .container {
    padding: 0 var(--space-6);
  }
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Print ---------- */
@media print {
  :root {
    --color-bg: #fff;
    --color-surface: #fff;
    --color-text: #000;
    --color-text-secondary: #333;
  }

  body {
    font-size: 11pt;
    line-height: 1.4;
    color: #000;
    background: #fff;
  }

  .no-print,
  .skip-link,
  .header,
  .progress-bar,
  .mobile-nav,
  .back-to-top,
  .theme-toggle,
  .search-container,
  .nav-toggle {
    display: none !important;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  .card, .callout, .table-wrapper {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-header {
    display: block !important;
    text-align: center;
    padding: 1rem 0;
    border-bottom: 2px solid #000;
    margin-bottom: 1rem;
  }
}
