/* ============================================================
   ESTILOS GENERALES
   ============================================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Roboto, system-ui, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.container {
    max-width: 480px;
    width: 100%;
    background: white;
    border-radius: 32px;
    padding: 32px 24px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    text-align: center;
    position: relative;
}

/* ============================================================
   TIPOGRAFÍA
   ============================================================ */
h1 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.subtitle {
    color: #64748b;
    font-size: 0.95rem;
    margin-bottom: 24px;
}

/* ============================================================
   PROGRESO (texto + barra) - VERSIÓN CORREGIDA Y VÁLIDA
   ============================================================ */

/* El botón "Comprobar" con barra de progreso interna */
#comprobarBtn {
    position: relative;              /* Necesario para posicionar la barra absoluta */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 32px;              /* Mismo padding que otros botones */
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 40px;
    background: #3b82f6;             /* Color de fondo del botón (se ve cuando no hay barra) */
    color: white;
    cursor: pointer;
    transition: 0.2s;
    overflow: hidden;                /* Para respetar el border-radius de la barra */
    min-width: 120px;
    height: 52px;
    line-height: 1.2;
    text-align: center;
    gap: 6px;
}

/* Texto del botón: siempre por encima de la barra */
#comprobarBtn .btn-text {
    position: relative;
    z-index: 2;
    pointer-events: none;            /* Permite que los clics pasen al botón */
}

/* Barra de progreso (ocupa todo el botón) */
#comprobarBtn .progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 0%;                       /* Se actualizará con JavaScript */
    height: 100%;
    display: block;                  /* Imprescindible cuando usamos <span> */
    background: #22c55e;             /* Verde brillante (sólido) – puedes cambiarlo */
    /* Si prefieres degradado: */
    /* background: linear-gradient(90deg, #3b82f6, #22c55e); */
    border-radius: 40px;             /* Debe coincidir con el border-radius del botón */
    transition: width 0.4s ease;
    z-index: 1;
    pointer-events: none;            /* Para que no interfiera con los clics */
    box-sizing: border-box; /* ocupe todo el botón */
}

/* Hover y disabled – se mantienen de la definición general de button */
#comprobarBtn:hover:not(:disabled) {
    background: #2563eb;
    transform: scale(1.02);
}
#comprobarBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ============================================================
   PROGRESO (texto + barra) - ESTILOS ADICIONALES (si se usan fuera del botón)
   ============================================================ */
.progress {
    font-size: 0.9rem;
    color: #475569;
    background: #f1f5f9;
    padding: 8px 16px;
    border-radius: 40px;
    display: inline-block;
    margin-bottom: 6px;
}

.progress-bar-wrapper {
    width: 100%;
    background-color: #e9ecef;
    border-radius: 20px;
    height: 10px;
    margin: 4px 0 20px 0;
    overflow: hidden;
}

/* ============================================================
   CONTADOR DE ACIERTOS/FALLOS
   ============================================================ */
