/**
 * Design Tokens - Sistema de diseño completo
 * Inspirado en Apple Design + iOS Human Interface Guidelines
 */

:root {
  /* ===================================
     COLORES - Modo Claro (Default)
     =================================== */

  /* Colores de Prioridad */
  --color-primary: #007aff; /* Azul iOS - Normal */
  --color-success: #34c759; /* Verde iOS - Éxito */
  --color-warning: #ff9500; /* Naranja iOS - Importante */
  --color-critical: #ff3b30; /* Rojo iOS - Crítico */
  --color-info: #5ac8fa; /* Azul claro - Info */

  /* Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f2f2f7;
  --bg-tertiary: #e5e5ea;
  --bg-quaternary: #d1d1d6;
  --bg-overlay: rgba(0, 0, 0, 0.3);

  /* Superficies Elevadas */
  --surface-elevated: #ffffff;
  --surface-card: #ffffff;

  /* Texto */
  --text-primary: #000000;
  --text-secondary: #3c3c43;
  --text-tertiary: #8e8e93;
  --text-quaternary: #c7c7cc;
  --text-inverse: #ffffff;

  /* Bordes */
  --border-light: rgba(0, 0, 0, 0.04);
  --border-medium: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.2);

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.15);

  /* ===================================
     TIPOGRAFÍA
     =================================== */

  /* Font Family - San Francisco like */
  --font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --font-family-mono:
    "SF Mono", "Monaco", "Inconsolata", "Fira Code", "Droid Sans Mono",
    "Source Code Pro", monospace;

  /* Font Sizes */
  --font-size-xs: 0.75rem; /* 12px */
  --font-size-sm: 0.875rem; /* 14px */
  --font-size-base: 1rem; /* 16px */
  --font-size-lg: 1.125rem; /* 18px */
  --font-size-xl: 1.25rem; /* 20px */
  --font-size-2xl: 1.5rem; /* 24px */
  --font-size-3xl: 1.875rem; /* 30px */
  --font-size-4xl: 2.25rem; /* 36px */

  /* Font Weights */
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-heavy: 800;

  /* Line Heights */
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  /* Letter Spacing */
  --letter-spacing-tight: -0.01em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.025em;

  /* ===================================
     ESPACIADO (Escala 4px base)
     =================================== */

  --space-0: 0;
  --space-1: 0.25rem; /* 4px */
  --space-2: 0.5rem; /* 8px */
  --space-3: 0.75rem; /* 12px */
  --space-4: 1rem; /* 16px */
  --space-5: 1.25rem; /* 20px */
  --space-6: 1.5rem; /* 24px */
  --space-7: 1.75rem; /* 28px */
  --space-8: 2rem; /* 32px */
  --space-10: 2.5rem; /* 40px */
  --space-12: 3rem; /* 48px */
  --space-16: 4rem; /* 64px */
  --space-20: 5rem; /* 80px */

  /* ===================================
     BORDES Y RADIOS
     =================================== */

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  --border-width-thin: 1px;
  --border-width-medium: 2px;
  --border-width-thick: 4px;

  /* ===================================
     ANIMACIONES Y TRANSICIONES
     =================================== */

  --transition-instant: 100ms;
  --transition-fast: 150ms;
  --transition-base: 250ms;
  --transition-slow: 350ms;
  --transition-slower: 500ms;

  --ease-linear: linear;
  --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-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* ===================================
     DIMENSIONES Y TAMAÑOS
     =================================== */

  /* Touch Targets (iOS mínimo 44x44px) */
  --touch-target-min: 44px;
  --touch-target-comfortable: 48px;
  --touch-target-large: 56px;

  /* Contenedores */
  --container-max-width: 640px;
  --header-height: 60px;
  --bottom-nav-height: 80px;

  /* Z-Index Scale */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-popover: 600;
  --z-tooltip: 700;
  --z-toast: 800;

  /* ===================================
     EFECTOS ESPECIALES
     =================================== */

  /* Blur (iOS-like glassmorphism) */
  --blur-sm: blur(8px);
  --blur-md: blur(12px);
  --blur-lg: blur(20px);

  /* Opacity */
  --opacity-disabled: 0.4;
  --opacity-subtle: 0.6;
  --opacity-medium: 0.8;

  /* ===================================
     SAFE AREA INSETS (iPhone notch/island)
     =================================== */

  --safe-area-top: env(safe-area-inset-top);
  --safe-area-bottom: env(safe-area-inset-bottom);
  --safe-area-left: env(safe-area-inset-left);
  --safe-area-right: env(safe-area-inset-right);
}

/* ===================================
   MODO OSCURO (Dark Theme)
   =================================== */

@media (prefers-color-scheme: dark) {
  :root {
    /* Colores ajustados para modo oscuro */
    --color-primary: #0a84ff; /* Azul más brillante */
    --color-success: #30d158;
    --color-warning: #ff9f0a;
    --color-critical: #ff453a;
    --color-info: #64d2ff;

    /* Backgrounds */
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --bg-quaternary: #3a3a3c;
    --bg-overlay: rgba(255, 255, 255, 0.1);

    /* Superficies */
    --surface-elevated: #1c1c1e;
    --surface-card: #2c2c2e;

    /* Texto */
    --text-primary: #ffffff;
    --text-secondary: #ebebf5;
    --text-tertiary: #8e8e93;
    --text-quaternary: #48484a;
    --text-inverse: #000000;

    /* Bordes */
    --border-light: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.2);

    /* Sombras más sutiles en dark mode */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.7);
  }
}

/* ===================================
   TEMA FORZADO (data-theme attribute)
   =================================== */

[data-theme="light"] {
  /* Forzar modo claro (override prefers-color-scheme) */
  --color-primary: #007aff;
  --bg-primary: #ffffff;
  --text-primary: #000000;
  /* ... resto de tokens light ... */
}

[data-theme="dark"] {
  /* Forzar modo oscuro */
  --color-primary: #0a84ff;
  --bg-primary: #000000;
  --text-primary: #ffffff;
  /* ... resto de tokens dark ... */
}

/* ===================================
   UTILIDADES GLOBALES
   =================================== */

/* Variables adicionales calculadas */
:root {
  /* Contenido con safe area */
  --content-padding-top: max(var(--space-4), var(--safe-area-top));
  --content-padding-bottom: max(var(--space-4), var(--safe-area-bottom));
  --content-padding-horizontal: max(
    var(--space-4),
    var(--safe-area-left),
    var(--safe-area-right)
  );

  /* Bottom nav con safe area */
  --bottom-nav-total-height: calc(
    var(--bottom-nav-height) + var(--safe-area-bottom)
  );
}
