:root {
    --sidebar-width: 280px;
    --brand-color: #3b5998;
    --navbar-color: #4a8bc7;
    --header-height: 60px;
}

html,
body,
.main-wrapper,
.content-area,
#main-content {
    width: 100%;
    max-width: 100% !important;
    overflow-x: hidden !important;
}

body {
    background-color: #f0f2f5;
    margin: 0;
    padding: 0;
    font-size: 1rem;
}

/* Correcciones globales de flex y tablas para evitar desbordamiento */
.row > * {
    min-width: 0;
}

.table-responsive {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* Tablet and mobile general text scaling and legibility improvements */
@media (max-width: 1024px) {
    body {
        font-size: 1.05rem;
    }

    .card-title {
        font-size: 1.25rem !important;
    }

    .card-body,
    p,
    span,
    a,
    td,
    th,
    label,
    input,
    select,
    textarea {
        font-size: 1.02rem;
    }

    .navbar-brand,
    .top-navbar {
        font-size: 1.1rem;
    }

    /* Make buttons and interactive controls larger and easier to tap */
    .btn {
        padding: 0.5rem 1rem !important;
        font-size: 1rem !important;
    }

    .btn-sm {
        padding: 0.35rem 0.75rem !important;
        font-size: 0.9rem !important;
    }
}

/* NAVBAR SUPERIOR */
.top-navbar {
    background-color: var(--navbar-color);
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

/* BOTÓN HAMBURGUESA */
.btn-hamburguesa {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    padding: 0;
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* SIDEBAR / OFFCANVAS */
.sidebar-header {
    background-color: var(--brand-color);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    color: white;
}

/* RESPONSIVE LOGIC */
@media (min-width: 992px) {
    .main-wrapper {
        display: flex;
    }

    .content-area {
        flex-grow: 1;
        min-width: 0;
        /* Importante para que no empuje el flexbox */
    }

    /* En escritorio el offcanvas es una columna fija */
    .offcanvas-lg {
        position: sticky;
        top: 0;
        display: flex !important;
        flex-direction: column;
        visibility: visible !important;
        transform: none !important;
        width: var(--sidebar-width) !important;
        min-width: var(--sidebar-width) !important;
        height: 100vh;
        border-right: 1px solid #dee2e6;
        flex-shrink: 0;
        z-index: 1020 !important;
    }

    .offcanvas-lg .offcanvas-body {
        flex-grow: 1;
        overflow-y: auto;
    }

    .btn-hamburguesa,
    .btn-cerrar {
        display: none !important;
    }
}

/* Ajustar la velocidad del Offcanvas */
.offcanvas {
    transition: transform 0.1s ease-in-out !important;
}

/* Evitar que los offcanvas ocultos provoquen desplazamiento horizontal en iOS Safari */
@media (max-width: 991.98px) {
    .offcanvas:not(.show):not(.showing):not(.hiding) {
        display: none !important;
    }
}

/* También ajustamos el fondo oscuro (backdrop) para que coincida */
.offcanvas-backdrop {
    transition: opacity 0.1s linear !important;
}

/* ESTILOS DE ENLACES */
.nav-link {
    color: #444;
    border-bottom: 1px solid #f1f1f1;
    padding: 1rem;
}

.nav-link:hover {
    background-color: #f8f9fa;
}

.nav-link.active {
    background-color: #e9ecef;
    font-weight: bold;
}


#sidebar-wrapper {
    min-height: 100vh;
    width: 250px;
    transition: margin .25s ease-out;
}

#page-content-wrapper {
    min-width: 100vw;
}

/* Estado oculto */
#wrapper.toggled #sidebar-wrapper {
    margin-left: -250px;
}

@media (min-width: 768px) {
    #page-content-wrapper {
        min-width: 0;
        width: 100%;
    }
}

/* Quita el borde inferior de los enlaces dentro del submenú para que se vea más limpio */
#submenuGestion .nav-link {
    border-bottom: none;
    font-size: 0.9rem;
}

/* Rotar la flecha cuando el menú está abierto */
[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
    transition: transform 0.2s;
}

[aria-expanded="false"] .bi-chevron-down {
    transition: transform 0.2s;
}

/* Estilos simplificados */
.bg-primary-subtle {
    background-color: #e0f0ff;
}

.bg-danger-subtle {
    background-color: #f8d7da;
}

.text-primary-emphasis {
    color: #052c65;
}

.text-danger-emphasis {
    color: #58151c;
}

.bg-primary-light {
    background-color: #3d8bfd !important;
}

.bg-primary-dark {
    background-color: #0b5ed7 !important;
}

/* UTILIDADES PARA SESIONES (Sobrescribiendo Bootstrap con tonos premium) */
.bg-success-subtle {
    background-color: #f0fdf4 !important;
    border-color: #bbf7d0 !important;
}

.text-success {
    color: #166534 !important;
}

