/* =======================================
   MODERN NEON GLASS DASHBOARD (Final Consolidado)
   ======================================= */
:root {
  --primary: #7b5cff;
  --primary-dark: #5a3ee5;
  --secondary: #0f172a;
  --accent: #00f5a0;
  --danger: #ef4444;
  --warning: #fbbf24;
  --success: #22c55e;
  --info: #3b82f6;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --bg-main: radial-gradient(circle at top left, #1e1b4b, #0f172a);
  --bg-card: rgba(255, 255, 255, 0.07);
  --blur-strong: blur(16px);
  --blur-soft: blur(6px);
  --radius: 14px;
  --shadow: 0 0 30px rgba(0, 0, 0, 0.25);
  --transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* RESET */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  font-family: "Inter", sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  letter-spacing: 0.2px;
}

/* =======================================
   LAYOUT & NAVIGATION
   ======================================= */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
  transition: var(--transition);
}
body.modal-open { overflow: hidden; }
.app-container.blur {
  filter: blur(8px) brightness(0.8);
  transition: var(--transition);
}

/* SIDEBAR */
.sidebar {
  width: 270px;
  background: rgba(20, 20, 40, 0.8);
  backdrop-filter: var(--blur-strong);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 25px;
  font-weight: 700;
  font-size: 1.2rem;
  background: linear-gradient(135deg, rgba(123,92,255,0.2), rgba(0,245,160,0.2));
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 0 15px rgba(123,92,255,0.6);
}

.nav-links {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.nav-link i, .nav-link span { z-index: 2; }

.nav-link::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  opacity: 0;
  z-index: 0;
  transition: var(--transition);
}

.nav-link:hover::before,
.nav-link.active::before {
  opacity: 0.15;
}

.nav-link:hover {
  color: #fff;
  transform: translateX(6px);
}

.nav-link.active {
  color: var(--accent);
  font-weight: 600;
}

.nav-link i {
  font-size: 1.2rem;
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  padding: 40px;
  overflow-y: auto;
  position: relative;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  background: var(--bg-card);
  backdrop-filter: var(--blur-strong);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.1);
}

.header h1 {
  font-size: 1.9em;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* =======================================
   BUTTONS & ACTIONS
   ======================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 0 15px rgba(123,92,255,0.4);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(123,92,255,0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-cancel {
  background: rgba(239,68,68,0.2);
  border: 1px solid var(--danger);
  color: #fff;
}
.btn-cancel:hover {
  background: var(--danger);
}

.btn-save {
  background: linear-gradient(135deg, var(--accent), #05c391);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 20px rgba(0,245,160,0.5);
}
.btn-save:hover { transform: scale(1.05); }

/* =======================================
   DASHBOARD STATS
   ======================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 25px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 25px;
  backdrop-filter: var(--blur-strong);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow);
  transition: var(--transition);
  animation: fadeInUp 0.6s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 0 30px rgba(123,92,255,0.3);
}

.stat-value {
  font-size: 2em;
  font-weight: bold;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-label {
  font-size: 0.9em;
  color: var(--text-muted);
  margin-top: 6px;
}

/* =======================================
   TABLES & LISTS
   ======================================= */
.table-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  backdrop-filter: var(--blur-strong);
  box-shadow: var(--shadow);
  overflow-x: auto;
  border: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 30px;
}

.data-table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
}

.data-table thead {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
}

.data-table th, .data-table td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: middle;
}

.data-table tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.08);
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: rgba(255,255,255,0.08);
}

/* STATUS BADGES - Colores de Estado */
.status-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: capitalize;
    display: inline-block;
    min-width: 80px;
    text-align: center;
    white-space: nowrap;
}

