﻿/* ========================================================================== */
/* INTRANET – UPLA MODE (TOPBAR FULL + SIDEBAR LIGHT + PANEL ON CLICK)        */
/* ========================================================================== */

:root {
    --brand: #5aa027;
    --brand-600: #4b8b21;
    --brand-100: rgba(90,160,39,.12);
    --topbar-h: 58px;
    /* sidebar total (rail + panel) */
    --sidebar-w: 260px;
    --rail-w: 84px;
    /* light sidebar */
    --sidebar-bg: #ffffff;
    --sidebar-border: #e7ebf0;
    --sidebar-muted: #6b7280;
    --sidebar-text: #111827;
    --sidebar-hover: rgba(17,24,39,.06);
    --sidebar-active: rgba(90,160,39,.16);
    --sidebar-active-border: rgba(90,160,39,.45);
    --content-bg: #f5f7fa;
}

/* ===== Base ===== */
.app-body {
    min-height: 100vh;
    background: var(--content-bg);
}

/* ========================================================================== */
/* TOPBAR                                                                      */
/* ========================================================================== */
.app-topbar {
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .65rem 1rem;
    min-height: var(--topbar-h);
}

.app-topbar--global {
    position: sticky;
    top: 0;
    z-index: 1030;
    width: 100%;
}

/* Quitar título dinámico en topbar */
.app-topbar .page-title {
    display: none !important;
}

/* Marca topbar */
.topbar-brand {
    display: flex;
    align-items: center;
    gap: .55rem;
    color: #111827;
    text-decoration: none;
}

.topbar-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: .55rem;
    background: var(--brand-100);
    display: grid;
    place-items: center;
    overflow: hidden;
    flex: 0 0 auto;
}

    .topbar-brand-mark img {
        width: 22px;
        height: 22px;
        object-fit: contain;
        display: block;
    }

.topbar-brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}

.topbar-brand-name {
    font-weight: 800;
    font-size: .95rem;
}

.topbar-brand-sub {
    font-size: .75rem;
    opacity: .7;
}

/* Perfil */
.user-avatar {
    width: 32px;
    height: 32px;
    object-fit: cover;
}

.user-profile-trigger {
    background: transparent;
    border-color: rgba(0,0,0,.12);
    color: #111827;
    padding-inline: .5rem;
}

    .user-profile-trigger .user-name {
        font-size: .85rem;
        font-weight: 600;
        line-height: 1.1;
    }

    .user-profile-trigger .user-code {
        font-size: .7rem;
        color: #6b7280;
        line-height: 1.1;
    }

/* ========================================================================== */
/* SHELL                                                                       */
/* ========================================================================== */
.app-shell {
    display: flex;
    min-height: calc(100vh - var(--topbar-h));
}

/* ========================================================================== */
/* SIDEBAR (LIGHT)                                                             */
/* ========================================================================== */
.app-sidebar {
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-right: 1px solid var(--sidebar-border);
    padding: 0;
    /* evitar barras raras */
    overflow-x: hidden;
    overflow-y: hidden;
}

/* DESKTOP: por defecto solo rail; al abrir panel => ancho total */
@media (min-width: 992px) {
    .app-sidebar {
        width: var(--rail-w);
        transition: width .18s ease;
    }

        .app-sidebar.panel-open {
            width: var(--sidebar-w);
        }

    #appSidebar.offcanvas-lg {
        position: sticky !important;
        top: var(--topbar-h) !important;
        height: calc(100vh - var(--topbar-h));
        transform: none !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .offcanvas-backdrop {
        display: none !important;
    }
}

/* MOBILE: offcanvas normal */
@media (max-width: 991.98px) {
    #appSidebar.offcanvas-lg {
        width: var(--sidebar-w);
        max-width: 86%;
        background: #ffffff;
        border-right: none;
        /* en móvil sí puede scrollear */
        overflow-y: auto;
        overflow-x: hidden;
    }

    .offcanvas-backdrop {
        background: rgba(15,23,42,.35);
    }
}

/* ========================================================================== */
/* MAIN CONTENT                                                                */
/* ========================================================================== */
.app-main {
    flex: 1;
    min-width: 0;
    background: var(--content-bg);
}

.app-content {
    padding: 1.2rem;
}

    .app-content .card {
        border-radius: .95rem;
        border: none;
        box-shadow: 0 8px 24px rgba(0,0,0,.06);
    }

.footer {
    font-size: .85rem;
    padding: 1rem;
    color: #6b7280;
}

/* ========================================================================== */
/* UPLA SIDEBAR (2 columnas) + PANEL ON CLICK                                  */
/* ========================================================================== */
.upla-sidebar {
    display: flex;
    height: 100%;
    min-height: 100%;
}

