/**
 * base.css — Estilos base, reset y utilidades premium
 * Enterprise SaaS Dark UI — KOVE Moto Perú
 */

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

html {
  font-size: 14px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
  scrollbar-width: thin;
  scrollbar-color: rgba(50, 166, 170, 0.2) transparent;
}

[data-theme="light"] {
  color-scheme: light;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(50, 166, 170, 0.05), transparent 60%),
    radial-gradient(circle at 90% 90%, rgba(50, 166, 170, 0.03), transparent 35%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition:
    background-color var(--dur-micro) var(--easing),
    color var(--dur-micro) var(--easing);
}

/* ══════════════════════════════════════════════
   TIPOGRAFÍA PREMIUM
   ══════════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  line-height: 1.15;
  text-wrap: balance;
}

h1 { font-size: 2rem;   letter-spacing: 0.08em; }
h2 { font-size: 1.5rem; letter-spacing: 0.07em; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem;   }

/* Clases editoriales opcionales */
.editorial {
  font-family: var(--font-editorial);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.editorial-i {
  font-family: var(--font-editorial);
  font-style: italic;
  font-weight: 400;
  text-transform: none;
}

/* Números monoespaciados */
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

p {
  color: var(--text-secondary);
  line-height: 1.6;
}

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

a:hover {
  color: var(--accent-light);
  text-shadow: 0 0 10px var(--accent-glow);
}

code, pre, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ══════════════════════════════════════════════
   SELECCIÓN Y FOCO
   ══════════════════════════════════════════════ */
::selection {
  background: rgba(50, 166, 170, 0.3);
  color: #fff;
}

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

/* ══════════════════════════════════════════════
   SCROLLBARS PREMIUM
   ══════════════════════════════════════════════ */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(50, 166, 170, 0.4);
}

/* ══════════════════════════════════════════════
   UTILIDADES DE TEXTO
   ══════════════════════════════════════════════ */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-green { color: var(--status-green); }
.text-red { color: var(--status-red); }
.text-amber { color: var(--status-amber); }
.text-blue { color: var(--status-blue); }

.bg-subtle { background-color: var(--bg-secondary); }
.bg-elevated { background-color: var(--bg-elevated); }

/* ══════════════════════════════════════════════
   UTILIDADES DE LAYOUT
   ══════════════════════════════════════════════ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.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); }

.w-full { width: 100%; }
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ══════════════════════════════════════════════
   EMPTY STATES
   ══════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-6);
  text-align: center;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(12, 16, 24, 0.4) 100%);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
  margin: var(--space-4) 0;
}

.empty-state-icon {
  font-size: 2.5rem;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  filter: drop-shadow(0 0 12px rgba(50, 166, 170, 0.2));
}

.empty-state-title {
  font-size: 1.15rem;
  margin-bottom: var(--space-2);
}

.empty-state-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 440px;
}

/* ══════════════════════════════════════════════
   DELTA / TREND BADGES
   ══════════════════════════════════════════════ */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.02em;
}

.delta-up {
  color: var(--status-green-text);
  background: var(--status-green-bg);
}

.delta-down {
  color: var(--status-red);
  background: var(--status-red-bg);
}

/* ══════════════════════════════════════════════
   AVATAR INITIALS
   ══════════════════════════════════════════════ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-family: var(--font-condensed);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 0.72rem;
}

.avatar-md {
  width: 40px;
  height: 40px;
  font-size: 0.82rem;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 1rem;
}

.avatar-accent {
  background: var(--accent-subtle-strong);
  color: var(--accent-light);
  border: 1px solid rgba(50, 166, 170, 0.3);
}

.avatar-muted {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

/* ══════════════════════════════════════════════
   PROGRESS BARS
   ══════════════════════════════════════════════ */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: var(--space-2);
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width var(--transition-slow);
  position: relative;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--shimmer-gradient);
  background-size: var(--shimmer-size);
  animation: shimmerScan var(--dur-shimmer) linear infinite;
  border-radius: var(--radius-pill);
}

.progress-green .progress-bar-fill { background: var(--status-green); }
.progress-amber .progress-bar-fill { background: var(--status-amber); }
.progress-accent .progress-bar-fill { background: var(--accent); }

/* ══════════════════════════════════════════════
   SEPARATOR LINE
   ══════════════════════════════════════════════ */
.separator {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-3) 0;
}

/* ══════════════════════════════════════════════
   ANIMACIONES DE ENTRADA — Stagger System
   ══════════════════════════════════════════════ */
.page-enter {
  opacity: 0;
  transform: translateY(12px);
  animation: pageEnter var(--dur-page) var(--easing) forwards;
}

@keyframes pageEnter {
  to { opacity: 1; transform: translateY(0); }
}

