
/* ============================================
   VARIABLES Y CONFIGURACIÓN BASE
   ============================================ */
:root {
    --primary-bg: #f4f4f9;
    --accent-color: #174cbf;
    --text-color: #ffffff; /* Texto claro por defecto para el fondo oscuro */
    --border-radius: 20px;
    --transition: all 0.3s ease;
    /* Fuente base dinámica: se ajusta suavemente según la pantalla */
    --font-base: clamp(16px, 1.2vw, 24px);
}

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

body, html {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
    height: 100vh;
    overflow: hidden; /* Evita scroll no deseado en escritorio y pantallas gigantes */
    font-size: var(--font-base);
}

/* ============================================
   FONDOS Y CABECERA
   ============================================ */
#fondo-body {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -10;
    background-image: url(assets/img/fondo-color.svg);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
}


#logo-cabecera {
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100%;
    height: clamp(5em, 8vh, 10em); /* Se adapta según el dispositivo */ 
    background-image: url(assets/img/I.E.S.-SALVADOR-ALLENDE.png);
    background-size: contain;
    background-repeat: no-repeat;
    background-color: var(--primary-bg);
    z-index: 1;
    box-shadow: 0px 4px 10px rgba(0,0,0,0.5);
}
    


/* ============================================
   ESTRUCTURA PRINCIPAL (PC POR DEFECTO)
   ============================================ */
#app {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 90%;
    padding: 2vw;
    padding-top: clamp(6em, 10vh, 12em); /* Compensa el logo */
}

/* Vista Inicio */
.view-home {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 40px;
    width: 85%;
    max-width: 1400px;
    
}

.main-card {
    background: rgba(2, 88, 128, 0.816);
    backdrop-filter: blur(15px);
    border: 2px solid #0000005f;
    border-radius: var(--border-radius);
    padding: 60px 30px;
    text-align: center;
    font-size: clamp(1.8rem, 2.5vw, 3rem);
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 10px 15px rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}

.main-card:hover {
    transform: translateY(-10px);
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

/* Vista Detalle (El JS la pone en 'grid', así que definimos la estructura grid aquí) */
/* --- VISTA DETALLE AMPLIADA --- */
.view-detail {
    display: none; /* El JS lo cambia a 'grid' */
    width: 100vw;  /* Ocupa todo el ancho de la pantalla */
    height:100vh; /* Ocupa todo el alto  de la pantalla */
    grid-template-columns: 350px 1fr;
    grid-template-rows: auto 1fr;
    gap: 20px;
    background-color: rgba(0, 0, 0, 0.88); /* Fondo oscuro más envolvente */
    padding: 20px;
    margin: 0; /* Eliminamos los márgenes que hacían que se viera "suelto" */
    border: none; /* Quitamos bordes exteriores para un look más moderno */
    box-sizing: border-box;
    position: relative;
    z-index: 4;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-right: 10px;
    padding-bottom: 10px;
}

/* Ajuste del contenedor de la aplicación para que no limite la vista */
#app {
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Alinea al inicio para pegar la vista a la cabecera */
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 0; /* Quitamos el padding para que la vista de detalle toque los bordes */
}

/* Reajustamos la vista de inicio para que no se pegue arriba por culpa del cambio anterior */
.view-home {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 3vw;
    width: 85%;
    max-width: 1600px;
    margin-top: auto;
    margin-bottom: auto; /* Centra las tarjetas de inicio verticalmente */
}

/* Mantenemos la zona del video protegida para los controles */
.content-area {
    background: #000;
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px; /* Margen interno para que no se corten los textos del video */
    overflow: hidden;
}

video {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
}

.header-title {
    grid-column: 1 / -1;
    color: white;
    font-size: clamp(2rem, 3vw, 3.5rem);
    text-align: center;
    font-weight: bold;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(255,255,255,0.2);
}



/* ============================================
   ESTILOS DE LA BARRA DE DESPLAZAMIENTO (SCROLLBAR)
   Para todos los dispositivos
   ============================================ */

/* 1. Soporte estándar para Firefox */
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) rgba(255, 255, 255, 0.1);
}

/* 2. Soporte para Chrome, Edge y Safari */
.sidebar::-webkit-scrollbar {
    width: 8px;  /* Grosor de la barra vertical en PC */
    height: 8px; /* Grosor de la barra horizontal en móviles */
}

/* El fondo por donde se desliza la barra */
.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05); 
    border-radius: 10px;
}

/* La parte móvil (el "pulgar") de la barra */
.sidebar::-webkit-scrollbar-thumb {
    background: var(--accent-color); /* Tu color azul */
    border-radius: 10px;
}

/* Al pasar el ratón por encima, se pone un azul un poco más oscuro */
.sidebar::-webkit-scrollbar-thumb:hover {
    background: #123a9a; 
}
/* FIn de side bar */

.menu-btn {
    padding: 18px 20px;
    font-size: clamp(1.1rem, 1.2vw, 1.5rem);
    font-weight: bold;
    border-radius: 12px;
    border: 2px solid #0000006a;
    background: white;
    color: #000;
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
}

