
:root {
    --app-shell-max-width: 1560px;
    --app-font-size: clamp(13.8px, 0.14vw + 13.4px, 15.2px);
    --app-shell-padding: clamp(0.75rem, 1.8vw, 2rem);
    --app-card-radius: 1rem;
    --app-soft-line: #dbe5f0;
    --app-soft-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

html {
    font-size: var(--app-font-size);
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: #f4f6f9d2;
    line-height: 1.45;
    overflow-x: hidden;
}

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

.app-top-shell,
.app-shell {
    width: min(100%, var(--app-shell-max-width));
    margin-inline: auto;
    padding-left: var(--app-shell-padding) !important;
    padding-right: var(--app-shell-padding) !important;
}

main.py-4,
main.min-vh-100 {
    padding-top: clamp(0.9rem, 1.4vw, 1.4rem) !important;
    padding-bottom: clamp(0.9rem, 1.4vw, 1.4rem) !important;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    font-size: 0.93rem;
}

.app-shell .table th,
.app-shell .table td {
    vertical-align: middle;
}

.app-shell .table-wrap,
.app-shell .table-responsive {
    border-radius: 0.95rem;
}

.app-navbar .navbar-nav.w-100 {
    gap: 0.2rem 0.35rem;
}

.navbar-nav .nav-link {
    color: #333;
    font-weight: 500;
    transition: all 0.3s ease;
    border-radius: 8px;
    padding: 0.46rem 0.8rem;
    margin: 0;
    font-size: 0.92rem;
    white-space: nowrap;
}
.navbar-nav .nav-link:hover {
    background-color: #f8f9fa;
    color: #007bff;
}
/* Active link style */
.navbar-nav .nav-link.active-link {
    background-color: #007bff;
    color: white !important;
    font-weight: 600;
}
.navbar-nav .nav-link.active-link:hover {
    background-color: #0056b3;
    color: white !important;
}
/* Icon spacing */
.navbar-nav .nav-link i {
    margin-right: 0.5rem;
}
.navbar-brand {
    font-size: 1.15rem;
    letter-spacing: 0.5px;
}

.top-user-link {
    color: #1f2937 !important;
    font-weight: 600;
    border-radius: 10px;
    padding: 0.28rem 0.45rem !important;
    background: transparent;
    text-decoration: none;
}

.top-user-link:hover {
    color: #111827 !important;
    background: #f1f5f9;
}

.top-user-role {
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 500;
}

.dropdown-menu[aria-labelledby="navbarDropdown"] {
    min-width: 10rem;
    padding: 0.35rem;
}

.logout-item {
    border-radius: 10px;
    padding: 0.55rem 0.75rem;
}
.card {
    border-radius: 1.15rem;
}

.card-body {
    padding: clamp(0.8rem, 1.05vw, 1.1rem);
}

.logout-item {
    transition: all 0.3s ease;
    font-weight: 500;
}
.logout-item:hover {
    background-color: #dc3545; /* Bootstrap danger red */
    color: #fff !important;
    border-radius: 6px;
}
.logout-item:hover i {
    color: #fff;
}

/* Global form consistency */
.app-shell .form-control,
.app-shell .form-select,
.app-shell .btn {
    min-height: 42px;
}

.app-shell textarea.form-control {
    min-height: 110px;
}

input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}

input[type="password"]::-webkit-credentials-auto-fill-button,
input[type="password"]::-webkit-textfield-decoration-container {
    display: none !important;
}

/* Keep dashboard actions tap-friendly across devices */
.action-icon-btn {
    min-width: 44px;
    min-height: 44px;
}

/* Responsive modal baseline */
.modal-dialog {
    margin: 1rem auto;
}

.modal-dialog-scrollable .modal-body {
    max-height: min(74vh, 760px);
}

/* STAT CARDS */
.stat-card {
    background: #ffffff;
    border: 0;
    border-radius: 1.5rem;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 22px 42px rgba(15, 23, 42, 0.1);
}

.icon-box {
    width: 56px;
    height: 56px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    box-shadow: 0 14px 26px rgba(15, 23, 42, 0.12);
}