/* Hijos con stagger automático */
.stagger > * {
  opacity: 0;
  transform: translateY(10px);
  animation: pageEnter var(--dur-page) var(--easing) forwards;
}
.stagger > *:nth-child(1)  { animation-delay:   0ms; }
.stagger > *:nth-child(2)  { animation-delay:  60ms; }
.stagger > *:nth-child(3)  { animation-delay: 120ms; }
.stagger > *:nth-child(4)  { animation-delay: 180ms; }
.stagger > *:nth-child(5)  { animation-delay: 240ms; }
.stagger > *:nth-child(6)  { animation-delay: 300ms; }
.stagger > *:nth-child(7)  { animation-delay: 360ms; }
.stagger > *:nth-child(8)  { animation-delay: 420ms; }
.stagger > *:nth-child(9)  { animation-delay: 480ms; }
.stagger > *:nth-child(10) { animation-delay: 540ms; }

/* Reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
  .page-enter, .stagger > * {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ══════════════════════════════════════════════
   KEYFRAMES — KOVE Motion System
   ══════════════════════════════════════════════ */

/* Shimmer sweep diagonal */
@keyframes shimmerScan {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

/* Glow pulsante para estados activos */
@keyframes glowPulse {
  0%, 100% { box-shadow: var(--glow-accent-xs); }
  50%       { box-shadow: var(--glow-accent-sm); }
}

/* Float suave para elementos hero */
@keyframes floatY {
  0%, 100% { transform: translateY(0);   }
  50%       { transform: translateY(-6px); }
}

/* Reveal numérico — entrada de valores KPI */
@keyframes countReveal {
  from { opacity: 0; transform: translateY(10px) scale(0.92); filter: blur(3px); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    filter: blur(0);   }
}

/* Pop de íconos en nav / acciones */
@keyframes iconPop {
  0%   { transform: scale(1);    }
  42%  { transform: scale(1.38); }
  70%  { transform: scale(0.88); }
  100% { transform: scale(1);    }
}

/* Border glow animado */
@keyframes borderGlow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(50,166,170,0.18), var(--glow-accent-xs); }
  50%       { box-shadow: 0 0 0 1px rgba(50,166,170,0.40), var(--glow-accent-sm); }
}

/* Scan-line sweep — barre la pantalla */
@keyframes scanSwipe {
  0%   { transform: translateY(-8px); opacity: 0; }
  8%   { opacity: 0.6; }
  92%  { opacity: 0.6; }
  100% { transform: translateY(calc(100vh + 8px)); opacity: 0; }
}

/* Status dot pulsante mejorado */
@keyframes statusPulseLive {
  0%, 100% { transform: scale(1);    opacity: 1;   }
  50%       { transform: scale(1.65); opacity: 0.5; }
}

/* Entrada de card desde abajo con fade */
@keyframes cardSlideUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Breath — para badges MUY CALIENTE */
@keyframes breatheBadge {
  0%, 100% { transform: scale(1);    box-shadow: 0 0  6px rgba(239,68,68,0.30); }
  50%       { transform: scale(1.04); box-shadow: 0 0 14px rgba(239,68,68,0.55); }
}

/* Entrada escalonada de filas de tabla */
@keyframes rowEntry {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Tabla con stagger: cada <tr> consume --row-index asignado por tilt.js */
.data-table tbody tr,
.table tbody tr {
  animation: rowEntry 200ms var(--easing-decelerate) both;
  animation-delay: calc(var(--row-index, 0) * 25ms);
}

@media (prefers-reduced-motion: reduce) {
  .data-table tbody tr,
  .table tbody tr {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ══════════════════════════════════════════════
   CLASES DE ANIMACIÓN — Utilities
   ══════════════════════════════════════════════ */

/* Shimmer activo sobre un elemento */
.shimmer-active {
  position: relative;
  overflow: hidden;
}
.shimmer-active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--shimmer-gradient);
  background-size: var(--shimmer-size);
  animation: shimmerScan var(--dur-shimmer) linear infinite;
  pointer-events: none;
  border-radius: inherit;
}

/* Reveal numérico */
.num-reveal {
  animation: countReveal 360ms var(--easing) both;
}

/* Glow pulsante en border */
.glow-pulse-border {
  animation: borderGlow 2s ease-in-out infinite;
}

/* Float suave */
.float-anim {
  animation: floatY var(--dur-float) ease-in-out infinite;
}

/* Card slide-up con stagger */
.card-appear {
  animation: cardSlideUp 320ms var(--easing) both;
}

/* Status dot mejorado */
.status-dot-live {
  display: inline-block;
  animation: statusPulseLive 2400ms ease-in-out infinite;
}

/* Reducción de movimiento — todos los nuevos keyframes */
@media (prefers-reduced-motion: reduce) {
  .shimmer-active::after,
  .num-reveal,
  .glow-pulse-border,
  .float-anim,
  .card-appear,
  .status-dot-live {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
