body {
    font-family: sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #f4f4f9;
    margin: 0;
    padding: 2vh 0; /* Un poco de respiro vertical para pantallas muy cortas */
    box-sizing: border-box;
}

/* Contenedor principal con perspectiva 3D */
.timeline-wrapper {
    position: relative;
    width: 85vw; /* Usamos viewport width en lugar de px fijos */
    max-width: 700px; 
    perspective: 1000px; 
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Barra superior de progreso (los circulitos) */
.progress-bar {
    display: flex;
    gap: 2vw; /* Espaciado dinámico */
    margin-bottom: 4vh; /* Viewport height para separación vertical */
    position: relative;
    width: 100%;
    justify-content: center;
}

/* Línea conectora de los puntos */
.progress-bar::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    width: 80%; /* Para que la línea no se salga en móviles */
    height: 3px;
    background: lightgray;
    z-index: 1;
    transform: translateY(-50%);
}

.dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: lightgray;
    z-index: 2;
    transition: all 0.4s ease;
}

.dot.active {
    background: #80DEEA;
    box-shadow: 0 0 10px rgba(128, 222, 234, 0.8);
    transform: scale(1.3);
}

/* Contenedor de las tarjetas */
.timeline-container {
    position: relative;
    width: 100%;
    height: 60vh; /* Altura basada en la pantalla */
    min-height: 450px; /* Altura mínima de seguridad para escritorio */
}

/* Estilo base de cada tarjeta (Fila) */
.fila {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    padding: 4vw; /* Padding dinámico */
    box-sizing: border-box;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    
    /* Estado inicial: Esperando a la derecha */
    opacity: 0;
    transform: translateX(100%) scale(0.8);
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.7s ease;
    pointer-events: none;
    overflow-y: auto; /* Permite scroll interno si el texto es muy largo en horizontal (landscape) */
}

/* Tarjeta actual (Centrada) */
.fila.active {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
    z-index: 2;
}

/* Tarjeta anterior (Se va hacia atrás) */
.fila.prev {
    opacity: 0;
    transform: translateZ(-300px) translateY(-20px) scale(0.6);
    z-index: 1;
}

/* Textos */
.fecha {
    font-size: 2em;
    font-weight: bold;
    color: #80DEEA;
    margin-bottom: 2vh;
}

.descripcion {
    font-size: 1.1em;
    color: #444;
    line-height: 1.5;
}

.subtitulo {
    margin: 10px 0; 
    color: #666;
    font-style: italic;
}

.lista-detallada {
    text-align: left; 
    font-size: 0.95em; 
    padding-left: 20px;
    margin-top: 15px;
}

.lista-detallada li {
    margin-bottom: 12px;
    line-height: 1.5;
}

/* --- Controles y Botones --- */
.controles {
    display: flex;
    gap: 15px;
    margin-top: 4vh;
    width: 100%;
    justify-content: center;
}

.btn-control {
    padding: 12px 30px;
    font-size: 1.1em;
    border: none;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

#btn-next {
    background: #26c6da;
    color: white;
    box-shadow: 0 4px 15px rgba(38, 198, 218, 0.4);
}

#btn-next:hover:not(:disabled) {
    background: #00acc1;
    transform: translateY(-2px);
}

#btn-prev {
    background: transparent;
    color: #26c6da;
    border: 2px solid #26c6da;
}

#btn-prev:hover:not(:disabled) {
    background: #e0f7fa;
    transform: translateY(-2px);
}

.btn-control:disabled {
    background: #cccccc;
    color: #666;
    border: 2px solid transparent;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Estilos de la tabla (Etapa 5) */
.tabla-responsive {
    overflow-x: auto;
    margin-top: 15px;
    width: 100%;
}

.matriz-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    text-align: left;
    min-width: 450px; /* Evita que las columnas se aplasten demasiado */
}

.matriz-tabla th, .matriz-tabla td {
    border: 1px solid #ddd;
    padding: 10px;
}

.matriz-tabla th {
    background-color: #26c6da;
    color: white;
    text-align: center;
}

.matriz-tabla td {
    text-align: center;
}

.riesgo-alto { color: #d32f2f; font-weight: bold; }
.riesgo-medio { color: #f57c00; font-weight: bold; }
.riesgo-bajo { color: #388e3c; font-weight: bold; }
.riesgo-excelente { color: #1976d2; font-weight: bold; }

/* ========================================= */
/*             MEDIA QUERIES                 */
/* ========================================= */

/* Tablets y celulares en horizontal */
@media screen and (max-width: 768px) {
    .timeline-wrapper {
        width: 95vw; /* Casi todo el ancho */
    }

    .timeline-container {
        height: 65vh; 
        min-height: 520px; /* Más espacio vertical porque el texto hace más saltos de línea */
    }

    .fila {
        padding: 25px 20px; /* Reducimos el padding para ganar espacio interior */
    }

    .fecha {
        font-size: 1.6em; /* Reducimos el tamaño del título */
    }

    .descripcion {
        font-size: 1em;
    }

    .lista-detallada {
        font-size: 0.9em;
        padding-left: 15px;
    }
}

/* Celulares en vertical (Pantallas pequeñas) */
@media screen and (max-width: 480px) {
    .timeline-container {
        height: 70vh;
        min-height: 580px; /* Máximo espacio vertical requerido para evitar cortes */
    }

    .fila {
        padding: 20px 15px;
        justify-content: flex-start; /* Alineamos arriba por si el texto es mucho */
    }

    .progress-bar {
        gap: 2vw; /* Juntamos los puntos */
    }

    .dot {
        width: 12px;
        height: 12px; /* Puntos más pequeños para que quepan los 9 */
    }

    /* Apilamos los botones para que sean fáciles de presionar con el pulgar */
    .controles {
        flex-direction: column-reverse; /* El de "Siguiente" queda arriba, es más intuitivo */
        gap: 10px;
    }

    .btn-control {
        width: 100%;
        padding: 15px 0;
    }

    .matriz-tabla {
        font-size: 0.8em;
    }
}