/* themes.css: Tema claro moderno y tema oscuro */

:root {
  --color-bg: #eff6ff;
  --color-bg-subtle: #dbeafe;
  --color-card: #ffffff;
  --color-text: #0f172a;
  --color-text-muted: #475569;
  --color-input: #ffffff;
  --color-input-text: #0f172a;
  --color-border: #93c5fd;
  --color-primary: #204fcf;      /* Azul sólido como Configuración */
  --color-primary-dark: #204fcf; /* Sin gradiente, mismo azul */
  --color-primary-hover: #3b82f6;
  --color-table-header: #1e3a8a;
  --color-table-header-text: #f8fafc;
  --color-table-row: #ffffff;
  --color-table-row-alt: #eff6ff;
  --color-nav: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  --color-nav-text: #ffffff;
  --color-label: #1e40af;
  --color-success: #059669;
  --color-error: #dc2626;
  --shadow-card: 0 1px 3px rgba(30, 58, 138, 0.06), 0 8px 24px rgba(30, 58, 138, 0.1);
  --shadow-card-hover: 0 4px 12px rgba(30, 58, 138, 0.1), 0 12px 32px rgba(30, 58, 138, 0.12);
  --radius-card: 16px;
  --radius-input: 10px;
}

/* ========== TEMA OSCURO PREMIUM ========== */
body.theme-oscuro {
  --color-bg: #0f1419;
  --color-card: #1a2332;
  --color-text: #e2e8f0;
  --color-input: #243044;
  --color-input-text: #f1f5f9;
  --color-border: #475569;
  --color-primary: #3b82f6;
  --color-primary-dark: #2563eb;
  --color-table-header: #1e3a5f;
  --color-table-header-text: #e0f2fe;
  --color-table-row: #1a2332;
  --color-table-row-alt: #151b27;
  --color-nav: #0d1321;
  --color-nav-text: #f8fafc;
  --color-label: #93c5fd;
  --color-success: #22c55e;
  --color-error: #ef4444;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Tema claro: tonalidad azul profundo */
body:not(.theme-oscuro) {
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 50%, #e0e7ff 100%) !important;
  min-height: 100vh;
}

main.theme-content {
  background: transparent !important;
  color: var(--color-text) !important;
  transition: color 0.3s ease;
}

body:not(.theme-oscuro) main.theme-content {
  background: transparent !important;
}

.card, .bg-blue-100, .bg-white, .bg-slate-800 {
  background: var(--color-card) !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
  box-shadow: var(--shadow-card);
  transition: background-color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

body:not(.theme-oscuro) .card,
body:not(.theme-oscuro) .bg-blue-100,
body:not(.theme-oscuro) .bg-white {
  background: #ffffff !important;
  border: 1px solid #93c5fd !important;
  border-radius: var(--radius-card) !important;
  box-shadow: var(--shadow-card) !important;
}

body:not(.theme-oscuro) .card:hover,
body:not(.theme-oscuro) .bg-blue-100:hover,
body:not(.theme-oscuro) .bg-white:hover {
  box-shadow: var(--shadow-card-hover) !important;
}

/* Títulos de sección en tema claro */
body:not(.theme-oscuro) h2.text-blue-600,
body:not(.theme-oscuro) h2.text-2xl {
  color: #1e3a8a !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em !important;
}

body:not(.theme-oscuro) table {
  border-radius: var(--radius-card) !important;
  overflow: hidden;
  box-shadow: var(--shadow-card) !important;
}

/* Navbar tema claro: azul profundo */
body:not(.theme-oscuro) nav {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 2px 16px rgba(30, 58, 138, 0.3) !important;
}

body:not(.theme-oscuro) nav a,
body:not(.theme-oscuro) nav span,
body:not(.theme-oscuro) nav i,
body:not(.theme-oscuro) nav button {
  color: var(--color-nav-text) !important;
}

body:not(.theme-oscuro) nav a:hover {
  color: rgba(255, 255, 255, 0.9) !important;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

/* Navbar en tema oscuro */
body.theme-oscuro nav {
  background: var(--color-nav) !important;
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3) !important;
}

body.theme-oscuro nav a,
body.theme-oscuro nav span,
body.theme-oscuro nav i,
body.theme-oscuro nav button {
  color: var(--color-nav-text) !important;
}

body.theme-oscuro nav a:hover {
  color: #93c5fd !important;
}

body.theme-oscuro nav .absolute {
  background: #1a2332 !important;
  border: 1px solid var(--color-border) !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
}

/* Inputs: bordes sutiles y focus refinado */
input, select, textarea {
  background: var(--color-input);
  color: var(--color-input-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  transition: border-color 0.2s, box-shadow 0.2s;
}

body:not(.theme-oscuro) input,
body:not(.theme-oscuro) select,
body:not(.theme-oscuro) textarea {
  background: #ffffff;
  border-color: #93c5fd;
}

body:not(.theme-oscuro) input:focus,
body:not(.theme-oscuro) select:focus,
body:not(.theme-oscuro) textarea:focus {
  outline: none !important;
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12) !important;
}

body.theme-oscuro input:focus,
body.theme-oscuro select:focus,
body.theme-oscuro textarea:focus {
  outline: none !important;
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important;
}

/* Botones primarios */
button[type="submit"], .btn-primary,
.bg-gradient-to-r.from-blue-500 {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark)) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25) !important;
  transition: transform 0.15s, box-shadow 0.15s !important;
}

