:root {
    --azul: #1e3a8a;
    --azul-claro: #3b82f6;
    --gris: #f3f4f6;
    --texto: #1f2937;
}

* { box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--gris);
    color: var(--texto);
    margin: 0;
}

.pagina-login {
    min-height: 20vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tarjeta-login {
    background: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 380px;
}

.tarjeta-login h1 { margin: 0 0 0.25rem; color: var(--azul); }
.subtitulo { margin: 0 0 1.5rem; color: #6b7280; font-size: 0.9rem; }

label { display: block; margin: 0.75rem 0 0.25rem; font-size: 0.85rem; font-weight: 600; }
input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
}

textarea {
    display: block;
    width: 100%;
    min-height: 120px;
    padding: 0.7rem 0.9rem;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
}
textarea:hover { border-color: #9ca3af; }
textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
/* El enunciado de la pregunta necesita más espacio que una justificación breve */
#enunciado { min-height: 160px; }

textarea {
    width: 100%;
    max-width: 100%;
    min-height: 120px;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}
textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    outline: none;
}

button {
    margin-top: 1.5rem;
    width: 100%;
    padding: 0.7rem;
    background: var(--azul);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}
button:hover { background: var(--azul-claro); }

.select {
  
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background-color: #fff;
  color: #374151;
  font-size: 15px;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
  
  /* Quita el estilo nativo */
  appearance: none;
  -webkit-appearance: none;

  /* Flecha personalizada */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

select:hover {
  border-color: #9ca3af;
}

select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

select {
  
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background-color: #fff;
  color: #374151;
  font-size: 15px;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
  
  /* Quita el estilo nativo */
  appearance: none;
  -webkit-appearance: none;

  /* Flecha personalizada */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

select:hover {
  border-color: #9ca3af;
}

select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.alerta-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

/* ===================== PANELES (admin / profesor / estudiante) ===================== */

.pagina-panel { background: var(--gris); }

.layout-panel {
    display: flex;
    min-height: 100vh;
}

.barra-lateral {
    width: 240px;
    background: var(--azul);
    color: #fff;
    padding: 1.5rem 1rem;
    min-width: 80px;
}
.barra-lateral .marca { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.5rem; }
.barra-lateral .marca span { font-weight: 300; opacity: 0.85; }
.barra-lateral ul { list-style: none; padding: 0; margin: 0; }
.barra-lateral li { margin-bottom: 0.35rem; }
.barra-lateral a {
    display: block;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
}
.barra-lateral a:hover { background: rgba(255,255,255,0.12); }
.barra-lateral .proximamente {
    display: block;
    padding: 0.5rem 0.6rem;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.45);
    cursor: default;
}

.columna-principal { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: #fff;
    padding: 0.9rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}
.topbar .etiqueta-rol {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    background: #eff6ff;
    color: var(--azul);
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
}
.boton-salir {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 0.4rem 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}
.boton-salir:hover { background: #f3f4f6; }

.contenido-panel { padding: 1.75rem 2rem; max-width: 1100px; }
.contenido-panel h1 { margin-top: 0; color: var(--azul); }
.contenido-panel .ambito { color: #6b7280; margin-top: -0.5rem; }

.tarjetas-stat {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}
.tarjeta-stat {
    background: #fff;
    border-radius: 10px;
    padding: 1.2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.tarjeta-stat .numero { display: block; font-size: 1.8rem; font-weight: 700; color: var(--azul); }
.tarjeta-stat .etiqueta { font-size: 0.85rem; color: #6b7280; }

.tarjeta-acceso {
    background: #fff;
    border-radius: 10px;
    padding: 1.2rem;
    display: block;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: box-shadow 0.15s ease, transform 0.1s ease;
}
a.tarjeta-acceso:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-1px); }
.tarjeta-acceso h3 { margin: 0 0 0.4rem; color: var(--azul); }
.tarjeta-acceso p { margin: 0 0 0.6rem; font-size: 0.85rem; color: #4b5563; }
.tarjeta-acceso .proximamente {
    font-size: 0.75rem;
    background: #f3f4f6;
    color: #6b7280;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.bloque-info {
    background: #fff;
    border-radius: 10px;
    padding: 1.2rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.bloque-info h2 { margin-top: 0; font-size: 1.05rem; color: var(--azul); }

.tabla-simple { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tabla-simple th, .tabla-simple td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid #e5e7eb; }
.tabla-simple th { color: #6b7280; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }

.alerta-info {
    background: #eff6ff;
    color: #1e40af;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* Ajuste razonable: fuente ampliada para estudiantes con discapacidad visual */
.fuente-grande .contenido-panel { font-size: 1.25rem; }
.fuente-grande .tarjeta-stat .numero { font-size: 2.2rem; }

/* ===================== Gestión de usuarios ===================== */

.barra-acciones {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.boton-primario {
    background: var(--azul);
    color: #fff;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    display: inline-block;
}
.boton-primario:hover { background: var(--azul-claro); }

.filtros-tabla { display: flex; gap: 0.5rem; }
.filtros-tabla select {
    padding: 0.4rem 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.85rem;
}

.celda-acciones a, .enlace-boton {
    font-size: 0.85rem;
    color: var(--azul);
    margin-right: 0.75rem;
    text-decoration: none;
}
.enlace-boton {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}
.celda-acciones a:hover, .enlace-boton:hover { text-decoration: underline; }

/* Botones de acción dentro de tablas (reemplaza los antiguos .enlace-boton) */
.celda-acciones { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.boton-tabla {
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--azul);
    background: #eff6ff;
    border: 1px solid #dbeafe;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, transform 0.1s ease;
}
.boton-tabla:hover { background: #dbeafe; }
.boton-tabla:active { transform: scale(0.97); }
.boton-tabla-peligro { color: #991b1b; background: #fef2f2; border-color: #fee2e2; }
.boton-tabla-peligro:hover { background: #fee2e2; }

/* Enlace "← Volver al listado" */
.enlace-volver {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #4b5563;
    text-decoration: none;
    padding: 0.4rem 0;
}
.enlace-volver:hover { color: var(--azul); }

/* Modal de confirmación (reemplaza confirm() nativo) */
.gs-modal-fondo {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
/* El atributo [hidden] debe ganarle siempre a "display: flex" de arriba,
   si no, el modal queda visible desde que carga la página. */
.gs-modal-fondo[hidden] {
    display: none !important;
}
.gs-modal-caja {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.gs-modal-caja p { margin: 0 0 1.25rem; font-size: 0.95rem; color: #1f2937; }
.gs-modal-botones { display: flex; justify-content: flex-end; gap: 0.6rem; }
.gs-modal-botones button {
    width: auto;
    margin-top: 0;
    padding: 0.5rem 1.1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
}
.gs-modal-cancelar { background: #f3f4f6; color: #374151; }
.gs-modal-cancelar:hover { background: #e5e7eb; }
.gs-modal-confirmar { background: #dc2626; color: #fff; }
.gs-modal-confirmar:hover { background: #b91c1c; }

.pastilla-estado {
    font-size: 0.75rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-weight: 600;
}
.pastilla-activo { background: #dcfce7; color: #166534; }
.pastilla-inactivo { background: #f3f4f6; color: #6b7280; }
.pastilla-bloqueado { background: #fee2e2; color: #991b1b; }

.nota-vacio { font-size: 0.8rem; color: #6b7280; margin: 0.25rem 0 0.75rem; }

/* ===================== Bienvenida y soporte ===================== */
.bloque-bienvenida h2 { color: var(--azul); }
.botones-soporte {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.75rem;
}
.boton-soporte {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    color: var(--azul);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.15s ease;
}
.boton-soporte:hover { background: #dbeafe; }
.icono-whatsapp { display: inline-flex; align-items: center; }

/* Flashcards embebido dentro del panel */
.iframe-flashcards {
    width: 100%;
    height: calc(100vh - 140px);
    border: none;
    border-radius: 12px;
    background: #f4f2fb;
    display: block;
}

/* Textarea de prompt: visible/seleccionable para copiar, pero discreta */
.prompt-oculto {
    width: 100%;
    min-height: 60px;
    font-size: 0.75rem;
    color: #6b7280;
    background: #f9fafb;
    margin-top: 0.5rem;
}

/* ===================== Entrenamiento / Simulacro (preguntas) ===================== */

.tarjeta-pregunta {
    background: #fff;
    border-radius: 10px;
    padding: 1.2rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border-left: 4px solid #e5e7eb;
}
.numero-pregunta { font-size: 0.8rem; color: #6b7280; font-weight: 600; margin: 0 0 0.5rem; display:flex; gap:0.5rem; align-items:center; }
.enunciado-pregunta { font-size: 1rem; margin: 0 0 0.75rem; white-space: pre-line; }
.imagen-pregunta { max-width: 100%; border-radius: 8px; margin-bottom: 0.75rem; display: block; }

.lista-opciones { display: flex; flex-direction: column; gap: 0.5rem; }
.opcion-respuesta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
}
.opcion-respuesta:hover { background: #f9fafb; }
.opcion-respuesta input[type="radio"] { width: auto; margin: 0; }
.imagen-opcion { max-width: 160px; border-radius: 6px; }

.opcion-solo-lectura { cursor: default; }
.opcion-solo-lectura:hover { background: transparent; }
.opcion-correcta { border-color: #16a34a; background: #f0fdf4; }
.opcion-marcada-mal { border-color: #dc2626; background: #fef2f2; }

.pregunta-correcta { border-left-color: #16a34a; }
.pregunta-incorrecta { border-left-color: #dc2626; }

.justificacion-pregunta {
    margin-top: 0.9rem;
    padding: 0.7rem 0.9rem;
    background: #eff6ff;
    border-radius: 8px;
    font-size: 0.88rem;
    color: #1e40af;
}

/* ===================== Mi perfil ===================== */
.rejilla-perfil {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
    align-items: start;
}

/* ===================== ADAPTACIÓN MÓVIL (Responsive) ===================== */

@media (max-width: 768px) {
    /* Cambiar la estructura a columna única */
    .layout-panel {
        flex-direction: column;
        min-height: auto;
    }

    /* Ajustar la barra lateral para que funcione como barra superior compacta o menú colapsable */
    .barra-lateral {
        width: 100%;
        padding: 1rem;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
    }

    .barra-lateral .marca {
        margin-bottom: 0;
        font-size: 1.1rem;
    }

    /* Opcional: Ocultar los enlaces de texto muy largos en móvil o transformarlos en un menú desplegable */
    .barra-lateral ul {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
        margin-top: 0.75rem;
        width: 100%;
    }

    .barra-lateral li {
        margin-bottom: 0;
    }

    .barra-lateral a {
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
        background: rgba(255, 255, 255, 0.08);
        border-radius: 4px;
    }

    /* Ajustar los contenedores principales y paddings */
    .columna-principal {
        width: 100%;
    }

    .contenido-panel {
        padding: 1rem;
        max-width: 100%;
    }

    /* Redimensionar tarjetas estadísticas para que no se desborden */
    .tarjetas-stat {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        margin: 1rem 0;
    }

    .tarjeta-stat .numero {
        font-size: 1.4rem;
    }

    /* Topbar adaptable */
    .topbar {
        padding: 0.75rem 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .topbar > div {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
}

@media (max-width: 768px) {
    /* Reducir ligeramente los encabezados principales en móviles */
    .contenido-panel h1 {
        font-size: 1.5rem;
        word-break: break-word;
    }

    body {
        font-size: 14px; /* Base más cómoda para lectura móvil */
    }

    /* Asegurar que las tablas tengan scroll horizontal si son muy anchas */
    .bloque-info {
        overflow-x: auto;
        padding: 1rem;
    }

    .tabla-simple {
        font-size: 0.85rem;
        min-width: 450px; /* Fuerza scroll horizontal fluido en vez de comprimir celdas */
    }
}


@media (max-width: 500px) {
    /* Forzar que el layout principal sea una columna */
    .layout-panel {
        flex-direction: column !important;
        min-height: auto !important;
    }

    /* Permitir que la barra lateral ocupe todo el ancho y sí pueda encogerse */
    .barra-lateral {
        width: 100% !important;
        flex-shrink: 1 !important;
        padding: 1rem !important;
    }

    /* Resto de adaptaciones para móvil */
    .columna-principal {
        width: 100% !important;
    }

    .contenido-panel {
        padding: 1rem !important;
        max-width: 100% !important;
    }
}