/**
 * ╔═══════════════════════════════════════════════════════════════╗
 * ║                    LUUK DESIGN SYSTEM                         ║
 * ║                   Design Tokens (v1.0)                        ║
 * ╚═══════════════════════════════════════════════════════════════╝
 *
 * Sistema de diseño unificado - La base de toda la UI de Luuk
 * Objetivo: Hacer que TrueContext y GoCanvas parezcan software del 2010
 *
 * ═══════════════════════════════════════════════════════════════
 *                    ESTRUCTURA DEL SISTEMA
 * ═══════════════════════════════════════════════════════════════
 *
 * Orden de carga recomendado en HTML:
 * 1. luuk-design-tokens.css  ← ESTE ARCHIVO (variables CSS, animaciones)
 * 2. luuk-components.css     ← Componentes reutilizables
 * 3. luuk-pages.css          ← Estilos específicos de página
 * 4. luuk-tables.css         ← Estilos de tablas y DataTables
 * 5. luuk-feedback.css       ← Loading, toasts, notificaciones
 *
 * ═══════════════════════════════════════════════════════════════
 *                    GUÍA DE USO RÁPIDO
 * ═══════════════════════════════════════════════════════════════
 *
 * Colores de cliente (personalizables):
 *   --color        → Color primario (acento)
 *   --color2       → Color secundario
 *   --colort       → Texto sobre color primario
 *   --coloro2      → Color primario con opacidad
 *
 * Grises neutros (usar SIEMPRE para fondos/bordes/texto):
 *   --gray-50      → Fondo secciones (#f9fafb)
 *   --gray-100     → Hover, badges (#f3f4f6)
 *   --gray-200     → Bordes (#e5e7eb)
 *   --gray-500     → Texto secundario (#6b7280)
 *   --gray-800     → Texto principal (#1f2937)
 *
 * Tipografía:
 *   --text-xs (11px), --text-sm (13px), --text-base (14px)
 *   --font-medium (500), --font-semibold (600), --font-bold (700)
 *
 * Espaciado (escala de 4px):
 *   --space-2 (8px), --space-4 (16px), --space-6 (24px)
 *
 * Bordes y sombras:
 *   --radius-sm (4px), --radius-md (6px), --radius-lg (8px)
 *   --shadow-sm, --shadow-md, --shadow-lg
 *
 * Transiciones:
 *   --duration-fast (150ms), --duration-normal (200ms)
 *   --ease-out: cubic-bezier(0, 0, 0.2, 1)
 *
 * ═══════════════════════════════════════════════════════════════
 */

/* ============================================
   ROOT VARIABLES
   ============================================ */

:root {
  /* ----------------------------------------
     COLORES PRIMARIOS (personalizables por cliente)
     Se sobrescriben inline desde el servidor
     ---------------------------------------- */
  --color: #29c178;
  --color2: #092825;
  --colort: #ffffff;
  --coloro2: rgba(41, 193, 120, 0.15);

  /* ----------------------------------------
     GRISES NEUTROS (fijos)
     ---------------------------------------- */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* ----------------------------------------
     TABLAS — JERARQUÍA VISUAL
     Zebra striping + hover + separadores para
     tablas de Usuarios, Grupos y similares
     ---------------------------------------- */
  --table-row-odd-bg: #ffffff;
  --table-row-even-bg: #fafafa;
  --table-row-hover-bg: #f3f4f6;
  --table-row-separator: #eeeeee;

  /* ----------------------------------------
     ESTADOS SEMÁNTICOS
     ---------------------------------------- */
  --success: #10b981;
  --success-light: #d1fae5;
  --success-dark: #047857;

  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --warning-dark: #b45309;

  --error: #ef4444;
  --error-light: #fee2e2;
  --error-dark: #b91c1c;

  /* Tokens semánticos de error para mensajes/badges/validación
     (legible: rojo oscuro sobre rojo claro — usado en SweetAlert2 validation, etc.) */
  --color-error-bg: #FEE2E2;
  --color-error-text: #DC2626;
  --color-error-icon: #DC2626;

  --info: #3b82f6;
  --info-light: #dbeafe;
  --info-dark: #1d4ed8;

  /* ----------------------------------------
     TIPOGRAFÍA
     ---------------------------------------- */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --text-4xl: 36px;

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

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

  /* ----------------------------------------
     ESPACIADO (escala de 4px)
     ---------------------------------------- */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* ----------------------------------------
     BORDES
     ---------------------------------------- */
  --radius-none: 0;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  --border-width: 1px;
  --border-color: var(--gray-200);
  --border: var(--border-width) solid var(--border-color);

  /* ----------------------------------------
     SOMBRAS
     ---------------------------------------- */
  --shadow-none: none;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);

  /* Focus ring */
  --ring-width: 3px;
  --ring-color: rgba(59, 130, 246, 0.3);
  --ring-focus: 0 0 0 var(--ring-width) var(--ring-color);

  /* ----------------------------------------
     TRANSICIONES
     ---------------------------------------- */
  --duration-instant: 50ms;
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
  --duration-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-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ----------------------------------------
     Z-INDEX
     ---------------------------------------- */
  --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;
}

