/* ===========================================================
   Prueba Saber 6.° - Matemáticas | Segundo periodo
   Hoja de estilos: diseño responsive para PC, tablet y celular
   =========================================================== */

:root {
    --azul-900: #14263f;
    --azul-700: #1d3557;
    --azul-500: #2c5282;
    --azul-300: #4a90d9;
    --azul-100: #e8f0fb;
    --verde: #2f9e6f;
    --verde-claro: #e6f5ee;
    --rojo: #d64545;
    --gris-900: #1f2933;
    --gris-600: #52606d;
    --gris-300: #d5dbe3;
    --gris-100: #f1f4f8;
    --fondo: #eef2f7;
    --blanco: #ffffff;

    --radio: 14px;
    --radio-sm: 9px;
    --sombra: 0 2px 4px rgba(20, 38, 63, .06), 0 8px 24px rgba(20, 38, 63, .08);
    --sombra-sm: 0 1px 2px rgba(20, 38, 63, .06), 0 3px 10px rgba(20, 38, 63, .06);
    --fila-alto: 2.9rem;
    /* alto de una fila: 5 filas visibles en la tabla */
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0 0 2.5rem;
    font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--gris-900);
    background-color: var(--fondo);
}

/* ---------- Encabezado ---------- */

.app-header {
    background: linear-gradient(135deg, var(--azul-700) 0%, var(--azul-500) 100%);
    color: var(--blanco);
    padding: 1.6rem 1rem 1.7rem;
    box-shadow: var(--sombra-sm);
}

.app-header__inner {
    max-width: 860px;
    margin: 0 auto;
    text-align: center;
}

.app-header__eyebrow {
    margin: 0 0 .35rem;
    font-size: .74rem;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .72);
}

.app-header h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.25;
}

.app-header__subtitle {
    margin: .3rem 0 0;
    font-size: .98rem;
    color: rgba(255, 255, 255, .85);
}

/* ---------- Contenedor y tarjetas ---------- */

.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 1.5rem 1rem 0;
}

.card {
    background-color: var(--blanco);
    border: 1px solid var(--gris-300);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    padding: 1.4rem 1.4rem 1.5rem;
    margin-bottom: 1.25rem;
}

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .85rem;
}

.card__title {
    margin: 0 0 1.1rem;
    font-size: 1.18rem;
    font-weight: 600;
    color: var(--azul-700);
}

.card__header .card__title {
    margin-bottom: 0;
}

.card__title--sm {
    font-size: 1.02rem;
}

.badge {
    display: inline-block;
    min-width: 2rem;
    padding: .15rem .6rem;
    border-radius: 999px;
    background-color: var(--azul-100);
    color: var(--azul-500);
    font-size: .82rem;
    font-weight: 600;
    text-align: center;
}

/* ---------- Formulario ---------- */

.form-group {
    margin-bottom: 1.05rem;
}

label {
    display: block;
    margin-bottom: .35rem;
    font-size: .92rem;
    font-weight: 600;
    color: var(--gris-600);
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: .7rem .85rem;
    border: 1px solid var(--gris-300);
    border-radius: var(--radio-sm);
    background-color: var(--blanco);
    font-family: inherit;
    font-size: 1rem;
    color: var(--gris-900);
    transition: border-color .2s, box-shadow .2s;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath fill='%2352606d' d='M1 1l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.4rem;
    cursor: pointer;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--azul-300);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, .18);
}

/* ---------- Botones ---------- */

.btn,
button {
    display: block;
    width: 100%;
    max-width: 340px;
    margin: 1.2rem auto 0;
    padding: .8rem 1.4rem;
    border: none;
    border-radius: var(--radio-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--blanco);
    background-color: var(--azul-500);
    cursor: pointer;
    transition: background-color .2s, transform .1s, box-shadow .2s;
    box-shadow: var(--sombra-sm);
}

.btn:hover,
button:hover {
    background-color: var(--azul-700);
}

.btn:active,
button:active {
    transform: translateY(1px);
}

.btn:focus-visible,
button:focus-visible {
    outline: 3px solid rgba(74, 144, 217, .45);
    outline-offset: 2px;
}