.contador {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 0.95rem;
    color: #475569;
    background: #f1f5f9;
    padding: 8px 16px;
    border-radius: 40px;
    margin-bottom: 16px;
}
.contador span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.contador .aciertos { color: #166534; }
.contador .fallos { color: #991b1b; }

/* ============================================================
   CAJA DE PREGUNTA
   ============================================================ */
.question-box {
    background: #f8fafc;
    border-radius: 20px;
    padding: 24px 16px;
    margin-bottom: 24px;
    overflow: visible;           /* No cortar contenido desbordado */
}

.question-text {
    font-size: 1.5rem;
    font-weight: 500;
    color: #0f172a;
    margin-bottom: 8px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    max-width: 100%;
}

.hint {
    font-size: 0.9rem;
    color: #64748b;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

/* ============================================================
   INPUT Y BOTONES
   ============================================================ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

input {
    padding: 16px 20px;
    font-size: 1.3rem;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    outline: none;
    transition: 0.2s;
    text-align: center;
    letter-spacing: 1px;
    background: #f8fafc;
    width: 100%;
}

input:focus {
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 4px rgba(59,130,246,0.15);
}

input:disabled {
    background: #f1f5f9;
    opacity: 0.7;
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

button {
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 40px;
    background: #3b82f6;
    color: white;
    cursor: pointer;
    transition: 0.2s;
    flex: 1 1 auto;
    min-width: 80px;
    max-width: 200px;
    white-space: normal;
    word-break: break-word;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1.2;
}

button:hover:not(:disabled) {
    background: #2563eb;
    transform: scale(1.02);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

button.secondary {
    background: #e2e8f0;
    color: #1e293b;
}

button.secondary:hover:not(:disabled) {
    background: #cbd5e1;
}

button.success {
    background: #22c55e;
}

button.success:hover:not(:disabled) {
    background: #16a34a;
}

/* Botones específicos del panel de configuración */
.config-panel .button-group button {
    flex: 1 1 auto;
    padding: 8px 14px;
    font-size: 0.85rem;
    min-width: 70px;
    max-width: 180px;
}

/* ============================================================
   FEEDBACK
   ============================================================ */
#feedback {
    margin-top: 20px;
    padding: 16px;
    border-radius: 16px;
    font-weight: 500;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
    text-align: left;
    line-height: 1.6;
}

.correct {
    background: #dcfce7;
    color: #166534;
}

.incorrect {
    background: #fee2e2;
    color: #991b1b;
}

.info {
    background: #e6f0ff;
    color: #1e4e8a;
}

.error {
    background: #fee2e2;
    color: #991b1b;
}

/* ============================================================
   RESULTADO FINAL
   ============================================================ */
.result-box {
    background: #f0fdf4;
    border-radius: 20px;
    padding: 24px;
    margin-top: 16px;
}

.result-box h2 {
    font-size: 2rem;
    color: #166534;
}

/* ============================================================
   ESTADO SCORM Y LOADER
   ============================================================ */
.scorm-status {
    margin-top: 16px;
    font-size: 0.8rem;
    color: #94a3b8;
    border-top: 1px solid #e2e8f0;
    padding-top: 16px;
}

.loader {
    margin: 20px 0;
    color: #475569;
}

.loader .spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 4px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================================
   ESTADOS DE OXIDACIÓN (pregunta y botón)
   ============================================================ */
.estados-pregunta {
    margin-top: 10px;
    padding: 8px 12px;
    background: #f1f5f9;
    border-radius: 8px;
    font-size: 0.95rem;
    color: #60a5fa;  
    text-align: center;
}

.estados-btn {
    margin-top: 12px;
    padding: 8px 20px;
    font-size: 0.95rem;
    background: #e2e8f0;
    color: #1e293b;
    border: none;
    border-radius: 40px;
    cursor: pointer;
    transition: 0.2s;
}
.estados-btn:hover {
    background: #cbd5e1;
}
.estados-btn:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

.estados-info {
    margin-top: 10px;
    padding: 12px 16px;
    background: #f1f5f9;
    border-radius: 12px;
    font-weight: 500;
    color: #60a5fa; 
    text-align: center;
}
.estados-info.hidden {
    display: none;
}

.hidden-detail {
    display: none !important;
}

/* ============================================================
   PANTALLA DE INICIO
   ============================================================ */
#inicio {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
    text-align: center;
}
#inicio .logo {
    margin-bottom: 16px;
}
#inicio .logo img {
    width: 80px;
    height: auto;
}
#inicio .autor {
    margin: 16px 0 24px 0;
    font-size: 0.9rem;
    color: #475569;
}
#inicio .autor a {
    color: #3b82f6;
    text-decoration: none;
}
#inicio .autor a:hover {
    text-decoration: underline;
}

/* ============================================================
   BOTONES DE INICIO (más estrechos)
   ============================================================ */
.inicio-botones {
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.inicio-botones button {
    flex: 0 1 auto;
    min-width: auto;
    padding: 10px 20px;
    font-size: 1rem;
    white-space: nowrap;
}

/* Ajuste para móviles: si quieres que ocupen todo el ancho en pantallas pequeñas */
@media (max-width: 600px) {
    .inicio-botones button {
        flex: 1 1 100%;
        white-space: normal;
    }
}

/* Botones de la pantalla de inicio */
.inicio-botones button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    transition: 0.2s;
    min-width: 120px;
    height: 52px;
}

/* Tamaño del emoji */
.inicio-botones .emoji-grande {
    font-size: 2.5rem;
    line-height: 1;
}

/* ============================================================
   PANEL DE CONFIGURACIÓN (MEJORADO)
   ============================================================ */
.config-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 950px;
    max-height: 90vh;
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    z-index: 1000;
}

@media (max-width: 600px) {
    .config-panel {
        width: 95%;
        max-width: 100%;
        padding: 20px;
        top: 10px;
        transform: translateX(-50%);
        max-height: 95vh;
    }
}

.config-panel h2 {
    margin-top: 0;
    font-size: 1.5rem;
    text-align: center;
}
.config-panel .config-campo {
    margin: 16px 0;
}
.config-panel .config-campo label {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
}
.config-panel .config-campo label.inline {
    display: inline-block;
    margin-right: 12px;
    font-weight: normal;
}
.config-panel input[type="number"] {
    width: 80px;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
}
.config-panel select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
}

