/* App shell: sidebar accent, topbar, main width, student mobile bottom nav */

.sidebar.appshell-sidebar {
    position: relative;
    border-right: 1px solid var(--ed-border);
}

/* Sidebar siswa: fixed ke viewport (tidak ikut scroll body). AdminKit memakai margin pada .sidebar;
   sibling .main dapat margin kiri di desktop saat sidebar terbuka. */
.sidebar.appshell-sidebar--student {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1055;
    display: flex;
    flex-direction: column;
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    box-sizing: border-box;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    /* Garis pemisah hanya di area menu, bukan di strip putih → brand full width ke tepi kanan */
    border-right: none;
}

.sidebar.appshell-sidebar--student > .appshell-student-brand {
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    align-self: stretch;
    min-width: 100%;
    margin-left: 0;
    margin-right: 0;
    /* Samarkan garis pemisah kanan (border sidebar-content) agar strip putih terlihat full */
    border-right: 1px solid #ffffff;
}

.sidebar.appshell-sidebar--student > .sidebar-content {
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;
    border-right: 1px solid var(--ed-border);
    /* Tanpa scroll di sidebar siswa (timpa SimpleBar + overflow flex) */
    overflow: hidden !important;
    overflow-y: hidden !important;
}

.sidebar.appshell-sidebar--student > .sidebar-content .simplebar-wrapper,
.sidebar.appshell-sidebar--student > .sidebar-content .simplebar-mask,
.sidebar.appshell-sidebar--student > .sidebar-content .simplebar-content-wrapper {
    overflow: hidden !important;
}

.sidebar.appshell-sidebar--student > .sidebar-content .simplebar-content-wrapper {
    overflow-y: hidden !important;
}

.sidebar.appshell-sidebar--student > .sidebar-content .simplebar-track {
    display: none !important;
}

/* Aksen kiri (gradient) dinonaktifkan di sidebar siswa: sering terlihat sebagai “garis biru” di tepi brand/menu */
.sidebar.appshell-sidebar--student::before {
    content: none !important;
    display: none !important;
    width: 0 !important;
    max-width: 0 !important;
    background: none !important;
    background-image: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.sidebar.appshell-sidebar--admin::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    z-index: 2;
    background: linear-gradient(180deg, var(--ed-secondary-brand) 0%, var(--ed-primary) 100%);
    border-radius: 0 2px 2px 0;
}

.navbar.appshell-topbar {
    border-bottom: 1px solid var(--ed-border);
    background: var(--ed-surface) !important;
    min-height: var(--ed-topbar-h);
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

/* Siswa: tanpa :has() (dukungan browser). Pakai sibling .sidebar ~ .main.
   max-height viewport = kolom utama tidak memanjangkan body; scroll hanya di main.content. */
.sidebar.appshell-sidebar--student ~ .main {
    overflow: hidden;
    min-height: 0;
    max-height: 100vh;
    max-height: 100dvh;
}

.sidebar.appshell-sidebar--student ~ .main > main.content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: clip;
    -webkit-overflow-scrolling: touch;
}

.sidebar.appshell-sidebar--student ~ .main > nav.navbar.appshell-topbar:first-of-type {
    position: relative;
    flex-shrink: 0;
    z-index: 1040;
}

/* Desktop: sidebar fixed keluar alur — beri ruang 260px (selaras AdminKit, breakpoint 992px). */
@media (min-width: 992px) {
    .sidebar.appshell-sidebar--student:not(.collapsed) ~ .main {
        margin-left: 260px;
        width: calc(100% - 260px);
        max-width: calc(100% - 260px);
    }

    .sidebar.appshell-sidebar--student.collapsed ~ .main {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }
}

.navbar-light.appshell-topbar .nav-link {
    color: var(--ed-text-secondary);
}

.appshell-page-head {
    min-width: 0;
}

.appshell-page-title {
    font-family: var(--ed-font-display);
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.25;
    color: var(--ed-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(50vw, 420px);
}

.appshell-page-subtitle {
    margin: 2px 0 0;
    font-size: 0.8125rem;
    color: var(--ed-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(55vw, 480px);
}

.appshell-role-badge {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--ed-primary-soft);
    color: var(--ed-link);
}

html:not(.dark-mode) .appshell-role-badge {
    color: var(--ed-primary);
}

/* Main content width */
.sidebar.appshell-sidebar--student ~ .main main.content {
    background: var(--ed-canvas) !important;
}

.wrapper:has(.appshell-sidebar--admin) main.content {
    background: var(--ed-canvas) !important;
}

.sidebar.appshell-sidebar--student ~ .main main.content > .container-fluid.p-0 {
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--ed-space-5) !important;
    padding-right: var(--ed-space-5) !important;
}

.wrapper:has(.appshell-sidebar--admin) main.content > .container-fluid.p-0 {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--ed-space-4) !important;
    padding-right: var(--ed-space-4) !important;
}

/* Admin slightly denser tables */
.wrapper:has(.appshell-sidebar--admin) .table {
    font-size: 0.875rem;
}

