/* =========================================
   GENESIS ENGINE V2.6 - MASTER STYLE (FULL PRODUCTION)
   ========================================= */

/* 1. RESET Y BASE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

:root {
  /* PALETA DE MARCA */
  --brand-black: #06180A;   
  --brand-berry: #862359;   
  --brand-olive: #B7B932;   
  
  /* TEMA CLARO (LIGHT) */
  --bg-app: #fafafa;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #f4f4f5;
  
  --text-main: var(--brand-black);
  --text-muted: #71717a;
  --border-color: #e4e4e7;
  
  /* ESTADOS */
  --color-primary: var(--brand-berry);
  --color-success: var(--brand-olive);
  --color-danger: #ef4444;
  
  /* DIMENSIONES Y EFECTOS */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-glow-primary: 0 4px 15px rgba(134, 35, 89, 0.3);
  --sidebar-width: 260px;
  --header-height-mobile: 80px;
  --radius: 12px;
}

/* TEMA OSCURO (DARK MODE) */
body.dark-mode {
  --bg-app: #050505;       
  --bg-sidebar: #0a0a0a;   
  --bg-card: #121212;      
  --bg-input: #1a1a1a;
  --bg-hover: #1f1f1f;
  
  --text-main: #ffffff;
  --text-muted: #a1a1aa;
  --border-color: #27272a;
  
  --color-primary: #d9468f; 
  --color-success: #eef255; 
  
  --shadow-card: 0 4px 20px rgba(0,0,0,0.5);
  --shadow-glow-primary: 0 4px 25px rgba(217, 70, 143, 0.5); 
}

body {
  font-family: 'Inter Tight', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-size: 14px;
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
}

/* UTILS */
.hidden { display: none !important; }

/* =========================================
   COMPONENTES DE UI
   ========================================= */

/* BOTONES */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 12px;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  color: var(--text-main);
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-berry), #5e173e);
  color: #fff !important;
  box-shadow: var(--shadow-glow-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
  box-shadow: 0 6px 20px rgba(134, 35, 89, 0.4);
}

.btn-secondary {
  background: var(--bg-sidebar); /* Blanco en Light, Negro en Dark */
  color: var(--text-main);    /* Negro en Light, Blanco en Dark */
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* TITULOS DE PÁGINA */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* TARJETAS DE ESTADÍSTICAS (KPIs) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 36px;
  font-weight: 800;
  margin-top: 8px;
  color: var(--color-primary);
}

/* GRÁFICOS Y ANALÍTICA */
.chart-card {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  margin-bottom: 32px;
  box-shadow: var(--shadow-card);
}

.analytics-dashboard {
  display: grid;
  gap: 20px;
  margin-bottom: 40px;
  grid-template-columns: 2fr 1fr;
}

/* TARJETAS DE ASISTENTES */
.assistants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.assistant-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  transition: 0.3s;
}

.assistant-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-primary);
}

.assistant-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.assistant-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-color);
}

/* LISTAS DE NÚMEROS */
.numbers-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.number-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

/* FORMULARIOS E INPUTS */
.form-input, .form-select, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-main);
  margin-bottom: 16px;
  display: block;
  font-family: inherit;
  transition: 0.2s;
}

.form-input:focus, .form-select:focus, textarea:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(134, 35, 89, 0.1);
}

.form-label {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  display: block;
  color: var(--text-main);
}

/* FILTROS DE FECHA */
.filter-group {
  display: inline-flex;
  background: var(--bg-hover);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.filter-btn {
  background: transparent;
  border: none;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 7px;
  transition: 0.2s;
}

.filter-btn.active {
  background: var(--bg-card);
  color: var(--color-primary);
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

/* FACTURACIÓN Y BILLETERA */
.plan-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.plan-card:hover {
  transform: translateY(-5px);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-glow-primary);
}

.wallet-card {
  background: linear-gradient(135deg, var(--brand-black), #4a1331);
  color: white;
  border-radius: 16px;
  padding: 30px;
  position: relative;
  overflow: hidden;
  margin-bottom: 30px;
  box-shadow: var(--shadow-glow-primary);
}

.wallet-balance-value {
  font-size: 48px;
  font-weight: 800;
  margin: 10px 0;
  letter-spacing: -1px;
}

/* MODALES */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

.modal.show {
  display: flex !important;
}

.modal-content {
  background: var(--bg-card);
  padding: 40px;
  border-radius: 20px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
}

/* ADMIN */
.admin-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-user-row {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--brand-berry);
  padding: 16px 24px;
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* INTERRUPTOR (SWITCH) */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #e4e4e7;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: var(--color-primary);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* TABLAS (Nuevo para Historial de Facturación) */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  padding: 12px;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-weight: 600;
}
td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

/* =========================================
   DISEÑO DE ESCRITORIO (DESKTOP)
   ========================================= */
@media (min-width: 769px) {
  body {
    display: flex;
  }
  
  .mobile-header, .mobile-overlay {
    display: none !important;
  }

  /* SIDEBAR FIJO */
  .sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 50;
  }
  
  .sidebar-header {
    padding: 32px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
  }
  
  .sidebar-logo-img {
    width: 140px;
    height: auto;
    object-fit: contain;
  }
  
  .sidebar-nav {
    flex: 1;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
  }
  
  .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
  }
  
  .nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
  }
  
