/* =========================================
   ACCESIBILIDAD Y FORMULARIOS (todas las páginas)
   Pensado para personas de todas las edades:
   letra grande, campos amplios, foco visible,
   errores escritos en palabras y alto contraste.
   ========================================= */
:root {
    --af-ink: #1D2A38;
    --af-body: #3E4A5A;
    --af-border: #8995A3;      /* borde con contraste suficiente (3:1) */
    --af-teal: #0E7C7E;
    --af-teal-soft: #E9F7F7;
    --af-error: #B42318;
    --af-error-soft: #FEF3F2;
    --af-ok: #1E7B3A;
    --af-focus: #FFB020;
}

/* ---------- Tamaño de texto (A / A+ / A++) ---------- */
html.text-grande body { zoom: 1.12; }
html.text-muy-grande body { zoom: 1.25; }

@supports not (zoom: 1) {
    html.text-grande { font-size: 112.5%; }
    html.text-muy-grande { font-size: 125%; }
}

.font-tools {
    background: #F5F8FA;
    border-bottom: 1px solid #DDE3E8;
}

.font-tools-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 8px 20px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    color: var(--af-body);
}

.font-tools button {
    min-width: 44px;
    height: 38px;
    border: 1px solid #C9D2DB;
    background: white;
    border-radius: 6px;
    font-weight: 700;
    color: var(--af-ink);
    cursor: pointer;
    font-size: 16px;
    font-family: inherit;
}

.font-tools button[data-size="grande"] { font-size: 18px; }
.font-tools button[data-size="muy-grande"] { font-size: 21px; }

.font-tools button[aria-pressed="true"] {
    background: var(--af-teal);
    border-color: var(--af-teal);
    color: white;
}

@media (max-width: 600px) {
    .font-tools-inner {
        justify-content: center;
    }
}

/* ---------- Foco visible al navegar con teclado ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--af-focus);
    outline-offset: 2px;
}

/* =========================================
   SISTEMA DE FORMULARIO (.af y .rx-form)
   ========================================= */
.af,
.rx-form {
    font-size: 1.0625rem;
    color: var(--af-ink);
}

.af-required-note {
    font-size: 1rem;
    color: var(--af-body);
    margin: 0 0 1.25rem;
}

.af-required-note b,
.af-req {
    color: var(--af-error);
}

/* Etiquetas */
.af label,
.rx-field label {
    display: block;
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--af-ink);
    margin-bottom: 0.4rem;
    line-height: 1.35;
}

.af-optional {
    font-weight: 400;
    color: var(--af-body);
    font-size: 0.95rem;
}

/* Campos */
.af input[type="text"],
.af input[type="email"],
.af input[type="tel"],
.af input[type="password"],
.af input[type="number"],
.af select,
.af textarea,
.rx-field input,
.rx-field select,
.rx-more textarea {
    width: 100%;
    min-height: 56px;
    padding: 0.8rem 1rem;
    border: 2px solid var(--af-border);
    border-radius: 10px;
    font-size: 1.125rem;          /* 18px: legible y evita el zoom automático en iPhone */
    font-family: inherit;
    color: var(--af-ink);
    background: white;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.af textarea,
.rx-more textarea {
    min-height: 120px;
    line-height: 1.5;
    resize: vertical;
}

.af select,
.rx-field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%231D2A38' stroke-width='2.2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.8rem;
}

.af ::placeholder,
.rx-form ::placeholder {
    color: #6B7785;
    opacity: 1;
}

.af input:hover,
.af select:hover,
.af textarea:hover,
.rx-field input:hover,
.rx-field select:hover,
.rx-more textarea:hover {
    border-color: #5F6B78;
}

.af input:focus,
.af select:focus,
.af textarea:focus,
.rx-field input:focus,
.rx-field select:focus,
.rx-more textarea:focus {
    outline: 3px solid var(--af-focus);
    outline-offset: 1px;
    border-color: var(--af-teal);
    box-shadow: none;
}

/* Ayudas y errores */
.af-hint,
.rx-hint {
    display: block;
    font-size: 0.95rem;
    color: var(--af-body);
    margin-top: 0.35rem;
    line-height: 1.4;
}

.af-error,
.rx-error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--af-error);
    margin-top: 0.4rem;
    line-height: 1.4;
}

.af-error::before,
.rx-error::before {
    content: "!";
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--af-error);
    color: white;
    font-size: 13px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.af-error:empty,
.rx-error:empty {
    display: none;
}

.af-field.invalid input,
.af-field.invalid select,
.af-field.invalid textarea,
.rx-field.invalid input,
.rx-field.invalid select {
    border-color: var(--af-error);
    background: var(--af-error-soft);
}