/* Rail */
.upla-rail {
    width: var(--rail-w);
    padding: .75rem .5rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    border-right: 1px solid var(--sidebar-border);
    background: #ffffff;
    /* FIX: no mostrar barrita / scrollbar inferior */
    overflow: hidden;
}

/* Items */
.upla-rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .65rem .35rem;
    border-radius: .85rem;
    color: var(--sidebar-muted);
    background: transparent;
    border: 1px solid transparent;
    text-decoration: none;
}

    .upla-rail-item i {
        font-size: 1.25rem;
        color: #64748b;
    }

    .upla-rail-item span {
        font-size: .72rem;
        line-height: 1;
        opacity: .9;
        text-align: center;
    }

    .upla-rail-item:hover {
        background: var(--sidebar-hover);
        color: var(--sidebar-text);
    }

        .upla-rail-item:hover i {
            color: var(--brand-600);
        }

    .upla-rail-item.nav-link.active {
        background: var(--sidebar-active);
        border-color: var(--sidebar-active-border);
        color: var(--sidebar-text);
    }

        .upla-rail-item.nav-link.active i {
            color: var(--brand-600);
        }

/* Panel */
.upla-panel {
    width: calc(var(--sidebar-w) - var(--rail-w));
    padding: .9rem .9rem;
    background: #ffffff;
    /* panel sí debe poder scrollear vertical */
    overflow-y: auto;
    overflow-x: hidden;
    display: none; /* oculto por defecto */
}

/* Mostrar panel cuando host está abierto */
.upla-sidebar.panel-open .upla-panel {
    display: block;
}

.upla-panel-title {
    font-size: .75rem;
    letter-spacing: .08em;
    color: #64748b;
    text-transform: uppercase;
    margin: .2rem 0 .8rem;
    padding-bottom: .6rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.upla-group {
    padding: .6rem 0;
}

.upla-group-title {
    font-size: .72rem;
    letter-spacing: .08em;
    color: #94a3b8;
    text-transform: uppercase;
    margin: .4rem 0 .5rem;
}

.upla-sub-link {
    display: block;
    padding: .55rem .65rem;
    margin: .15rem 0;
    border-radius: .75rem;
    color: #334155;
    text-decoration: none;
    border: 1px solid transparent;
}

    .upla-sub-link:hover {
        background: rgba(17,24,39,.05);
        color: #111827;
    }

    .upla-sub-link.active {
        background: rgba(90,160,39,.14);
        border-color: rgba(90,160,39,.35);
        color: #111827;
    }

/* Ocultar brand dentro del sidebar (marca ya está en topbar) */
.app-sidebar .app-brand {
    display: none !important;
}

/* Si aún existe “Ayuda” en algún sidebar, lo oculta */
.upla-rail-item .bi-question-circle,
.upla-rail-item:has(.bi-question-circle) {
    display: none !important;
}

/* ========================================================================== */
/* OPTIONAL: ocultar scrollbar visual (sin romper scroll)                      */
/* ========================================================================== */
.upla-panel::-webkit-scrollbar,
#appSidebar.offcanvas-lg::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.upla-panel,
#appSidebar.offcanvas-lg {
    scrollbar-width: none; /* Firefox */
}

/* ========================================================================== */
/* FIX: FOTO PERFIL EN MODAL (NO GIGANTE)                                      */
/* ========================================================================== */
.user-profile-card {
    overflow: hidden;
}

.user-profile-photo {
    width: 132px !important;
    height: 132px !important;
    max-width: 132px !important;
    max-height: 132px !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block;
    margin: 0 auto 1rem;
    box-shadow: 0 4px 18px rgba(0,0,0,.18);
}

/* Fallback por si un CSS global fuerza tamaños en modales */
#userProfileModal img {
    max-width: 100%;
    height: auto;
}
/* ========================================================================== */
/* BOLETA DE NOTAS (Estilo UPLA)                                               */
/* ========================================================================== */

.boleta .boleta-card {
    border-radius: 1rem;
}

.boleta .boleta-section-title {
    font-weight: 700;
    color: #1f2a39;
    padding: .35rem .6rem;
    border: 1px solid rgba(0,0,0,.06);
    border-radius: .6rem;
    display: inline-flex;
    align-items: center;
    background: #fff;
}

.boleta-photo-wrap {
    width: 110px;
    height: 110px;
    border-radius: .8rem;
    border: 1px solid rgba(0,0,0,.08);
    background: #fff;
    display: grid;
    place-items: center;
    overflow: hidden;
    flex: 0 0 auto;
}

.boleta-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.boleta-field {
    display: flex;
    flex-direction: column;
    gap: .1rem;
}

.boleta-label {
    font-size: .75rem;
    color: #6b7280;
}

.boleta-value {
    font-weight: 700;
    color: #111827;
}

.boleta-side-note {
    min-width: 220px;
    border-left: 3px solid rgba(0,0,0,.08);
    padding-left: 1rem;
    margin-left: auto;
}

