/* ==========================================================================
    style.css — UAA Vocacional: estilos unificados
    --------------------------------------------------------------------------
    Estructura:
    01) Variables y resets
    02) Utilidades
    03) Layouts por página (formulario / test)
    04) Componentes comunes (botones)
    05) Formulario centrado (.container)
    06) Sección introductoria del test
    07) Tabla del test (sticky header, zebra, radios, colores por columna)
    08) Responsivo
    09) Impresión
   ========================================================================== */

/* ==========================================================================
    01) Variables y resets
   ========================================================================== */
:root{
    --color-bg-site: #f9fbfd;
    --color-card: #ffffff;
    --color-text: #2c3e50;
    --color-border: #ccc;
    --color-shadow: rgba(0,0,0,.1);
    --color-green: #4caf50;
    --color-green-hover: #45a049;
    --color-red: #ff0000;
    --color-red-hover: #e50000;
    --color-th-red: #ff0000; /* Mantener rojo original (#4) */
}

*, *::before, *::after{
    box-sizing: border-box; /* Box model predecible */
}

html, body{
    margin: 0;
    padding: 0;
    min-height: 100%;
    line-height: 1.5;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--color-text);
    background-color: var(--color-bg-site);
}

/* Fondo global para ambas páginas */
body{
    background-image: url("img/fondo.jpg");
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center center;
    background-attachment: fixed; /* se desactiva en móviles abajo */
}

/* ==========================================================================
    02) Utilidades
   ========================================================================== */

/* Solo para lectores de pantalla */
.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;
}

/* Espaciados */
.mt0{
    margin-top: 0;
}
.mt10{
    margin-top: 10px;
}
.mt15{
    margin-top: 15px;
}
.mt20{
    margin-top: 20px;
}
.mb10{
    margin-bottom: 10px;
}
.mb15{
    margin-bottom: 15px;
}
.mb20{
    margin-bottom: 20px;
}
.pt0{
    padding-top: 0;
}

/* Text */
.text-center{
    text-align: center;
}

/* ==========================================================================
    03) Layouts por página
    --------------------------------------------------------------------------
    Añadí una clase al <body> para evitar conflictos entre páginas:
    - <body class="page-form">  → vista de formulario centrado
    - <body class="page-test">  → vista del test (ambas usan el fondo del body)
   ========================================================================== */

/* 3.1) Formulario centrado */
.page-form{
    /* transparente para ver el fondo global del body */
    background-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh; /* usa min-height para evitar problemas en móviles */
    width: 100%;
    position: relative;
}

/* 3.2) Test (sin fondo propio; hereda del body) */
.page-test{
    background-color: transparent;
    min-height: 100vh;
    padding: 20px;
}

/* ==========================================================================
    04) Componentes comunes
   ========================================================================== */

/* Enlace con aspecto de botón (mejor semántica que <button onclick>) */
.btn,
button{
    background-color: var(--color-green);
    color: #fff;
    padding: 14px 20px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    line-height: 1.6;
    display: inline-block;
}

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

/* Accesibilidad: foco visible (útil para teclado) */
.btn:focus-visible,
button:focus-visible{
    outline: 3px solid #2e7d32;
    outline-offset: 2px;
}

.btn-cancelar {
    margin-top: 1px;
    margin-left: 2px;
    background-color: var(--color-red);
}

.btn-cancelar:hover {
    background-color: var(--color-red-hover);
}

.btn-block {
    display: block;
}

/* ==========================================================================
    05) Formulario centrado (.container) — inputs de texto/select
    --------------------------------------------------------------------------
    Importante: se limita el alcance de estilos de inputs para NO afectar
    a los radios de la tabla del test.
   ========================================================================== */

.container{
    background-color: var(--color-card);
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 0 20px var(--color-shadow);
    width: 90%;
    max-width: 400px;
    min-width: 280px;
    position: relative;
    z-index: 1;
}

.container h2{
    text-align: center;
    color: var(--color-text);
    margin-top: 0;
}

.container label{
    display: block;
    margin-top: 15px;
    margin-bottom: 5px;
    font-weight: 500;
}

/* Inputs/select del formulario (no radios del test) */
.container input,
.container select{
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    font-size: 14px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #fff;
}

/* Ícono de flecha para <select> (SVG embebido en una sola línea) */
.container select{
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23999'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 40px; /* espacio para el ícono */
}

/* Foco visible en campos del formulario */
.container input:focus-visible,
.container select:focus-visible{
    outline: 3px solid #2e7d32;
    outline-offset: 2px;
}

/* ==========================================================================
    06) Sección introductoria del test
   ========================================================================== */

.intro-container{
    max-width: 1280px;
    margin: 20px auto;
    padding: 24px 28px;
    background-color: rgba(255,255,255,0.95);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    text-align: center;
}

.intro-container h1{
    font-size: 28px;
    color: var(--color-red-hover);
    margin: 0 0 6px;
}

.intro-container h2{
    font-size: 22px;
    color: #000;
    margin: 0 0 16px;
}

.intro-container .instrucciones{
    font-size: 16px;
    color: #000;
    font-style: italic;
}

/* ==========================================================================
    07) Tabla del test (sticky header, zebra, radios, colores por columna)
   ========================================================================== */