.af-field.valid input,
.rx-field.valid input {
    border-color: var(--af-ok);
}

.af-field.invalid .af-hint,
.rx-field.invalid .rx-hint {
    display: none;
}

/* Resumen de errores al enviar */
.af-summary {
    border: 2px solid var(--af-error);
    background: var(--af-error-soft);
    border-radius: 12px;
    padding: 1rem 1.2rem;
    margin-bottom: 1.4rem;
    color: var(--af-ink);
}

.af-summary[hidden] {
    display: none;
}

.af-summary h3 {
    font-size: 1.125rem;
    color: var(--af-error);
    margin: 0 0 0.5rem;
    display: flex;
    gap: 8px;
    align-items: center;
}

.af-summary ul {
    margin: 0;
    padding-left: 1.2rem;
}

.af-summary li {
    margin: 0.25rem 0;
    font-size: 1rem;
}

.af-summary a {
    color: var(--af-error);
    font-weight: 700;
    text-decoration: underline;
}

/* Grupos de campos */
.af-grid,
.rx-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem 1.25rem;
}

.af-full {
    grid-column: 1 / -1;
}

.af-field {
    margin-bottom: 1.25rem;
}

.af-grid .af-field {
    margin-bottom: 0;
}

.af fieldset {
    border: 0;
    margin: 0 0 1.8rem;
    padding: 0;
    min-width: 0;
}

.af legend,
.rx-subtitle {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--af-ink);
    margin: 0 0 1rem;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.af-step-num {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--af-teal);
    color: white;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Opciones grandes (radio como tarjeta) */
.af-choices {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.af-choice {
    position: relative;
    display: block;
    cursor: pointer;
    margin: 0 !important;
}

.af-choice input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.af-choice-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: 100%;
    border: 2px solid var(--af-border);
    border-radius: 12px;
    padding: 1rem 1rem 1rem 3.2rem;
    position: relative;
    background: white;
    font-weight: 400;
    transition: border-color 0.15s, background 0.15s;
}

.af-choice-box::before {
    content: "";
    position: absolute;
    left: 1rem;
    top: 1.1rem;
    width: 22px;
    height: 22px;
    border: 2px solid var(--af-border);
    border-radius: 50%;
    background: white;
}

.af-choice-box strong {
    font-size: 1.08rem;
    color: var(--af-ink);
}

.af-choice-box span {
    font-size: 0.95rem;
    color: var(--af-body);
    line-height: 1.4;
}

.af-choice:hover .af-choice-box {
    border-color: #5F6B78;
}

.af-choice input:checked + .af-choice-box {
    border-color: var(--af-teal);
    background: var(--af-teal-soft);
}

.af-choice input:checked + .af-choice-box::before {
    border-color: var(--af-teal);
    background: radial-gradient(circle, var(--af-teal) 0 6px, white 7px);
}

.af-choice input:focus-visible + .af-choice-box {
    outline: 3px solid var(--af-focus);
    outline-offset: 2px;
}

/* Casilla de verificación grande */
.af-check {
    display: flex !important;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-weight: 400 !important;
    line-height: 1.45;
}

.af-check input {
    width: 26px;
    height: 26px;
    min-height: 0;
    flex-shrink: 0;
    margin: 0;
    accent-color: var(--af-teal);
    cursor: pointer;
}

/* Mostrar / ocultar contraseña */
.af-password {
    position: relative;
}

.af-password input {
    padding-right: 7.5rem;
}

.af-toggle-pass {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    min-height: 42px;
    padding: 0 0.9rem;
    border: 0;
    border-radius: 8px;
    background: var(--af-teal-soft);
    color: var(--af-teal);
    font-weight: 700;
    font-size: 0.98rem;
    font-family: inherit;
    cursor: pointer;
}

/* Botón principal */
.af-submit,
.rx-submit {
    width: 100%;
    min-height: 60px;
    border: 0;
    border-radius: 12px;
    background: #1E8E3E !important;
    color: white;
    font-size: 1.2rem !important;
    font-weight: 800;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.af-submit:hover,
.rx-submit:hover,
.af-submit:focus-visible,
.rx-submit:focus-visible {
    background: #E06A00 !important;
}

.af-submit[disabled],
.rx-submit[disabled] {
    opacity: 0.7;
    cursor: wait;
}

/* Mensajes de resultado */
.af-result {
    border-radius: 14px;
    padding: 1.4rem 1.5rem;
    margin-top: 1.4rem;
    font-size: 1.05rem;
    line-height: 1.55;
}

.af-result[hidden] {
    display: none;
}

.af-result h3 {
    font-size: 1.25rem;
    margin: 0 0 0.5rem;
    display: flex;
    gap: 10px;
    align-items: center;
}

.af-result p {
    margin: 0.3rem 0;
}

.af-result.info {
    background: #EEF6FF;
    border: 2px solid #9CC3F0;
    color: var(--af-ink);
}

.af-result.ok {
    background: #ECFDF3;
    border: 2px solid #A6E3BE;
    color: var(--af-ink);
}

.af-result.warn {
    background: #FFF8E6;
    border: 2px solid #F3C969;
    color: var(--af-ink);
}

.af-result a {
    color: var(--af-teal);
    font-weight: 700;
}

.af-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 0.9rem;
}

