/* ==========================================================================
   ATISA - PREMIUM DESIGN SYSTEM — APP-FIRST (zero scroll)
   ========================================================================== */

:root {
    --azul-atisa: #004766;
    --azul-texto: #0b4964;
    --verde-atisa: #9bd326;
    --gris-linea: #d8e1e8;
    --gris-texto: #5d6b7a;
    --gris-suave: #f4f8fa;
    --blanco: #ffffff;
    --sombra: 0 18px 45px rgba(0, 35, 50, 0.18);
    --radio: 24px;
    --primary-color: #004766;
    --accent-color: #9bd326;
    --text-color: #0b4964;
    --text-muted: #5d6b7a;
    --white: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    font-family: 'Lato', Arial, Helvetica, sans-serif;
    color: var(--azul-texto);
}

body.atisa-bg {
    background: url("../images/bg_premium.png") no-repeat center center fixed;
    background-size: cover;
}

/* ========== LAYOUT PRINCIPAL (viewport-locked) ========== */
.container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.main-card {
    width: min(980px, 100%);
    max-height: min(96vh, 96dvh);
    height: auto;
    background: var(--blanco);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

/* ========== CARD HEADER ========== */
.card-header {
    text-align: center;
    flex-shrink: 0;
    margin-bottom: 0;
}

.card-logo {
    max-width: 200px;
    width: auto;
    height: auto;
    margin-bottom: 0;
}

/* ========== LOGO ROW (Dual Branding) ========== */
.logo-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 2vh;
    flex-wrap: nowrap; /* Force same line */
}

.logo-row img {
    max-width: 130px;
    width: auto;
    height: auto;
    flex-shrink: 1;
}

.logo-row .separator {
    width: 1px;
    height: 40px;
    background-color: rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.card-title {
    font-family: 'Aleo', Georgia, serif;
    font-size: clamp(1rem, 2.5vh, 1.5rem);
    color: var(--azul-atisa);
    font-weight: 700;
    line-height: 1.15;
}

.card-subtitle {
    margin: 4px 0 0;
    color: var(--gris-texto);
    font-size: clamp(0.72rem, 1.4vh, 0.88rem);
    line-height: 1.3;
}

/* ========== PROGRESO ========== */
.progreso {
    margin: clamp(8px, 1.5vh, 18px) 0;
    flex-shrink: 0;
}

.progreso-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: clamp(0.7rem, 1.2vh, 0.82rem);
    color: var(--azul-atisa);
    margin-bottom: 6px;
    font-weight: 600;
}

.progreso-info strong { font-weight: 700; }

.barra {
    height: 5px;
    border-radius: 999px;
    background: #e8eef2;
    overflow: hidden;
}

.barra span {
    display: block;
    width: 0%;
    height: 100%;
    background: var(--verde-atisa);
    transition: width 0.25s ease;
}

.progress-container { display: none; }

/* ========== FORM FLEX LAYOUT ========== */
#form-questionnaire {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.question-slider {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.question-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.question-slide {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.question-slide.active {
    display: flex;
}

