/* Student Home Portal - Central Stylesheet */

:root {
    --primary: #4f46e5;
    --primary-light: rgba(79, 70, 229, 0.1);
    --primary-hover: #4338ca;
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --bg-gradient: radial-gradient(circle at top right, #f8fafc, #e2e8f0);
    --glass: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.5);
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Outfit', sans-serif;
    color: #1e293b;
    background: #f8fafc;
    min-height: 100vh;
    margin: 0;
}

/* Only set while student home drawer (#mainSidebar) is open on mobile */
@media (max-width: 991.98px) {
    body.student-home-sidebar-open {
        overflow: hidden;
    }
}

/* Layout */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: #fff;
    position: fixed;
    top: 0;
    left: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    z-index: 1030;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sidebar nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.sidebar .sidebar-footer .nav-link {
    margin: 4px 16px;
}

.main-content {
    margin-left: var(--sidebar-width);
    padding: 30px;
    min-height: 100vh;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/*
 * Pages that omit includes/sidebar.php (payment bridge, gateway confirm/return,
 * mobile online payment, etc.) must not reserve sidebar space.
 */
body:not(:has(#mainSidebar)) .main-content {
    margin-left: 0;
}

body.sidebar-collapsed:not(:has(#mainSidebar)) .main-content {
    margin-left: 0;
}

/* Center standalone content on no-sidebar pages (auth & payment-response style themselves). */
body:not(:has(#mainSidebar)):not(.auth-page):not(.payment-response-page) .main-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

body:not(:has(#mainSidebar)):not(.auth-page):not(.payment-response-page) .main-content > .row,
body:not(:has(#mainSidebar)):not(.auth-page):not(.payment-response-page) .main-content > .glass-card,
body:not(:has(#mainSidebar)):not(.auth-page):not(.payment-response-page) .main-content > .alert,
body:not(:has(#mainSidebar)):not(.auth-page):not(.payment-response-page) .main-content > #pageAlertArea {
    width: 100%;
    max-width: 960px;
}

/* Async page shell — hide content until bootstrap/data is ready */
.student-page-shell {
    position: relative;
}

.student-page-shell .student-portal-preloader {
    display: none;
    min-height: 55vh;
    align-items: center;
    justify-content: center;
}

.student-page-shell.is-loading .student-portal-preloader {
    display: flex;
}

.student-page-shell.is-loading .student-page-content {
    display: none;
}

.student-page-shell.is-busy .student-portal-preloader {
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 30;
    min-height: 100%;
    background: rgba(248, 250, 252, 0.78);
}

.student-page-shell.is-busy .student-page-content {
    pointer-events: none;
}

.student-portal-preloader-card {
    text-align: center;
    padding: 1.5rem 2rem;
    border-radius: 16px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: var(--card-shadow);
}

/*
 * Mobile drawer — scoped to portal/student/home (#mainSidebar + #studentHomeSidebarOverlay only).
 * Other portals (staff, legacy student) use their own CSS and are unaffected.
 */
@media (max-width: 991.98px) {
    #mainSidebar.sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        z-index: 1050;
    }

    #mainSidebar.sidebar.show {
        transform: translateX(0);
    }

    #studentHomeSidebarOverlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 1040;
        display: none;
    }

    #studentHomeSidebarOverlay.show {
        display: block;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 20px;
    }

    .mobile-top-bar {
        z-index: 1060;
    }

    /* Full-width drawer: always show labels, submenus, and comfortable tap targets */
    #mainSidebar.sidebar .sidebar-header h5,
    #mainSidebar.sidebar .nav-link span:not(.material-symbols-outlined) {
        display: inline !important;
    }

    #mainSidebar.sidebar .nav-link,
    #mainSidebar.sidebar .nav-group .nav-group-toggle {
        justify-content: flex-start;
        padding: 12px 20px;
        min-height: 44px;
    }

    #mainSidebar.sidebar #studentMainNav .nav-group-toggle .nav-chevron {
        display: inline-flex !important;
    }

    #mainSidebar.sidebar #studentMainNav .nav-group.open .nav-submenu {
        display: block !important;
    }

    #mainSidebar.sidebar #studentMainNav .nav-sublink {
        min-height: 44px;
    }

    .glass-card {
        border-radius: 18px;
        padding: 1.25rem !important;
    }

    .student-page-shell .student-portal-preloader {
        min-height: 45vh;
    }

    /* Prevent iOS zoom when focusing form fields */
    .form-control,
    .form-select,
    textarea.form-control {
        font-size: 16px;
    }

    #mainSidebar.sidebar nav {
        -webkit-overflow-scrolling: touch;
    }
}

/* Sidebar Nav */
.nav-link {
    color: #64748b;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 12px;
    margin: 4px 16px;
    transition: all 0.2s;
    text-decoration: none;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-link .material-symbols-outlined {
    font-size: 22px;
}

#studentMainNav .nav-group {
    margin: 4px 16px;
}

#studentMainNav .nav-group .nav-group-toggle {
    margin: 0;
    width: 100%;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

#studentMainNav .nav-group-toggle .nav-chevron {
    margin-left: auto;
    font-size: 20px;
    transition: transform 0.2s ease;
}

#studentMainNav .nav-group.open .nav-group-toggle .nav-chevron {
    transform: rotate(180deg);
}