/* Custom purple */
.bg-purple {
    background: linear-gradient(135deg, #8e44ad, #6c5ce7);
}
.bg-green {
    background: #16F51C;
}
.bg-orange {
    background: #ffc107;
}
.bg-blue {
    background: #007bff;
}

.avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Teacher dashboard system */
.teacher-system-shell {
    max-width: 1700px;
    margin: 0 auto;
}

.teacher-system-page {
    display: grid;
    gap: 1.5rem;
}

.teacher-system-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.teacher-system-title {
    font-size: clamp(1.6rem, 1.2rem + 1vw, 2.05rem);
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 0.35rem;
}

.teacher-system-subtitle {
    margin: 0;
    color: #64748b;
    font-size: 1rem;
    line-height: 1.5;
}

.teacher-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 0.3rem;
}

.teacher-section-subtitle {
    margin: 0;
    color: #64748b;
    font-size: 0.94rem;
    line-height: 1.5;
}

.teacher-system-hero,
.teacher-system-card,
.teacher-system-toolbar,
.teacher-system-table-shell {
    border: 0;
    border-radius: 24px;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.06);
    background: #fff;
}

.teacher-system-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #0056b3 0%, #226ab6 52%, #6195cc 100%);
    color: #fff;
}

.teacher-system-hero::after {
    content: '';
    position: absolute;
    inset: auto -8% -35% auto;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    pointer-events: none;
}

.teacher-system-hero > * {
    position: relative;
    z-index: 1;
}

.teacher-system-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    font-weight: 600;
}

.teacher-system-hero-note {
    color: rgba(255, 255, 255, 0.84);
    max-width: 60ch;
}

.teacher-system-stat {
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(6px);
    min-height: 100%;
}