.card__title-grade {
    display: inline-block;
    margin-left: .35rem;
    padding: .05rem .5rem;
    border-radius: 999px;
    background-color: var(--azul-700);
    color: var(--blanco);
    font-size: .8rem;
    font-weight: 600;
    vertical-align: middle;
}

.sync-state {
    margin: .7rem 0 0;
    font-size: .82rem;
    color: var(--gris-600);
    text-align: right;
}

.sync-state--error {
    color: var(--rojo);
}

/* ---------- Tabla de estudiantes ---------- */

.table-scroll {
    /* 5 filas visibles + encabezado; el resto se ve con scroll vertical */
    max-height: calc(var(--fila-alto) * 6);
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--gris-300);
    border-radius: var(--radio-sm);
    -webkit-overflow-scrolling: touch;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

.results-table th,
.results-table td {
    padding: .6rem .75rem;
    text-align: left;
    border-bottom: 1px solid var(--gris-300);
    white-space: nowrap;
    height: var(--fila-alto);
}

.results-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: var(--gris-100);
    color: var(--azul-700);
    font-size: .82rem;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.results-table tbody tr:nth-child(even) {
    background-color: #fafbfd;
}

.results-table tbody tr:last-child td {
    border-bottom: none;
}

.results-table td:first-child {
    font-weight: 600;
    white-space: normal;
    min-width: 8rem;
}

.results-table .col-puntaje {
    white-space: normal;
    line-height: 1.25;
}

.results-table .col-puntaje small {
    display: block;
    font-size: .74rem;
    color: var(--gris-600);
    white-space: normal;
}

.chip-incompleta {
    display: inline-block;
    margin-top: .2rem;
    padding: .05rem .45rem;
    border-radius: 999px;
    background-color: #fdecec;
    color: var(--rojo);
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
}

.results-table .col-pct {
    font-weight: 600;
    color: var(--azul-500);
}

.results-table .col-pct--alto {
    color: var(--verde);
}

.results-table .col-pct--bajo {
    color: var(--rojo);
}

.results-table .col-fecha {
    color: var(--gris-600);
    font-size: .85rem;
    white-space: normal;
    line-height: 1.25;
}

.results-table .col-fecha span {
    display: block;
    white-space: nowrap;
}

.results-table .col-fecha small {
    display: block;
    white-space: nowrap;
    font-size: .78rem;
    opacity: .8;
}

.table-empty {
    margin: .9rem 0 0;
    text-align: center;
    color: var(--gris-600);
    font-size: .92rem;
}

/* ---------- Barra del cuestionario ---------- */

.quiz-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .7rem;
}

.quiz-bar__student {
    font-size: .92rem;
    font-weight: 600;
    color: var(--gris-600);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timer {
    flex-shrink: 0;
    padding: .2rem .7rem;
    border-radius: 999px;
    background-color: var(--azul-100);
    color: var(--azul-700);
    font-size: .9rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.progress-bar {
    height: 8px;
    background-color: var(--gris-100);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 1.1rem;
}

.progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--azul-300), var(--azul-500));
    border-radius: 999px;
    transition: width .35s ease;
}

/* ---------- Pregunta ---------- */

.question-container {
    padding: 0;
}

.question-number {
    margin: 0 0 .9rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--azul-100);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--azul-700);
}

.initial-info,
.secondary-info {
    margin: 0 0 1rem;
    padding: .85rem 1rem;
    border-radius: var(--radio-sm);
    font-size: 1rem;
}

.initial-info {
    background-color: var(--gris-100);
    color: var(--gris-900);
}

.secondary-info {
    background-color: var(--azul-100);
    border-left: 4px solid var(--azul-300);
    font-weight: 600;
    color: var(--azul-900);
}

.question-image-container {
    margin: 0 0 1rem;
    padding: .75rem;
    text-align: center;
    background-color: var(--blanco);
    border: 1px solid var(--gris-300);
    border-radius: var(--radio-sm);
}

