/* --- ¡NUEVO! Importar la fuente Montserrat --- */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700;900&display=swap');

/* --- INICIO: RESET Y ESTILOS GLOBALES --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    height: 100%;
    /* --- ¡CAMBIO! Nueva fuente --- */
    font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f6;
    color: #333;
}

a {
    text-decoration: none;
}

/* Regla global para imágenes responsivas */
img {
    max-width: 100%;
    height: auto;
    display: block; /* Previene espacios extra debajo de la imagen */
}

/* --- INICIO: NUEVO LAYOUT DEL DASHBOARD --- */

.app-wrapper {
    display: flex;
    height: 100vh;
}

/* --- 1. SIDEBAR (Menú Lateral) --- */
.sidebar {
    width: 260px;
    flex-shrink: 0; 
    /* --- ¡COLOR CORRECTO! Azul del logo --- */
    background-color: #071f4d; 
    color: white;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user {
    padding: 20px 15px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #143163; /* Acento azul eléctrico */
    /* --- ¡COLOR CORRECTO! Texto del avatar --- */
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2em;
    flex-shrink: 0; 
}

.user-name {
    font-weight: bold;
    white-space: normal; 
    overflow-wrap: break-word; 
    word-wrap: break-word; 
    line-height: 1.4; 
}

.sidebar-nav {
    flex-grow: 1;
    list-style: none;
    padding: 10px 0;
}

.sidebar-nav li a {
    display: block;
    padding: 15px 20px;
    color: #f0f0f0;
    font-weight: 700; /* Letra más gruesa */
    transition: background-color 0.3s, padding-left 0.3s;
}

.sidebar-nav li a:hover {
    background-color: rgba(255, 255, 255, 0.05);
    padding-left: 25px;
}

.sidebar-nav li a.active {
    background-color: #c6ccd1; /* Acento azul eléctrico */
    /* --- ¡COLOR CORRECTO! Texto activo --- */
    color: #0a1a36;
}

.sidebar-footer {
    padding: 20px;
    text-align: center;
    font-size: 0.8em;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer a {
    color: #f2f3f3; /* Acento azul eléctrico */
    font-weight: bold;
}

/* Estilo para el logo en el menú lateral */
.sidebar-logo {
    max-width: 180px; 
    height: auto; 
    margin: 0 auto;
}

/* Contenedor para el nombre y la nueva info */
.user-details {
    display: flex;
    flex-direction: column;
}

/* Estilos para la nueva información (ID, Carrera, Coord) */
.user-meta-info {
    margin-top: 8px; 
}

/* Estilos para la nueva información (ID, Carrera, Coord, Correo) */
.user-meta-item {
    display: block; 
    font-size: 0.70em; 
    color: rgba(255, 255, 255, 0.75); 
    line-height: 1.5; 
    
    /* Mantenemos normal para permitir saltos de línea normales */
    white-space: normal; 
    
    /* --- ¡LA SOLUCIÓN! Fuerza a que las palabras se rompan para caber --- */
    overflow-wrap: break-word; 
}

/* --- 2. CONTENEDOR PRINCIPAL (Derecha) --- */
.content-wrapper {
    flex-grow: 1; 
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; 
}

/* --- 2.1 Cabecera Superior --- */
.top-header {
    height: 60px;
    flex-shrink: 0;
    background-color: #ffffff;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    gap: 15px; /* <-- ¡CORRECCIÓN RESPONSIVA! */
}

.top-header h1 {
    font-size: 1.5em;
    /* --- ¡COLOR CORRECTO! Título --- */
    color: #1e3a6b;
    margin: 0;
    font-weight: 900; /* Título extra-grueso */
}

/* --- 2.2 Área de Contenido de la Página --- */
.page-content {
    flex-grow: 1;
    overflow-y: auto; /* Mantiene el scroll del contenido */
    padding: 25px;
    
    /* --- FONDO OSCURO AÑADIDO --- */
    /* 1. El overlay oscuro (ajusta el 0.3 si lo quieres más oscuro) */
    background-image: 
        linear-gradient(rgba(228, 228, 228, 0.3), rgba(212, 212, 212, 0.3)),
    /* 2. Tu imagen de fondo */
        url('../img/Fondo2.jpg'); 
        
    background-size: cover;
    background-position: center center;
    background-attachment: fixed; /* El fondo se queda fijo cuando haces scroll en el contenido */
    
    /* Color de respaldo por si la imagen falla */
    background-color: #f0f2ff; 
}

/* --- FIN: NUEVO LAYOUT DEL DASHBOARD --- */


/* --- INICIO: ESTILOS DE LA ENCUESTA (Apilado Vertical) --- */
/* ¡CAMBIO CLAVE AQUÍ! Eliminamos 'display: flex' para que se apilen naturalmente */
.survey-view-container {
    /* display: flex; <--- ELIMINADO: Se apilan por defecto */
    gap: 25px;
    max-width: 1400px;
    margin: 0 auto;
}

.survey-info-panel {
    /* width: 350px; <--- ELIMINADO: Ocupará el 100% del ancho */
    width: 100%; /* Aseguramos que ocupe todo el ancho */
    flex-shrink: 0;
}

.survey-questions-panel {
    flex-grow: 1;
}

/* Panel de Información (Ahora Arriba) */
.info-card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
}
.info-card-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
}
.info-card-header h3 {
    margin: 0;
    /* --- ¡COLOR CORRECTO! Título tarjeta --- */
    color: #1e3a6b;
    font-weight: 700;
}
.info-card-body {
    padding: 20px;
    font-size: 0.95em;
}
.info-card-body p {
    margin-bottom: 15px;
}
.info-card-body strong {
    display: block;
    color: #555;
    margin-bottom: 5px;
    font-size: 0.9em;
    font-weight: 700;
}

