/* ====== Design System v3.4 — Metallic Blue ====== */

:root {
  /* Azul metálico (del logo) */
  --color-primary: #1e40af;          /* azul royal */
  --color-primary-dark: #172554;     /* azul medianoche */
  --color-primary-light: #3b82f6;    /* azul brillante */
  --color-primary-glow: #60a5fa;     /* azul resplandor */

  /* Plata / Acero */
  --color-silver: #94a3b8;
  --color-silver-light: #cbd5e1;
  --color-silver-dark: #64748b;
  --color-steel: #475569;

  /* Acentos */
  --color-accent: #06b6d4;           /* cyan eléctrico para CTAs especiales */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;

  /* Textos */
  --color-text: #0f172a;
  --color-text-soft: #334155;
  --color-text-muted: #64748b;
  --color-text-inverse: #f8fafc;

  /* Fondos */
  --color-bg: #f1f5f9;
  --color-bg-soft: #f8fafc;
  --color-card: #ffffff;
  --color-card-elevated: #ffffff;

  /* Bordes */
  --color-border: #e2e8f0;
  --color-border-soft: #f1f5f9;
  --color-border-metal: #cbd5e1;

  /* Sombras frías (azuladas) */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 24px -6px rgba(15, 23, 42, 0.12), 0 4px 8px -2px rgba(15, 23, 42, 0.06);
  --shadow-xl: 0 24px 48px -12px rgba(15, 23, 42, 0.18);
  --shadow-blue: 0 8px 24px -4px rgba(30, 64, 175, 0.25);
  --shadow-blue-lg: 0 16px 40px -8px rgba(30, 64, 175, 0.35);

  /* Radios */
  --radius-sm: 0.5rem;
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-2xl: 1.5rem;

  /* Gradientes metálicos */
  --gradient-primary: linear-gradient(135deg, #1e40af 0%, #172554 100%);
  --gradient-primary-hover: linear-gradient(135deg, #2451c9 0%, #1e3a8a 100%);
  --gradient-silver: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 50%, #cbd5e1 100%);
  --gradient-steel: linear-gradient(135deg, #475569 0%, #1e293b 100%);
  --gradient-hero: linear-gradient(135deg, #1e3a8a 0%, #172554 50%, #0f172a 100%);
  --gradient-card-shine: linear-gradient(135deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0) 100%);
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-feature-settings: 'cv11', 'ss01', 'cv02';
  background: var(--color-bg);
  color: var(--color-text);
  letter-spacing: -0.011em;
}

h1, h2, h3, h4 { letter-spacing: -0.022em; font-weight: 700; color: var(--color-text); }
h1 { letter-spacing: -0.035em; font-weight: 800; }

/* === Botones === */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.65rem 1.3rem; font-weight: 600; font-size: 0.875rem;
  border-radius: var(--radius); transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer; border: none; text-decoration: none; position: relative;
  line-height: 1.25;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn-primary, .btn-brand {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-blue), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-primary:hover, .btn-brand:hover {
  background: var(--gradient-primary-hover);
  box-shadow: var(--shadow-blue-lg), inset 0 1px 0 rgba(255,255,255,0.2);
}

.btn-secondary {
  background: var(--color-card);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--color-bg); border-color: var(--color-border-metal); box-shadow: var(--shadow-md); }

.btn-silver {
  background: var(--gradient-silver);
  color: var(--color-text);
  border: 1px solid var(--color-border-metal);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.6);
}

.btn-success { background: var(--color-success); color: white; box-shadow: 0 4px 12px -2px rgba(16,185,129,0.3); }
.btn-warning { background: var(--color-warning); color: white; box-shadow: 0 4px 12px -2px rgba(245,158,11,0.3); }
.btn-danger { background: var(--color-error); color: white; box-shadow: 0 4px 12px -2px rgba(239,68,68,0.3); }
.btn-ghost { background: transparent; color: var(--color-text-soft); box-shadow: none; }
.btn-ghost:hover { background: var(--color-border-soft); color: var(--color-text); }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.95rem 1.85rem; font-size: 1rem; }

/* === Cards === */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.card-hover:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--color-border-metal);
}

.card-padded { padding: 1.5rem; }

.card-gradient {
  background: var(--gradient-primary);
  color: white;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: var(--shadow-blue);
  position: relative;
  overflow: hidden;
}
.card-gradient::before {
  content: ''; position: absolute; inset: 0;
  background: var(--gradient-card-shine);
  pointer-events: none;
}
.card-gradient > * { position: relative; z-index: 1; }

.card-metal {
  background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
  border: 1px solid var(--color-border-metal);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.7);
}