#question-image {
    max-width: 100%;
    max-height: 340px;
    height: auto;
    border-radius: 6px;
}

/* ---------- Opciones ---------- */

.options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
    margin-top: 1rem;
}

.option {
    display: flex;
    align-items: center;
    padding: .85rem 1rem;
    background-color: var(--blanco);
    border: 2px solid var(--gris-300);
    border-radius: var(--radio-sm);
    cursor: pointer;
    transition: border-color .18s, background-color .18s, box-shadow .18s;
}

.option:hover {
    border-color: var(--azul-300);
    background-color: var(--azul-100);
}

.option.selected {
    border-color: var(--azul-500);
    background-color: var(--azul-100);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, .18);
}

.option.selected .option-text {
    color: var(--azul-900);
    font-weight: 600;
}

.option-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    width: 100%;
}

.option-image {
    max-width: 100%;
    max-height: 230px;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}

.option-text {
    text-align: center;
    font-size: .95rem;
    line-height: 1.4;
}

/* ---------- Resultados ---------- */

.results {
    text-align: left;
}

.score-panel {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding: 1.1rem;
    margin-bottom: 1.4rem;
    background-color: var(--panel-bg, var(--verde-claro));
    border-radius: var(--radio-sm);
    transition: background-color .3s;
}

.score-panel p {
    margin: 0;
    font-size: 1rem;
    color: var(--gris-900);
}

.score-panel__ring {
    position: relative;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: conic-gradient(var(--verde) 0deg, var(--gris-300) 0deg);
}

.score-panel__ring::before {
    content: "";
    position: absolute;
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background-color: var(--panel-bg, var(--verde-claro));
}

.score-panel__pct {
    position: relative;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--azul-900);
}

/* ---------- Utilidades ---------- */

.hidden {
    display: none !important;
}

.visible {
    display: block;
}

.hidden-section {
    display: none;
}

/* ---------- Tablet ---------- */

@media (max-width: 720px) {
    .app-header h1 {
        font-size: 1.35rem;
    }

    .card {
        padding: 1.15rem 1.05rem 1.25rem;
    }
}

/* ---------- Celular ---------- */

@media (max-width: 560px) {
    body {
        font-size: 15px;
        padding-bottom: 1.5rem;
    }

    .app-header {
        padding: 1.2rem .9rem 1.3rem;
    }

    .app-header h1 {
        font-size: 1.18rem;
    }

    .app-header__eyebrow {
        font-size: .68rem;
    }

    .container {
        padding: 1rem .7rem 0;
    }

    .card {
        padding: 1rem .9rem 1.1rem;
        border-radius: 12px;
    }

    .card__title {
        font-size: 1.05rem;
    }

    /* En pantallas angostas las opciones van en una sola columna */
    .options {
        grid-template-columns: 1fr;
        gap: .65rem;
    }

    .option {
        padding: .75rem .85rem;
        /* área táctil cómoda */
        min-height: 48px;
    }

    .option-image {
        max-height: 200px;
    }

    #question-image {
        max-height: 260px;
    }

    .btn,
    button {
        max-width: none;
        padding: .85rem 1rem;
    }

    .initial-info,
    .secondary-info {
        padding: .75rem .85rem;
        font-size: .96rem;
    }

    .results-table {
        font-size: .86rem;
    }

    .results-table th,
    .results-table td {
        padding: .5rem .45rem;
    }

    .results-table td:first-child {
        min-width: 5.2rem;
    }

    .results-table .col-puntaje small {
        font-size: .68rem;
    }

    .chip-incompleta {
        padding: .02rem .35rem;
        font-size: .64rem;
    }

    .results-table .col-fecha,
    .results-table .col-fecha small {
        font-size: .74rem;
    }

    .score-panel {
        flex-direction: column;
        text-align: center;
        gap: .8rem;
    }

    .score-panel__ring {
        width: 86px;
        height: 86px;
    }

    .score-panel__ring::before {
        width: 66px;
        height: 66px;
    }
}

/* Pantallas muy pequeñas */
@media (max-width: 360px) {
    .results-table .col-fecha {
        font-size: .78rem;
    }
}
