/* ============================================================
   DANGOFE OS LIQUID V2 — core.css
   Tokens (variables base) + Reset
   ============================================================ */

/* ------------------------------------------------------------
   1. TOKENS GLOBALES (no dependen del tema)
   ------------------------------------------------------------ */
:root {
  /* Tipografía */
  --font-sans: 'Segoe UI', 'Inter', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;

  /* ---- Familias tipográficas seleccionables (panel Configuración) ----
     El selector de tipografía escribe --font-family-ui (settings.js
     ejecuta applyFontVar). Se aplica a toda la interfaz. */
  --font-inter: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-manrope: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-poppins: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-nunito: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-jakarta: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-system: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  /* Familia activa de la interfaz (por defecto Inter). */
  --font-family-ui: var(--font-inter);

  --fs-xs: 0.72rem;
  --fs-sm: 0.82rem;
  --fs-md: 0.95rem;
  --fs-lg: 1.15rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2.1rem;
  --fs-3xl: 2.6rem;

  /* Radios */
  --radius-outer: clamp(0px, 2.2vw, 30px);   /* contenedor exterior de la app (fluido) */
  --radius-card: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  /* Espaciado */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Márgenes del contenedor exterior (fluido: se adapta al ancho del viewport) */
  --app-margin: clamp(10px, 1.8vw, 28px);

  /* Sidebar */
  --sidebar-w: 80px;
  --sidebar-w-expanded: 230px;

  /* Acentos corporativos DANGOFE (fijos, solo para elementos de marca
     y semánticos; los reflejos ambientales usan la paleta adaptable) */
  --lava-orange: #ff7a1a;
  --lava-orange-soft: rgba(255, 122, 26, 0.35);
  --lava-red: #e6352b;
  --lava-yellow: #ffc94d;

  /* ---- Color de ACENTO de la interfaz (adaptable) ----
     Fuente de verdad del acento visual (botones, chips, tabs, focos,
     indicadores, calendario, etc.). Por defecto es el naranja
     corporativo DANGOFE; cuando hay un fondo activo con «adaptación
     ambiental», lava-scene.js lo ajusta a un tono derivado del fondo.
     Los colores SEMÁNTICOS (éxito/peligro/aviso) nunca cambian. */
  /* Fase 3B.3: el naranja YA NO es el acento predeterminado del sistema.
     El acento por defecto es NEUTRO (sigue al tema: claro=negro, oscuro=blanco).
     El naranja queda disponible solo como preset opcional del administrador
     (--accent-preset-orange) o como color semántico de advertencia. */
  --accent-rgb: 235, 235, 240;
  --accent: rgb(var(--accent-rgb));
  --accent-soft: rgba(var(--accent-rgb), 0.35);
  --accent-subtle: rgba(var(--accent-rgb), 0.10);
  --accent-preset-orange: 255, 122, 26; /* preset opcional, NO predeterminado */

  /* Botón de ACCIÓN principal por tema (Fase 3B.3):
     claro = fondo negro/texto blanco · oscuro = fondo blanco/texto negro.
     Versión 1.0.1: los valores viven ÚNICAMENTE en themes.css (ambos
     temas los definen); se retira el duplicado con valores del tema
     oscuro que aquí podía pisar al modo claro. */

  /* Alias de compatibilidad: --brand-* ahora sigue a --accent-*.
     (Única línea que conserva el nombre «brand-rgb».) */
  --brand-rgb: var(--accent-rgb);
  --brand: var(--accent);
  --brand-soft: var(--accent-soft);

  /* ---- Paleta adaptable del efecto volcánico (publicada por JS) ----
     lava-scene.js actualiza estas variables al analizar el fondo activo
     (mezcla parcial regulada por «Intensidad de adaptación»).
     Valores por defecto = paleta volcánica original. */
  --lava-primary-rgb: 255, 122, 26;   /* color dominante del flujo   */
  --lava-secondary-rgb: 255, 201, 77; /* color secundario / chispas  */
  --lava-core-rgb: 255, 245, 214;     /* núcleo incandescente        */
  --lava-glow-rgb: 255, 110, 30;      /* resplandor del vidrio (gated por «reflejos») */
  --lava-shadow-rgb: 30, 10, 4;
  /* Humo (paleta propia, adaptable con «Adaptar humo y partículas») */
  --smoke-primary-rgb: 41, 18, 15;
  --smoke-secondary-rgb: 107, 51, 33;
  /* Tinte armonizable del fallback estático (sin WebGL) */
  --fallback-hue: 0deg;
  --fallback-sat: 1;       /* sombra profunda del efecto  */
  /* Acento AMBIENTAL discreto (indicador activo del menú, bordes e
     iluminación secundaria). Gated por «bordes ambientales». */
  /* Fase 3B.3: el ambiente predeterminado es neutro (sin naranja). */
  --ambient-rgb: 148, 163, 184;

  /* (--accent y --accent-soft se definen arriba como fuente de verdad) */

  /* ---- Parámetros de vidrio configurables (futuro panel de Configuración)
     Multiplicadores neutros = 1; JS podrá ajustarlos sin tocar CSS. ----*/
  --glass-opacity-mul: 1;
  --glass-blur-mul: 1;
  /* Refuerzo mínimo de opacidad cuando el fondo es muy brillante
     (lo eleva background-manager.js para proteger la legibilidad) */
  --glass-boost: 0;

  /* Estados */
  --color-success: #3ddc84;
  --color-danger: #ff5a4e;
  --color-warning: #ffb648;
  --color-info: #6c8cff;
  --color-purple: #a06bff;

  /* Transiciones */
  --t-fast: 0.18s ease;
  --t-med: 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 0.55s cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-index — capas visuales (Fase 3):
     fondo HD (0) < efectos 3D (1) < app-shell (2).
     El contenido vive DENTRO del app-shell, por lo que su z-index es
     relativo a ese contexto de apilamiento (auto = sobre el shell). */
  --z-wallpaper: 0;
  --z-effects: 1;
  --z-shell: 2;
  --z-content: auto;
  --z-lava: 0;   /* alias histórico del canvas de lava (= efectos) */
  --z-sidebar: 30;
  --z-topbar: 20;
  --z-drawer-backdrop: 40;
  --z-drawer: 50;
  --z-modal: 100;
  --z-toast: 200;
}

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