.af-btn-light {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 50px;
    padding: 0 1.1rem;
    border-radius: 10px;
    border: 2px solid var(--af-teal);
    background: white;
    color: var(--af-teal) !important;
    font-weight: 700;
    text-decoration: none;
    font-size: 1rem;
}

.af-btn-light:hover {
    background: var(--af-teal-soft);
}

/* Caja de ayuda junto al formulario */
.af-help {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: var(--af-teal-soft);
    border-radius: 14px;
    padding: 1.1rem 1.2rem;
    margin-top: 1.2rem;
    color: var(--af-ink);
    font-size: 1rem;
    line-height: 1.5;
}

.af-help i {
    color: var(--af-teal);
    font-size: 1.4rem;
    margin-top: 2px;
}

.af-help a {
    color: var(--af-teal);
    font-weight: 800;
    font-size: 1.1rem;
    text-decoration: none;
    white-space: nowrap;
}

/* Tarjeta contenedora para formularios fuera de las páginas de receta */
.af-card {
    background: white;
    border: 1px solid #DDE3E8;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(29, 42, 56, 0.06);
}

.af-card h2 {
    font-size: 1.6rem;
    color: var(--af-ink);
    margin: 0 0 0.4rem;
}

.af-card > p {
    color: var(--af-body);
    font-size: 1.05rem;
    margin: 0 0 1.2rem;
}

