/* ========================================= */
/* 1. VARIABLES Y FUENTES (Modo VisionRs)    */
/* ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600&family=Segoe+UI:wght@400;600&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
    --primary: #f8fafc;       /* Slate 50 - Texto principal blanco/claro */
    --accent: #34d399;        /* Esmeralda brillante (VisionRs) */
    --accent-hover: #10b981;  /* Esmeralda oscuro */
    --success: #10b981;       /* Verde éxito */
    --danger: #ef4444;        /* Rojo alerta */
    --bg: #0f172a;            /* Slate 900 - Fondo principal re oscuro */
    --white: #1e293b;         /* Slate 800 - Fondo de paneles y tarjetas */
    --border: #334155;        /* Slate 700 - Líneas sutiles */
    --text-muted: #94a3b8;    /* Slate 400 - Textos secundarios */
    --ambar: #f59e0b;         /* Ámbar para recordatorios y alertas */
}

/* ========================================= */
/* 2. CONFIGURACIÓN BASE                     */
/* ========================================= */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--primary);
    margin: 0;
    padding: 20px;
}

/* Personalizamos la barra de scroll para que no quede gris fea */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.container {
    max-width: 900px;
    margin: auto;
}

h1, h2, h3 {
    font-family: 'Segoe UI', sans-serif;
    letter-spacing: 1px;
    color: var(--primary);
}

h1 {
    text-transform: uppercase;
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 40px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

hr {
    border: 0;
    height: 1px;
    background-image: linear-gradient(to right, transparent, var(--border), transparent);
    margin: 40px 0;
}

/* ========================================= */
/* 3. MENÚ HAMBURGUESA Y SIDEBAR             */
/* ========================================= */
.hamburger-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(5px);
    border: 1px solid var(--border);
    color: var(--accent);
    padding: 8px 15px;
    border-radius: 12px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: 0.3s;
}

.hamburger-btn:hover {
    background: var(--accent);
    color: var(--bg);
    transform: scale(1.05);
}

.sidebar {
    height: 100dvh;
    width: 260px;
    position: fixed;
    z-index: 2000;
    top: 0;
    left: -260px;
    background: var(--white);
    border-right: 1px solid var(--border);
    box-shadow: 5px 0 25px rgba(0,0,0,0.5);
    overflow-x: hidden;
    overflow-y: auto;
    transition: 0.4s ease;
    padding-top: 60px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sidebar-top { text-align: center; }
.sidebar-logo { max-width: 150px; margin: 0 auto 30px auto; filter: drop-shadow(0 0 8px rgba(52, 211, 153, 0.3)); }
.sidebar-bottom { padding-bottom: 30px; width: 100%; }

.sidebar a.nav-link {
    padding: 15px 30px;
    text-decoration: none;
    font-size: 1.1rem;
    color: var(--text-muted);
    display: block;
    transition: 0.3s;
    font-weight: 600;
    border-left: 5px solid transparent;
    text-align: left;
}

.sidebar a.nav-link:hover, .sidebar a.nav-link.active {
    background-color: var(--bg);
    border-left: 5px solid var(--accent);
    color: var(--accent);
}

.sidebar a.logout-link {
    color: var(--danger);
    border-top: 1px solid var(--border);
    padding-top: 20px;
    margin-top: 10px;
}

.sidebar .close-btn {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 36px;
    text-decoration: none;
    color: var(--text-muted);
    line-height: 1;
}

.overlay {
    position: fixed;
    display: none;
    width: 100vw;
    height: 100dvh;
    top: 0;
    left: 0;
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1500;
    animation: fadeIn 0.3s ease;
}

/* ========================================= */
/* 4. TARJETAS Y PANELES (EFECTO DARK GLASS) */
/* ========================================= */
.admin-panel, .dia-card, .detalle-dia {
    background: var(--white);
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-radius: 18px;
    margin-bottom: 25px;
    padding: 25px;
    animation: fadeIn 0.3s ease;
}

.dia-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.dia-card:hover {
    transform: translateY(-5px);
    border-color: rgba(52, 211, 153, 0.4);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

.detalle-dia { display: none; }
.dia-info, .info-turnos { display: flex; align-items: center; gap: 10px; }

/* ========================================= */
/* 5. INPUTS Y FORMULARIOS                   */
/* ========================================= */
.form-asignar {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 15px;
    flex-grow: 1;
    margin: 0;
}

input, select, textarea, .input-full, .input-fecha {
    background-color: var(--bg) !important;
    border: 1px solid var(--border) !important;
    color: var(--primary) !important;
    border-radius: 12px;
    padding: 10px 15px;
    font-size: 0.95em;
    outline: none;
    transition: all 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.1) !important;
}

select option { background: var(--bg); color: var(--primary); }
input::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }

/* ========================================= */
/* 6. BOTONES PRO                            */
/* ========================================= */
button { cursor: pointer; transition: all 0.3s ease; font-weight: 700; border: none; }

.btn-success, .btn-ver {
    background-color: var(--accent) !important;
    color: var(--bg) !important;
    border-radius: 25px;
    text-transform: uppercase;
    font-size: 0.8em;
    letter-spacing: 1px;
    padding: 10px 20px;
    font-weight: 800;
}

.btn-success:hover, .btn-ver:hover {
    background-color: var(--accent-hover) !important;
    box-shadow: 0 5px 15px rgba(52, 211, 153, 0.3);
}

.btn-outline {
    background: transparent !important;
    border: 1px solid var(--accent) !important;
    color: var(--accent) !important;
    border-radius: 25px;
}
.btn-outline:hover { background: rgba(52, 211, 153, 0.1) !important; }

.btn-liberar {
    background-color: rgba(239, 68, 68, 0.1) !important;
    color: var(--danger) !important;
    border: 1px solid var(--danger) !important;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.85em;
}
.btn-liberar:hover { background-color: var(--danger) !important; color: white !important;}

.btn-eliminar { display: flex; align-items: center; justify-content: center; background: none; font-size: 1.3rem; opacity: 0.5; padding: 5px; }
.btn-eliminar:hover { opacity: 1; transform: scale(1.2); }

/* ========================================= */
/* 7. GRILLAS Y FILAS DE TURNOS              */
/* ========================================= */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.turno-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border) !important;
    gap: 15px;
}
.turno-time { min-width: 90px; white-space: nowrap; font-weight: bold; color: var(--accent); display: flex; align-items: center; }
.turno-action { display: flex; align-items: center; justify-content: space-between; gap: 15px; width: 100%; }

/* ========================================= */
/* 10. BOTÓN PRINCIPAL (Agregar Horario)     */
/* ========================================= */
.contenedor-agregar-horario { display: flex; justify-content: center; width: 100%; margin-bottom: 30px; }
.btn-agregar-principal {
    background-color: var(--accent) !important;
    color: var(--bg) !important;
    padding: 12px 30px;
    border-radius: 30px;
    font-size: 1.1em;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(52, 211, 153, 0.2);
}
.btn-agregar-principal:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(52, 211, 153, 0.4); }

/* ========================================= */
/* 11 TÍTULO DE AGENDA Y BUSCADOR            */
/* ========================================= */
.header-agenda { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; flex-wrap: wrap; gap: 15px; }
.titulo-agenda { margin: 0; width: auto; }
.buscador-agenda { display: flex; gap: 10px; align-items: center; }
.label-buscar { font-weight: 600; font-size: 0.9em; color: var(--primary) !important;}
.btn-refresh { background: transparent; border: 1.5px solid var(--accent); border-radius: 25px; padding: 8px 15px; cursor: pointer; transition: 0.3s; }
.btn-refresh:hover { background-color: rgba(52, 211, 153, 0.1); }

/* ========================================= */
/* 15 PAGINACIÓN                             */
/* ========================================= */
.pagination-container { display: flex; justify-content: center; align-items: center; gap: 15px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); width: 100%; }
.pagination-text { font-size: 0.95em; color: var(--text-muted); font-weight: 600; }
.btn-pagina { background-color: transparent; border: 1px solid var(--accent); color: var(--accent); padding: 8px 18px; border-radius: 20px; font-size: 0.85em; font-weight: bold; text-decoration: none; }
.btn-pagina:hover { background-color: var(--accent); color: var(--bg); }
.btn-pagina.disabled { opacity: 0.3; cursor: not-allowed; border-color: var(--text-muted); color: var(--text-muted); }