.boleta-tabs {
    display: flex;
    gap: .75rem;
    align-items: center;
}

.boleta-tab {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .9rem;
    border-radius: .8rem;
    text-decoration: none;
    border: 1px solid rgba(0,0,0,.10);
    color: #111827;
    background: #fff;
    font-weight: 600;
}

    .boleta-tab .dot {
        width: 22px;
        height: 22px;
        border-radius: 999px;
        border: 2px solid rgba(0,0,0,.25);
        background: #f8fafc;
    }

    .boleta-tab.active {
        border-color: rgba(0,0,0,.18);
        box-shadow: 0 8px 20px rgba(0,0,0,.06);
    }

        .boleta-tab.active .dot {
            border-color: rgba(90,160,39,.55);
            background: rgba(90,160,39,.18);
        }

.boleta-kpi {
    border-radius: 1rem;
    padding: 1.1rem 1.1rem;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,.08);
    background: #fff;
    min-height: 108px;
}

    .boleta-kpi .kpi-title {
        color: #6b7280;
        font-size: .85rem;
        font-weight: 600;
    }

    .boleta-kpi .kpi-value {
        font-size: 1.7rem;
        font-weight: 800;
        margin-top: .25rem;
        color: #111827;
    }

    .boleta-kpi .kpi-ico {
        position: absolute;
        right: 14px;
        bottom: 10px;
        font-size: 2.1rem;
        opacity: .18;
    }

    .boleta-kpi.kpi-green {
        border-left: 6px solid rgba(90,160,39,.75);
    }

    .boleta-kpi.kpi-gray {
        border-left: 6px solid rgba(100,116,139,.55);
    }

    .boleta-kpi.kpi-blue {
        border-left: 6px solid rgba(59,130,246,.55);
    }

    .boleta-kpi.kpi-amber {
        border-left: 6px solid rgba(245,158,11,.60);
    }

.boleta-acc .boleta-acc-item {
    border-radius: .9rem;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,.08);
    margin-bottom: .85rem;
}

.boleta-acc .boleta-acc-btn {
    font-weight: 800;
    background: rgba(90,160,39,.10);
}

.boleta-table thead th {
    background: rgba(15,23,42,.06);
    font-weight: 800;
    border-bottom: 1px solid rgba(0,0,0,.10);
}

.boleta-badge {
    border-radius: 999px;
    padding: .35rem .6rem;
    font-weight: 700;
}

.boleta-score {
    display: inline-block;
    min-width: 64px;
    text-align: right;
    font-weight: 900;
}

    .boleta-score.ok {
        color: #111827;
    }

    .boleta-score.na {
        color: #94a3b8;
    }

/* =========================
   APP LAYOUT (INTRANET)
   ========================= */

.app-topbar--global {
    position: sticky;
    top: 0;
    z-index: 1030;
}

/* Shell */
.app-shell {
    display: flex;
    min-height: calc(100vh - 56px); /* ajusta si tu topbar mide distinto */
}

/* Sidebar visible en PC (lg+) */
@media (min-width: 992px) {
    #appSidebar.app-sidebar {
        position: sticky;
        top: 56px; /* igual al alto del topbar */
        height: calc(100vh - 56px);
        overflow-y: auto;
    }

    .app-main {
        flex: 1 1 auto;
        min-width: 0; /* IMPORTANTE: evita overflow raro */
    }

    .app-content {
        padding: 1rem 1rem;
    }
}

/* Móvil: sidebar es offcanvas y el contenido ocupa 100% */
@media (max-width: 991.98px) {
    .app-shell {
        display: block;
    }

    .app-main {
        width: 100%;
    }

    .app-content {
        padding: .75rem .75rem;
    }

    /* ancho del offcanvas */
    #appSidebar.offcanvas {
        width: min(86vw, 320px);
    }
}
/* ====== Student Dashboard (shared) ====== */
.page-head h3 {
    font-weight: 700;
    letter-spacing: -.2px;
}

.table-dash thead th {
    font-size: .85rem;
    color: #6c757d;
    text-transform: none;
}

.table-dash tbody td {
    padding-top: .85rem;
    padding-bottom: .85rem;
}

.dash-kpi {
    border-radius: 16px;
    padding: 16px 16px 14px;
    border: 1px solid rgba(0,0,0,.06);
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.04);
    background: #fff;
}

    .dash-kpi .kpi-title {
        font-size: .85rem;
        color: #6c757d;
    }

    .dash-kpi .kpi-value {
        font-size: 1.65rem;
        font-weight: 800;
        line-height: 1.1;
    }

    .dash-kpi .kpi-suffix {
        font-size: 1rem;
        font-weight: 700;
        margin-left: 2px;
        opacity: .8;
    }

    .dash-kpi .kpi-ico {
        font-size: 1.35rem;
        opacity: .65;
    }

