/* ====================================================================
   Caso «Agenda de turnos» — Oficina de Atención Ciudadana de Villa Ejemplo (sitio FICTICIO)
   --------------------------------------------------------------------
   Esta hoja la cargan las DOS versiones (con barreras y corregida) para que se vean igual y se
   puedan comparar lado a lado. Lo que cambia entre una y otra es el marcado y el comportamiento, no
   la identidad visual.

   Las clases con «-baja», «.dia», «.hora», «.velo»… son de la versión con barreras (en la corregida
   se usan otras: .ayuda, .picker, .opcion-hora…). Cada barrera está comentada en turnos.js / index.html.
   Nada de fuentes ni imágenes de otros sitios: tipografía del sistema y SVG propios.
   ==================================================================== */
:root {
    --petroleo: #0e4a6b;
    --petroleo-oscuro: #0a3550;
    --ambar: #f2b134;
    --crema: #f4f1ea;
    --tinta: #1f2933;
    --tinta-suave: #4a5560;
    --linea: #b9c2c9;
    --libre: #e1f3e6;
    --libre-tinta: #14532d;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--crema);
    color: var(--tinta);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
}

.saltar {
    position: absolute;
    left: -9999px;
    top: 0;
    background: #fff;
    color: var(--petroleo-oscuro);
    padding: 10px 14px;
    z-index: 5;
}
.saltar:focus { left: 8px; top: 8px; }