/* === KPIs === */
.kpi {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--gradient-primary); opacity: 0;
  transition: opacity 0.2s ease;
}
.kpi:hover::before { opacity: 1; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.kpi-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--color-text-muted); }
.kpi-value { font-size: 2rem; font-weight: 800; margin-top: 0.5rem; letter-spacing: -0.03em; }
.kpi-sub { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.25rem; font-weight: 500; }

.kpi-gradient {
  background: var(--gradient-primary);
  color: white;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: var(--shadow-blue);
  position: relative;
}
.kpi-gradient::before { display: none; }
.kpi-gradient::after {
  content: ''; position: absolute; inset: 0; border-radius: var(--radius-lg);
  background: var(--gradient-card-shine); pointer-events: none;
}
.kpi-gradient .kpi-label, .kpi-gradient .kpi-sub { color: rgba(255,255,255,0.85); }
.kpi-gradient > * { position: relative; z-index: 1; }

/* === Inputs === */
.input, .textarea, .select {
  width: 100%; padding: 0.7rem 0.9rem; font-size: 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
  transition: all 0.15s ease;
  color: var(--color-text); font-family: inherit;
  box-shadow: inset 0 1px 2px rgba(15,23,42,0.04);
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(30, 64, 175, 0.1), inset 0 1px 2px rgba(15,23,42,0.04);
}
.input::placeholder, .textarea::placeholder { color: var(--color-silver); }

.label { display: block; font-size: 0.8125rem; font-weight: 600;
  color: var(--color-text-soft); margin-bottom: 0.45rem; }

/* === Tables === */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table thead { background: var(--color-bg-soft); }
.table th { padding: 0.75rem 1rem; text-align: left; font-weight: 700;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); }
.table td { padding: 0.875rem 1rem; border-top: 1px solid var(--color-border-soft); }
.table tbody tr { transition: background 0.15s ease; }
.table tbody tr:hover { background: var(--color-bg-soft); }

/* === Badges === */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.18rem 0.65rem; border-radius: 9999px;
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.01em;
}
.badge-success { background: rgba(16, 185, 129, 0.1); color: #047857; }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: #b45309; }
.badge-error { background: rgba(239, 68, 68, 0.1); color: #b91c1c; }
.badge-info { background: rgba(30, 64, 175, 0.1); color: #1e3a8a; }
.badge-neutral { background: var(--color-border-soft); color: var(--color-text-soft); }
.badge-metal { background: var(--gradient-silver); color: var(--color-text); border: 1px solid var(--color-border-metal); }

/* === Alerts === */
.alert { padding: 1rem 1.25rem; border-radius: var(--radius); border: 1px solid; font-size: 0.875rem;
  display: flex; align-items: flex-start; gap: 0.75rem; }
.alert-success { background: rgba(16, 185, 129, 0.06); border-color: rgba(16, 185, 129, 0.2); color: #065f46; }
.alert-error { background: rgba(239, 68, 68, 0.06); border-color: rgba(239, 68, 68, 0.2); color: #991b1b; }
.alert-info { background: rgba(30, 64, 175, 0.06); border-color: rgba(30, 64, 175, 0.2); color: #1e3a8a; }
.alert-warning { background: rgba(245, 158, 11, 0.06); border-color: rgba(245, 158, 11, 0.2); color: #92400e; }

/* === Sidebar === */
.sidebar {
  background: var(--color-card);
  border-right: 1px solid var(--color-border);
}
.sidebar-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.85rem; border-radius: var(--radius); font-size: 0.875rem;
  color: var(--color-text-soft); transition: all 0.15s ease; text-decoration: none;
  font-weight: 500;
}
.sidebar-link svg, .sidebar-link .icon { color: var(--color-silver-dark); transition: color 0.15s ease; }
.sidebar-link:hover { background: var(--color-bg-soft); color: var(--color-text); }
.sidebar-link:hover svg, .sidebar-link:hover .icon { color: var(--color-primary); }
.sidebar-link.active { background: rgba(30, 64, 175, 0.08); color: var(--color-primary-dark); font-weight: 600; }
.sidebar-link.active svg, .sidebar-link.active .icon { color: var(--color-primary); }

/* === Hero === */
.hero-gradient {
  background: var(--gradient-hero);
  color: white;
  position: relative;
  overflow: hidden;
}
.hero-gradient::before {
  content: ''; position: absolute; top: -30%; right: -10%;
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.15) 0%, transparent 60%);
  pointer-events: none;
}
.hero-gradient::after {
  content: ''; position: absolute; bottom: -50%; left: -10%;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
  pointer-events: none;
}
.hero-gradient > * { position: relative; z-index: 1; }

/* === Animaciones === */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards; }

@keyframes pulse-soft { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.pulse-soft { animation: pulse-soft 2s ease-in-out infinite; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.shimmer {
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

/* === Status dots === */
.dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; }
.dot-green { background: var(--color-success); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15); }
.dot-amber { background: var(--color-warning); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15); }
.dot-red { background: var(--color-error); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15); }
.dot-blue { background: var(--color-primary); box-shadow: 0 0 0 4px rgba(30, 64, 175, 0.15); }

/* === Icon wrapper para SVGs personalizados === */
.icon-wrap {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.25rem; height: 1.25rem;
  flex-shrink: 0;
}
.icon-wrap svg { width: 100%; height: 100%; stroke-width: 1.75; }

.icon-wrap-lg { width: 2rem; height: 2rem; }
.icon-wrap-xl { width: 3rem; height: 3rem; }

.icon-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem;
  border-radius: var(--radius);
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-blue);
}
.icon-badge svg { width: 1.25rem; height: 1.25rem; stroke-width: 2; }