.bg-primary-subtle {
    background-color: #eff6ff !important;
    border-color: #bfdbfe !important;
}

.text-primary {
    color: #1e40af !important;
}

.bg-warning-subtle {
    background-color: #fffbeb !important;
    border-color: #fef3c7 !important;
}

.text-warning-emphasis {
    color: #92400e !important;
}

.bg-comida {
    background-color: #f8f9fa !important;
    border-color: #dee2e6 !important;
    color: #6c757d !important;
}

/* AGENDA SEMANAL */
.table-fixed-week {
    table-layout: fixed;
    min-width: 700px;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #eee !important;
}

.table-fixed-week thead th {
    background-color: #0d6efd;
    color: white;
    font-size: 0.85rem;
    padding: 10px 5px !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.table-fixed-week thead th.cabecera-hoy {
    background-color: #004fb1 !important;
    color: white !important;
}

.table-fixed-week tbody td {
    border: 1px solid #eee !important;
}

.table-fixed-week thead th:first-child {
    width: 80px;
    background-color: #fff !important;
    color: #0d6efd !important;
    position: sticky;
    left: 0;
    z-index: 10;
}

/* TABLA FIJA GENERAL (MES) */
.table-fixed {
    table-layout: fixed;
    min-width: 800px;
}

.table-fixed-week tbody td:first-child {
    width: 80px;
    background-color: #f8f9fa;
    font-weight: bold;
    position: sticky;
    left: 0;
    z-index: 5;
    border-right: 2px solid #dee2e6;
}

.celda-agenda-semana:hover {
    background-color: #f8f9fa;
}

@media (max-width: 767.98px) {
    .event-date {
        width: 50px !important;
    }

    .event-date .fs-4 {
        font-size: 1.2rem !important;
    }
}

/* Evitar conflictos entre Offcanvas y Collapse interno */
@media (max-width: 991.98px) {
    #sidebarMenu .collapse {
        position: relative;
        z-index: 1050;
    }
}

/* Asegurar que el área del perfil no dispare eventos de cierre */
.bg-light.border-bottom {
    pointer-events: auto !important;
}

/* MI HORARIO / AGENDA */
.extra-small {
    font-size: 0.8rem !important;
}

.texto-semana-grupo {
    font-size: 0.85rem !important;
    line-height: 1.2 !important;
    word-break: break-word;
}

.texto-semana-detalle {
    font-size: 0.75rem !important;
    line-height: 1.2 !important;
}

.truncate-2-lines {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bg-primary-subtle-light {
    background-color: rgba(13, 110, 253, 0.03);
}

/* Efecto hover en las celdas */
.celda-horario:hover {
    background-color: #f8f9fa;
}

/* Ajustes para móvil */
@media (max-width: 991.98px) {
    .main-wrapper {
        position: relative !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        overflow-x: clip !important;
    }

    .content-area {
        position: relative !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        overflow-x: clip !important;
    }

    /* Forzamos que la columna de hora y la seleccionada se vean */
    .d-none.d-lg-table-cell.show-mobile {
        display: table-cell !important;
        width: 100%;
    }
}

/* Estilo para filas de recreo */
.hora-recreo,
.hora-recreo td,
.hora-recreo .bg-light {
    background-color: #fffbeb !important;
    color: #92400e !important;
}

/* Estilo para filas de comida */
.hora-comida,
.hora-comida td,
.hora-comida .bg-light {
    background-color: #f8f9fa !important;
    color: #6c757d !important;
}

/* Fila por defecto (blanca) para horas lectivas */
.hora-lectiva,
.hora-lectiva td,
.hora-lectiva .bg-light {
    background-color: #ffffff !important;
    color: #374151 !important;
}

/* Indicador para añadir sesiones en huecos vacíos */
.indicador-add {
    border: 1px dashed #ced4da;
    border-radius: 50px;
    color: #adb5bd;
    width: fit-content;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
}

.celda-horario:hover .indicador-add {
    border-color: #adb5bd;
    color: #6c757d;
    background-color: rgba(0, 0, 0, 0.03);
}

/* ANOTACIONES DE CLASE */
.anotacion-clase-container {
    word-break: break-word;
}

.anotacion-clase-container ul {
    margin-bottom: 0;
    padding-left: 1.2rem;
}

.anotacion-clase-container li {
    margin-bottom: 2px;
}

#editorAnotacion ul {
    padding-left: 1.2rem;
}

/* EXÁMENES (Naranja) */
.bg-exam-subtle {
    background-color: #fff7ed !important;
    border-color: #ffedd5 !important;
}

.text-exam {
    color: #c2410c !important;
}

.btn-exam {
    background-color: #f97316 !important;
    border-color: #f97316 !important;
    color: white !important;
}

.btn-exam:hover {
    background-color: #ea580c !important;
    border-color: #ea580c !important;
    color: white !important;
}

.btn-outline-exam {
    color: #f97316 !important;
    border-color: #f97316 !important;
}