body:not(.theme-oscuro) button[type="submit"]:hover,
body:not(.theme-oscuro) .btn-primary:hover {
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35) !important;
  transform: translateY(-1px);
}

body.theme-oscuro button[type="submit"]:hover,
body.theme-oscuro .btn-primary:hover {
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.45) !important;
  transform: translateY(-1px);
}

/* Tabla: encabezado con tonalidad azul */
thead, thead tr, .bg-blue-900 {
  background: var(--color-table-header) !important;
  color: var(--color-table-header-text) !important;
}

body:not(.theme-oscuro) thead,
body:not(.theme-oscuro) thead tr,
body:not(.theme-oscuro) .bg-blue-900 {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%) !important;
  border-bottom: 2px solid #1d4ed8 !important;
  color: #ffffff !important;
}

body.theme-oscuro thead {
  border-bottom: 2px solid var(--color-primary) !important;
}

thead th {
  font-weight: 600 !important;
  letter-spacing: 0.025em !important;
}

tbody tr {
  background: var(--color-table-row) !important;
  color: var(--color-text) !important;
  transition: background-color 0.15s ease;
}

tbody tr:nth-child(even) {
  background: var(--color-table-row-alt) !important;
}

body:not(.theme-oscuro) tbody tr {
  background: #ffffff !important;
}

body:not(.theme-oscuro) tbody tr:nth-child(even) {
  background: #eff6ff !important;
}

body:not(.theme-oscuro) tbody tr:hover {
  background: #dbeafe !important;
}

body.theme-oscuro tbody tr:hover {
  background: rgba(59, 130, 246, 0.08) !important;
}

/* Bordes tema claro: azul profundo */
body:not(.theme-oscuro) .border,
body:not(.theme-oscuro) .border-blue-200,
body:not(.theme-oscuro) td.border-b,
body:not(.theme-oscuro) th.border-b {
  border-color: #93c5fd !important;
}

.border, .border-blue-200,
td.border-b, th.border-b {
  border-color: var(--color-border) !important;
}

body.theme-oscuro td,
body.theme-oscuro th {
  border-color: rgba(255, 255, 255, 0.06) !important;
}

/* Labels tema claro: azul profundo */
body:not(.theme-oscuro) label,
body:not(.theme-oscuro) .text-blue-700 {
  color: #1e40af !important;
  font-weight: 500 !important;
}

body.theme-oscuro label,
body.theme-oscuro .text-blue-700 {
  color: var(--color-label) !important;
}

/* Botones de acción: Editar (amarillo) y Eliminar (rojo) */
body.theme-oscuro .bg-yellow-400,
body.theme-oscuro .bg-yellow-400:hover {
  background: linear-gradient(135deg, #facc15, #eab308) !important;
  color: #1e293b !important;
  box-shadow: 0 2px 8px rgba(250, 204, 21, 0.4) !important;
}

body.theme-oscuro .bg-red-500,
body.theme-oscuro .bg-red-500:hover {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4) !important;
}

/* Mensajes de éxito */
.text-green-700, .text-green-600 {
  color: var(--color-success) !important;
}

body.theme-oscuro .text-gray-400 {
  color: #64748b !important;
}

body.theme-oscuro .text-gray-800,
body.theme-oscuro .text-gray-900 {
  color: var(--color-text) !important;
}