.teacher-system-icon-box {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.teacher-system-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.teacher-system-action-row {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.teacher-system-card-body {
    padding: 1.5rem;
}

.teacher-stat-grid {
    --bs-gutter-y: 1.5rem;
}

.teacher-stat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    min-height: 100%;
}

.teacher-stat-title {
    margin: 0;
    color: #000000;
    font-size: 1.3rem;
    font-weight: 700;
}

.teacher-stat-value {
    margin: 0;
    color: #0f172a;
    font-size: clamp(1.8rem, 1.3rem + 1vw, 2.35rem);
    font-weight: 700;
    line-height: 1;
}

.teacher-stat-sub {
    color: #94a3b8;
    font-size: 0.86rem;
    line-height: 1.45;
}

@media (max-width: 991.98px) {
    .teacher-system-shell {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
}

@media (max-width: 767.98px) {
    .teacher-system-header,
    .teacher-system-section-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .teacher-system-hero,
    .teacher-system-card,
    .teacher-system-toolbar,
    .teacher-system-table-shell {
        border-radius: 18px;
    }
}

body.app-standalone {
    padding-left: var(--app-shell-padding);
    padding-right: var(--app-shell-padding);
}

@media (max-width: 1399.98px) {
    /* Responsive navbar panel for admin/teacher/guest views */
    .role-admin .app-navbar .navbar-collapse,
    .role-teacher .app-navbar .navbar-collapse,
    .role-guest .app-navbar .navbar-collapse {
        position: absolute;
        top: calc(100% + 0.45rem);
        left: 0.9rem;
        right: 0.9rem;
        background: #fff;
        border: 1px solid #dbe5f0;
        border-radius: 16px;
        padding: 0.75rem;
        box-shadow: var(--app-soft-shadow);
        z-index: 1035;
    }

    .role-admin .app-navbar .navbar-nav.w-100,
    .role-teacher .app-navbar .navbar-nav.w-100,
    .role-guest .app-navbar .navbar-nav.w-100 {
        width: 100% !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 0.3rem !important;
        margin-bottom: 0.45rem;
    }

    .role-admin .app-navbar .navbar-nav.w-100 .nav-link,
    .role-teacher .app-navbar .navbar-nav.w-100 .nav-link,
    .role-guest .app-navbar .navbar-nav.w-100 .nav-link {
        display: flex;
        align-items: center;
        width: 100%;
        border-radius: 10px;
        padding: 0.58rem 0.75rem;
    }

    .role-admin .app-navbar .navbar-nav.ms-auto,
    .role-teacher .app-navbar .navbar-nav.ms-auto,
    .role-guest .app-navbar .navbar-nav.ms-auto {
        width: 100%;
        border-top: 1px solid #e6edf5;
        padding-top: 0.6rem;
        margin-top: 0.45rem;
        justify-content: flex-end;
        gap: 0.45rem;
    }

    .app-navbar .navbar-nav.w-100 {
        justify-content: flex-start !important;
    }

    .navbar-nav .nav-link {
        white-space: normal;
        line-height: 1.25;
    }

    .top-user-link {
        max-width: 170px;
    }
}

@media (max-width: 991.98px) {
    .app-top-shell,
    .app-shell {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }

    .navbar-nav .nav-link {
        font-size: 0.88rem;
    }

    .card-body {
        padding: 0.95rem;
    }

    .app-shell .btn {
        min-height: 44px;
    }

    .app-shell .table {
        font-size: 0.88rem;
    }

    .app-shell .table thead th,
    .app-shell .table tbody td {
        white-space: nowrap;
    }

    .modal-dialog {
        max-width: calc(100% - 1.35rem);
    }

    /* Modal form readability on small screens */
    .modal-body .row > [class*='col-'] {
        margin-bottom: 0.35rem;
    }
}

@media (max-width: 575.98px) {
    .top-user-link {
        max-width: 130px;
        padding: 0.22rem 0.35rem !important;
        font-size: 0.8rem !important;
    }

    .top-user-role {
        display: none;
    }

    .dropdown-menu[aria-labelledby="navbarDropdown"] {
        min-width: 8.8rem;
        margin-top: 0.25rem;
    }

    .logout-item {
        padding: 0.5rem 0.65rem;
        font-size: 0.88rem;
    }

    .app-top-shell,
    .app-shell {
        padding-left: 0.65rem !important;
        padding-right: 0.65rem !important;
    }

    .app-shell .card,
    .app-shell .panel-card,
    .app-shell .section-panel,
    .app-shell .content-card,
    .app-shell .manage-toolbar,
    .app-shell .manage-table-shell {
        border-radius: var(--app-card-radius) !important;
    }

    .app-shell .form-control,
    .app-shell .form-select,
    .app-shell .btn {
        font-size: 0.9rem;
    }

    .modal-dialog {
        margin: 0.55rem;
        max-width: calc(100% - 1.1rem);
    }

    .modal-content {
        border-radius: 0.95rem !important;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }

    .app-shell .table {
        font-size: 0.84rem;
    }
}

@media (min-width: 1200px) {
    .approval-shell,
    .materials-shell,
    .reports-shell,
    .manage-shell,
    .student-shell,
    .profile-shell {
        max-width: 1420px !important;
    }

    .approval-layout {
        grid-template-columns: 240px minmax(0, 1fr) !important;
        gap: 1rem !important;
    }

    .approval-hero,
    .materials-hero,
    .hero-card,
    .manage-table-shell,
    .manage-toolbar,
    .approval-sidebar,
    .section-panel,
    .report-table-shell {
        border-radius: 18px !important;
    }

    .summary-icon,
    .manage-avatar,
    .student-avatar {
        width: 44px !important;
        height: 44px !important;
        font-size: 0.95rem !important;
        border-radius: 12px !important;
    }

    .search-input {
        height: 50px !important;
    }

    .filter-chip,
    .pill-level,
    .pill-status {
        padding: 0.62rem 0.9rem !important;
        font-size: 0.82rem !important;
    }

    .manage-table thead th,
    .manage-table tbody td,
    .report-table thead th,
    .report-table tbody td {
        padding: 0.85rem 0.9rem !important;
    }

    .app-shell h1,
    .app-shell h2 {
        line-height: 1.2;
    }
}