.wrapper:has(.appshell-sidebar--admin) .table th,
.wrapper:has(.appshell-sidebar--admin) .table td {
    padding: 0.5rem 0.65rem;
}

/* Card surface */
.ed-card {
    background: var(--ed-surface);
    border: 1px solid var(--ed-border);
    border-radius: var(--ed-radius-lg);
    box-shadow: var(--ed-shadow-card);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.ed-card:hover {
    box-shadow: var(--ed-shadow-elevated);
}

html.dark-mode .ed-card:hover {
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
}

.ed-page-header {
    margin-bottom: var(--ed-space-5);
}

.ed-page-header h1,
.ed-page-header .h3 {
    font-family: var(--ed-font-display);
    font-weight: 700;
    margin-bottom: var(--ed-space-2);
}

.ed-page-header .lead,
.ed-page-header p.text-muted {
    font-size: 0.9375rem;
    max-width: 52ch;
}

/* Breadcrumbs (admin) */
.appshell-breadcrumb {
    font-size: 0.8125rem;
    margin-bottom: 4px;
}

.appshell-breadcrumb a {
    color: var(--ed-text-muted);
    text-decoration: none;
}

.appshell-breadcrumb a:hover {
    color: var(--ed-primary);
}

/* Quiz focus layout */
html.appshell-quiz-focus .wrapper .main {
    max-width: 100%;
}

html.appshell-quiz-focus main.content > .container-fluid.p-0 {
    max-width: 960px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

html.appshell-quiz-focus .navbar.fixed-top {
    box-shadow: var(--ed-shadow-md);
}

#autoSaveStatus {
    font-size: 0.8125rem;
    color: var(--ed-success);
    margin-bottom: 0.75rem;
    min-height: 1.25em;
}

/* Student bottom navigation */
.appshell-bottomnav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    background: var(--ed-surface);
    border-top: 1px solid var(--ed-border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
    align-items: stretch;
    gap: 2px;
}

.appshell-bottomnav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--ed-radius-sm);
    min-width: 0;
    color: var(--ed-text-secondary) !important;
}

.appshell-bottomnav a i {
    font-size: 1.15rem;
    color: var(--ed-link) !important;
}

.appshell-bottomnav a:hover,
.appshell-bottomnav a:focus-visible {
    color: var(--ed-primary) !important;
    background: var(--ed-primary-soft);
}

.appshell-bottomnav a.active {
    color: #f8f9fc !important;
    background: rgba(var(--ed-primary-rgb), 0.22) !important;
}

html:not(.dark-mode) .appshell-bottomnav a {
    color: var(--ed-text-muted) !important;
}

html:not(.dark-mode) .appshell-bottomnav a i {
    color: var(--ed-primary) !important;
}

html:not(.dark-mode) .appshell-bottomnav a.active {
    color: var(--ed-primary) !important;
    background: var(--ed-primary-soft) !important;
}

@media (max-width: 767.98px) {
    .appshell-bottomnav {
        display: flex;
    }

    .sidebar.appshell-sidebar--student ~ .main main.content {
        padding-bottom: 72px !important;
    }
}

/* Distraction-free reader hint (materi viewer uses own page; class for embed) */
.materi-reader-focus {
    max-width: 65ch;
    margin-left: auto;
    margin-right: auto;
}

/* Student sidebar — optional image brand strip (Admin: Brand Area); always white strip */
.sidebar.appshell-sidebar--student .appshell-student-brand {
    flex-shrink: 0;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    overflow: hidden;
    background: #ffffff !important;
    border-bottom: 1px solid rgba(15, 23, 42, 0.1);
}

html.dark-mode .sidebar.appshell-sidebar--student .appshell-student-brand {
    background: #ffffff !important;
    border-bottom-color: rgba(15, 23, 42, 0.14);
}

.sidebar.appshell-sidebar--student .appshell-student-brand__link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    /* Padding horizontal lebih besar → ruang letterbox untuk object-position X (logo mendatar) */
    padding: var(--sb-pt, 12px) clamp(16px, 8%, 40px) var(--sb-pb, 12px);
    text-decoration: none;
    min-height: 0;
    background-color: #ffffff !important;
}

.sidebar.appshell-sidebar--student .appshell-student-brand__link:focus-visible {
    outline: 2px solid var(--ed-primary);
    outline-offset: -2px;
}

.sidebar.appshell-sidebar--student .appshell-student-brand__img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: calc(56px * var(--sb-scale, 100) / 100);
    object-fit: var(--sb-fit, contain);
    object-position: var(--sb-ox, 50%) var(--sb-oy, 50%);
}

/* Admin setting preview: same --sb-* behavior as student sidebar (not inside .sidebar) */
.appshell-student-brand.appshell-student-brand--preview {
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    background: #ffffff;
    border-bottom: 1px solid rgba(15, 23, 42, 0.1);
}