/* ========================================= */
/* ========================================= */
/* MAGIA DE VISIONRS: OVERRIDES V2           */
/* ========================================= */

/* 1. Forzar a oscuro TODOS los contenedores claros (Divs y Formularios) */
form.buscador-agenda,
form[style*="white"],
div[style*="white"],
div[style*="#f9f9f9"],
div[style*="#fff3f3"],
div[style*="rgba(255, 255, 255"],
.panel-historial, 
.panel-lista {
    background: var(--white) !important;
    border: 1px solid var(--border) !important;
    color: var(--primary) !important;
}

/* 2. Arreglar los títulos de Estadísticas y Cuenta Corriente */
h3[style*="color: var(--primary)"],
h3[style*="color: #c62828"] {
    color: var(--accent) !important;
    border-bottom-color: var(--border) !important;
}

/* 3. Arreglar textos grises perdidos (Para que se lean en fondo oscuro) */
span[style*="color: #555"], div[style*="color: #555"],
span[style*="color: #666"], div[style*="color: #666"],
span[style*="color: #888"], p[style*="color: #888"],
small[style*="color: #888"], span[style*="color: #777"] {
    color: var(--text-muted) !important;
}

/* 4. Resaltar las palabras "Paciente:", "Desde:", "Hasta:" */
span.label-buscar, 
label.form-label {
    color: var(--accent) !important;
}

/* 5. Badges (Etiquetas) y Alertas */
.badge { padding: 6px 14px; border-radius: 20px; font-size: 0.8em; font-weight: 600; border: 1px solid transparent; }
.badge-libre { background: rgba(52, 211, 153, 0.1) !important; color: var(--accent) !important; border-color: rgba(52, 211, 153, 0.3) !important; }
.badge-ocupado { background: rgba(239, 68, 68, 0.1) !important; color: var(--danger) !important; border-color: rgba(239, 68, 68, 0.3) !important; }
.badge-reasignado { background: rgba(245, 158, 11, 0.1) !important; color: var(--ambar) !important; border-color: rgba(245, 158, 11, 0.3) !important; }

.alerta-flash { padding: 15px; margin-bottom: 20px; border-radius: 12px; text-align: center; font-weight: bold; }
div[style*="background-color: #e8f5e9"], .alerta-success { background: rgba(16, 185, 129, 0.1) !important; color: var(--accent) !important; border: 1px solid rgba(16, 185, 129, 0.3) !important; }
div[style*="background-color: #ffebee"], div[style*="background-color: #f2e2e2"], .alerta-danger { background: rgba(239, 68, 68, 0.1) !important; color: var(--danger) !important; border: 1px solid rgba(239, 68, 68, 0.3) !important; }
div[style*="background-color: #fff3cd"], .alerta-warning { background: rgba(245, 158, 11, 0.1) !important; color: var(--ambar) !important; border: 1px solid rgba(245, 158, 11, 0.3) !important; }

/* 6. Panel de Recordatorios */
.panel-recordatorios { background: rgba(245, 158, 11, 0.05) !important; border-left: 4px solid var(--ambar) !important; border-radius: 12px; padding: 20px; color: var(--primary); }
.item-recordatorio { background: var(--bg) !important; border: 1px solid rgba(245, 158, 11, 0.2) !important; display: flex; justify-content: space-between; align-items: center; padding: 12px 15px; border-radius: 10px; margin-bottom: 10px;}
.panel-recordatorios h3 { color: var(--ambar) !important; }

.btn-whatsapp-recordatorio { background: rgba(16, 185, 129, 0.1) !important; color: var(--accent) !important; border: 1px solid var(--accent) !important; padding: 8px 15px; border-radius: 20px; text-decoration: none; font-weight: bold; transition: 0.3s;}
.btn-whatsapp-recordatorio:hover { background: var(--accent) !important; color: var(--bg) !important; }

/* Responsive General */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 600px) {
    .admin-grid, .turno-row, .form-asignar { flex-direction: column; align-items: stretch; }
    h1 { margin-top: 70px; }
    .dia-card { flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 20px 15px; }
    .header-agenda { flex-direction: column; justify-content: center; align-items: center; gap: 20px; }
    .buscador-agenda { justify-content: center; flex-wrap: wrap; }
}