/* Estilos base (Mobile-First) */
:root {
    --color-primario: #007bff;
    --color-secundario: #6c757d;
    --color-fondo: #f8f9fa;
    --color-texto: #333;
    --color-blanco: #fff;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--color-fondo);
    color: var(--color-texto);
    line-height: 1.6;
}
header {
    background-color: #003366;
    color: var(--color-blanco);
    padding: 0.8rem 1rem;
    text-align: center;
    border-bottom: 3px solid #001f3f;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
header h1 { font-size: 1.5em; margin: 0; font-weight: 500; }
nav ul { list-style: none; padding: 0; margin: 0; background-color: #c0c0c0; display: flex; justify-content: center; flex-wrap: wrap; }
nav a { display: block; padding: 0.8rem 1rem; color: var(--color-texto); text-decoration: none; }
nav a:hover { background-color: #a9a9a9; }
main { padding: 1.5rem; }
.container { max-width: 1200px; margin: auto; overflow: auto; padding: 0 2rem; }
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
table, th, td { border: 1px solid #ddd; }
th, td { padding: 0.8rem; text-align: left; }
th { background-color: #f2f2f2; }
.btn { display: inline-block; padding: 0.5rem 1rem; border: none; border-radius: 4px; background-color: var(--color-primario); color: white; text-decoration: none; cursor: pointer; text-align: center; }
.btn-secundario { background-color: #17a2b8; }
.btn-peligro { background-color: #dc3545; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.5rem; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
footer { text-align: center; padding: 0.6rem 1rem; margin-top: 2rem; background-color: #e0e0e0; color: var(--color-texto); border-top: 1px solid #c0c0c0; box-shadow: 0 -2px 4px rgba(0,0,0,0.1); }
.footer-content { display: flex; justify-content: center; align-items: center; gap: 10px; }
.footer-logo { height: 1.2em; width: auto; vertical-align: middle; }
footer p { margin: 0; }
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.5); }
.modal-content { background-color: #fefefe; margin: 10% auto; padding: 20px; border: 1px solid #888; width: 80%; max-width: 600px; border-radius: 5px; position: relative; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.close-button { color: #aaa; float: right; font-size: 28px; font-weight: bold; position: absolute; right: 15px; top: 5px; }
.close-button:hover, .close-button:focus { color: black; text-decoration: none; cursor: pointer; }
.info-card, .accordion-item { background-color: #fff; border: 1px solid #ddd; border-radius: 5px; margin-bottom: 10px; overflow: hidden; }
.info-card { padding: 20px; }
.accordion-header { padding: 15px 20px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; background-color: #f7f7f7; }
.accordion-header::-webkit-details-marker { display: none; }
.accordion-header::after { content: '+'; font-size: 1.5em; color: var(--color-primario); transition: transform 0.2s; }
details[open] > .accordion-header { border-bottom: 1px solid #ddd; }
details[open] > .accordion-header::after { content: '−'; transform: rotate(180deg); }
.accordion-header:hover { background-color: #e9e9e9; }
.accordion-header h3 { margin: 0; font-size: 1.2em; font-weight: 500; }
.accordion-content { padding: 20px; border-top: 1px solid #ddd; }
.accordion-content .info-card { border: none; padding: 0; margin-bottom: 0; box-shadow: none; }
.sesiones-list { margin-top: 20px; }
.sesion-item { border-top: 1px solid #eee; padding-top: 15px; margin-top: 15px; }
.sesion-item:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.sesion-item h5 { margin-top: 0; color: var(--color-primario); }
.dia-card { background-color: #fff; border: 1px solid #ddd; border-radius: 5px; padding: 15px; margin-bottom: 15px; }
.dia-card h4 { margin-top: 0; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.bloque-horario { display: flex; align-items: center; margin-bottom: 10px; }
.bloque-horario label { margin: 0 5px; }
.bloque-horario input[type="time"] { width: auto; }
.btn-remove { background: #dc3545; color: white; border: none; border-radius: 50%; width: 24px; height: 24px; font-size: 16px; line-height: 24px; text-align: center; cursor: pointer; margin-left: 15px; }
.btn-add { background: #28a745; color: white; border: none; border-radius: 4px; padding: 5px 10px; cursor: pointer; font-size: 14px; }
.agenda-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.agenda-table { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 800px; }
.agenda-table th, .agenda-table td { border: 1px solid #ddd; padding: 5px; text-align: center; vertical-align: top; height: 60px; }
.agenda-table th { background-color: #f2f2f2; font-size: 0.9em; position: sticky; top: 0; z-index: 10; }
.agenda-table td { background-color: #fff; }
.cita-evento { position: relative; padding: 8px; border-radius: 4px; color: white; font-size: 0.8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; transition: transform 0.2s; }
.cita-evento:hover { transform: scale(1.05); }
.cita-link { text-decoration: none; color: white; display: block; }
.estado-confirmada { background-color: #5cb85c; }
.estado-pendiente-de-confirmación { background-color: #f0ad4e; }
.estado-asistió { background-color: #337ab7; }
.estado-no-asistió { background-color: #d9534f; }
.estado-cancelada { background-color: #777; }
.add-cita-link { display: block; width: 100%; height: 100%; text-decoration: none; color: #ccc; font-size: 2em; line-height: 50px; transition: all 0.2s; }
.add-cita-link:hover { background-color: #e8f7ff; color: var(--color-primario); }
.cita-acciones { position: absolute; top: 5px; right: 5px; display: flex; gap: 5px; }
.btn-accion-cita { display: inline-block; width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: 50%; color: white; font-weight: bold; text-decoration: none; transition: transform 0.2s; }
.btn-accion-cita:hover { transform: scale(1.2); }
.btn-confirmar { background-color: #28a745; }
.btn-rechazar { background-color: #dc3545; font-size: 1.2em; }
.agenda-movil-container .accordion-item { margin-bottom: 5px; }
.agenda-movil-container .accordion-header h3 { font-size: 1.1em; }
.agenda-movil-container .accordion-content { padding: 0; }
.lista-horas { list-style: none; padding: 0; margin: 0; }
.lista-horas li { display: flex; align-items: center; border-bottom: 1px solid #eee; }
.lista-horas .hora { font-weight: bold; padding: 15px; width: 60px; background-color: #f9f9f9; text-align: center; }
.lista-horas .evento { padding: 15px; flex-grow: 1; }
.cita-link-movil, .add-cita-link-movil { display: block; text-decoration: none; padding: 8px; border-radius: 4px; }
.add-cita-link-movil { color: var(--color-primario); }
.add-cita-link-movil:hover { background-color: #e8f7ff; }
.cita-link-movil.estado-confirmada { background-color: #5cb85c; color: white; }
.cita-link-movil.estado-pendiente-de-confirmación { background-color: #f0ad4e; color: white; }
.cita-link-movil.estado-asistió { background-color: #337ab7; color: white; }
.cita-link-movil.estado-no-asistió { background-color: #d9534f; color: white; }
.cita-link-movil.estado-cancelada { background-color: #777; color: white; }
.nav-movil { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 5px; background-color: #c0c0c0; }
.nav-movil-btn { display: block; padding: 12px 5px; background-color: #f0f0f0; color: var(--color-texto); text-decoration: none; text-align: center; border-radius: 4px; font-weight: 500; }
.nav-movil-btn:hover { background-color: #e0e0e0; }

/* ================================================================ */
/* ESTILOS PARA EL BUSCADOR DE PACIENTES (VERSIÓN CORREGIDA FINAL)  */
/* ================================================================ */

/* Nuevo contenedor para aislar el buscador */
.form-group-buscador {
    margin-bottom: 1rem;
    position: relative; /* Contexto para la lista de resultados */
}
.form-group-buscador label {
    display: block;
    margin-bottom: 0.5rem;
}

.buscador-paciente-wrapper {
    display: flex;
}

/* Regla súper específica que anula el 'width: 100%' */
.form-group-buscador .buscador-paciente-wrapper input {
    width: auto; /* Anulamos la regla general */
    flex: 1; /* El input crece para llenar el espacio */
    min-width: 0; /* Permite que el input se encoja si es necesario */
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.btn-add-paciente { display: flex; align-items: center; justify-content: center; width: 40px; background-color: #28a745; color: white; font-size: 1.5em; font-weight: bold; text-decoration: none; border-top-right-radius: 4px; border-bottom-right-radius: 4px; flex-shrink: 0; }
.resultados-busqueda { position: absolute; background-color: white; border: 1px solid #ccc; border-top: none; width: 100%; z-index: 100; max-height: 200px; overflow-y: auto; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.resultado-item { padding: 10px; cursor: pointer; }
.resultado-item:hover { background-color: #f0f0f0; }
.resultado-item span { color: #777; font-size: 0.9em; margin-left: 10px; }
.resultado-item-none { padding: 10px; color: #777; font-style: italic; }

/* ESTILOS PARA AGENDAMIENTO PÚBLICO */
.agendamiento-publico { background-color: #fff; border: 1px solid #ddd; border-radius: 5px; padding: 20px; }
.dias-selector { display: flex; overflow-x: auto; border-bottom: 2px solid #eee; margin-bottom: 20px; }
.dia-tab { padding: 10px 15px; border: none; background-color: transparent; cursor: pointer; text-align: center; min-width: 100px; border-bottom: 3px solid transparent; }
.dia-tab:hover { background-color: #f7f7f7; }
.dia-tab.active { border-bottom: 3px solid var(--color-primario); font-weight: bold; }
.dia-tab strong { display: block; font-size: 1em; }
.dia-tab span { font-size: 0.9em; color: #555; }
.horarios-container h4 { margin-top: 0; }
.slots-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.slot-btn { background-color: var(--color-primario); color: white; border: none; padding: 12px; border-radius: 4px; cursor: pointer; text-align: center; transition: background-color 0.2s; }
.slot-btn:hover { background-color: #0056b3; }
.btn.disabled { background-color: #ccc; cursor: not-allowed; pointer-events: none; }

/* Media Query para Tabletas y Escritorio */
@media (min-width: 768px) {
    nav ul {
        justify-content: flex-start;
    }
}