.btn-outline-exam:hover {
    background-color: #f97316 !important;
    color: white !important;
}

/* UTILIDADES RESPONSIVAS */
@media (min-width: 768px) {
    .rounded-md-3 {
        border-radius: 0.5rem !important;
    }

    .border-md {
        border: 1px solid #dee2e6 !important;
    }
}

@media (max-width: 767.98px) {
    .rounded-md-3 {
        border-radius: 0 !important;
    }

    .border-md {
        border-left: 0 !important;
        border-right: 0 !important;
    }
}

/* UTILIDADES DE ANCHO RESPONSIVO */
@media (min-width: 576px) {
    .w-sm-auto {
        width: auto !important;
    }

    .w-sm-100 {
        width: 100% !important;
    }
}

@media (min-width: 768px) {
    .w-md-auto {
        width: auto !important;
    }

    .w-md-100 {
        width: 100% !important;
    }
}

/* Ajustes para botones en pie de página (formularios) */
@media (max-width: 575.98px) {
    .btn-responsive-mobile {
        font-size: 0.95rem !important;
        padding-top: 0.6rem !important;
        padding-bottom: 0.6rem !important;
        white-space: nowrap;
        /* Evita que el texto salte a 2 líneas */
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* MENÚ LATERAL DERECHO (OFFCANVAS) — Optimizaciones para Tablets */
#offcanvasDinamico {
    width: 480px !important;
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.12) !important;
    border-left: 1px solid #e5e7eb !important;
}

#offcanvasDinamico,
#offcanvasDinamico .card-body,
#offcanvasDinamico p,
#offcanvasDinamico span,
#offcanvasDinamico a,
#offcanvasDinamico select,
#offcanvasDinamico button,
#offcanvasDinamico label,
#offcanvasDinamico textarea,
#offcanvasDinamico h5,
#offcanvasDinamico h6 {
    font-size: 1.05rem !important;
}

#offcanvasDinamico .extra-small {
    font-size: 0.85rem !important;
}

#offcanvasDinamico .small {
    font-size: 0.95rem !important;
}

@media (max-width: 767.98px) {
    #offcanvasDinamico {
        width: 100% !important;
    }
}

/* LIST-GROUP SELECTION STYLING — Premium Aesthetic */
.list-group-item.active {
    background-color: #eff6ff !important;
    color: #1d4ed8 !important;
    border-color: #bfdbfe !important;
    font-weight: 600 !important;
}

.list-group-item:not(.active):hover {
    background-color: #f8fafc !important;
    cursor: pointer;
}

/* Cabecera unificada para tablas de calendario (Agenda y Reservas) */
.cabecera-calendario {
    background-color: #0d6efd !important;
}

.cabecera-calendario th {
    background-color: #0d6efd !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    font-size: 0.82rem !important;
    letter-spacing: 0.5px;
    border-color: rgba(255, 255, 255, 0.15) !important;
    vertical-align: middle;
}

/* Columna de hora destacada en las cabeceras */
.cabecera-calendario th.columna-hora {
    background-color: #ffffff !important;
    color: #0d6efd !important;
    font-weight: 700 !important;
}

/* Asegurar que el menú lateral sea siempre desplazable si el contenido excede la pantalla */
#sidebarMenu .offcanvas-body {
    overflow-y: auto !important;
    max-height: calc(100vh - var(--header-height, 60px)) !important;
}

#sidebarMenu .nav,
#sidebarMenu .flex-column {
    flex-wrap: nowrap !important;
}

/* Cabecera de Página Unificada y Premium */
.page-header-premium {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

@media (min-width: 768px) {
    .page-header-premium {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
    }
}

.page-header-premium-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #212529 !important;
    /* text-dark */
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-header-premium-icon {
    color: #0d6efd;
    /* text-primary */
}

.page-header-premium-desc {
    color: #6c757d;
    /* text-muted */
    margin-bottom: 0;
    font-size: 0.85rem;
    /* small */
}

/* ============================================================
   Botón universal de descarga / impresión en PDF
   Equivalente visual al botón de referencia en Mi Horario
   ============================================================ */
.btn-pdf {
    background-color: transparent !important;
    border: 1px solid #ff6b2b !important;
    color: #ff6b2b !important;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.35rem 0.75rem;
    border-radius: 50rem;
    box-shadow: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    white-space: nowrap;
}

.btn-pdf:hover,
.btn-pdf:focus {
    background-color: #ff6b2b !important;
    border-color: #ff6b2b !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(255, 107, 43, 0.35);
    transform: translateY(-1px);
}

.btn-pdf i {
    font-size: 1rem;
}

/* Ajuste de centrado vertical para avatares con fotos de carnet/DNI alargadas */
.avatar-image,
.avatar-img,
img[src*="assets/avatars/"] {
    object-fit: cover !important;
    object-position: center 20% !important;
}