/* Panel de Preguntas (Ahora Abajo) */
.questions-card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
}
.questions-card-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
}
.questions-card-header h3 {
    margin: 0;
    color: #333;
    font-weight: 700;
}
.questions-card-body {
    padding: 20px;
}


/* --- INICIO: ESTILOS DE LOGIN Y FORMULARIOS --- */

/* Estilos para la PÁGINA de Login */
body.login-page {
    /* --- ¡FONDO CON OVERLAY OSCURO Y DESENFOQUE! --- */
    background-image: 
        linear-gradient(rgba(2, 2, 2, 0.205), rgba(0, 0, 0, 0.4)), /* Ajusta la oscuridad aquí */
        url('../img/Fachada-Retoque.jpg'); 
    background-size: cover; 
    background-position: center center; 
    background-repeat: no-repeat; 
    background-attachment: fixed; 
    background-color: #f0f2f5; 
    
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;

}

/* Tarjeta contenedora del login */
.login-card {
    background-color: #ffffff;
    width: 400px;
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Logo en el login */
.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

/* --- ¡LOGO RESPONSIVO CORREGIDO! --- */
.login-logo img {
    width: 90%; /* Hará que el logo ocupe el 70% del ancho de la tarjeta */
    max-width: 800px; /* Pero nunca será más grande que 220px */
    height: auto;
    margin: 0 auto; 
}

/* --- ¡ESTILOS ACTUALIZADOS! Pestañas de Login --- */
.login-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin-bottom: 1.5rem;
}

.tab-link {
    flex: 1; /* Ocupa la mitad del espacio */
    padding: 12px 10px;
    text-align: center;
    font-weight: 400; /* Letra normal para inactiva */
    color: #888; /* Texto más gris */
    background-color: #f0f2f5; /* Fondo apagado */
    border: 1px solid #ddd;
    border-bottom: 1px solid #ddd; 
    cursor: pointer;
    transition: all 0.3s;
    border-top: 3px solid transparent; /* Espacio reservado para el borde */
}

.tab-link:first-child {
    border-radius: 8px 0 0 0;
    border-right: none;
}
.tab-link:last-child {
    border-radius: 0 8px 0 0;
}

.tab-link.active {
    color: #1e3a6b; /* Tu azul principal */
    background-color: #fff;
    border-bottom-color: #fff; /* Oculta el borde de abajo */
    font-weight: 900; /* Letra extra-gruesa */
    border-top: 3px solid #00aaff; /* Borde de acento azul eléctrico */
}
/* --- FIN DE ESTILOS DE PESTAÑAS --- */


/* Estilos para los inputs dentro del login-card */
.login-card .form-group {
    margin-bottom: 1rem;
}

.login-card label {
    font-weight: 700; /* Letra más gruesa */
    font-size: 0.9em;
    color: #555;
    margin-bottom: 8px;
}

/* --- ¡CORRECCIÓN DE FUENTE EN INPUTS! --- */
.login-card input[type="text"],
.login-card input[type="tel"],
.login-card input[type="password"],
.login-card input[type="email"] { 
    width: 100%;
    padding: 12px; 
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff; 
    font-family: 'Montserrat', sans-serif; /* <-- ¡LÍNEA AÑADIDA! */
}

/* Botón de "Iniciar Sesión" */
.login-card .btn-login {
    width: 100%;
    padding: 12px;
    background-color: #1e3a6b; /* Azul del logo */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 700;
    transition: background-color 0.3s;
}