@media (max-width: 700px) {
    .af-grid,
    .rx-grid,
    .af-choices {
        grid-template-columns: 1fr;
    }

    .af-card {
        padding: 1.3rem 1.1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .af *,
    .rx-form * {
        transition: none !important;
    }
}

.af-card-wide {
    max-width: 760px;
    margin: 0 auto 40px;
}

.af-card-narrow {
    max-width: 520px;
    margin: 0 auto 40px;
}

.af-center {
    text-align: center;
    margin-top: 1rem;
}

.af-center a {
    color: var(--af-teal);
    font-weight: 700;
}

/* Barra de progreso del seguimiento */
.af-progress {
    height: 14px;
    background: #DDE3E8;
    border-radius: 10px;
    overflow: hidden;
    margin: 0.6rem 0 0.3rem;
}

.af-progress span {
    display: block;
    height: 100%;
    background: var(--af-teal);
    border-radius: 10px;
}

/* El título del grupo se comporta como un bloque normal (sin cortar líneas) */
.af legend {
    float: left;
    width: 100%;
}

.af legend + * {
    clear: both;
}

/* Campo trampa antispam: invisible para las personas */
.af-trampa {
    position: absolute !important;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Contador de caracteres */
.rx-counter {
    text-align: right;
}

/* Botón mientras se envía */
.rx-submit[aria-busy="true"] {
    font-size: 1.05rem !important;
}

/* =========================================
   AVISO Y CONFIGURACIÓN DE COOKIES
   ========================================= */
.cookie-bar {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    z-index: 3000;
    max-width: 1080px;
    margin: 0 auto;
    background: #1D2A38;
    color: white;
    border-radius: 14px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
    transform: translateY(140%);
    transition: transform 0.35s ease;
}

.cookie-bar.show {
    transform: translateY(0);
}

.cookie-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
}

.cookie-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.cookie-text {
    flex: 1;
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: #E8EDF2;
}

.cookie-text strong {
    color: white;
}

.cookie-text a {
    color: #7FE0E2;
    font-weight: 700;
    text-decoration: underline;
}

.cookie-acciones {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.cookie-btn {
    min-height: 46px;
    padding: 0 1.2rem;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.cookie-btn:focus-visible {
    outline: 3px solid #FFC94D;
    outline-offset: 2px;
}

.cookie-accept {
    border: 2px solid #1E8E3E;
    background: #1E8E3E;
    color: white;
}

.cookie-accept:hover {
    background: #187634;
    border-color: #187634;
}

/* Rechazar tiene el mismo peso visual que Aceptar */
.cookie-reject {
    border: 2px solid #FFFFFF;
    background: transparent;
    color: white;
}

.cookie-reject:hover {
    background: rgba(255, 255, 255, 0.12);
}

.cookie-config {
    border: 2px solid transparent;
    background: transparent;
    color: #7FE0E2;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cookie-config:hover {
    color: white;
}

/* Panel de configuración */
html.cookie-panel-abierto {
    overflow: hidden;
}

.cookie-panel-fondo {
    position: fixed;
    inset: 0;
    z-index: 3100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(13, 22, 31, 0.55);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.cookie-panel-fondo.show {
    opacity: 1;
}

.cookie-panel {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 28px 28px 24px;
    border-radius: 16px;
    background: white;
    color: #1D2A38;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.cookie-panel h2 {
    margin: 0 40px 8px 0;
    font-size: 1.4rem;
    color: #1D2A38;
}

.cookie-panel-intro {
    margin: 0 0 16px;
    font-size: 15px;
    line-height: 1.5;
    color: #4A5866;
}

.cookie-panel-x {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: #EEF2F5;
    color: #1D2A38;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.cookie-panel-x:hover {
    background: #E1E7EC;
}

.cookie-tipo {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
    border-top: 1px solid #E6EBEF;
}

.cookie-tipo-texto {
    flex: 1;
}

.cookie-tipo-texto strong {
    display: block;
    font-size: 16px;
    margin-bottom: 2px;
}

.cookie-tipo-texto span {
    font-size: 14px;
    line-height: 1.45;
    color: #5B6976;
}

.cookie-siempre {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
    color: #0E7C7E;
}

.cookie-switch {
    position: relative;
    flex-shrink: 0;
    width: 52px;
    height: 30px;
    cursor: pointer;
}

.cookie-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.cookie-slider {
    position: absolute;
    inset: 0;
    border-radius: 30px;
    background: #C5CED6;
    transition: background 0.2s;
}

.cookie-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s;
}

.cookie-switch input:checked + .cookie-slider {
    background: #129B9E;
}

.cookie-switch input:checked + .cookie-slider::after {
    transform: translateX(22px);
}

.cookie-switch input:focus-visible + .cookie-slider {
    outline: 3px solid #FFC94D;
    outline-offset: 2px;
}

.cookie-panel-acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid #E6EBEF;
}

.cookie-panel-acciones .cookie-btn {
    flex: 1 1 auto;
}

.cookie-panel .cookie-reject {
    border-color: #1D2A38;
    color: #1D2A38;
}

.cookie-panel .cookie-reject:hover {
    background: #F1F4F6;
}

.cookie-guardar {
    border: 2px solid #129B9E;
    background: white;
    color: #0E7C7E;
}

.cookie-guardar:hover {
    background: #E8F6F6;
}

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

@media (max-width: 860px) {
    .cookie-inner {
        flex-wrap: wrap;
    }

    .cookie-acciones {
        width: 100%;
    }

    .cookie-acciones .cookie-btn {
        flex: 1;
    }
}

@media (max-width: 640px) {
    .cookie-bar {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .cookie-inner {
        padding: 14px;
        gap: 10px;
    }

    .cookie-icon {
        display: none;
    }

    .cookie-text {
        font-size: 14px;
    }

    .cookie-acciones {
        flex-wrap: wrap;
    }

    .cookie-acciones .cookie-accept,
    .cookie-acciones .cookie-reject {
        flex: 1 1 40%;
    }

    .cookie-acciones .cookie-config {
        order: 3;
        flex: 1 1 100%;
        min-height: 38px;
    }

    .cookie-panel {
        padding: 22px 18px 18px;
    }

    .cookie-panel-acciones .cookie-btn {
        flex: 1 1 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cookie-bar,
    .cookie-panel-fondo,
    .cookie-slider,
    .cookie-slider::after {
        transition: none;
    }
}

/* Enlaces legales en el pie */
.sf-legal {
    display: block;
    margin-top: 6px;
}

.sf-legal a {
    color: var(--primary-color, #24AEB1);
    margin: 0 6px;
}

/* Ayuda junto a la etiqueta (RUT del responsable) */
.af-label-help { display: block; font-weight: 400; font-size: .9em; color: #5b6573; margin-top: 2px; }
/* Nota de medios de pago en el pie */
.sf-pay-note { margin: 8px 0 0; font-size: .9rem; opacity: .9; }
/* Horario sin MAYÚSCULAS (T10) */
.branch-closed { text-transform: none; letter-spacing: 0; font-size: 13px; }
