/* --- VARIABLES Y BASES --- */
:root {
    --uda: #003366;
    --GENERAL: #f1c40f;
    --ESPECIALIDAD: #27ae60;
    --OPTATIVA: #800000;
    --ELECTIVA: #7f8c8d;
    --PRACTICA: #4169E1; 
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background-color: #f0f2f5;
    margin: 0; padding: 20px;
    display: flex; flex-direction: column; align-items: center;
    overflow-x: hidden;
}

.background-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('fondo.png'); background-size: cover;
    background-position: center; opacity: 0.15; z-index: -2; pointer-events: none;
}

/* --- LOGOS Y HEADER (PC) --- */
.logo-top-left { position: absolute; top: 15px; left: 20px; z-index: 10; }
.logo-top-right { position: absolute; top: 15px; right: 20px; display: flex; gap: 15px; z-index: 10; }
.logo-img { height: 75px; width: auto; filter: drop-shadow(2px 2px 5px rgba(0,0,0,0.1)); }

header { text-align: center; color: var(--uda); margin-bottom: 10px; position: relative; z-index: 5; }
header h1 { font-size: 1.8rem; margin: 10px 0; }

/* --- MENÚ --- */
.menu-container { position: relative; display: inline-block; margin-bottom: 15px; z-index: 9999; }
.btn-menu { background: var(--uda); color: white; padding: 8px 30px; border: none; border-radius: 25px; cursor: pointer; font-weight: bold; font-size: 13px; }
.menu-content { display: none; position: absolute; left: 50%; transform: translateX(-50%); background-color: white; min-width: 260px; box-shadow: 0px 8px 20px rgba(0,0,0,0.3); border-radius: 8px; padding: 10px 0; text-align: left; }
.menu-container:hover .menu-content { display: block; }
.menu-content a { color: #333; padding: 10px 15px; text-decoration: none; display: block; font-size: 12px; }
.menu-content a:hover { background-color: #f1f1f1; }
.menu-title { display: block; padding: 5px 15px; font-size: 10px; color: #888; font-weight: bold; text-transform: uppercase; }

/* --- ESTADÍSTICAS --- */
.stats-bar {
    display: flex; justify-content: space-around; width: fit-content; min-width: 400px;
    background: var(--uda); color: white; padding: 10px 30px;
    border-radius: 50px; margin-bottom: 25px; font-size: 14px;
}
.time-estimate {
    background: #fff; color: var(--uda); border: 2px solid var(--uda);
    padding: 10px 20px; border-radius: 8px; margin-bottom: 20px;
    font-weight: bold; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    animation: pulse 2s infinite;
}

/* --- MALLA (CONTENEDOR) --- */
.malla-scroll-container {
    width: 100%;
    display: flex;
    justify-content: center;
    overflow-x: auto;
    padding-bottom: 20px;
}

#malla-container {
    display: flex;
    gap: 10px;
    padding: 20px;
}

/* --- MATERIAS / RAMOS --- */
.ano-col { display: flex; flex-direction: column; gap: 10px; }
.ano-label { background: var(--uda); color: white; text-align: center; font-size: 10px; padding: 4px; font-weight: bold; border-radius: 4px; }
.nivel-section { display: flex; flex-direction: column; gap: 6px; }
.nivel-label { text-align: center; font-size: 9px; background: #ddd; color: #444; font-weight: bold; padding: 2px; }

.materia {
    background: white; border: 1px solid #bbb;
    width: 120px; height: 90px;
    border-radius: 4px; position: relative;
    display: flex; flex-direction: column; justify-content: center;
    align-items: center; padding: 8px; box-sizing: border-box;
    cursor: pointer; opacity: 0.35; pointer-events: none;
    transition: 0.2s;
}

.materia.disponible { opacity: 1; pointer-events: auto; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.materia.aprobada { background: #2d3436 !important; color: white !important; border-top-color: #000 !important; }

/* Categorías */
.GENERAL { border-top: 5px solid var(--GENERAL); }
.ESPECIALIDAD { border-top: 5px solid var(--ESPECIALIDAD); }
.OPTATIVA { border-top: 5px solid var(--OPTATIVA); }
.ELECTIVA { border-top: 5px solid var(--ELECTIVA); }
.PRÁCTICA { border-top: 5px solid var(--PRACTICA) !important; }

.nombre { font-size: 10px; font-weight: bold; text-align: center; line-height: 1.1; width: 100%; margin-top: 10px; }
.info-top { position: absolute; top: 4px; left: 6px; right: 6px; display: flex; justify-content: space-between; font-size: 7px; font-weight: bold; color: #888; }
.info-bottom { position: absolute; bottom: 4px; left: 6px; right: 6px; display: flex; justify-content: space-between; font-size: 8px; font-weight: bold; color: #777; }

/* --- ELEMENTOS DE APOYO --- */
.legend { display: flex; justify-content: center; gap: 15px; margin-top: 30px; padding: 12px 25px; background: white; border-radius: 30px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.legend-item { display: flex; align-items: center; font-size: 10px; font-weight: bold; }
.dot { height: 10px; width: 10px; border-radius: 50%; margin-right: 6px; }
.dot-general { background: var(--GENERAL); }
.dot-especialidad { background: var(--ESPECIALIDAD); }
.dot-optativa { background: var(--OPTATIVA); }
.dot-electiva { background: var(--ELECTIVA); }
.dot-practica { background: var(--PRACTICA); }

.controls { display: flex; gap: 10px; margin-top: 20px; }
.btn { padding: 8px 16px; font-size: 11px; cursor: pointer; border: none; border-radius: 4px; color: white; }
.share { background: #0984e3; }
.pdf { background: #2d3436; }
.reset { background: #d63031; }

.mascota-dinamica {
    position: fixed; bottom: 0; right: 10px; width: 250px;
    z-index: -1; pointer-events: none; opacity: 0.85;
    animation: pulse 4s infinite ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* --- AJUSTES MÓVIL (SÓLO LO NECESARIO) --- */
@media (max-width: 768px) {
    /* 1. Logos arriba alineados */
    .logo-top-left, .logo-top-right {
        position: relative; top: 0; left: 0; right: 0;
        display: flex; justify-content: center; gap: 10px;
        margin: 5px auto;
    }
    .logo-img { height: 45px; }

    /* 2. Malla horizontal deslizable (Para que no se amontone) */
    .malla-scroll-container {
        justify-content: flex-start;
        padding-left: 10px;
    }
    #malla-container {
        width: max-content; /* Permite que crezca a la derecha */
    }
    .ano-col {
        min-width: 130px; /* Ancho fijo para cada año en el scroll */
    }

    /* 3. Mascota de fondo */
    .mascota-dinamica {
        width: 150px;
        right: 50%;
        transform: translateX(50%);
        opacity: 0.2;
    }

    /* 4. Otros ajustes */
    header h1 { font-size: 1.1rem; }
    .stats-bar { min-width: 90%; font-size: 11px; padding: 10px; }
    .legend { flex-wrap: wrap; gap: 10px; border-radius: 15px; }
}

@media print { .controls, .legend, .stats-bar, header, .menu-container { display: none; } }

/* --- SOLUCIÓN LOGOS EN FILA HORIZONTAL (CELULAR) --- */
/* --- AJUSTE FINAL: 3 LOGOS EN FILA Y MASCOTA --- */
@media (max-width: 768px) {
    /* 1. Contenedor para que los logos no se pierdan */
    .logo-top-left, .logo-top-right {
        position: static !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 8px !important; /* Espacio más pequeño para que quepan */
        margin: 5px 0 !important;
        width: 100% !important;
    }

    /* Unimos visualmente ambos contenedores en el flujo */
    .logo-top-right {
        margin-top: -5px !important; /* Los pega al de arriba para que parezcan una sola fila */
    }

    .logo-img {
        height: 42px !important; /* Tamaño ideal para que el Logo1 y los otros se mantengan */
        width: auto;
        filter: drop-shadow(1px 1px 3px rgba(0,0,0,0.1));
    }

    /* 2. Recuperamos a la mascota (Ratón) */
    .mascota-dinamica {
        width: 140px; /* Tamaño mediano, ni muy grande ni muy chico */
        bottom: 15px;
        right: 10px;
        opacity: 0.5; /* Un poco de transparencia para que no tape los ramos */
        z-index: -1; /* Pasa por detrás de las letras */
    }

    /* 3. Título compacto */
    header h1 {
        font-size: 1.1rem !important;
        padding: 0 10px;
    }

    /* 4. Menú accesible */
    .btn-menu {
        padding: 8px 20px;
        font-size: 12px;
    }
}




@media (max-width: 768px) {
    /* 1. LOGOS: Alineación perfecta en una sola fila */
    .header-logos-container {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 12px !important; /* Espacio uniforme entre los 3 */
        width: 100% !important;
        padding: 10px 0 !important;
    }

    /* Forzamos a que los contenedores antiguos no metan márgenes extra */
    .logo-top-left, .logo-top-right {
        position: static !important;
        display: flex !important;
        margin: 0 !important;
        padding: 0 !important;
        gap: 12px !important;
    }

    .logo-img {
        height: 38px !important; /* Un poco más pequeños para asegurar que no salten de línea */
        width: auto !important;
    }

    /* 2. ATACAMITO: Fijo, centrado y más visible */
    .mascota-dinamica {
        position: fixed !important; /* Se queda quieto en la pantalla al scrollear */
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 280px !important; /* Tamaño intermedio (no gigante) */
        opacity: 0.35 !important; /* Menos transparente para que se vea mejor */
        z-index: -1; 
        pointer-events: none; /* No estorba los clics en los ramos */
    }

    /* 3. TÍTULO Y MALLA */
    header h1 {
        font-size: 1.1rem !important;
        text-align: center;
        margin-top: 5px;
    }

    .malla-scroll-container {
        overflow-x: auto;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }

    #malla-container {
        width: max-content;
        padding: 20px;
    }
}





@media (max-width: 768px) {
    /* 1. LOGOS: Alineación horizontal perfecta */
    .header-logos-container {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 12px !important;
        width: 100% !important;
        padding: 10px 0 !important;
    }

    .logo-img {
        height: 38px !important;
        width: auto !important;
    }

    /* 2. ATACAMITO: Fijo y centrado */
    .mascota-dinamica {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 280px !important; 
        opacity: 0.35 !important;
        z-index: -1; 
        pointer-events: none;
    }

    /* 3. AJUSTES MALLA Y TÍTULO */
    header h1 { font-size: 1.1rem !important; margin-top: 5px; }
    .malla-scroll-container { overflow-x: auto; width: 100%; -webkit-overflow-scrolling: touch; }
    #malla-container { width: max-content; padding: 20px; }
}


.menu-main-center .menu-content {
    z-index: 9999 !important; /* Para que siempre flote por encima de Atacamito */
}
/* Estilos para los 3 botones principales */
.menu-container {
    display: flex;
    flex-direction: row; /* Esto los pone en fila */
    justify-content: center; /* Los centra horizontalmente */
    align-items: flex-start; /* Los alinea por la parte superior */
    gap: 20px; /* Espacio entre los botones */
    margin-top: 30px;
    width: 100%;
    flex-wrap: wrap; /* Importante: si la pantalla es chica, se bajan automáticamente */
}

/* Ajusta el ancho de los botones para que quepan bien en fila */
.btn-portada {
    width: 220px; /* Un poco más angostos para que quepan 3 en línea */
    padding: 15px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    background-color: var(--uda);
    color: white;
    border: none;
    border-radius: 10px;
    transition: 0.3s;
    text-transform: uppercase;
}

.dropdown-principal {
    position: relative;
    display: inline-block;
    width: 100%;
}

.btn-portada {
    width: 280px; /* Tamaño fijo para que todos se vean iguales */
    padding: 15px;
    font-size: 16px;
    cursor: pointer;
    background-color: var(--uda);
    color: white;
    border: none;
    border-radius: 10px;
    transition: 0.3s;
}

.link-directo {
    text-decoration: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* El contenido que se despliega */
.menu-content-custom {
    display: none;
    position: absolute;
    background-color: white;
    min-width: 280px;
    box-shadow: 0px 8px 16px rgba(0,0,0,0.2);
    z-index: 100;
    border-radius: 8px;
    margin-top: 5px;
}

.menu-content-custom a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    border-bottom: 1px solid #eee;
}

.menu-content-custom a:hover { background-color: #f1f1f1; }

/* Mostrar al pasar el mouse (PC) o tocar (Mobile) */
.dropdown-principal:hover .menu-content-custom {
    display: block;
}




.dropdown-principal { position: relative; width: 100%; }
.menu-content-custom {
    display: none;
    position: absolute;
    background-color: white;
    min-width: 280px;
    box-shadow: 0px 8px 16px rgba(0,0,0,0.2);
    z-index: 100;
    border-radius: 8px;
    left: 50%;
    transform: translateX(-50%);
}
.dropdown-principal:hover .menu-content-custom { display: block; }
.menu-content-custom a { color: black; padding: 12px; text-decoration: none; display: block; border-bottom: 1px solid #eee; }
.menu-content-custom a:hover { background-color: #f1f1f1; }

@media (max-width: 768px) {
    .menu-container {
        flex-direction: column; /* Vuelve a columna en celular */
        align-items: center;
    }
    
    .btn-portada {
        width: 280px; /* Vuelve al ancho original en celular */
    }
}



<style>
    /* Reset y Base */
    html, body { height: 100%; margin: 0; padding: 0; overflow: hidden; font-family: 'Segoe UI', sans-serif; }

    .body-portada {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        height: 100vh;
        background-color: #f0f2f5;
        position: relative;
    }

    /* NUEVO CONTENEDOR DE MENÚ EN FILAS */
    .menu-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
        z-index: 50;
        margin-top: 30px;
    }

    .fila-superior {
        display: flex;
        gap: 20px; /* Espacio entre Mallas y Repositorio */
        justify-content: center;
    }

    /* BOTÓN FLOTANTE DEL CHAT (El que lo abre) */
    #chat-trigger {
        position: fixed;
        bottom: 80px;
        right: 30px;
        width: 60px;
        height: 60px;
        background: #e67e22;
        color: white;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 5px 15px rgba(0,0,0,0.3);
        z-index: 1000;
        font-size: 30px;
        transition: 0.3s;
    }

    /* VENTANA DEL CHAT MOVIBLE */
    #chat-window {
        display: none; /* Empieza oculto */
        position: fixed;
        bottom: 150px;
        right: 30px;
        width: 350px;
        height: 450px;
        background: white;
        border-radius: 15px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        z-index: 1001;
        flex-direction: column;
        border: 2px solid #003366;
    }

    .chat-header {
        background: #003366;
        color: white;
        padding: 10px;
        cursor: move; /* Indica que se puede mover */
        display: flex;
        justify-content: space-between;
        border-top-left-radius: 12px;
        border-top-right-radius: 12px;
    }

    /* Ajustes móviles */
    @media (max-width: 768px) {
        .fila-superior { flex-direction: column; gap: 10px; }
        #chat-window { width: 90%; right: 5%; }
    }
</style>
/* Transición suave para que la expansión se vea como magia moderna */
#ventana-chat {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* LA CLASE MUTANTE: Esto es lo que pone el chat gigante */
.chat-expandido-max {
    position: fixed !important;
    top: 5vh !important;
    left: 5vw !important;
    width: 90vw !important; /* 90% del ancho de la pantalla */
    height: 90vh !important; /* 90% del alto de la pantalla */
    z-index: 99999 !important; /* Por encima de dioses y mortales */
    border-radius: 15px !important;
    box-shadow: 0 0 50px rgba(0,0,0,0.6) !important;
    max-height: none !important;
    max-width: none !important;
}

/* Ajuste vital: Que el área de mensajes crezca para rellenar el nuevo espacio */
/* Reemplaza '.chat-messages' por la clase donde aparecen los globos de texto */
.chat-expandido-max .chat-messages {
    height: calc(100% - 130px) !important; /* Altura total menos cabecera y el input de texto */
    max-height: none !important;
}