.question {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.user-info-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

/* Scrollbar styling for premium look */
.question::-webkit-scrollbar,
.user-info-container::-webkit-scrollbar {
    width: 4px;
}
.question::-webkit-scrollbar-track,
.user-info-container::-webkit-scrollbar-track {
    background: transparent;
}
.question::-webkit-scrollbar-thumb,
.user-info-container::-webkit-scrollbar-thumb {
    background-color: rgba(0, 71, 102, 0.2);
    border-radius: 10px;
}

/* ========== ETIQUETA ========== */
.etiqueta {
    display: inline-block;
    margin-bottom: clamp(4px, 0.8vh, 10px);
    padding: 4px 10px;
    border-radius: 999px;
    background: #eef6fa;
    color: var(--azul-atisa);
    font-size: clamp(0.65rem, 1.1vh, 0.78rem);
    font-weight: 700;
    line-height: 1.25;
    align-self: flex-start;
    flex-shrink: 0;
}

/* ========== PREGUNTA ========== */
.question-text {
    margin: 0 0 clamp(4px, 0.8vh, 12px);
    font-size: clamp(1rem, 2.8vh, 1.65rem);
    line-height: 1.18;
    color: var(--azul-atisa);
    font-weight: 700;
    flex-shrink: 0;
}

/* ========== AYUDA ========== */
.ayuda {
    margin: 0 0 4px;
    font-size: clamp(0.78rem, 1.4vh, 1rem);
    line-height: 1.4;
    color: var(--gris-texto);
    flex-shrink: 0;
}

/* ========== OPCIONES LIKERT — flex-grow para llenar espacio ========== */
.likert-options {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(8px, 1.2vh, 14px);
    margin: clamp(8px, 1.5vh, 20px) 0;
    flex-shrink: 0;
}

.likert-option {
    position: relative;
    min-height: 0;
}

.likert-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.likert-option label {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;          /* CLAVE: iguala todas las cajas a la celda más alta */
    padding: clamp(10px, 1.5vh, 18px) clamp(6px, 0.8vw, 12px) clamp(8px, 1.2vh, 16px);
    border: 2px solid var(--gris-linea);
    border-radius: 20px;
    background: var(--blanco);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    -webkit-tap-highlight-color: transparent;
    text-align: center;
    overflow: hidden;
}

.likert-option label:hover {
    transform: translateY(-2px);
    border-color: #bdd5e2;
    box-shadow: 0 10px 22px rgba(0, 71, 102, 0.10);
}

.likert-option input[type="radio"]:checked + label {
    border-color: var(--verde-atisa);
    background: #f7fcea;
    box-shadow: 0 10px 24px rgba(155, 211, 38, 0.25);
}

.likert-option .numero {
    width: clamp(26px, 4vh, 34px);
    height: clamp(26px, 4vh, 34px);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: clamp(4px, 1vh, 12px);
    background: #eef3f6;
    color: var(--azul-atisa);
    font-weight: 700;
    font-size: clamp(0.75rem, 1.3vh, 0.95rem);
    flex: 0 0 auto;
}

.likert-option input[type="radio"]:checked + label .numero {
    background: var(--verde-atisa);
    color: var(--azul-atisa);
}

.opcion-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 0;
    flex: 1;
}

.likert-option .nivel {
    margin: 0 0 clamp(2px, 0.6vh, 8px);
    font-size: clamp(0.7rem, 1.3vh, 0.9rem);
    font-weight: 700;
    color: var(--azul-atisa);
}

.likert-option .descripcion {
    margin: 0;
    color: var(--gris-texto);
    font-size: clamp(0.58rem, 1.1vh, 0.78rem);
    line-height: 1.3;
}

/* ========== NOTA CRITERIO (Badge) ========== */
.nota {
    margin-top: auto;
    padding: clamp(6px, 1vh, 12px) 14px;
    border-radius: 999px;
    background: var(--gris-suave);
    color: var(--gris-texto);
    font-size: clamp(0.65rem, 1.1vh, 0.82rem);
    line-height: 1.35;
    border: 1px solid #e2eaf0;
    flex-shrink: 0;
    text-align: center;
}

/* ========== FEEDBACK ========== */
.feedback-container {
    margin-top: 4px;
    flex-shrink: 0;
}

.feedback {
    padding: 8px 14px;
    border-radius: 12px;
    font-size: clamp(0.7rem, 1.2vh, 0.85rem);
    line-height: 1.35;
}