.menu-btn:hover, .menu-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    transform: translateX(5px);
}

.content-area {
    background: #000;
    border: 5px solid #000;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px; /* <-- CLAVE: Separa el video del borde para que no se corte nada */
    box-sizing: border-box;
    position: relative;
    /* Quitamos el overflow: hidden de aquí para que no recorte los controles */
}

video {
    width: 90%;
    height: 90%;
    max-height: 100%; /* <-- CLAVE: Evita que el video se amplíe más allá de la caja */
    object-fit: contain; /* Obliga a mantener el 16:9 original sin hacer zoom */
    border-radius: 10px; /* Le damos un borde curvo suave al propio video */
    outline: none; /* Quita el borde azul que sale a veces al hacer clic */
}

.placeholder-text {
    font-size: 1.5rem;
    color: #aaa;
    text-align: center;
}

/* Botón Volver (Escritorio) */
.back-btn {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: #000256f9;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    z-index: 100;
}

.video-copyright {
    position: absolute;
    bottom: 10px;
    left: 10px;
    color: rgba(255, 255, 255, 0.45);
    font-size: clamp(9px, 0.7vw, 14px);
    line-height: 1.3;
    font-weight: 400;
    pointer-events: none;
    z-index: 10;
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
    user-select: none;
    white-space: pre-line;
    max-width: 50%;
}

.back-btn:hover {
    background: #1f84cc;
}

/* Textos adaptativos */
.text-mobile { display: none; }
.text-desktop { display: inline; }

/* ============================================
   MÓVILES Y TABLETS (<= 1024px)
   ============================================ */
@media (max-width: 1024px) {
    body, html {
        overflow-y: auto; /* Permitir scroll si es necesario en móvil */
    }

    #app {
        padding: 15px;
        padding-top: calc(clamp(4em, 8vh, 6em) + 20px);
        width: 100vw;
        height: 100vh;
    }

    .view-home {
        grid-template-columns: 1fr;
        gap: 20px;
        width: 100%;
        margin-top: 2rem;
    }

    .main-card {
        padding: 30px 20px;
        min-height: 150px;
    }

    /* Modificamos el Grid para que sea una sola columna */
    .view-detail {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr auto; /* Titulo, Carrusel, Video, Vacio */
        height: auto;
        min-height: calc(100dvh - 120px); /* Usa dvh para evitar cortes con el navegador */
        padding: 15px;
        gap: 15px;
        margin-top: 10px;
    }

    .header-title {
        font-size: 1.5rem;
        border: none;
    }

    /* Carrusel Horizontal para los botones */
    .sidebar {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 5px;
        gap: 10px;
        -webkit-overflow-scrolling: touch; /* Scroll suave en iOS */
    }
    /*
    .sidebar::-webkit-scrollbar {
        height: 6px;
    }
    .sidebar::-webkit-scrollbar-thumb {
        background: var(--accent-color);
        border-radius: 3px;
    }
        */

    .menu-btn {
        flex: 0 0 auto; /* Evita que se encojan */
        white-space: nowrap;
        padding: 12px 20px;
        font-size: 1.1rem;
        text-align: center;
        border-width: 1px;
    }

    /* El contenedor del vídeo toma el espacio restante */
    .content-area {
        min-height: 40dvh; /* Asegura un tamaño mínimo decente */
        width: 100%;
        border-width: 3px;
        border-radius: 12px;
    }

    .back-btn {
        position: relative;
        bottom: 0;
        left: 0;
        width: 100%;
        padding: 15px;
        margin-top: 10px;
        text-align: center;
    }

    .text-desktop { display: none; }
    .text-mobile { display: inline; }
}

/* ============================================
   PANTALLAS GIGANTES DEL INSTITUTO (>= 2000px)
   ============================================ */
@media (min-width: 2000px) {
    :root {
        --font-base: 32px;
    }

    #app {
        padding-top: 15em;
    }

    #logo-cabecera {
        height: 15em;
    }

    .view-home {
        gap: 60px;
        max-width: 2000px;
        margin-top: 5rem;
    }

    .main-card {
        padding: 100px 50px;
        border-width: 6px;
        border-radius: 40px;
    }

    .view-detail {
        grid-template-columns: 500px 1fr;
        height: 75vh;
        max-height: none;
        padding: 50px;
        gap: 20px;
    }

    .header-title {
        font-size: 4rem;
        padding-bottom: 20px;
    }

    .sidebar {
        gap: 10px;
        padding-bottom: 160px;
    }

    .menu-btn {
        padding: 20px 25px;
        font-size: 1.5rem;
        border-width: 4px;
        border-radius: 20px;
    }

    .content-area {
        border-width: 8px;
        border-radius: 40px;
    }

    .placeholder-text {
        font-size: 3rem;
    }

    .back-btn {
        padding: 30px 60px;
        font-size: 1.5rem;
        bottom: 50px;
        left: 50px;
        border-radius: 60px;
    }
}