.config-panel .config-preview {
    background: #f1f5f9;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    overflow-x: auto;
    margin-top: 12px;
    max-height: 200px;
    white-space: pre-wrap;
    word-break: break-all;
}
.config-panel .button-group {
    margin-top: 16px;
}
.config-panel .button-group button {
    flex: 1;
}

/* Fondo oscuro detrás del panel (overlay) */
.config-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 999;
    display: none;
}
.config-overlay.active {
    display: block;
}

/* ============================================================
   MARCOS DE CONFIGURACIÓN (ajustados al contenido y centrados)
   ============================================================ */
.config-marco {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px auto;
    width: fit-content;
    max-width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 20px;
    background-color: #f8fafc;
}

.config-marco legend {
    font-weight: 600;
    padding: 0 8px 4px 8px;
    font-size: 0.95rem;
    color: #1e293b;
    width: 100%;
    margin-bottom: 2px;
    text-align: center;
    background-color: transparent;
}

#configFamilias,
#configTipos {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 18px;
    width: 100%;
}

/* ============================================================
   RESPONSIVE ADICIONAL (tablets y móviles)
   ============================================================ */
@media (max-width: 600px) {
    .container {
        padding: 24px 16px;
    }
    .question-text {
        font-size: 1.3rem;
    }
    button {
        flex: 1 1 100%;
        min-width: unset;
    }
    .config-panel {
        padding: 16px;
    }
    .inicio-botones button {
        min-width: 120px;
    }
    .contador {
        gap: 16px;
        font-size: 0.85rem;
        flex-wrap: wrap;
    }

    .config-marco {
        flex-direction: column;
        align-items: center;
        width: 100%;
        margin: 12px 0;
        padding: 12px;
        gap: 8px;
    }

    #configFamilias,
    #configTipos {
        flex-direction: column;
        align-items: center;
        gap: 6px;
        width: 100%;
    }
}

/* ============================================================
   CONFIGURACIÓN – Checkboxes y etiquetas
   ============================================================ */
.config-familia-item,
.config-marco label,
#configTipos label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    font-weight: normal;
    margin: 2px 0;
}

.config-familia-item label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: normal;
    margin-right: 0;
}

.config-nomenclaturas-container {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px 30px !important;
    margin-top: 4px !important;
    width: 100% !important;
}
.config-nomenclaturas-container label {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    white-space: nowrap !important;
    font-weight: normal !important;
    font-size: 0.95rem !important;
}

/* ============================================================
   BOTÓN COMPROBAR - centrado y padding simétrico
   ============================================================ */
/* NOTA: Este bloque ya está incluido en la sección "PROGRESO (texto + barra)" arriba.
   Lo dejamos como referencia pero sin duplicar. */
.foca {
    font-size: 2.5rem;
    display: inline-block;
    vertical-align: middle;
    margin-right: 4px;
}

/* ============================================================
   ACCESIBILIDAD: enfoque visible
   ============================================================ */
button:focus-visible,
input:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

/* ============================================================
   ESTILOS PARA EL RESUMEN DE RESULTADOS (tabla)
   ============================================================ */
#resultContainer table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.9rem;
}
#resultContainer th {
    background: #f1f5f9;
    font-weight: 600;
    padding: 8px 12px;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
}
#resultContainer td {
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
}
#resultContainer tr:last-child td {
    border-bottom: none;
}
#resultContainer .button-group {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================================
   AUTO‑AVANCE: contenedor del checkbox
   ============================================================ */
.auto-advance-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.85rem;
    color: #475569;
}
.auto-advance-container input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.auto-advance-container label {
    cursor: pointer;
}


/* Para iOS Safari 
- el motor WebKit maneja de forma más restrictiva ciertas propiedades CSS, sobre todo cuando los elementos se añaden dinámicamente al DOM. (que son los checks del panel que fallan) */

/* Primera sugerencia: "Asegurar que el contenedor de los checkboxes tenga estilos robustos en el CSS global (no solo en línea). " */

/* Tras ver captura: El problema es claramente de Safari (especialmente en iOS) y su manejo del flexbox y el texto con white-space: nowrap. Los textos se cortan o se envuelven mal porque los contenedores dinámicos no tienen estilos suficientes para que Safari los renderice correctamente. */

/* Para probar subo el css, y pruebo con https://www.browserling.com/ pero no se ve mejor, elimino */ 

