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

:root {
    --primary: #6c2e2e; 
    --accent: #a35d5d; 
    --success: #637a67; 
    --danger: #b54c4c;  
    --bg: #e9e3d5;
    --white: #fbf9f6; 
}

/* ========================================= */
/* 2. CONFIGURACIÓN BASE                     */
/* ========================================= */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    background-image: linear-gradient(rgba(233, 227, 213, 0.92), rgba(233, 227, 213, 0.92)), 
                      url('../img/Logo.png'); 
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 50%;
    color: var(--primary);
    margin: 0;
    padding: 20px;
}

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

h1 {
    font-family: 'Playfair Display', serif;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 1.8rem;
    text-align: center;
    color: var(--primary);
    margin-bottom: 40px;
}

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

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

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

.sidebar {
    height: 100dvh; /* ¡MAGIA NUEVA! Se adapta a la barra de direcciones del celular */
    width: 260px;
    position: fixed;
    z-index: 2000;
    top: 0;
    left: -260px;
    background: var(--white);
    box-shadow: 5px 0 25px rgba(0,0,0,0.15);
    overflow-x: hidden;
    overflow-y: auto; /* ¡CLAVE! Permite scrollear la barra por dentro si el celu es chico */
    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: 120px;
    margin: 20px auto 30px auto;
}

.sidebar-bottom {
    padding-bottom: 30px;
    width: 100%;
}

.sidebar a.nav-link {
    padding: 15px 30px;
    text-decoration: none;
    font-size: 1.1rem;
    color: var(--primary);
    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: #c62828;
    border-top: 1px solid #ddd;
    padding-top: 20px;
    margin-top: 10px;
}

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

.overlay {
    position: fixed;
    display: none;
    width: 100vw;  /* Ocupa el 100% del ancho visual exacto */
    height: 100dvh; /* Ocupa el 100% del alto visual exacto, adaptándose a la barra de Chrome */
    top: 0;
    left: 0;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
    z-index: 1500; /* Está perfecto, queda justo por debajo de los 2000 del sidebar */
    animation: fadeIn 0.3s ease;
}

/* ========================================= */
/* 4. TARJETAS Y PANELES (EFECTO GLASS)      */
/* ========================================= */
.admin-panel, .dia-card, .detalle-dia {
    background: rgba(251, 249, 246, 0.96);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(108, 46, 46, 0.12);
    box-shadow: 0 10px 30px rgba(108, 46, 46, 0.06);
    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);
    box-shadow: 0 15px 35px rgba(108, 46, 46, 0.12);
}

.detalle-dia {
    display: none;
}

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

.badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
}