.appshell-student-brand.appshell-student-brand--preview .appshell-student-brand__link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    padding: var(--sb-pt, 12px) clamp(16px, 8%, 40px) var(--sb-pb, 12px);
    text-decoration: none;
    min-height: 0;
    background-color: #ffffff;
}

.appshell-student-brand.appshell-student-brand--preview .appshell-student-brand__img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: calc(48px * var(--sb-scale, 100) / 100);
    object-fit: var(--sb-fit, contain);
    object-position: var(--sb-ox, 50%) var(--sb-oy, 50%);
}

.appshell-student-brand__empty {
    display: block;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--ed-text-muted, #6b7280);
    padding: 0.75rem 0.5rem;
    text-align: center;
}

html:not(.dark-mode) .appshell-student-brand__empty {
    color: #6b7280;
}

/* Sidebar brand — tokenized (replaces hardcoded #fff in PHP) */
.sidebar .sidebar-brand.appshell-sidebar-brand {
    gap: 10px;
    width: 100%;
    min-height: 58px;
    padding: 12px 14px;
    border-radius: 0;
    box-sizing: border-box;
    overflow: hidden;
    background: var(--ed-surface-elevated) !important;
    border-bottom: 1px solid var(--ed-border);
}

html:not(.dark-mode) .sidebar .sidebar-brand.appshell-sidebar-brand {
    background: #ffffff !important;
}

/* Nama merek di strip brand: teks gelap di atas latar putih (kalahkan gaya AdminKit / link). */
html:not(.dark-mode) .sidebar a.sidebar-brand.appshell-sidebar-brand,
html:not(.dark-mode) .sidebar a.sidebar-brand.appshell-sidebar-brand:hover,
html:not(.dark-mode) .sidebar a.sidebar-brand.appshell-sidebar-brand:focus,
html:not(.dark-mode) .sidebar a.sidebar-brand.appshell-sidebar-brand:focus-visible,
html:not(.dark-mode) .sidebar a.sidebar-brand.appshell-sidebar-brand .align-middle {
    color: #111827 !important;
}

.navbar-light.appshell-topbar,
.navbar-light.appshell-topbar.navbar-bg {
    background: var(--ed-surface) !important;
}

.navbar-light.appshell-topbar .nav-link,
.navbar-light.appshell-topbar .navbar .dropdown-toggle {
    color: var(--ed-text-secondary) !important;
}

.navbar-light.appshell-topbar .nav-link:hover,
.navbar-light.appshell-topbar .nav-link:focus {
    color: var(--ed-text) !important;
}

/* Sidebar: separate primary study nav from secondary links */
.sidebar.appshell-sidebar .sidebar-nav > .appshell-nav-divider {
    list-style: none;
    height: 0;
    margin: 0.5rem 1rem 0.55rem;
    padding: 0;
    border: 0;
    border-top: 1px solid var(--ed-border-strong);
    pointer-events: none;
}

/* ------------------------------------------------------------------------- */
/* Siswa — dark mode: sidebar, nav, dan outline button (selaras token)        */
/* ------------------------------------------------------------------------- */

html.dark-mode .sidebar.appshell-sidebar--student {
    background: var(--ed-sidebar-bg) !important;
    color: var(--ed-text);
}

html.dark-mode .sidebar.appshell-sidebar--student .sidebar-content {
    background: transparent !important;
}

html.dark-mode .sidebar.appshell-sidebar--student .sidebar-link,
html.dark-mode .sidebar.appshell-sidebar--student .sidebar-link span {
    color: var(--ed-text-secondary) !important;
}

html.dark-mode .sidebar.appshell-sidebar--student .sidebar-link:hover {
    color: var(--ed-text) !important;
    background: rgba(255, 255, 255, 0.045) !important;
}

html.dark-mode .sidebar.appshell-sidebar--student .sidebar-item.active > .sidebar-link {
    color: var(--ed-text) !important;
    background: rgba(var(--ed-primary-rgb), 0.14) !important;
    box-shadow: inset 3px 0 0 var(--ed-primary);
}

html.dark-mode .sidebar.appshell-sidebar--student .sidebar-item.active > .sidebar-link i {
    color: var(--ed-link) !important;
}

html.dark-mode .sidebar.appshell-sidebar--student .timeline-submenu .sidebar-link {
    color: var(--ed-text-secondary) !important;
    box-shadow: none !important;
}

html.dark-mode .sidebar.appshell-sidebar--student .timeline-submenu .sidebar-item.active > .sidebar-link {
    color: var(--ed-text) !important;
    background: rgba(255, 255, 255, 0.06) !important;
}

html.dark-mode .sidebar.appshell-sidebar--student ~ .main .btn-outline-primary {
    --bs-btn-color: var(--ed-link);
    color: var(--ed-link) !important;
}

html.dark-mode .sidebar.appshell-sidebar--student ~ .main .btn-outline-primary:hover {
    color: #fff !important;
}

html.dark-mode .sidebar.appshell-sidebar--student ~ .main main.content .list-unstyled .border-bottom {
    border-color: var(--ed-border-strong) !important;
}
