/* ============================================================
   Tema SI-BK MAN 2 Agam — Hijau Madrasah
   Bootstrap 5.3 + CSS Variables (mendukung Dark Mode)
   ============================================================ */

:root {
    --brand: #0f6b4f;
    --brand-2: #17976d;
    --brand-soft: #e6f4ee;
    --brand-light: #f3faf7;
    --sidebar-bg: #0c4f3b;
    --sidebar-bg-2: #0a4232;
    --sidebar-text: #cfe8dd;
    --sidebar-active: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, .08);
    --sidebar-width: 262px;
    --body-bg: #f4f7f6;
    --card-radius: 14px;
    --shadow-soft: 0 4px 16px rgba(15, 107, 79, .08);
}

[data-bs-theme="dark"] {
    --body-bg: #10181a;
    --sidebar-bg: #0b1814;
    --sidebar-bg-2: #09130f;
    --sidebar-text: #9db8ac;
    --shadow-soft: 0 4px 16px rgba(0, 0, 0, .35);
}

body {
    background: var(--body-bg);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: .925rem;
}

/* ---------- Scrollbar halus ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(15, 107, 79, .35); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Warna brand ---------- */
.text-brand { color: var(--brand) !important; }
.text-brand-emphasis { color: var(--brand-2) !important; }
.bg-brand { background: var(--brand) !important; }
.bg-brand-soft { background: var(--brand-soft) !important; }
.bg-brand-subtle { background: var(--brand-soft) !important; }
.btn-outline-brand { border: 1.5px solid var(--brand); color: var(--brand); border-radius: 9px; }
.btn-outline-brand:hover { background: var(--brand); color: #fff; }
.btn-brand {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    border: 0; color: #fff; border-radius: 9px; font-weight: 500;
}
.btn-brand:hover { color: #fff; filter: brightness(1.08); }
.btn-brand-outline { border: 1.5px solid var(--brand); color: var(--brand); border-radius: 9px; }
.btn-brand-outline:hover { background: var(--brand); color: #fff; }

/* ---------- Loading screen ---------- */
#loadingScreen {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--body-bg);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: opacity .35s ease;
}
#loadingScreen.hidden { opacity: 0; pointer-events: none; }
.loading-logo {
    width: 64px; height: 64px; border-radius: 18px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.8rem; margin-bottom: 14px;
    animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.spinner-brand { width: 34px; height: 34px; border: 3.5px solid rgba(15,107,79,.18); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
    color: var(--sidebar-text);
    position: fixed; inset: 0 auto 0 0; z-index: 1040;
    display: flex; flex-direction: column;
    transition: transform .28s ease;
}
.sidebar-brand {
    padding: 18px 20px; display: flex; align-items: center; gap: 12px;
    color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand-icon {
    width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--brand-2), #22c58e);
    display: flex; align-items: center; justify-content: center; font-size: 1.25rem;
}
.sidebar-brand .brand-text { line-height: 1.15; }
.sidebar-brand .brand-text strong { font-size: .86rem; display: block; color: #fff; }
.sidebar-brand .brand-text span { font-size: .7rem; opacity: .75; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); }

.nav-group-title {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
    color: rgba(207, 232, 221, .5); padding: 14px 12px 6px; font-weight: 600;
}
.sidebar-nav a.nav-link {
    color: var(--sidebar-text); border-radius: 9px;
    padding: 9px 12px; margin-bottom: 2px; font-size: .88rem;
    display: flex; align-items: center; gap: 11px; text-decoration: none;
    transition: background .15s, color .15s;
}
.sidebar-nav a.nav-link i { font-size: 1.02rem; width: 20px; text-align: center; }
.sidebar-nav a.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav a.nav-link.active {
    background: linear-gradient(135deg, var(--brand-2), #22c58e);
    color: #fff; font-weight: 500; box-shadow: 0 4px 12px rgba(23,151,109,.35);
}
.sidebar-nav a.nav-link .badge { margin-left: auto; }

.sidebar-footer { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: .72rem; color: rgba(207,232,221,.55); }

/* Main content */
.main-content {
    flex: 1; margin-left: var(--sidebar-width);
    min-width: 0; display: flex; flex-direction: column; min-height: 100vh;
}
.content-body { flex: 1; padding: 22px 26px 40px; }

/* Topbar */
.topbar {
    background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color);
    padding: 10px 26px; position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: 14px;
}
.topbar .search-box { max-width: 380px; width: 100%; }
.topbar .search-box input { border-radius: 50rem; background: var(--bs-tertiary-bg); border: 0; }

/* Notification dropdown */
.notif-dropdown { width: 340px; max-height: 420px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: inherit; }
.notif-item:hover { background: var(--bs-tertiary-bg); }
.notif-item .notif-icon {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: .95rem;
}
.notif-item.unread { background: var(--brand-soft); }

/* ---------- Card ---------- */
.card { border: 0; border-radius: var(--card-radius); box-shadow: var(--shadow-soft); }
.card-header { border-radius: var(--card-radius) var(--card-radius) 0 0 !important; }
.stat-card { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: var(--card-radius); }
.stat-icon {
    width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.35rem;
}
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .78rem; color: var(--bs-secondary-color); }

/* ---------- Tables ---------- */
.table thead th {
    font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--bs-secondary-color); border-bottom-width: 1.5px; white-space: nowrap;
}
.table tbody td { vertical-align: middle; }
.table-row-hover tbody tr { transition: background .12s; }
.table-row-hover tbody tr:hover { background: var(--bs-tertiary-bg); }

/* ---------- Form ---------- */
.form-control, .form-select {
    border-radius: 9px; border-color: var(--bs-border-color);
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(15,107,79,.12);
}
.form-label { font-size: .82rem; font-weight: 500; margin-bottom: .3rem; }
.input-group-text { border-radius: 9px 0 0 9px; background: var(--bs-tertiary-bg); }

/* ---------- Auth pages ---------- */
.auth-body {
    background: linear-gradient(135deg, #0c4f3b 0%, #0f6b4f 55%, #17976d 100%);
    min-height: 100vh; position: relative; overflow-x: hidden;
}
.auth-bg {
    position: absolute; inset: 0; pointer-events: none;
    background:
        radial-gradient(circle at 12% 18%, rgba(255,255,255,.10) 0, transparent 34%),
        radial-gradient(circle at 88% 82%, rgba(255,255,255,.08) 0, transparent 36%);
}

.auth-wrapper { position: relative; z-index: 1; display: flex; min-height: 100vh; }

/* Panel kiri: informasi aplikasi */
.auth-aside {
    flex: 1 1 52%; padding: 48px 56px; color: #eaf6f1;
    display: flex; align-items: center; justify-content: center;
}
.auth-aside-inner { max-width: 520px; width: 100%; }
.auth-aside-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 36px; }
.auth-aside-logo {
    width: 52px; height: 52px; border-radius: 15px; flex-shrink: 0;
    background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.5rem;
}
.auth-aside-brand strong { display: block; font-size: 1rem; color: #fff; line-height: 1.2; }
.auth-aside-brand span { font-size: .8rem; opacity: .78; }
.auth-aside-title {
    font-size: 1.95rem; line-height: 1.22; font-weight: 700; color: #fff; margin-bottom: 14px;
}
.auth-aside-sub { font-size: .93rem; opacity: .85; margin-bottom: 30px; line-height: 1.65; }
.auth-aside-list { list-style: none; padding: 0; margin: 0 0 36px; }
.auth-aside-list li { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.auth-aside-icon {
    width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
    background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.18);
    display: flex; align-items: center; justify-content: center; color: #fff;
}
.auth-aside-list strong { display: block; font-size: .9rem; color: #fff; font-weight: 600; }
.auth-aside-list em { font-style: normal; font-size: .8rem; opacity: .78; }
.auth-aside-footer { font-size: .78rem; opacity: .72; border-top: 1px solid rgba(255,255,255,.16); padding-top: 16px; }

/* Panel kanan: formulir */
.auth-main {
    flex: 1 1 48%; background: var(--body-bg);
    display: flex; align-items: center; justify-content: center;
    padding: 40px 24px; border-radius: 28px 0 0 28px;
    box-shadow: -24px 0 60px rgba(0,0,0,.18);
}
.auth-main-inner { width: 100%; max-width: 400px; }

.auth-card {
    background: var(--bs-body-bg); border-radius: 20px;
    padding: 34px 30px; box-shadow: 0 18px 44px rgba(15,23,42,.10);
    border: 1px solid var(--bs-border-color);
    animation: fadeUp .5s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.auth-logo {
    width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 18px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.7rem;
}
.auth-title { text-align: center; font-size: 1.25rem; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { text-align: center; color: var(--bs-secondary-color); font-size: .85rem; margin-bottom: 24px; }
.auth-note {
    font-size: .78rem; color: var(--bs-secondary-color);
    background: var(--brand-soft); border: 1px dashed rgba(15,107,79,.28);
    border-radius: 10px; padding: 10px 12px; line-height: 1.5;
}
.auth-page-credit { text-align: center; margin-top: 18px; font-size: .78rem; color: var(--bs-secondary-color); }

@media (max-width: 991.98px) {
    .auth-main { border-radius: 0; box-shadow: none; background: transparent; padding: 28px 18px; }
    .auth-card { background: var(--bs-body-bg); }
    .auth-page-credit { color: rgba(255,255,255,.75); }
}

/* ---------- Utilities ---------- */
.badge { font-weight: 500; }
.small-text { font-size: .78rem; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
    background: var(--bs-tertiary-bg);
}
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }
.avatar-sm { width: 28px; height: 28px; }
.permission-group {
    border: 1px solid var(--bs-border-color); border-radius: 12px; padding: 12px 14px; height: 100%;
}
.permission-group-title {
    font-size: .78rem; font-weight: 600; color: var(--brand);
    padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px dashed var(--bs-border-color);
}
.permission-group code { font-size: .68rem; margin-left: 4px; }

.mini-calendar td { text-align: center; padding: 4px 0; font-size: .8rem; }
.mini-calendar .cal-today {
    background: var(--brand); color: #fff; border-radius: 50%;
    width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
}
.mini-calendar .cal-muted { color: var(--bs-secondary-color); opacity: .5; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-backdrop {
        position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1035;
        display: none;
    }
    .sidebar-backdrop.show { display: block; }
    .content-body { padding: 16px 14px 30px; }
    .topbar { padding: 10px 14px; }
}
@media (min-width: 992px) { .sidebar-backdrop { display: none !important; } }

/* ---------- Footer aplikasi ---------- */
.app-footer {
    border-top: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    padding: 14px 26px;
}
.app-footer-inner {
    display: flex; flex-wrap: wrap; gap: 6px 16px;
    align-items: center; justify-content: space-between;
    font-size: .78rem; color: var(--bs-secondary-color);
}
.app-footer-credit strong { color: var(--brand); letter-spacing: .02em; }
.app-footer-copy { line-height: 1.4; }

.app-credit { color: var(--bs-secondary-color); }
.app-credit strong { color: var(--brand); }
.app-credit-print { text-align: center; font-size: 11px; color: #555; margin-top: 14px; }

/* ---------- Avatar inisial ---------- */
.avatar-initial {
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; font-weight: 600; font-size: .95rem; flex-shrink: 0;
}

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 42px 18px; color: var(--bs-secondary-color); }
.empty-state i { font-size: 2.6rem; opacity: .45; display: block; margin-bottom: 12px; }
.empty-state .empty-title { font-weight: 600; color: var(--bs-body-color); margin-bottom: 4px; }
.empty-state .empty-text { font-size: .84rem; }

/* ---------- Sidebar footer dua baris ---------- */
.sidebar-footer-line { margin-bottom: 3px; }
.sidebar-footer-credit { font-size: .68rem; opacity: .8; }
.sidebar-footer-credit strong { color: #b8e6d3; }

/* ---------- Halaman cetak / PDF ---------- */
.print-page { background: #fff; color: #111; }
.print-page .app-credit-print { border-top: 1px solid #ddd; padding-top: 8px; }

/* Print friendly */
@media print {
    .sidebar, .topbar, #loadingScreen, .app-footer, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-body { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd; }
    .app-credit-print { display: block !important; }
}

@media (max-width: 991.98px) {
    .app-footer { padding: 12px 14px; }
    .app-footer-inner { justify-content: center; text-align: center; }
}

/* ---------- Logo sekolah ---------- */
.sidebar-brand .brand-icon.berlogo {
    background: #fff; padding: 4px; overflow: hidden;
}
.sidebar-brand .brand-icon.berlogo img { width: 100%; height: 100%; object-fit: contain; display: block; }

.auth-aside-logo.berlogo { background: #fff; padding: 5px; overflow: hidden; }
.auth-aside-logo.berlogo img { width: 100%; height: 100%; object-fit: contain; display: block; }

.auth-logo.berlogo { background: #fff; border: 1px solid var(--bs-border-color); padding: 6px; overflow: hidden; }
.auth-logo.berlogo img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ---------- Pratinjau logo di Pengaturan ---------- */
.logo-preview {
    height: 130px; border: 1px dashed var(--bs-border-color); border-radius: 12px;
    background: var(--bs-tertiary-bg);
    display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 10px;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview-empty { text-align: center; color: var(--bs-secondary-color); font-size: .78rem; }
.logo-preview-empty i { display: block; font-size: 1.9rem; opacity: .5; margin-bottom: 4px; }

/* ---------- Pemilih warna tema ---------- */
.palet-dot {
    width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.15); cursor: pointer; transition: transform .15s ease;
}
.palet-dot:hover { transform: scale(1.12); }
.warna-preview .badge { font-size: .72rem; }

/* ---------- Panel tindak lanjut dashboard ---------- */
.tindak-item {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 12px; border-radius: 10px; background: var(--bs-tertiary-bg);
    margin-bottom: 8px; text-decoration: none; color: inherit;
    transition: background .15s ease;
}
.tindak-item:hover { background: var(--brand-soft); color: inherit; }
.tindak-hari {
    flex-shrink: 0; min-width: 44px; text-align: center; border-radius: 8px;
    background: #fff; border: 1px solid var(--bs-border-color); padding: 4px 6px;
}
.tindak-hari b { display: block; font-size: 1rem; line-height: 1; color: var(--bs-danger); }
.tindak-hari span { font-size: .62rem; color: var(--bs-secondary-color); }
@media print { .app-footer, .no-print { display: none !important; } }

/* ---------- Header dashboard berlogo ---------- */
.dashboard-logo {
    width: 54px; height: 54px; border-radius: 14px; flex-shrink: 0;
    background: var(--brand-soft); color: var(--brand);
    display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
}
.dashboard-logo.berlogo { background: #fff; border: 1px solid var(--bs-border-color); padding: 5px; }
.dashboard-logo.berlogo img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ---------- Halaman Tentang Aplikasi ---------- */
.tentang-logo {
    width: 76px; height: 76px; border-radius: 18px; flex-shrink: 0;
    background: var(--brand-soft); color: var(--brand);
    display: flex; align-items: center; justify-content: center; font-size: 2.1rem;
}
.tentang-logo.berlogo { background: #fff; border: 1px solid var(--bs-border-color); padding: 8px; }
.tentang-logo.berlogo img { width: 100%; height: 100%; object-fit: contain; display: block; }

.credit-badge {
    background: var(--brand-soft); color: var(--brand);
    border: 1px dashed rgba(15, 107, 79, .3);
    border-radius: 12px; padding: 10px 16px; font-size: .82rem;
}
.credit-badge strong { letter-spacing: .02em; }

.fitur-icon {
    width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
    background: var(--brand-soft); color: var(--brand);
    display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
}