/* 1. Activa (Verde) */
.status-activa {
    background-color: var(--success, #22c55e); 
    color: #fff;
}

/* 2. Vencida (Amarillo/Naranja) */
.status-vencida {
    background-color: var(--warning, #fbbf24);
    color: #333;
}

/* 3. Inactiva/Cancelada (Rojo) */
.status-inactiva, .status-cancelada {
    background-color: var(--danger, #ef4444);
    color: #fff;
}

.actions-cell {
    white-space: nowrap;
}
.actions-cell button {
    margin: 0 2px;
}

/* =======================================
   MODAL & FORMS (Consolidado Neon Glass)
   ======================================= */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: var(--blur-soft);
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}
.modal.show { display: flex; }

.modal-content {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(25px);
  border-radius: var(--radius);
  /* padding: 25px; ELIMINADO para dar estructura */
  width: 90%;
  max-width: 600px;
  box-shadow: 0 0 30px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  animation: scaleIn 0.4s ease;
  color: var(--text-main);
  overflow: hidden; /* IMPORTANTE para contener los padding internos */
}

/* AJUSTES ESTRUCTURALES DEL MODAL (FALTA ESTO) */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* El padding se mueve a los elementos internos */
  padding: 20px 25px 0 25px; /* Top padding */
}

.modal-header h3 {
    margin-bottom: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.6em;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--danger); }

/* CUERPO DEL MODAL (Body) */
.modal-body {
    /* Padding que faltaba */
    padding: 20px 25px; 
    max-height: 70vh;
    overflow-y: auto;
    /* Aseguramos que el cuerpo ocupe el espacio */
    flex-grow: 1; 
}

/* PIE DE PÁGINA DEL MODAL (Footer) */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    /* Padding que faltaba */
    padding: 15px 25px 20px 25px; 
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* FORMS - Adaptado al tema Neon Glass */
form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }

label {
  font-weight: 600;
  font-size: 0.9em;
  color: var(--text-muted);
}

input, select, textarea {
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  font-size: 0.95em;
  background: rgba(255,255,255,0.05);
  color: #fff;
  transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(0,245,160,0.4);
  outline: none;
  background: rgba(0, 0, 0, 0.4);
  color: #fff; 
}
input::placeholder { color: rgba(255, 255, 255, 0.5); }
select { appearance: none; }


/* =======================================
   CLIENT SUMMARY MODAL STYLES (Ajustados)
   ======================================= */
.client-info h4 {
  font-size: 1.3rem;
  margin-bottom: 8px;
  color: var(--primary);
}
.subscription-list {
    list-style: none;
    padding-left: 0;
}
.subscription-list li {
    padding: 6px 0;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
    font-size: 0.95rem;
}
.total-pending {
    margin-top: 15px;
    padding: 10px;
    border-radius: var(--radius);
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
    font-weight: 600;
    text-align: center;
}

/* =======================================
   NOTIFICATIONS (ALERTAS FLOTANTES)
   ======================================= */