/* ---- Banda superior (la identidad de la oficina) ------------------- */
.banda {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--petroleo);
    color: #fff;
    padding: 14px 20px;
    border-bottom: 5px solid var(--ambar);
}
.banda img { display: block; width: 44px; height: auto; flex: none; }
.banda-nombre { margin: 0; font-size: 1.35rem; font-weight: 700; line-height: 1.2; color: #fff; }
.banda-sub { margin: 2px 0 0; font-size: 0.95rem; color: #dbeaf2; }

/* ---- Contenido ------------------------------------------------------- */
.pagina { max-width: 640px; margin: 0 auto; padding: 24px 16px 56px; }
.tarjeta {
    background: #fff;
    border: 1px solid var(--linea);
    border-radius: 12px;
    padding: 22px 22px 26px;
}
.tarjeta h1, .tarjeta h2, .tarjeta h3, .tarjeta h4, .tarjeta h5 { color: var(--petroleo-oscuro); line-height: 1.25; }
.tarjeta h1 { margin: 0 0 6px; font-size: 1.6rem; }
.tarjeta h3 { margin: 0 0 6px; font-size: 1.45rem; }
.tarjeta h4 { margin: 0 0 6px; font-size: 1.35rem; }
.tarjeta h5 { margin: 18px 0 8px; font-size: 1.05rem; }
.tarjeta h2 { margin: 18px 0 8px; font-size: 1.15rem; }

/* Texto de ayuda de la versión con barreras: gris claro sobre blanco (≈ 2,6:1) — falla 1.4.3. */
.ayuda-baja { margin: 0 0 10px; color: #a3acb4; font-size: 0.9rem; }
/* El de la corregida: mismo lugar y tamaño, con contraste suficiente. */
.ayuda { margin: 0 0 10px; color: var(--tinta-suave); font-size: 0.95rem; }

.campo { margin: 16px 0; }
.campo > label, .campo > .etiqueta-falsa, .campo > fieldset > legend {
    display: block;
    font-weight: 600;
    margin: 0 0 6px;
    padding: 0;
}
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

select, .entrada {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: 2px solid #6b7782;
    border-radius: 8px;
    background: #fff;
    color: var(--tinta);
    font: inherit;
}
select:focus, .entrada:focus-visible { outline: 3px solid var(--petroleo); outline-offset: 2px; }

.fecha-caja { position: relative; }

.boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 20px;
    border: 2px solid var(--petroleo);
    border-radius: 8px;
    background: var(--petroleo);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.boton:hover { background: var(--petroleo-oscuro); }
.boton:focus-visible { outline: 3px solid var(--ambar); outline-offset: 2px; box-shadow: 0 0 0 5px var(--petroleo-oscuro); }
.boton-sec { background: #fff; color: var(--petroleo-oscuro); }
.boton-sec:hover { background: #e8f0f5; }

/* ---- Horarios (barreras: se distinguen solo por color) ---------------- */
.horas { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.hora {
    min-height: 44px;
    border: 1px solid #b7c4b9;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.hora.libre { background: var(--libre); color: var(--libre-tinta); }
.hora.ocupada { background: #f1e1e1; color: #bfa0a0; border-color: #e6d3d3; } /* B5: «ocupado» = solo un tono rosado. */
.hora.elegida { outline: 3px solid var(--petroleo); outline-offset: 1px; }

/* ---- Calendario hecho de <div> (versión con barreras) ------------------ */
.cal {
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    z-index: 4;
    width: 308px;
    max-width: 100%;
    background: #fff;
    border: 1px solid var(--linea);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    padding: 10px;
}
.cal[hidden] { display: none; }
.cal-cab { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-mes { font-weight: 700; text-transform: capitalize; }
.flecha { display: inline-block; width: 32px; height: 32px; line-height: 30px; text-align: center; font-size: 1.5rem; cursor: pointer; border-radius: 6px; }
.flecha:hover { background: #e8f0f5; }
.cal-rejilla { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-sem { font-size: 0.8rem; font-weight: 700; color: var(--tinta-suave); padding: 4px 0; }
.dia { padding: 8px 0; border-radius: 6px; cursor: pointer; }
.dia.libre:hover { background: #e8f0f5; }
.dia.vacio { cursor: default; }
.dia.nodisp { color: #cdd2d6; cursor: not-allowed; }   /* B5/B6: «no disponible» = solo más gris (y casi invisible). */
.dia.hoy { color: #d9480f; font-weight: 700; }          /* B5: «hoy» = solo otro color de texto. */
.dia.sel { background: var(--petroleo); color: #fff; }

/* ---- Modal de la versión con barreras ----------------------------------- */
.velo {
    position: fixed;
    inset: 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.velo[hidden] { display: none; }
.modal { position: relative; width: 100%; max-width: 420px; background: #fff; border-radius: 12px; padding: 24px 24px 22px; }
.modal h5 { margin: 0 0 8px; font-size: 1.2rem; }
.cerrar { position: absolute; right: 12px; top: 8px; font-size: 1.8rem; line-height: 1; cursor: pointer; color: #6b7782; }

/* ---- Aviso que desaparece solo ------------------------------------------ */
.toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 9;
    max-width: min(360px, calc(100% - 32px));
    background: #1f2933;
    color: #fff;
    border-left: 6px solid var(--ambar);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.toast[hidden] { display: none; }

/* ---- Pantalla de turno confirmado ---------------------------------------- */
.resumen-img { display: block; max-width: 100%; height: auto; border: 1px solid var(--linea); border-radius: 10px; margin: 14px 0; }
.codigo { display: inline-block; font-family: ui-monospace, Consolas, monospace; font-size: 1.6rem; font-weight: 700; letter-spacing: 0.06em; background: #fff7e0; border: 2px solid var(--ambar); border-radius: 8px; padding: 4px 14px; color: var(--tinta); }
.datos { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 16px 0; }
.datos dt { font-weight: 700; }
.datos dd { margin: 0; }

.pie-sitio { max-width: 640px; margin: 0 auto; padding: 0 16px 32px; color: var(--tinta-suave); font-size: 0.9rem; }
.pie-sitio-baja { max-width: 640px; margin: 0 auto; padding: 0 16px 32px; color: #a3acb4; font-size: 0.9rem; } /* contraste bajo a propósito (barreras) */

.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ====================================================================
   Versión CORREGIDA
   ==================================================================== */
/* Foco visible y claro en todo lo que se opera con teclado (2.4.7, 2.4.11 y 2.4.13). */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid var(--petroleo);
    outline-offset: 2px;
}
.errores { border: 3px solid #9b1c1c; border-radius: 10px; background: #fdf0f0; padding: 12px 16px; margin: 0 0 16px; }
.errores h2 { margin: 0 0 6px; color: #7f1414; font-size: 1.1rem; }
.errores ul { margin: 0; padding-left: 20px; }
.errores a { color: #7f1414; font-weight: 600; }
.errores:focus { outline: 3px solid #9b1c1c; outline-offset: 2px; }
.error-campo { margin: 6px 0 0; color: #8a1414; font-weight: 600; }
.error-campo::before { content: "Error: "; }
[aria-invalid="true"] { border-color: #9b1c1c; border-width: 3px; }

.fecha-fila { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.fecha-fila .entrada { flex: 1 1 180px; width: auto; }
.fecha-fila .boton { flex: none; }

.opciones-hora { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.opcion-hora { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 10px; border: 1px solid var(--linea); border-radius: 8px; background: #fff; }
.opcion-hora input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--petroleo); }
.opcion-hora label { flex: 1; cursor: pointer; padding: 6px 0; }
.opcion-hora.ocupado { background: #f3f4f6; color: var(--tinta-suave); }
.opcion-hora.ocupado label { cursor: not-allowed; }

/* Date picker accesible (diálogo con grilla, patrón de la APG). */
.picker {
    width: min(340px, calc(100% - 24px));
    padding: 14px;
    border: 1px solid var(--linea);
    border-radius: 12px;
    background: #fff;
    color: var(--tinta);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.picker::backdrop { background: rgba(0, 0, 0, 0.5); }
.picker h2 { margin: 0 0 8px; font-size: 1.15rem; }
.picker-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.picker-mes { font-weight: 700; text-align: center; flex: 1; }
.picker-mes::first-letter { text-transform: uppercase; }
.picker-cab button {
    width: 44px; height: 44px; border: 2px solid var(--petroleo); border-radius: 8px;
    background: #fff; color: var(--petroleo-oscuro); font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.picker-cab button:hover { background: #e8f0f5; }
.picker table { width: 100%; border-collapse: separate; border-spacing: 2px; table-layout: fixed; }
.picker th { font-size: 0.85rem; font-weight: 700; color: var(--tinta-suave); padding: 4px 0; text-align: center; }
.picker td { padding: 0; text-align: center; }
.picker td button {
    width: 100%; min-height: 44px; border: 2px solid transparent; border-radius: 8px;
    background: #fff; color: var(--tinta); font: inherit; font-weight: 700; cursor: pointer;
}
.picker td button:hover { background: #e8f0f5; }
/* «No disponible» se ve (tachado y con otro fondo) además de decirse en texto. */
.picker td button[aria-disabled="true"] { background: #eef0f2; color: var(--tinta-suave); font-weight: 400; text-decoration: line-through; cursor: not-allowed; }
/* «Hoy» se ve por la forma (borde doble), no solo por el color. */
.picker td button.es-hoy { border: 4px double var(--petroleo); }
.picker td[aria-selected="true"] button { background: var(--petroleo); color: #fff; }
.picker td[aria-selected="true"] button::after { content: " ✓"; }
.picker-ayuda { margin: 10px 0; font-size: 0.9rem; color: var(--tinta-suave); }
.picker-pie { display: flex; justify-content: flex-end; }

/* Diálogo de confirmación (<dialog> nativo). */
.dialogo { width: min(440px, calc(100% - 24px)); padding: 22px; border: 1px solid var(--linea); border-radius: 12px; background: #fff; color: var(--tinta); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); }
.dialogo::backdrop { background: rgba(0, 0, 0, 0.5); }
.dialogo h2 { margin: 0 0 10px; font-size: 1.25rem; }
.dialogo-acciones { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

@media (max-width: 480px) {
    .horas { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tarjeta { padding: 16px 14px 20px; }
    .datos { grid-template-columns: minmax(0, 1fr); }
    .datos dd { margin-bottom: 6px; }
    .banda { padding: 12px 14px; }
}