.kpi-green {
    background: linear-gradient(180deg, rgba(25,135,84,.10), rgba(255,255,255,1));
}

.kpi-blue {
    background: linear-gradient(180deg, rgba(13,110,253,.10), rgba(255,255,255,1));
}

.kpi-amber {
    background: linear-gradient(180deg, rgba(255,193,7,.14), rgba(255,255,255,1));
}

.kpi-red {
    background: linear-gradient(180deg, rgba(220,53,69,.10), rgba(255,255,255,1));
}

.kpi-gray {
    background: linear-gradient(180deg, rgba(108,117,125,.10), rgba(255,255,255,1));
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,.07);
    background: rgba(255,255,255,.7);
    font-size: .85rem;
}

.empty-state {
    text-align: center;
    display: grid;
    gap: 6px;
    justify-items: center;
}

.empty-ico {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(108,117,125,.10);
    color: rgba(33,37,41,.65);
    font-size: 1.2rem;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-green {
    background: #198754;
}

.dot-amber {
    background: #ffc107;
}

.dot-red {
    background: #dc3545;
}

.dot-blue {
    background: #0dcaf0;
}

.dot-gray {
    background: #6c757d;
}

.dash-link {
    text-decoration: none;
    color: inherit;
}

    .dash-link:hover {
        transform: translateY(-1px);
        transition: .15s ease;
    }

.dash-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
}

.dash-tip {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(13,110,253,.10);
    color: rgba(13,110,253,.9);
    font-size: 1.2rem;
}
.tip-card {
    border-radius: 16px;
    max-width: 420px;
}

.mini-stat {
    border: 1px solid rgba(0,0,0,.06);
    border-radius: 14px;
    padding: 10px 12px;
    background: rgba(255,255,255,.7);
}

.chart-wrap {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    align-items: end;
    height: 160px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,.06);
    background: rgba(255,255,255,.7);
}

.chart-col {
    display: grid;
    gap: 8px;
    justify-items: center;
}

.chart-bar {
    width: 100%;
    border-radius: 14px;
    border: 1px solid rgba(0,0,0,.08);
    background: linear-gradient(180deg, rgba(13,110,253,.35), rgba(25,135,84,.20));
}

.chart-lbl {
    font-size: .85rem;
    color: #6c757d;
}



/* ========================================================================== */
/* FIX DEFINITIVO: EVITAR QUE LOS BOTONES SE APLASTEN EN LA BARRA LATERAL     */
/* ========================================================================== */
.upla-sidebar .upla-rail {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex-wrap: nowrap !important; /* 🔥 LA SOLUCIÓN: Prohibido saltar a una columna invisible */
    justify-content: flex-start !important;
}

.upla-sidebar .upla-rail-item {
    flex-shrink: 0 !important;
    min-height: 72px !important; /* Candado de altura */
    width: 100% !important; /* Candado de anchura */
}

/* Diseño de la barrita de scroll para que no se vea tosca */
.upla-sidebar .upla-rail::-webkit-scrollbar {
    width: 4px;
}

.upla-sidebar .upla-rail::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 4px;
}

/* =========================================================
   RESPONSIVE GLOBAL INTRANET
   ========================================================= */

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

.app-shell, .app-main, .app-content {
    min-width: 0;
    max-width: 100%;
}

img, video, canvas, svg {
    max-width: 100%;
}

@media(max-width:991.98px) {
    .app-shell {
        display: block !important;
        width: 100% !important;
    }

    .app-main {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden;
    }

    .app-content {
        width: 100% !important;
        max-width: 100% !important;
        padding: .75rem !important;
        overflow-x: hidden;
    }

    #appSidebar.offcanvas-lg {
        width: min(86vw,320px) !important;
        max-width: min(86vw,320px) !important;
    }

    .upla-sidebar {
        width: 100%;
        max-width: 100%;
    }
}

@media(max-width:767.98px) {
    .app-topbar {
        min-height: 58px;
        padding: .45rem .65rem !important;
    }

        .app-topbar .left,
        .app-topbar .right {
            gap: .35rem !important;
            min-width: 0;
        }

    .user-profile-trigger {
        padding: .2rem !important;
        min-width: auto !important;
    }

        .user-profile-trigger .user-avatar {
            width: 38px !important;
            height: 38px !important;
        }

    .app-content > .container-fluid {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .modal-dialog {
        max-width: calc(100vw - 1rem);
    }

    .modal-content {
        max-width: 100%;
    }

    .form-control,
    .form-select,
    .input-group {
        max-width: 100%;
    }

    .table-responsive {
        max-width: 100%;
    }

    h1, h2, h3, h4, h5 {
        overflow-wrap: anywhere;
    }

    .alert {
        max-width: 100%;
    }
}