.nav-item.active {
    /* Fondo sólido suave del color de marca en lugar de gris/transparente */
    background-color: rgba(134, 35, 89, 0.08) !important; 
    color: var(--brand-berry) !important;
    font-weight: 800;
    border-left: 4px solid var(--brand-berry);
    /* Eliminamos el degradado que se ve sucio */
    background-image: none; 
}

/* Ajuste para Modo Oscuro (asegura legibilidad) */
body.dark-mode .nav-item.active {
    background-color: rgba(217, 70, 143, 0.15) !important;
    color: #d9468f !important; /* Berry más brillante */
    border-left-color: #d9468f;
}
  
  .sidebar-footer {
    padding: 0;
    border-top: 1px solid var(--border-color);
  }

  /* CONTENIDO PRINCIPAL */
  .main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 40px;
    width: calc(100% - var(--sidebar-width));
  }
}

/* =========================================
   DISEÑO MÓVIL (MOBILE) - TOUCH FRIENDLY V2 (FINAL)
   ========================================= */
@media (max-width: 768px) {
  
  body {
    display: block !important;
    overflow-x: hidden;
    background: var(--bg-app);
  }

  /* HEADER SUPERIOR */
  .mobile-header {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    height: 80px; 
    padding: 0 24px;
    background: var(--bg-card); 
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
  }

  .mobile-logo {
    max-width: 140px;
    height: auto;
  }

  .btn-menu {
    font-size: 28px;
    background: var(--bg-hover);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    color: var(--text-main);
    cursor: pointer; 
  }

  /* SIDEBAR (EL MENÚ) */
  .sidebar {
    display: none;
    position: fixed;
    top: 80px; /* Coincide con altura header */
    left: 0;
    width: 100%;
    height: calc(100vh - 80px);
    background: var(--bg-app);
    z-index: 1000;
    flex-direction: column;
    overflow-y: auto;
    padding-bottom: 60px;
  }

  .sidebar.open {
    display: flex !important;
    animation: slideIn 0.3s ease;
  }

  /* Ocultamos logo interno */
  .sidebar-header, .sidebar-logo-img {
    display: none !important;
  } 

  /* NAVEGACIÓN TÁCTIL (ESTILO APP) */
  .sidebar-nav {
    padding: 24px 20px;
    gap: 12px;
  }

  .nav-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 18px 24px; /* Área de toque GRANDE */
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    transition: transform 0.1s, background 0.2s;
  }

  /* Efecto al tocar con el dedo */
  .nav-item:active {
    transform: scale(0.97);
    background: var(--bg-hover);
  }

  /* Ítem Activo */
  .nav-item.active {
    background: var(--color-primary) !important;
    color: white !important;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(134, 35, 89, 0.3);
  }

  /* FOOTER DEL MENÚ (PERFIL) */
  .sidebar-footer {
    margin: 20px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
  }

  /* OVERLAY */
  .mobile-overlay {
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 900;
    display: none;
    backdrop-filter: blur(5px);
  }
  .mobile-overlay.show {
    display: block;
  }

  /* AJUSTES CONTENIDO */
  .main-content {
    margin-left: 0 !important;
    padding: 20px;
    width: 100%;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-header button {
    width: 100%;
    height: 50px;
    font-size: 16px;
  }
  
  .analytics-dashboard {
    grid-template-columns: 1fr;
  }

  .admin-user-row {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
  }

  .wallet-card {
    padding: 20px;
  }

  .wallet-balance-value {
    font-size: 36px;
  }
  
  @keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

body.auth-guard {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-in-out;
}

body.auth-guard.app-ready {
    opacity: 1;
    pointer-events: auto;
}

/* =======================================================
   REDELIVERY: ESTILO PREMIUM 
    Agentes y Marcador
   ======================================================= */

/* 1. EL MARCADOR (Targeting específico para no afectar Analítica) */
#dashboard-section .chart-card {
    /* Fondo Degradado Berry "Lujoso" */
    background: linear-gradient(135deg, #2d0f1f 0%, var(--brand-berry) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px -10px rgba(134, 35, 89, 0.5); /* Resplandor */
    border-radius: 16px;
    padding: 30px;
    position: relative;
    overflow: hidden;
}

/* Texto del Título "MARCADOR DE PRUEBA" */
#dashboard-section .chart-card h3 {
    color: white !important;
    letter-spacing: 1.5px;
    opacity: 0.9;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
    display: inline-block;
}