#studentMainNav .nav-submenu {
    display: none;
    padding-left: 0.35rem;
}

#studentMainNav .nav-group.open .nav-submenu {
    display: block;
}

#studentMainNav .nav-sublink {
    margin: 2px 0 2px 0.75rem;
    padding: 10px 16px 10px 20px;
    font-size: 0.92rem;
}

#studentMainNav .nav-sublink .material-symbols-outlined {
    font-size: 20px;
}

/* Student identity block (name + admission no) */
.student-identity {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 16px 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--primary-light);
    text-decoration: none;
    transition: all 0.2s;
}

.student-identity:hover {
    background: var(--primary-light);
    filter: brightness(0.97);
}

.student-identity .si-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.student-identity .si-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.student-identity .si-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.student-identity .si-adm {
    font-size: 0.78rem;
    color: #64748b;
}

/* Desktop collapsed sidebar + per-item flyouts */
@media (min-width: 992px) {
    .sidebar.collapsed .student-identity {
        justify-content: center;
        padding: 8px;
    }

    .sidebar.collapsed .student-identity .si-text {
        display: none;
    }

    .sidebar.collapsed {
        width: var(--sidebar-collapsed-width);
        overflow: visible;
        z-index: 1100;
    }

    .sidebar.collapsed nav {
        overflow: visible;
    }

    body.sidebar-collapsed .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }

    .sidebar.collapsed .sidebar-header h5,
    .sidebar.collapsed .nav-link span:not(.material-symbols-outlined) {
        display: none;
    }

    .sidebar.collapsed .sidebar-footer {
        display: block;
        margin-top: auto;
        padding-bottom: 0.75rem;
        flex-shrink: 0;
    }

    .sidebar.collapsed .sidebar-footer hr {
        margin: 0.5rem 0.65rem;
        opacity: 0.12;
    }

    .sidebar.collapsed .nav-link {
        justify-content: center;
        padding: 12px;
    }

    .sidebar.collapsed #studentMainNav .nav-group .nav-group-toggle {
        margin: 0;
        justify-content: center;
        padding: 12px;
    }

    .sidebar.collapsed #studentMainNav .nav-submenu,
    .sidebar.collapsed #studentMainNav .nav-group-toggle .nav-chevron {
        display: none !important;
    }

    .sidebar.collapsed #studentMainNav .nav-group {
        position: relative;
    }

    .sidebar.collapsed #studentMainNav > a.nav-link,
    .sidebar.collapsed .sidebar-footer .nav-link {
        position: relative;
    }

    .sidebar.collapsed #studentMainNav > a.nav-link:not(.nav-group-toggle):hover::after,
    .sidebar.collapsed .sidebar-footer .nav-link:hover::after {
        content: attr(data-nav-label);
        position: absolute;
        left: calc(100% + 10px);
        top: 50%;
        transform: translateY(-50%);
        white-space: nowrap;
        background: #fff;
        color: #1e293b;
        padding: 0.5rem 0.85rem;
        border-radius: 10px;
        border: 1px solid #e2e8f0;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
        z-index: 1200;
        font-size: 0.9rem;
        font-weight: 500;
        pointer-events: none;
    }

    .sidebar.collapsed #studentMainNav .nav-group.flyout-active .nav-submenu {
        display: block !important;
        position: absolute;
        left: 100%;
        top: auto;
        bottom: 0;
        min-width: 230px;
        max-height: calc(100vh - 16px);
        overflow-y: auto;
        overscroll-behavior: contain;
        margin: 0;
        padding: 0.5rem;
        padding-left: 0.65rem;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        box-shadow: 0 14px 32px rgba(15, 23, 42, 0.16);
        z-index: 1300;
    }

    /* Invisible bridge so the cursor can reach the flyout without closing it */
    .sidebar.collapsed #studentMainNav .nav-group.flyout-active .nav-submenu::before {
        content: '';
        position: absolute;
        top: 0;
        right: 100%;
        width: 14px;
        height: 100%;
        background: transparent;
    }

    .sidebar.collapsed #studentMainNav .nav-group.flyout-active .nav-submenu .nav-sublink {
        margin: 2px 0;
        padding: 10px 14px;
        justify-content: flex-start;
    }

    .sidebar.collapsed #studentMainNav .nav-group.flyout-active .nav-submenu .nav-sublink span:not(.material-symbols-outlined) {
        display: inline !important;
    }
}

/* Modals above mobile drawer (1050) on student home pages only (this stylesheet) */
.modal-backdrop {
    z-index: 1070;
}
.modal {
    z-index: 1080;
}

/* Cards & Glassmorphism */
.glass-card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.05);
}

.stat-card {
    background: #fff;
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--card-shadow);
    border: 1px solid #f1f5f9;
}

/* Buttons */
.btn-gradient {
    background: var(--primary-gradient);
    border: none;
    color: #fff;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.2);
}

.btn-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.4);
    color: #fff;
}