/* Fase 3C.3-C.2.1 (punto 2): el atributo hidden SIEMPRE oculta el elemento,
   aunque una regla posterior le asigne display:flex/grid (p. ej. .ls-aviso).
   Sin esta regla, las zonas de anulación/reversión del modal de factura
   quedaban visibles a la vez pese a llevar hidden. */
[hidden] {
  display: none !important;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family-ui);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------
   MODO LIMPIO (Fase 3A.3)
   Cuando el usuario desactiva el fondo (data-wallpaper="none") y los
   efectos (data-effects="none"), la interfaz queda plana: blanco puro
   en claro y casi negro en oscuro, sin brillo de vidrio ni sombra de app.
   ------------------------------------------------------------ */
[data-theme='light'] body[data-wallpaper='none'][data-effects='none'],
[data-theme='light'] body[data-wallpaper='none']:not([data-effects]),
[data-theme='light'] body:not([data-wallpaper]):not([data-effects]) {
  --bg-page: #FFFFFF;
  --bg-app: #FFFFFF;
  --shadow-app: none;
  --glass-glow-pct: 0%;
  background: #FFFFFF;
}
[data-theme='dark'] body[data-wallpaper='none'][data-effects='none'],
[data-theme='dark'] body[data-wallpaper='none']:not([data-effects]),
[data-theme='dark'] body:not([data-wallpaper]):not([data-effects]) {
  --bg-page: #05060A;
  --bg-app: #05060A;
  --shadow-app: none;
  --glass-glow-pct: 0%;
  background: #05060A;
}

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

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

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

/* Scrollbar discreto */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 8px;
}

/* Accesibilidad: foco visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Utilidad para lectores de pantalla */
.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;
}


/* ------------------------------------------------------------
   Versión 1.0.1 — Cambio de tema ATÓMICO
   Mientras el gestor de temas conmuta data-theme se añade la
   clase .theme-switching a <html>: se suprimen TODAS las
   transiciones para que fondo y texto de los controles activos
   (pastillas de período, pestañas, botones) cambien a la vez y
   nunca quede un estado intermedio ilegible.
   ------------------------------------------------------------ */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: none !important;
}

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

/* ============================================================
   Fase 2A — Control maestro de animaciones del sistema
   body.anim-off      → Desactivadas: sin transiciones ni keyframes
   body.anim-reduced  → Reducidas: transiciones mínimas
   body.fx-*-off      → controles independientes
   ============================================================ */
body.anim-off *,
body.anim-off *::before,
body.anim-off *::after {
  animation: none !important;
  transition: none !important;
}
body.anim-off .glass-hover:hover {
  transform: none !important;
}

body.anim-reduced *,
body.anim-reduced *::before,
body.anim-reduced *::after {
  animation-duration: 0.001s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.06s !important;
}
body.anim-reduced .glass-hover:hover {
  transform: none !important;
}

/* Microanimaciones (hover, focus, botones) desactivadas */
body.fx-micro-off * {
  transition: none !important;
}
body.fx-micro-off .btn:hover,
body.fx-micro-off .sidebar__item:hover {
  transform: none !important;
}

/* Animaciones de widgets/tarjetas desactivadas */
body.fx-widgets-off .glass-hover:hover {
  transform: none !important;
  box-shadow: 0 12px 34px var(--glass-shadow), inset 0 1px 0 var(--glass-inner-hi);
}

/* Movimiento ambiental desactivado (pulsos, latidos de estado) */
body.fx-ambient-off .dot,
body.fx-ambient-off [class*='pulse'] {
  animation: none !important;
}



/* ============================================================
   Responsive móvil global (Fase 2A.1)
   Objetivos táctiles mínimos de 44x44px en controles interactivos
   para cumplir con las pautas de accesibilidad en pantallas táctiles.
   ============================================================ */
@media (max-width: 820px) {
  .btn,
  button,
  .card-action,
  .effect-btn,
  .preset-btn {
    min-height: 44px;
    min-width: 44px;
  }
}
