/* ===========================================================
   Sistema de Temas Claro/Oscuro - Servisur
   =========================================================== */

/* TEMA CLARO (default) */
:root {
  --brand: #1f6feb;
  --brand-dark: #0b4fc0;
  --ink: #1c2230;
  --ink-secondary: #4b5563;
  --muted: #6b7280;
  --bg: #eef1f6;
  --bg-secondary: #f9fafb;
  --card: #ffffff;
  --line: #e6e9f0;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #e11d48;
  --shadow: 0 6px 20px rgba(20,30,60,.08);
  --radius: 18px;
  
  /* Específicos para temas */
  --appbar-bg: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  --appbar-text: #ffffff;
  --input-bg: #fbfcfe;
  --input-border: #e5e7eb;
  --hover-bg: #f3f4f6;
  --text-primary: #1c2230;
  --text-secondary: #6b7280;
}

/* TEMA OSCURO */
[data-theme="dark"] {
  --ink: #f3f4f6;
  --ink-secondary: #d1d5db;
  --muted: #9ca3af;
  --bg: #111827;
  --bg-secondary: #1f2937;
  --card: #1f2937;
  --line: #374151;
  --shadow: 0 6px 20px rgba(0,0,0,.5);
  
  /* Específicos para tema oscuro */
  --appbar-bg: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  --appbar-text: #f9fafb;
  --input-bg: #374151;
  --input-border: #4b5563;
  --hover-bg: #374151;
  --text-primary: #f3f4f6;
  --text-secondary: #d1d5db;
  
  /* Ajustes de colores para mejor contraste */
  --brand: #60a5fa;
  --brand-dark: #3b82f6;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 18px;
}

/* Toggle de tema */
.theme-toggle {
  position: relative;
  width: 54px;
  height: 28px;
  background: var(--line);
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: background .3s;
  padding: 0;
  overflow: hidden;
}

.theme-toggle::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: var(--card);
  border-radius: 50%;
  transition: transform .3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}

[data-theme="dark"] .theme-toggle::before {
  transform: translateX(26px);
}

.theme-toggle:hover {
  opacity: 0.9;
}

/* Icon dentro del toggle */
.theme-toggle-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  transition: opacity .2s;
}

.theme-toggle .sun {
  left: 6px;
}

.theme-toggle .moon {
  right: 6px;
  opacity: 0.4;
}

[data-theme="dark"] .theme-toggle .sun {
  opacity: 0.4;
}

[data-theme="dark"] .theme-toggle .moon {
  opacity: 1;
}

/* Ajustes generales para el tema oscuro */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: var(--input-bg);
  color: var(--text-primary);
  border-color: var(--input-border);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

[data-theme="dark"] label {
  color: var(--text-secondary);
}

[data-theme="dark"] .field label {
  color: var(--text-primary);
}

/* Botones ghost y chips */
[data-theme="dark"] .btn.ghost,
[data-theme="dark"] .chip {
  background: var(--card);
  color: var(--text-primary);
  border-color: var(--line);
}

[data-theme="dark"] .chip.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* Pills y badges */
[data-theme="dark"] .pill,
[data-theme="dark"] .badge {
  filter: brightness(0.85);
}

/* Banners y flash messages */
[data-theme="dark"] .banner.offline,
[data-theme="dark"] .flash.warning {
  background: #78350f;
  color: #fef3c7;
}

[data-theme="dark"] .banner.done,
[data-theme="dark"] .flash.success {
  background: #14532d;
  color: #d1fae5;
}

[data-theme="dark"] .flash.danger {
  background: #7f1d1d;
  color: #fecaca;
}

/* Stepper dots */
[data-theme="dark"] .step .dot {
  background: var(--card);
  border-color: var(--line);
}

[data-theme="dark"] .step.done .dot,
[data-theme="dark"] .step.active .dot {
  background: var(--brand);
  border-color: var(--brand);
}

/* Timeline */
[data-theme="dark"] .tl-item::before {
  background: var(--brand);
  border-color: var(--card);
}

/* Notification panel */
[data-theme="dark"] .notif-panel {
  background: var(--card);
  border-color: var(--line);
}

/* Modal en tema oscuro */
[data-theme="dark"] .modal {
  background: rgba(0,0,0,.7);
}

[data-theme="dark"] .modal-header {
  background: var(--bg-secondary);
  border-bottom-color: var(--line);
}

/* Transición suave al cambiar tema */
body {
  transition: background-color .3s ease, color .3s ease;
}

.card, .item-card, .money-card, .appbar {
  transition: background .3s ease, box-shadow .3s ease;
}