/* ============================================
   ANIMACIONES DISTINTIVAS DE LUUK
   ============================================ */

/* Pulso del isotipo - loading principal */
@keyframes luuk-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.92);
    opacity: 0.85;
  }
}

/* Fade in con movimiento sutil */
@keyframes luuk-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade in desde arriba */
@keyframes luuk-fade-in-down {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Slide in desde la derecha */
@keyframes luuk-slide-in-right {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scale in */
@keyframes luuk-scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Shake sutil para errores */
@keyframes luuk-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Skeleton loading shimmer */
@keyframes luuk-skeleton {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Bounce sutil para notificaciones */
@keyframes luuk-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

/* Spin para spinners */
@keyframes luuk-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Ping para indicadores */
@keyframes luuk-ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* ============================================
   UTILIDADES DE ANIMACIÓN
   ============================================ */

.animate-fade-in {
  animation: luuk-fade-in var(--duration-normal) var(--ease-out);
}

.animate-fade-in-down {
  animation: luuk-fade-in-down var(--duration-normal) var(--ease-out);
}

.animate-slide-in-right {
  animation: luuk-slide-in-right var(--duration-normal) var(--ease-out);
}

.animate-scale-in {
  animation: luuk-scale-in var(--duration-fast) var(--ease-out);
}

.animate-shake {
  animation: luuk-shake var(--duration-slow) var(--ease-in-out);
}

.animate-pulse {
  animation: luuk-pulse 1.2s var(--ease-in-out) infinite;
}

.animate-bounce {
  animation: luuk-bounce 1s var(--ease-in-out) infinite;
}

.animate-spin {
  animation: luuk-spin 1s var(--ease-linear) infinite;
}

/* ============================================
   SKELETON LOADING
   ============================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--gray-100) 25%,
    var(--gray-200) 50%,
    var(--gray-100) 75%
  );
  background-size: 200% 100%;
  animation: luuk-skeleton 1.5s var(--ease-in-out) infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
}

.skeleton-text:last-child {
  width: 70%;
  margin-bottom: 0;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton-button {
  height: 36px;
  width: 100px;
}

.skeleton-card {
  height: 120px;
}

/* ============================================
   TRANSICIONES GLOBALES
   ============================================ */

/* Aplicar transición suave a elementos interactivos */
.transition-colors {
  transition-property: color, background-color, border-color;
  transition-duration: var(--duration-fast);
  transition-timing-function: var(--ease-out);
}

.transition-transform {
  transition-property: transform;
  transition-duration: var(--duration-fast);
  transition-timing-function: var(--ease-out);
}

.transition-shadow {
  transition-property: box-shadow;
  transition-duration: var(--duration-fast);
  transition-timing-function: var(--ease-out);
}

.transition-opacity {
  transition-property: opacity;
  transition-duration: var(--duration-fast);
  transition-timing-function: var(--ease-out);
}

.transition-all {
  transition-property: all;
  transition-duration: var(--duration-fast);
  transition-timing-function: var(--ease-out);
}

/* ============================================
   ESTADOS INTERACTIVOS GLOBALES
   ============================================ */

/* Focus visible mejorado para accesibilidad */
:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus);
}

/* Hover en elementos clickeables */
[role="button"]:not(:disabled):hover,
button:not(:disabled):hover,
a:hover {
  cursor: pointer;
}

/* Disabled state global */
[disabled],
.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================
   UTILIDADES DE LAYOUT
   ============================================ */

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.hidden { display: none; }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }

.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }
.flex-none { flex: none; }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ============================================
   UTILIDADES DE TEXTO
   ============================================ */

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }

.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

.text-gray-400 { color: var(--gray-400); }
.text-gray-500 { color: var(--gray-500); }
.text-gray-600 { color: var(--gray-600); }
.text-gray-700 { color: var(--gray-700); }
.text-gray-800 { color: var(--gray-800); }

.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-info { color: var(--info); }

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

/* ============================================
   IA INDICATORS (Diferenciador único de Luuk)
   ============================================ */

.ia-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: #166534;
}

.ia-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
  animation: luuk-pulse 2s var(--ease-in-out) infinite;
}

.ia-indicator-processing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--gray-600);
}

.ia-indicator-processing::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid var(--gray-300);
  border-top-color: var(--color);
  border-radius: 50%;
  animation: luuk-spin 0.8s var(--ease-linear) infinite;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .no-print {
    display: none !important;
  }

  * {
    box-shadow: none !important;
  }
}