.login-card .btn-login:hover {
    background-color: #152a4f; /* Tono más oscuro del nuevo azul */
}

/* Alertas de error en el login */
.login-card .alert {
    width: 100%;
    margin-top: 1.5rem;
}

/* Formularios (Login y Encuesta) */
form {
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 15px;
}

label {
    font-weight: 700; /* Letra más gruesa */
    margin-bottom: 5px;
    display: block;
}

input[type="text"],
input[type="password"],
input[type="tel"],
input[type="email"], /* Añadido para el correo */
select,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box; 
    font-size: 1em;
    font-family: 'Montserrat', sans-serif; /* Heredar fuente */
}

button {
    padding: 12px 20px;
    background-color: #1e3a6b; /* Azul del logo */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 700;
    transition: background-color 0.3s;
    margin-top: 10px; 
}

button:hover {
    background-color: #152a4f; /* Azul del logo oscuro */
}

/* Alertas y Notificaciones */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-weight: 700;
}
.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}
.alert-success {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}
.alert-info { 
    color: #0c5460;
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
}
.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
}

/* Listado de Encuestas (Vista Dashboard) */
.survey-list a {
    display: block;
    padding: 20px;
    background-color: #ffffff;
    margin-bottom: 15px;
    text-decoration: none;
    color: #1e3a6b; /* Azul del logo */
    border-radius: 8px;
    transition: background-color 0.3s, box-shadow 0.3s;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.survey-list a:hover {
    background-color: #fafafa;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}
.survey-list h4 { margin: 0 0 5px 0; font-size: 1.2em; font-weight: 700; }
.survey-list p { margin: 0; font-size: 0.95em; color: #555; }
.survey-deadline { color: #d9534f; font-weight: 700; font-size: 0.9em; margin-top: 10px; display: block;}

/* Estructura del Formulario de Encuesta */
.survey-section {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 5px;
}

.survey-section h3 {
    border-bottom: 2px solid #1e3a6b; /* Azul del logo */
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 15px; 
    font-weight: 900; /* Título extra-grueso */
}


/* * -------------------------------------------------------------
 * *** ¡ESTILOS DE TABLA (ESCRITORIO)! ***
 * -------------------------------------------------------------
*/
.level-table,
.survey-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.level-table th,
.level-table td,
.survey-table th, 
.survey-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
    vertical-align: middle;
}

.level-table th,
.survey-table thead th {
    background-color: #f4f7f6;
    font-size: 0.85em;
    font-weight: 700; /* Letra más gruesa */
}

.survey-table thead th:first-child {
    width: auto; 
    text-align: left;
}
.survey-table tbody td:first-child {
    text-align: left;
    font-weight: 700; /* Letra más gruesa */
    background-color: #fdfdfd;
}

.level-table input[type="radio"],
.survey-table input[type="radio"] {
    margin: 0;
    cursor: pointer;
}
/* -------------------------------------------------------------
 * *** FIN DE ESTILOS DE TABLA (ESCRITORIO) ***
 * -------------------------------------------------------------
*/


/* Estilos para grupos de radio-buttons (Secciones 4, 5, 6) */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding-top: 5px;
}

.radio-group label {
    font-weight: 400; /* Regular */
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.95em; 
}


/* --- INICIO: ESTILOS RESPONSIVOS --- */

/* --- 1. Botón de Hamburguesa y Overlay --- */

.menu-toggle {
    display: none; 
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.menu-toggle svg {
    fill: #1e3a6b; /* Azul del logo */
}

.overlay {
    display: none; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999; 
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

/* --- 2. Media Query (La Magia) --- */
/* Estilos para pantallas de 992px o menos (tablets y móviles) */
@media (max-width: 992px) {

    .menu-toggle {
        display: block; 
    }

    .sidebar {
        position: fixed; 
        left: 0;
        top: 0;
        height: 100%;
        z-index: 1000;
        transform: translateX(-100%); 
        transition: transform 0.3s ease-in-out;
        box-shadow: 0 0 20px rgba(0,0,0,0.2); 
    }
    
    body.sidebar-is-open .sidebar {
        transform: translateX(0); 
    }

    body.sidebar-is-open .overlay {
        display: block;
        opacity: 1;
        visibility: visible;
    }
    
    .content-wrapper {
        width: 100%; 
    }

    .page-content {
        padding: 15px; 
    }

    .survey-view-container {
        /* Se apila por defecto, solo ajustamos el gap */
        /* flex-direction: column; Ya no es estrictamente necesario, pero se podría dejar */
        gap: 15px;
    }

    .survey-info-panel {
        width: 100%; 
    }
    
    body.login-page {
        height: auto; 
        min-height: 100vh;
        padding: 20px 0;
    }
    
    .login-card {
        width: 90%; 
        max-width: 400px;
        padding: 1.5rem; 
    }
    
    /* * -------------------------------------------------------------
     * *** ¡NUEVOS ESTILOS PARA GRÁFICAS (TABLETS / 992PX)! ***
     * -------------------------------------------------------------
    */

    /* Reducir el tamaño de las tarjetas de gráficos en general */
    .card h3 {
        font-size: 1.2em;
    }
    
    .card p {
        font-size: 0.85em;
    }

    /* Contenedor del resumen global (anillo) */
    .card > div:first-child {
        flex-direction: column; /* Apilar el gráfico y la leyenda */
        gap: 20px !important;
    }
    
    /* Contenedor del anillo para que use menos espacio */
    .card > div:first-child > div:first-child {
        width: 250px !important; 
    }
    
    .card > div:first-child h2 {
        font-size: 2.5em !important;
    }
    
    /* Ajuste de filtros */
    #filtro_grafico_carrera,
    #filtro_grafico_modalidad,
    #filtro_carrera,
    #filtro_modalidad,
    #filtro_estatus {
        width: 100% !important; /* Ocupar todo el ancho disponible */
    }
    
    /* Agrupar filtros en columnas */
    .card > div:last-child {
        flex-direction: column;
        align-items: flex-start;
    }
}


/* * -------------------------------------------------------------
 * *** ¡SOLUCIÓN RESPONSIVA PARA TABLAS! ***
 * Estilos para pantallas de 768px o menos (móviles)
 * -------------------------------------------------------------
*/
@media (max-width: 768px) {

    /* Ocultar los encabezados de las tablas (0, 1, 2, 3...) */
    .survey-table thead,
    .level-table thead {
        display: none;
    }

    /* Convertir la fila (tr) en una tarjeta */
    .survey-table tr,
    .level-table tr {
        display: flex; /* Usamos flexbox */
        flex-wrap: wrap; /* ¡Permitimos que los botones se envuelvan! */
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 5px;
        overflow: hidden; /* Para que los bordes redondeados funcionen */
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    
    .survey-table td,
    .level-table td {
        border: none; /* Quitamos bordes internos */
        padding: 8px;
        text-align: center;
    }

    /* La primera celda (la pregunta) se convierte en el TÍTULO de la tarjeta */
    .survey-table td:first-child {
        flex-basis: 100%; /* Ocupa el 100% del ancho */
        width: 100%;
        text-align: left;
        background-color: #f9f9f9; /* Fondo ligero para el título */
        border-bottom: 1px solid #eee;
        font-size: 0.95em;
    }

    /* Las celdas de radio (0-10) */
    .survey-table td {
        flex-grow: 1; /* Ocupan el espacio disponible */
        flex-basis: 15%; /* Intentan ocupar ~15% */
        min-width: 40px; /* Ancho mínimo antes de envolverse */
    }
    
    /* La celda de 1-9 (level-table) */
    .level-table td {
        flex-grow: 1;
        flex-basis: 10%;
        min-width: 35px;
    }

    /* Para que el label (0, 1, 2...) se muestre */
    .survey-table td::before,
    .level-table td::before {
        content: attr(data-label); /* Muestra el texto de 'data-label' */
        display: block;
        font-weight: bold;
        font-size: 0.85em;
        margin-bottom: 5px;
    }
    
    /* Ocultamos el label de la pregunta (ya es el título) */
    .survey-table td:first-child::before {
        display: none;
    }
    
    /* * -------------------------------------------------------------
     * *** ¡NUEVOS ESTILOS PARA GRÁFICAS (MÓVILES / 768PX)! ***
     * -------------------------------------------------------------
    */
    
    /* Para que el contenedor de filtros sea flexible verticalmente */
    .card > div:last-child {
        flex-direction: column;
    }

    .card > div:last-child > * {
        margin-bottom: 10px;
    }
    
    /* El botón de descarga al final */
    #btnDescargarFiltro {
        width: 100%;
        text-align: center;
        margin-top: 10px;
        padding: 15px 0 !important;
        border: 1px solid #1e3a6b !important;
        border-radius: 5px;
    }
    
    /* Asegurar que las etiquetas de filtro se vean bien */
    .card > div:last-child label {
        font-size: 0.9em;
        width: 100%;
        text-align: left;
    }
}
/* --- FIN: ESTILOS RESPONSIVOS --- */