/* Contenedor con scroll para que el thead sticky funcione */
.table-container{
    max-width: 1280px;
    margin: 20px auto;
    border: 1px solid var(--color-bg-site);
    border-radius: 8px;
    background-color: rgba(255,255,255,0.95);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Limitar estilos a la tabla del test */
.table-container table{
    width: 100%;
    border-collapse: collapse;
}

.table-container th,
.table-container td{
    border: 1px solid #ddd;
    padding: 12px;
    font-size: 15px;
}

/* Encabezado pegajoso (mantener rojo original) */
.table-container th{
    position: sticky;
    top: 0;
    background-color: var(--color-th-red); /* (NO cambiar por #4) */
    color: #fff;
    z-index: 2;
    font-size: 19px;   /* tamaño grande para contraste AA */
    font-weight: 700;
}

/* Filas de sección del cuestionario (reemplazo del inline style) */
.table-container tr.seccion td,
.table-container tr.seccion th{
    background: #dce6f1;
    font-weight: 500;
    font-size: 16px;
    padding: 10px;
}

/* Si se usa <th> en filas de sección, evitar sticky y color del header principal */
.table-container tr.seccion th{
    position: static;           /* no sticky */
    color: inherit;             /* no blanco */
    background: #dce6f1;        /* asegura el fondo correcto */
    z-index: 1;
}

/* Centrado de opciones (todas las columnas desde la 2) */
.table-container tbody td:nth-child(n+2){
    text-align: center;
}

/* Hover sobre filas de preguntas */
.table-container tbody tr:hover{
    background-color: rgba(238,247,255,0.9);
}

/* Estilo del texto de la pregunta */
.pregunta{
    font-weight: 600;
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.4;
    background: #dce6f1;
    font-weight: bold;
    font-size: 16px;
    padding: 10px;
}

/* Colores de fondo por columna (solo TD; no afecta TH) */
.table-container td:nth-child(2){ background-color: #ffe6e6; } /* No me interesa */
.table-container td:nth-child(3){ background-color: #fff8dc; } /* Tengo dudas */
.table-container td:nth-child(4){ background-color: #e6ffe6; } /* Me interesa */

/* Radios más visibles + color de acento (acotados a la tabla) */
.table-container input[type="radio"]{
    transform: scale(1.2);
    accent-color: var(--color-red-hover);
    border-color: var(--color-red-hover);
}

.actions {
    max-width: 1280px;
    margin: 20px auto;
}

/* ==========================================================================
    10) Resultados (página de resultados)
   ========================================================================== */

/* Layout general de la página de resultados */
.page-results{
    background-color: transparent;
    min-height: 100vh;
    padding: 20px;
}

/* Mensaje destacado con top-3 */
.page-results #mensaje{
    background-color: rgba(208, 240, 192, 0.95);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    font-size: 18px;
    font-weight: 500;
    max-width: 700px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.page-results #listadoCarreras{ margin-top: 40px; }

.page-results .resultado-carrera{ margin-bottom: 20px; }

.page-results .label{
    font-weight: bold;
    margin-bottom: 4px;
    display: block;
}

.page-results .progress{
    background-color: #e0e0e0;
    border-radius: 20px;
    overflow: hidden;
    height: 24px;
}

.page-results .progress-bar{
    height: 100%;
    text-align: right;
    padding-right: 10px;
    line-height: 24px;
    color: #fff;
    font-weight: bold;
    background-color: var(--color-green);
    width: 0%;
    transition: width 1s ease-in-out;
}

/* ==========================================================================
    08) Responsivo
   ========================================================================== */

/* ≤ 768px */
@media (max-width: 768px){
    /* Mejor rendimiento: desactivar fondo fijo global */
    body{
        background-attachment: scroll;
    }

    /* Test: ajustar padding */
    .page-test{
        padding: 12px;
    }

    .table-container th,
    .table-container td{
        padding: 10px;
        font-size: 14px;
    }

    .pregunta{
        font-size: 13px;
    }

    /* Formulario centrado: card más compacto */
    .container{
        padding: 20px;
        margin: 20px;
        width: calc(100% - 40px);
    }

    /* Resultados */
    .page-results #mensaje{ font-size: 16px; padding: 15px; }
    .page-results h2, .page-results h3{ font-size: 1.4em; }
}

/* ≤ 480px */
@media (max-width: 480px){
    /* Test: celdas y tipografía más compactas */
    .table-container th,
    .table-container td{
        padding: 8px;
        font-size: 13px;
    }

    .pregunta{
        font-size: 12px;
    }

    /* Escala de radios ligeramente menor en pantallas muy pequeñas (solo tabla) */
    .table-container input[type="radio"]{
        transform: scale(1.1);
    }

    /* Formulario centrado: evitar zoom automático en iOS (solo inputs del form) */
    .container input,
    .container select,
    .container button{
        font-size: 16px;
    }

    .container{
        padding: 15px;
        margin: 10px;
        width: calc(100% - 20px);
    }

    .container h2{
        font-size: 1.5em;
    }

    /* Resultados */
    .page-results #mensaje{ font-size: 14px; padding: 12px; }
    .page-results h2, .page-results h3{ font-size: 1.2em; }
}

/* ==========================================================================
    09) Impresión
   ========================================================================== */
@media print{
    /* Fondo blanco al imprimir (sin imagen) */
    body{
        background: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .table-container{
        box-shadow: none;
        max-height: none;
        overflow: visible;
    }

    /* Bordes nítidos y encabezado no sticky en impresión */
    .table-container th,
    .table-container td{
        border-color: #000;
    }

    .table-container th{
        position: static !important; /* evita glitches en algunos drivers */
    }

    .table-container thead{
        display: table-header-group; /* ayuda a repetir el header por página */
    }

    /* Evitar fondos de columna en impresión */
    .table-container td:nth-child(2),
    .table-container td:nth-child(3),
    .table-container td:nth-child(4){
        background: #fff !important;
    }
}