.notification {
  position: fixed; 
  right: 16px; 
  top: 16px; 
  background: #333; 
  color: #fff; 
  padding: 12px 18px;
  border-radius: var(--radius); 
  z-index: 9999; 
  transition: opacity .3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 250px;
}
.notification-info { background: var(--info, #3b82f6); }
.notification-success { background: var(--success, #16a34a); }
.notification-danger { background: var(--danger, #ef4444); }
.notification-warning { background: var(--warning, #fbbf24); color: #333;}


/* =======================================
   ANIMATIONS & RESPONSIVE
   ======================================= */
@keyframes fadeInUp {
  from { transform: translateY(15px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1); } }

@media (max-width: 768px) {
  .sidebar { 
    width: 100%;
    height: auto;
    position: static;
  }
  .app-container {
    flex-direction: column;
    height: auto;
  }
  .main-content { padding: 20px; }
  .header { flex-direction: column; align-items: flex-start; gap: 15px; }
  .data-table { min-width: 600px; }
}
/* =======================================
   KPI SECUNDARIO (Ganancia en Tarjeta)
   ======================================= */
.stat-secondary {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--accent); /* Color de acento para la ganancia */
    background: rgba(0, 0, 0, 0.2);
    padding: 3px 8px;
    border-radius: 6px;
}

/* --- Tooltips de KPIs (Añadir al final de style.css) --- */

/* 1. Asegurar que la tarjeta sea el 'padre' */
.stat-card {
  position: relative;
}

/* 2. El icono 'i' y su contenedor */
.kpi-info-icon {
  position: absolute;
  bottom: 10px;
  right: 12px;
  cursor: help;
  color: rgba(255, 255, 255, 0.3); /* Color sutil */
  z-index: 5; /* Asegura que esté sobre el texto */
}

/* 3. El pop-up (tooltip) - Oculto por defecto */
.kpi-info-icon .kpi-info-tooltip {
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
  
  /* Posicionamiento */
  position: absolute;
  bottom: 25px; /* Aparece 25px debajo del icono */
  right: 0; 
  
  /* Estilos de la caja */
  width: 280px; 
  background-color: #1e293b; /* Color oscuro (ajustar al de tu app) */
  color: #f1f5f9;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 10;
  
  /* Estilos del texto */
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
}

/* 4. La "flecha" del tooltip */
.kpi-info-icon .kpi-info-tooltip::after {
  content: '';
  position: absolute;
  top: 100%; /* Se posiciona arriba del tooltip */
  right: 10px; /* Alineado con el icono */
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent #1e293b transparent;
}

/* 5. Mostrar al hacer hover sobre el icono */
.kpi-info-icon:hover {
  color: rgba(255, 255, 255, 0.7); /* Aclara el icono al pasar el ratón */
}

.kpi-info-icon:hover .kpi-info-tooltip {
  visibility: visible;
  opacity: 1;
}

/*
================================
--- Estilos del Login (auth.php) ---
================================
*/

/* 1. El Fondo (body) */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  padding: 1rem;
  box-sizing: border-box; /* Asegura que el padding no cause desbordamiento */
  
  /* Usamos las variables de fondo de la app */
  background-color: var(--bg-dark, #0f172a); 
  /* Un gradiente sutil para darle profundidad */
  background-image: linear-gradient(145deg, var(--bg-dark, #0f172a) 0%, #1e293b 100%);
  
  /* Aseguramos la fuente de la app */
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* 2. La Tarjeta de Login */
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
  
  /* Usamos el color de fondo "claro" (que sigue siendo oscuro) de la app */
  background: var(--bg-light, #1e293b); 
  
  border-radius: 12px; /* Esquinas más redondeadas */
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  
  /* Sombra moderna para que "flote" */
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  
  text-align: center;
}

/* 3. Título (<h1>) */
.login-card h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-light, #f1f5f9);
  margin-top: 0;
  margin-bottom: 2rem;
  
  /* Centrar el ícono y el texto */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem; /* Espacio entre ícono y texto */
}

/* El ícono del candado */
.login-card h1 .fas {
  color: var(--primary, #3b82f6); /* Color primario de la app */
  margin-bottom: -4px; /* Ajuste visual leve */
}

/* 4. Formulario */
.login-card form {
  text-align: left;
}

/* Contenedor para Label + Input */
.form-group {
  margin-bottom: 1.5rem;
}

/* Label (Clave maestra) */
.login-card label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-muted, #94a3b8);
  margin-bottom: 0.5rem;
}

/* Input (el campo de la clave) */
.login-card .form-control {
  /* Aplicamos el estilo de .form-control que usa el resto de la app */
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-light, #f1f5f9);
  background-color: var(--bg-dark, #0f172a);
  background-clip: padding-box;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  border-radius: 8px;
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
  box-sizing: border-box; /* Importante para que el padding no rompa el ancho */
}

.login-card .form-control:focus {
  color: var(--text-light);
  background-color: var(--bg-dark);
  border-color: var(--primary, #3b82f6);
  outline: 0;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2); /* Sombra de foco */
}

/* 5. Botón */
.login-card .btn-primary {
  width: 100%; /* Botón de ancho completo */
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px; /* Le da un toque pro */
}

/* 6. Alerta de Error */
.alert.alert-danger {
  color: #f87171; /* Rojo claro */
  background-color: rgba(239, 68, 68, 0.05); /* Fondo rojo muy sutil */
  border: 1px solid rgba(239, 68, 68, 0.2); /* Borde rojo sutil */
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  text-align: center;
}