/* Etiquetas (Labels) */
#dashboard-section .chart-card label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Inputs y Selects dentro del Marcador */
#dashboard-section .chart-card .form-input,
#dashboard-section .chart-card .form-select {
    background: rgba(255, 255, 255, 0.1); /* Transparente */
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(5px);
}

#dashboard-section .chart-card .form-input:focus,
#dashboard-section .chart-card .form-select:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: white;
    box-shadow: 0 0 0 4px rgba(255,255,255,0.1);
}

/* Placeholder (Texto de ayuda) */
#dashboard-section .chart-card input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Botón "LLAMAR" - Debe resaltar (Color Lima/Oro) */
#dashboard-section .chart-card #btnDial {
    background-color: #B7B932; /* Tu color Brand Olive */
    color: #050505 !important;
    font-weight: 800;
    border: none;
    box-shadow: 0 5px 15px rgba(183, 185, 50, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

#dashboard-section .chart-card #btnDial:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(183, 185, 50, 0.6);
    background-color: #dbe032;
}


/* 2. TARJETAS DE AGENTES (Efecto Flotante 3D) */
.assistant-card {
    background: var(--bg-card); /* ✅ CORREGIDO: Usa variable dinámica */
    border: 1px solid var(--border-color) !important; /* Agregamos borde sutil para modo oscuro */
    /* La línea de color izquierda se mantiene porque está inline en el HTML */
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    z-index: 1;
}

/* Efecto HOVER: La tarjeta se levanta */
.assistant-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-glow-primary);
    z-index: 2;
    border-color: var(--brand-berry) !important;
}

/* Icono del Agente */
.assistant-icon {
    border: 3px solid var(--bg-app); /* ✅ CORREGIDO: Borde dinámico */
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    width: 52px;
    height: 52px;
}

/* Botón "Editar" dentro de la tarjeta */
.assistant-card button:first-of-type {
    background-color: var(--bg-hover) !important; /* ✅ CORREGIDO */
    color: var(--text-main) !important; /* ✅ CORREGIDO */
    border: 1px solid var(--border-color) !important;
    font-weight: 600;
}
.assistant-card button:first-of-type:hover {
    background-color: var(--border-color) !important;
    filter: brightness(1.1);
}
/* =========================================
   GENESIS CALENDAR (FULLCALENDAR OVERRIDES)
   ========================================= */

/* Contenedor y Tipografía */
.fc {
    font-family: 'Inter Tight', sans-serif !important;
}

/* Encabezado (Mes/Semana) */
.fc .fc-toolbar-title {
    font-size: 20px !important;
    font-weight: 800 !important;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: -0.5px;
}

/* Botones de Navegación (Hoy, Atrás, Adelante) */
.fc .fc-button-primary {
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border-color) !important;
    font-weight: 700;
    text-transform: capitalize;
    box-shadow: none !important;
    transition: all 0.2s;
}
.fc .fc-button-primary:hover {
    background-color: var(--bg-hover) !important;
    transform: translateY(-1px);
}
.fc .fc-button-primary:disabled {
    opacity: 0.6;
}

/* Días de la semana */
.fc .fc-col-header-cell-cushion {
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    padding: 10px 0 !important;
}

/* Celdas del calendario */
.fc .fc-daygrid-day-number {
    font-weight: 600;
    color: var(--text-main);
    font-size: 13px;
    padding: 8px !important;
}
.fc .fc-day-today {
    background-color: rgba(134, 35, 89, 0.03) !important; /* Berry muy suave */
}

/* LOS EVENTOS (LAS CITAS) */
.fc-event {
    border: none !important;
    border-radius: 6px !important;
    padding: 2px 4px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.1s;
}
.fc-event:hover {
    transform: scale(1.02);
    filter: brightness(1.1);
}

/* Indicador de "Hora Actual" en vista semanal */
.fc .fc-timegrid-now-indicator-line {
    border-color: var(--brand-berry);
}
.fc .fc-timegrid-now-indicator-arrow {
    border-color: var(--brand-berry);
}