.icon-badge-silver {
  background: var(--gradient-silver);
  color: var(--color-primary-dark);
  border: 1px solid var(--color-border-metal);
  box-shadow: var(--shadow-sm);
}

/* === Logo === */
.logo-mark {
  filter: drop-shadow(0 4px 8px rgba(30, 64, 175, 0.15));
}

/* === Mobile === */
@media (max-width: 768px) {
  .kpi-value { font-size: 1.75rem; }
  h1 { font-size: 1.875rem !important; }
}

/* ====== v3.4.3: Mobile drawer support ====== */
@media (max-width: 767px) {
  /* Espacio para el header móvil fijo */
  main {
    padding-top: 4rem !important;
  }
  /* Si la página no tiene .md\:flex envolvente, asegurar margen */
  body > main:not([class*="hero"]) {
    padding-top: 4.5rem;
  }
  /* Esconder sidebar default mientras carga JS para evitar flash */
  #sidebar:not([style]) {
    /* transform-translate-x-full ya lo maneja */
  }
}

/* ====== v3.4.4: Sidebar y header mobile en azul metalico oscuro ====== */
.sidebar {
  background: linear-gradient(180deg, #172554 0%, #1e3a8a 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

/* Bordes del sidebar todos en blanco semi-transparente */
.sidebar .border-slate-200 {
  border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Header del sidebar (nombre del sitio) en blanco */
.sidebar [style*="color: var(--color-primary-dark)"] {
  color: white !important;
}

/* Texto descriptivo bajo el nombre */
.sidebar .text-slate-500,
.sidebar .text-slate-400 {
  color: #94a3b8 !important;
}

/* Links del menu */
.sidebar-link {
  color: #cbd5e1 !important;
}
.sidebar-link svg,
.sidebar-link .icon {
  color: #94a3b8 !important;
}
.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  color: white !important;
}
.sidebar-link:hover svg,
.sidebar-link:hover .icon {
  color: #60a5fa !important;
}
.sidebar-link.active {
  background: rgba(96, 165, 250, 0.15) !important;
  color: white !important;
}
.sidebar-link.active svg,
.sidebar-link.active .icon {
  color: #60a5fa !important;
}

/* Etiquetas de seccion (Usuarios, Personalizacion) */
.sidebar nav > div > div:first-child {
  color: #64748b !important;
}

/* Card del avatar en sidebar usuario */
.sidebar [style*="linear-gradient(135deg, #f8fafc"] {
  background: rgba(255, 255, 255, 0.04) !important;
}

/* Badge ADMIN sobre fondo oscuro */
.sidebar .badge-info {
  background: rgba(96, 165, 250, 0.2) !important;
  color: #93c5fd !important;
}

/* Botones X de cerrar en mobile */
.sidebar button[aria-label="Cerrar"]:hover {
  background: rgba(255, 255, 255, 0.1) !important;
}

/* ====== Header móvil oscuro ====== */
.md\:hidden.fixed.top-0.bg-white {
  background: linear-gradient(180deg, #172554 0%, #1e3a8a 100%) !important;
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}
.md\:hidden.fixed.top-0 [style*="color: var(--color-primary-dark)"] {
  color: white !important;
}
.md\:hidden.fixed.top-0 button {
  color: white !important;
}
.md\:hidden.fixed.top-0 button:hover {
  background: rgba(255, 255, 255, 0.1) !important;
}
.md\:hidden.fixed.top-0 [style*="color: var(--color-primary)"]:not(.badge-info) {
  color: #60a5fa !important;
}
.md\:hidden.fixed.top-0 .badge-info {
  background: rgba(96, 165, 250, 0.2) !important;
  color: #93c5fd !important;
}

/* Brillo sutil del logo sobre fondo oscuro */

/* v3.4.5: Logo con glow brillante */
.sidebar .logo-mark,
.md\:hidden.fixed.top-0 .logo-mark {
  filter:
    drop-shadow(0 0 12px rgba(96, 165, 250, 0.7))
    drop-shadow(0 0 4px rgba(147, 197, 253, 0.5))
    brightness(1.12)
    contrast(1.08);
}