/* Modal de confirmación en tema oscuro */
body.theme-oscuro #modal-eliminar > div {
  background: var(--color-card) !important;
  border: 1px solid var(--color-border) !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6) !important;
}

body.theme-oscuro #modal-eliminar .bg-gray-200 {
  background: #334155 !important;
  color: var(--color-text) !important;
}

/* ========== VENTANA FLOTANTE (TOAST) ========== */
#toast-container {
  position: fixed;
  top: 5.5rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

#toast-container > * {
  pointer-events: auto;
}

.toast-flotante {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  min-width: 300px;
  max-width: 420px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
  animation: toast-slide-in 0.35s ease-out;
  border: 1px solid;
}

body.theme-oscuro .toast-flotante {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.toast-flotante.toast-success {
  background: var(--color-card);
  border-color: var(--color-success);
  color: var(--color-text);
}

.toast-flotante.toast-success .toast-icon {
  color: var(--color-success);
}

.toast-flotante.toast-error {
  background: var(--color-card);
  border-color: var(--color-error);
  color: var(--color-text);
}

.toast-flotante.toast-error .toast-icon {
  color: var(--color-error);
}

.toast-flotante .toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.toast-flotante .toast-mensaje {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
}

.toast-flotante .toast-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, transform 0.15s;
}

.toast-flotante.toast-success .toast-btn {
  background: var(--color-success);
  color: white;
}

.toast-flotante.toast-error .toast-btn {
  background: var(--color-error);
  color: white;
}

.toast-flotante .toast-btn:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ========== LOGIN - TEMA OSCURO ========== */
body.theme-oscuro.login-page {
  background: #0f1419 !important;
}

body.theme-oscuro .login-panel {
  background: #1a2332 !important;
  border: 1px solid #475569 !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
}

body.theme-oscuro .login-panel .text-blue-600,
body.theme-oscuro .login-panel svg {
  color: #93c5fd !important;
}

body.theme-oscuro .login-panel .text-gray-900,
body.theme-oscuro .login-panel h2 {
  color: #f1f5f9 !important;
}

body.theme-oscuro .login-panel .text-gray-500,
body.theme-oscuro .login-panel p {
  color: #94a3b8 !important;
}

body.theme-oscuro .login-panel label,
body.theme-oscuro .login-panel .text-gray-700 {
  color: #e2e8f0 !important;
}

body.theme-oscuro .login-panel input {
  background: #243044 !important;
  border-color: #475569 !important;
  color: #f1f5f9 !important;
}

body.theme-oscuro .login-panel input::placeholder {
  color: #64748b;
}

body.theme-oscuro .login-panel input:focus {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important;
}

body.theme-oscuro .login-panel button[type="submit"] {
  background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.35) !important;
}

body.theme-oscuro .login-panel button[type="submit"]:hover {
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.45) !important;
}

body.theme-oscuro .login-panel .text-red-600 {
  color: #f87171 !important;
}

/* ========== LOGIN - TEMA CLARO AZUL PROFUNDO ========== */
body.theme-claro.login-page,
body.login-page:not(.theme-oscuro) {
  background: linear-gradient(160deg, #eff6ff 0%, #dbeafe 50%, #e0e7ff 100%) !important;
  min-height: 100vh;
}

body:not(.theme-oscuro) .login-panel {
  background: #ffffff !important;
  border: 1px solid #93c5fd !important;
  box-shadow: 0 4px 6px -1px rgba(30, 58, 138, 0.08), 0 20px 50px -12px rgba(30, 58, 138, 0.15) !important;
  backdrop-filter: blur(12px);
}

body:not(.theme-oscuro) .login-panel h2 {
  color: #0f172a !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em !important;
}

body:not(.theme-oscuro) .login-panel p {
  color: #64748b !important;
}

body:not(.theme-oscuro) .login-panel label {
  color: #334155 !important;
}

body:not(.theme-oscuro) .login-panel input {
  background: #ffffff !important;
  border: 1px solid #93c5fd !important;
  color: #0f172a !important;
}

body:not(.theme-oscuro) .login-panel input:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1) !important;
}

body:not(.theme-oscuro) .login-panel button[type="submit"] {
  background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4) !important;
}

body:not(.theme-oscuro) .login-panel button[type="submit"]:hover {
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45) !important;
  transform: translateY(-1px);
}

body:not(.theme-oscuro) .login-panel svg,
body:not(.theme-oscuro) .login-panel .text-blue-600 {
  color: #1e40af !important;
}

@keyframes toast-slide-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}
