/* ============================================================
   BASE — Variables, reset, typography, utilities
   Mobile-first: styles par defaut = mobile
   ============================================================ */

:root {
  /* Colors */
  --c-primary: #0f2f50;
  --c-primary-light: #173b5c;
  --c-primary-hover: #1a4a72;
  --c-accent: #2a7de1;
  --c-accent-hover: #1d6bc9;
  --c-accent-soft: #e8f1fc;
  --c-success: #0f7c4a;
  --c-success-bg: #e9f8ef;
  --c-warn: #9a6200;
  --c-warn-bg: #fff5e6;
  --c-error: #b91c1c;
  --c-error-bg: #fef2f2;
  --c-bg: #f4f7fb;
  --c-surface: #ffffff;
  --c-surface-alt: #f8fbff;
  --c-border: #d9e7f2;
  --c-border-light: #edf3f9;
  --c-text: #1a2b3c;
  --c-text-secondary: #5b7086;
  --c-text-muted: #8a9bb0;

  /* Spacing */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 12px;
  --sp-lg: 16px;
  --sp-xl: 24px;
  --sp-2xl: 32px;
  --sp-3xl: 48px;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(15, 47, 80, .06);
  --shadow-md: 0 4px 12px rgba(15, 47, 80, .08);
  --shadow-lg: 0 12px 32px rgba(15, 47, 80, .1);

  /* Sidebar */
  --sidebar-w: 260px;

  /* Transitions */
  --ease: cubic-bezier(.4, 0, .2, 1);

  /* Z-index layers */
  --z-sidebar: 100;
  --z-overlay: 200;
  --z-modal: 300;
  --z-toast: 400;
}

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

html {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { min-height: 100dvh; }

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

a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.25; }

/* === Typography ============================================ */
.text-xs   { font-size: 11px; }
.text-sm   { font-size: 13px; }
.text-base { font-size: 15px; }
.text-lg   { font-size: 17px; }
.text-xl   { font-size: 20px; }
.text-2xl  { font-size: 24px; }

.font-medium { font-weight: 500; }
.font-bold   { font-weight: 700; }
.font-black  { font-weight: 900; }

.text-muted     { color: var(--c-text-muted); }
.text-secondary { color: var(--c-text-secondary); }
.text-accent    { color: var(--c-accent); }
.text-success   { color: var(--c-success); }
.text-warn      { color: var(--c-warn); }
.text-error     { color: var(--c-error); }

/* === Utilities ============================================= */
.hidden { display: none !important; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.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;
}

/* Flex helpers */
.flex       { display: flex; }
.flex-col   { display: flex; flex-direction: column; }
.flex-wrap  { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs  { gap: var(--sp-xs); }
.gap-sm  { gap: var(--sp-sm); }
.gap-md  { gap: var(--sp-md); }
.gap-lg  { gap: var(--sp-lg); }
.gap-xl  { gap: var(--sp-xl); }

/* Grid helpers */
.grid { display: grid; }

/* === Accessibility ========================================= */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

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

@media (prefers-contrast: more) {
  :root {
    --c-border: #666;
    --c-text-muted: #555;
  }
}

/* === Dark theme ============================================ */
[data-theme="dark"] {
  --c-primary: #e2e8f0;
  --c-primary-light: #cbd5e1;
  --c-primary-hover: #94a3b8;
  --c-bg: #0f172a;
  --c-surface: #1e293b;
  --c-surface-alt: #253449;
  --c-border: #334155;
  --c-border-light: #1e293b;
  --c-text: #e2e8f0;
  --c-text-secondary: #94a3b8;
  --c-text-muted: #64748b;
  --c-accent-soft: rgba(42, 125, 225, .15);
  --c-success-bg: rgba(15, 124, 74, .15);
  --c-warn-bg: rgba(154, 98, 0, .15);
  --c-error-bg: rgba(185, 28, 28, .15);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .4);
}

[data-theme="dark"] .sidebar {
  background: #0b1120;
}

[data-theme="dark"] .login-screen {
  background: linear-gradient(135deg, #0b1120 0%, #1e293b 100%);
}

[data-theme="dark"] .login-card {
  background: var(--c-surface);
  box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .login-card__brand-name {
  color: var(--c-text);
}

[data-theme="dark"] .modal {
  background: var(--c-surface);
}

[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, .7);
}

[data-theme="dark"] .field__input,
[data-theme="dark"] .field__select,
[data-theme="dark"] .field__textarea {
  background: var(--c-surface-alt);
  border-color: var(--c-border);
  color: var(--c-text);
}

[data-theme="dark"] .event-row:hover {
  background: var(--c-surface-alt);
}

[data-theme="dark"] .data-table tr:hover td {
  background: var(--c-surface-alt);
}

[data-theme="dark"] code {
  color: var(--c-accent);
}