.badge-libre { background: #dce4dd; color: #4a5c4d; }
.badge-ocupado { background: #f2e2e2; color: #9c5c5c; }

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

.form-asignar input, .admin-panel input {
    background-color: white;
    border: 1.5px solid #e2ddd3;
    border-radius: 25px;
    padding: 0 15px;
    font-size: 0.95em;
    color: var(--primary);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    transition: all 0.3s ease;
    outline: none;
    height: 38px;
    box-sizing: border-box;
    margin: 0;
}

.form-asignar input:focus, .admin-panel input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(163, 93, 93, 0.2);
    transform: translateY(-1px);
}

input::-webkit-calendar-picker-indicator { display: none !important; }

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

.btn-success, .btn-ver {
    background-color: var(--success);
    color: white;
    border-radius: 25px;
    text-transform: uppercase;
    font-size: 0.8em;
    letter-spacing: 1px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    margin: 0;
}

.btn-success:hover, .btn-ver:hover {
    background-color: #4e6151;
    box-shadow: 0 5px 15px rgba(99, 122, 103, 0.3);
}

.btn-liberar {
    background-color: var(--danger);
    color: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.85em;
}

.btn-eliminar { 
    display: flex;
    align-items: center;
    justify-content: center;
    background: none; 
    font-size: 1.3rem; 
    opacity: 0.4; 
    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 rgba(0,0,0,0.05);
    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%;
}

/* ========================================= */
/* 8. PANEL DE RECORDATORIOS AUTOMÁTICOS     */
/* ========================================= */
.panel-recordatorios {
    background: #fff8e1;
    border-left: 6px solid #ffb300;
    max-width: 600px;
    margin: 0 auto 40px auto;
    padding: 20px;
    border-radius: 15px;
    text-align: left;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    animation: fadeIn 0.5s ease;
}

.panel-recordatorios h3 {
    color: #f57c00;
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3em;
}

.panel-recordatorios p {
    font-size: 0.95em;
    color: #555;
    margin-bottom: 15px;
}

.lista-recordatorios {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item-recordatorio {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 12px 15px;
    border-radius: 10px;
    border: 1px solid #ffe0b2;
}

.item-recordatorio .nombre-paciente {
    font-weight: bold;
    color: var(--primary);
}

.item-recordatorio .hora-turno {
    color: var(--accent);
    font-weight: 600;
}

.btn-whatsapp-recordatorio {
    background: #25D366;
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: bold;
    display: flex;
    gap: 5px;
    align-items: center;
    box-shadow: 0 2px 5px rgba(37,211,102,0.3);
    transition: transform 0.3s ease;
}

.btn-whatsapp-recordatorio:hover {
    transform: scale(1.05);
}

/* ========================================= */
/* 9. ESTILOS DE TURNO OCUPADO Y CANCELACIÓN */
/* ========================================= */
.turno-ocupado-wrapper {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.info-paciente-ocupado .nombre-destacado {
    color: var(--primary);
    font-weight: bold;
    font-size: 1.2em;
}

.info-paciente-ocupado .telefono-destacado {
    color: #666;
    font-size: 1em;
}

.form-liberar {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex: 1;
}

.opciones-aviso-cancelar {
    display: flex;
    gap: 10px;
    align-items: center;
    background: #fff3f3;
    padding: 6px 15px;
    border-radius: 20px;
    border: 1px solid #ffcdd2;
}

.titulo-aviso {
    font-size: 0.85em;
    color: #c62828;
    font-weight: bold;
}

.label-aviso {
    font-size: 0.85em;
    cursor: pointer;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.label-aviso input {
    width: 16px;
    height: 16px;
}

/* ========================================= */
/* 10. BOTÓN PRINCIPAL (Agregar Horario)         */
/* ========================================= */
.contenedor-agregar-horario {
    display: flex;
    justify-content: center; /* Esto es lo que lo clava en el medio exacto */
    width: 100%;
    margin-bottom: 30px;
}

.btn-agregar-principal {
    background-color: var(--accent);
    color: white;
    padding: 12px 30px;
    border-radius: 30px;
    font-size: 1.1em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(163, 93, 93, 0.3);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-agregar-principal:hover {
    background-color: var(--primary); /* Se oscurece un poquito al pasar el mouse */
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 46, 46, 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;
}

.input-fecha {
    background-color: var(--white);
    border: 1.5px solid var(--accent);
    border-radius: 20px;
    padding: 8px 15px;
    color: var(--primary);
    outline: none;
    cursor: pointer;
}

.btn-refresh {
    background: transparent;
    border: 1.5px solid var(--accent);
    border-radius: 25px;
    padding: 8px 15px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-refresh:hover {
    background-color: #e2ddd3;
}

/* --- REGLA PARA CENTRAR EN CELULARES --- */
@media (max-width: 600px) {
    .header-agenda {
        flex-direction: column; /* Apila el título arriba y el buscador abajo */
        justify-content: center;
        align-items: center;
        gap: 20px;
    }

    .titulo-agenda {
        text-align: center;
    }

    .buscador-agenda {
        justify-content: center;
        flex-wrap: wrap; /* Evita que los botones se salgan de la pantalla si es muy chica */
    }
}


/* ========================================= */
/* 12 NUEVOS BOTONES DE ESTADO E HISTORIAL      */
/* ========================================= */
.acciones-ocupado {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: flex-end;
    flex: 1;
}

.select-motivo {
    padding: 8px 12px;
    border-radius: 20px;
    border: 1.5px solid #ffcdd2;
    color: var(--danger);
    background: white;
    outline: none;
    font-size: 0.85em;
    font-weight: bold;
    cursor: pointer;
}

@media (max-width: 500px) {
    .acciones-ocupado {
        align-items: stretch;
        width: 100%;
    }
    
    .select-motivo {
        width: 100%;
        margin-bottom: 10px;
    }
}

/* ========================================= */
/* 13 ESTILOS PARA BOTONES APAGADOS Y PEQUEÑOS  */
/* ========================================= */
button:disabled {
    opacity: 0.4;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

.form-atendido {
    margin: 0;
}

.btn-chico {
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85em;
    margin: 0;
}

/* ========================================= */
/* 16 PANEL DE HISTORIAL Y ETIQUETAS            */
/* ========================================= */
.panel-historial {
    background: rgba(251, 249, 246, 0.96);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(108, 46, 46, 0.12);
    box-shadow: 0 10px 30px rgba(108, 46, 46, 0.06);
    border-radius: 18px;
    margin-bottom: 25px;
    padding: 25px;
    animation: fadeIn 0.3s ease;
    display: block; /* A diferencia del panel de agenda, este siempre es visible */
}

.badge-reasignado { 
    background: #fff3e0; 
    color: #ef6c00; 
}

.turno-fecha-historial {
    font-size: 0.9em;
    color: #666;
    display: block;
    margin-bottom: 3px;
}

/* ========================================= */
/* 15 ESTILOS DE PAGINACIÓN PREMIUM             */
/* ========================================= */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    width: 100%; /* Para que ocupe todo el ancho del panel */
}

.pagination-text {
    font-size: 0.95em;
    color: var(--primary);
    font-weight: 600;
}

.btn-pagina {
    background-color: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: bold;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-pagina:hover {
    background-color: var(--accent);
    color: white;
}

.btn-pagina.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: #ccc;
    color: #999;
}

.btn-pagina.disabled:hover {
    background-color: transparent;
    color: #999;
}

.detalle-dia {
    margin-top: 10px;
    margin-bottom: 40px; /* Le damos mucho aire abajo para que se despegue del siguiente */
    border-top: 3px solid var(--accent); /* Un detalle visual para saber dónde empieza */
}

/* ========================================= */
/* ALERTAS FLASH (MENSAJES DEL SISTEMA)      */
/* ========================================= */
.alerta-flash {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 15px;
    text-align: center;
    font-weight: bold;
    animation: fadeIn 0.3s ease;
}

.alerta-success {
    background-color: #dce4dd;
    color: #4a5c4d;
    border: 1px solid #c8d6cb;
}

.alerta-danger {
    background-color: #f2e2e2;
    color: #9c5c5c;
    border: 1px solid #ffcdd2;
}

/* ========================================= */
/* 16 RESPONSIVE Y ANIMACIONES              */
/* ========================================= */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
    .nav-container { gap: 20px; }
    .nav-link { padding: 8px 12px; font-size: 0.85em; }
    
    /* Le sacamos el .dia-card a esta regla para que no se estire toscamente */
    .admin-grid, .turno-row, .form-asignar { flex-direction: column; align-items: stretch; }
    h1 { margin-top: 70px; }

    /* Nuevo estilo elegante y centrado para las tarjetas de los días */
    .dia-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 12px;
        padding: 20px 15px;
    }

    .dia-card .dia-info h3 {
        margin: 0;
        font-size: 1.25em;
    }

    .dia-card .info-turnos {
        justify-content: center;
        width: 100%;
    }

    .dia-card .btn-ver {
        width: 100%;
        max-width: 240px; /* Le ponemos un límite para que no parezca un ladrillo */
        margin-top: 5px;
    }
}

@media (max-width: 500px) {
    .turno-ocupado-wrapper {
        flex-direction: column; 
        align-items: flex-start; 
        gap: 20px;
    }

    .form-liberar {
        width: 100%; 
        flex-direction: column; 
        align-items: stretch; 
    }

    .opciones-aviso-cancelar {
        justify-content: center; 
        width: 100%;
        box-sizing: border-box;
    }

    .form-liberar .btn-liberar {
        width: 100%; 
        justify-content: center;
        margin-top: 5px; 
    }
}

@media (max-width: 480px) {
    .item-recordatorio {
        flex-direction: column; 
        align-items: flex-start; 
        gap: 15px; 
    }

    .btn-whatsapp-recordatorio {
        width: 100%; 
        justify-content: center; 
        box-sizing: border-box; 
    }
}

.boton-cerrar-sesion {
    position: fixed;      /* Esto lo clava en la pantalla */
    top: 20px;            /* Lo separa 20 píxeles desde arriba */
    right: 20px;          /* Lo separa 20 píxeles desde la derecha */
    z-index: 1000;        /* Asegura que siempre esté por encima de cualquier otro elemento */
    
    /* Podés agregarle color y diseño acá abajo si querés */
    background-color: #ff4d4d;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    text-decoration: none;
}