.feedback.positive { background: #f0fad6; color: #3d6b00; }
.feedback.neutral  { background: #fef9e7; color: #7a6a00; }
.feedback.negative { background: #fde8e8; color: #9b1c1c; }

/* ========== BOTONES NAVEGACIÓN ========== */
.question-nav {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-top: auto;
    padding-top: clamp(8px, 1.2vh, 16px);
    flex-shrink: 0;
    width: 100%;
}

.prev-question-btn, .next-question-btn, .submit-btn {
    min-width: 140px;
    border: none;
    border-radius: 14px;
    padding: clamp(10px, 1.6vh, 16px) 22px;
    font-size: clamp(0.8rem, 1.3vh, 0.94rem);
    font-weight: 700;
    letter-spacing: 0.35px;
    cursor: pointer;
    transition: opacity 0.18s ease, transform 0.18s ease;
    font-family: inherit;
    text-transform: uppercase;
}

.prev-question-btn:not(:disabled):active,
.next-question-btn:not(:disabled):active,
.submit-btn:not(:disabled):active {
    transform: scale(0.98);
}

.prev-question-btn:disabled,
.next-question-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.prev-question-btn {
    background: #eef3f7;
    color: #687889;
}

.next-question-btn, .submit-btn {
    background: var(--verde-atisa);
    color: var(--azul-atisa);
}

/* ========== LOADING ========== */
.loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--blanco);
    z-index: 1000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radio);
    gap: 15px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-overlay.visible {
    display: flex;
    opacity: 1;
    pointer-events: all;
}

.loading-overlay p {
    font-weight: 700;
    color: var(--azul-atisa);
    font-size: 0.85rem;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(155, 211, 38, 0.1);
    border-top: 3px solid var(--verde-atisa);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========== DATOS PERSONALES ========== */
.submit-container {
    padding: 0 5px;
}

.submit-container h2,
.user-info-container .question-text {
    color: var(--azul-atisa);
    font-family: 'Aleo', Georgia, serif;
    font-size: clamp(1rem, 2.2vh, 1.3rem);
    text-align: center;
    margin-bottom: 2vh;
    line-height: 1.2;
}

.user-info-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group {
    margin-bottom: 4px;
}

.form-group.full-width {
    grid-column: span 2;
}

.form-group label {
    display: block;
    font-weight: 700;
    font-size: 0.7rem;
    margin-bottom: 3px;
    color: var(--azul-atisa);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group label .required {
    color: #e53e3e;
    margin-left: 2px;
    font-size: 0.8rem;
}

.form-group input {
    width: 100%;
    padding: clamp(8px, 1.2vh, 12px) 15px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.9rem;
    background: white;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--verde-atisa);
    box-shadow: 0 0 0 4px rgba(155, 211, 38, 0.1);
}

.checkbox-group {
    grid-column: span 2;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.7rem;
    margin-top: 3px;
    color: var(--gris-texto);
    background: rgba(0,0,0,0.02);
    padding: 8px;
    border-radius: 8px;
}

.checkbox-group input {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    accent-color: var(--verde-atisa);
}

/* ========== RESPONSIVE: ≤ 900px — Lista vertical ========== */
@media (max-width: 900px) {
    .container { padding: 8px; }
    .main-card { padding: 16px 18px; height: min(98vh, 98dvh); }

    .likert-options {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .likert-option label {
        min-height: auto;
        display: grid;
        grid-template-columns: 36px 1fr;
        grid-template-areas:
            "numero nivel"
            "numero descripcion";
        align-items: center;
        column-gap: 10px;
        padding: clamp(8px, 1.5vh, 14px) 12px;
    }

    .likert-option .numero {
        grid-area: numero;
        margin: 0;
        width: 30px;
        height: 30px;
    }

    .opcion-info { display: contents; }

    .likert-option .nivel {
        grid-area: nivel;
        margin-bottom: 2px;
        text-align: left;
        font-size: 0.8rem;
    }

    .likert-option .descripcion {
        grid-area: descripcion;
        text-align: left;
        font-size: 0.72rem;
    }
}

/* ========== RESPONSIVE: ≤ 520px — Mobile Modal ========== */
@media (max-width: 520px) {
    .container { padding: 8px; }

    .main-card {
        height: 100%;
        max-height: 100%;
        border-radius: 20px;
        padding: 14px 14px 16px;
        box-shadow: var(--sombra);
    }

    .card-logo { max-width: 60px; }
    .logo-row { gap: 12px; margin-bottom: 1.5vh; }
    .logo-row img { max-width: 90px; }
    .logo-row .separator { height: 25px; }
    .card-title { font-size: 1rem; }
    .card-subtitle { font-size: 0.75rem; }
    .progreso { margin: 10px 0 12px; }
    .etiqueta { font-size: 0.68rem; padding: 3px 8px; }
    .question-text { font-size: 1rem; margin-bottom: 4px; }

    .likert-options { gap: 5px; margin: 8px 0; }

    .likert-option label {
        padding: 8px 10px;
        border-radius: 14px;
    }

    .nota { font-size: 0.68rem; padding: 5px 10px; }

    .question-nav { margin-top: 8px; gap: 10px; }

    .prev-question-btn, .next-question-btn, .submit-btn {
        min-width: 0;
        flex: 1;
        padding: 12px 10px;
        font-size: 0.82rem;
    }

    .user-info-fields { grid-template-columns: 1fr; }
    .checkbox-group { grid-column: span 1; }
}

/* ========== PANTALLAS ALTAS (> 800px height) — más espacio ========== */
@media (min-height: 800px) {
    .main-card { padding: 24px 28px; }
    .card-logo { max-width: 180px; }
    .question-text { font-size: clamp(1.3rem, 3vh, 1.75rem); }
}