/* Forms */
.form-control {
    border-radius: 12px;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    background: rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

.form-control:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* Authentication Pages (login, register, forgot password) */
body.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem 1rem;
    background: linear-gradient(165deg, #eef2ff 0%, #f8fafc 42%, #e8eeff 100%);
}

body.auth-page.bg-login {
    background:
        radial-gradient(ellipse 80% 50% at 100% 0%, rgba(124, 58, 237, 0.12), transparent 55%),
        radial-gradient(ellipse 70% 45% at 0% 100%, rgba(79, 70, 229, 0.1), transparent 50%),
        linear-gradient(165deg, #eef2ff 0%, #f8fafc 45%, #e8eeff 100%);
}

body.auth-page .mobile-top-bar {
    display: none !important;
}

.auth-shell {
    width: 100%;
    max-width: 380px;
    position: relative;
    z-index: 2;
}

.auth-shell--wide {
    max-width: 520px;
}

.auth-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.1), 0 2px 8px rgba(15, 23, 42, 0.04);
    padding: 1.25rem 1.35rem;
    position: relative;
}

@media (min-width: 576px) {
    .auth-card {
        padding: 1.4rem 1.6rem;
    }
}

body.auth-page .glass-card.auth-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.1), 0 2px 8px rgba(15, 23, 42, 0.04);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.auth-brand {
    text-align: center;
    margin-bottom: 1rem;
}

.auth-brand img {
    max-height: 72px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.08));
}

@media (min-width: 576px) {
    .auth-brand img {
        max-height: 80px;
    }
}

.auth-brand h1,
.auth-brand .auth-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0.45rem 0 0;
    line-height: 1.3;
}

.auth-brand p,
.auth-brand .auth-subtitle {
    font-size: 0.8125rem;
    color: #64748b;
    margin: 0.2rem 0 0;
}

.auth-footer-link {
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: #64748b;
}

.auth-page .form-label {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: #475569;
}

.auth-page .form-control {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    border-radius: 10px;
    background: #f8fafc;
    border-color: #e2e8f0;
}

.auth-page .form-control:focus {
    background: #ffffff;
}

.auth-page .input-group-text {
    padding: 0.45rem 0.6rem;
    border-radius: 10px;
    background: #f8fafc !important;
    border-color: #e2e8f0;
}

.auth-page .input-group .form-control {
    border-radius: 0 10px 10px 0;
}

.auth-page .input-group .input-group-text:first-child {
    border-radius: 10px 0 0 10px;
}

.auth-page .btn-gradient {
    padding: 0.55rem 1rem;
    font-size: 0.9rem;
    border-radius: 10px;
}

.auth-page .btn-light.btn-lg,
.auth-page .btn-gradient.btn-lg {
    padding: 0.55rem 1rem;
    font-size: 0.9rem;
}

.auth-page .alert {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    margin-bottom: 0.75rem;
    border-radius: 10px;
}

.auth-page .form-step h5 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.auth-page .form-step > p.text-muted.small {
    margin-bottom: 0.75rem;
}

.auth-page .student-info-card {
    padding: 0.65rem 0.85rem !important;
    margin-bottom: 0.75rem !important;
    border-radius: 12px !important;
}

.auth-page .student-info-card .material-symbols-outlined {
    font-size: 32px !important;
}

.auth-page .student-info-card .fw-bold.fs-5 {
    font-size: 1rem !important;
}

.auth-page .step-indicator {
    margin-bottom: 1rem !important;
}

.auth-page .step-dot {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
}

.auth-page .otp-digit {
    width: 42px !important;
    height: 48px !important;
    max-width: 42px;
    font-size: 1.2rem !important;
    border-radius: 8px !important;
    border: 1.5px solid #cbd5e1 !important;
    background: #fff !important;
    padding: 0.25rem !important;
}

.auth-page .otp-digit:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12) !important;
}

.auth-page .chip-option {
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
}

.auth-page .loading-overlay {
    border-radius: 16px !important;
}

.auth-page #successMessage .material-symbols-outlined {
    font-size: 56px !important;
}

.auth-page #successMessage h3 {
    font-size: 1.25rem;
}

/* Legacy aliases */
.login-overlay {
    display: none;
}

/* Width helper only — do not override .auth-card surface */
.login-card.auth-card {
    width: 100%;
}

.reg-container {
    width: 100%;
    max-width: 520px;
    padding: 0;
}

.step-indicator {
    position: relative;
    display: flex;
    justify-content: space-between;
}

.step-indicator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: #e2e8f0;
    transform: translateY(-50%);
    z-index: 1;
}

.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
    color: #94a3b8;

}

.step-dot.active {
    border-color: var(--primary);
    background: var(--primary-gradient);
    color: #fff;
}

.step-dot.completed {
    background: #10b981;
    border-color: #10b981;
    color: #fff;
}

.chip-option {
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.chip-option:hover,
.chip-option.selected {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

/* Utilities */
.fw-600 {
    font-weight: 600;
}

.cursor-pointer {
    cursor: pointer;
}

.bg-primary-light {
    background-color: var(--primary-light);
}

.border-bottom-dashed {
    border-bottom: 1px dashed #e2e8f0;
}

.text-primary-grad {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}