@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Amiri:wght@400;700&family=Noto+Kufi+Arabic:wght@400;600;700&display=swap');

:root {
    --emerald-deep: #123c35;
    --emerald: #16715d;
    --emerald-light: #28a784;
    --gold-antique: #c59435;
    --gold-light: #e6be65;
    --gold-pale: #f6ead0;
    --papyrus: #f4f6f3;
    --papyrus-dark: #e2e8e3;
    --ink-dark: #17251f;
    --ink: #293b34;
    --ink-light: #6d7c75;
    --font-body: 'Manrope', sans-serif;
    --font-display: 'Manrope', sans-serif;
    --surface: #fff;
    --surface-soft: #f8faf8;
    --border: #e3e9e5;
    --sidebar-width: 276px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 2px rgba(19, 48, 39, .04), 0 4px 14px rgba(19, 48, 39, .035);
    --shadow-md: 0 12px 30px rgba(19, 48, 39, .09);
    --shadow-lg: 0 22px 50px rgba(19, 48, 39, .14);
}

html { background: var(--papyrus); }
body { background: var(--papyrus); font-size: 14px; }
body::before { opacity: .4; }
a { color: var(--emerald); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(22, 113, 93, .28) !important; outline-offset: 3px; }
::selection { background: var(--gold-pale); color: var(--emerald-deep); }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(165deg, #123c35 0%, #0c2c27 68%, #09231f 100%);
    border-right: 1px solid rgba(255,255,255,.06);
    box-shadow: 8px 0 32px rgba(6, 34, 28, .12);
}
.sidebar-logo { padding: 25px 22px 21px; text-align: left; border-bottom-color: rgba(255,255,255,.08); }
.sidebar-logo .islamic-star { width: 44px; height: 44px; margin: 0 0 16px; }
.sidebar-logo .islamic-star::before, .sidebar-logo .islamic-star::after { width: 29px; height: 29px; border-width: 1.5px; }
.sidebar-logo h1 { font-size: .96rem; color: #edcb7b; margin-bottom: 7px; }
.sidebar-logo .subtitle { font-size: .83rem; font-weight: 700; letter-spacing: -.01em; }
.sidebar-logo .subtitle-small { font-size: .67rem; color: rgba(255,255,255,.48); }
.sidebar-nav { padding: 16px 14px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.nav-section { margin-bottom: 17px; }
.nav-section-title { display: block; padding: 0 12px; color: rgba(255,255,255,.38); font-size: .61rem; font-weight: 700; letter-spacing: .13em; margin-bottom: 6px; }
.nav-item { position: relative; padding: 10px 12px; margin-bottom: 3px; border-radius: 10px; color: rgba(255,255,255,.67); font-size: .83rem; font-weight: 500; }
.nav-item i { width: 21px; font-size: .91rem; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.065); transform: translateX(2px); }
.nav-item.active { color: #fff; background: rgba(230,190,101,.13); box-shadow: inset 3px 0 #e6be65; }
.nav-item.active i { color: #edcb7b; }
.sidebar-footer { padding: 13px 18px 17px; background: rgba(0,0,0,.08); }
.quick-actions { justify-content: flex-start; margin-bottom: 10px; padding: 0; }
.user-info { padding: 9px 5px 0; }
.user-avatar { background: linear-gradient(135deg, #edcb7b, #c59435); color: #173b32; box-shadow: 0 4px 12px rgba(0,0,0,.13); }
.user-details h4 { font-family: var(--font-body); font-size: .78rem; font-weight: 700; }
.user-details span { font-size: .66rem; }

.main-content { margin-left: var(--sidebar-width); padding: 0 30px 34px; max-width: 1700px; width: calc(100% - var(--sidebar-width)); min-width: 0; }
.grid > *, .app-topbar > *, .global-search { min-width: 0; }
.app-topbar {
    min-height: 78px;
    display: flex;
    align-items: center;
    gap: 22px;
    margin: 0 -30px 28px;
    padding: 13px 30px;
    position: sticky;
    top: 0;
    z-index: 45;
    background: rgba(244,246,243,.88);
    border-bottom: 1px solid rgba(218,226,220,.85);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.topbar-context { min-width: 175px; }
.topbar-eyebrow { display: block; color: var(--ink-light); font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.topbar-title { display: block; color: var(--emerald-deep); font-size: .95rem; font-weight: 800; margin-top: 2px; }
.global-search { flex: 1; max-width: 550px; margin: 0 auto; position: relative; }
.global-search > i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--ink-light); pointer-events: none; }
.global-search input { width: 100%; height: 44px; border: 1px solid var(--border); border-radius: 13px; padding: 0 74px 0 43px; background: rgba(255,255,255,.85); color: var(--ink); box-shadow: var(--shadow-sm); }
.global-search input:focus { outline: none; border-color: rgba(22,113,93,.45); box-shadow: 0 0 0 4px rgba(22,113,93,.08); }
.search-shortcut { position: absolute; right: 10px; top: 9px; border: 1px solid var(--border); background: var(--surface-soft); color: var(--ink-light); border-radius: 7px; padding: 3px 7px; font-size: .66rem; }
.search-results { display: none; position: absolute; top: calc(100% + 9px); left: 0; right: 0; max-height: 380px; overflow-y: auto; padding: 7px; background: var(--surface); border: 1px solid var(--border); border-radius: 15px; box-shadow: var(--shadow-lg); }
.search-results.show { display: block; }
.search-result { display: flex; align-items: center; gap: 11px; padding: 11px; border-radius: 10px; color: var(--ink); }
.search-result:hover, .search-result.active { background: var(--surface-soft); color: var(--emerald); }
.search-result-icon { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; background: rgba(22,113,93,.08); color: var(--emerald); }
.search-result small { display: block; color: var(--ink-light); }
.search-empty { padding: 20px; text-align: center; color: var(--ink-light); }
.topbar-meta { display: flex; align-items: center; gap: 10px; }
.school-year { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; padding: 8px 11px; border-radius: 10px; background: var(--gold-pale); color: #76571d; font-size: .72rem; font-weight: 700; }
.topbar-avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--emerald-deep); color: #fff; font-weight: 800; text-decoration: none; }

.page-header { align-items: center; margin-bottom: 24px; padding-bottom: 0; border: 0; }
.page-header h1 { font-size: 1.65rem; letter-spacing: -.035em; font-weight: 800; margin-bottom: 5px; }
.page-header .breadcrumb { font-size: .78rem; }
.header-actions { align-items: center; gap: 10px; }
.header-actions > .text-muted { font-size: .76rem; }
.card, .stat-card { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.card { padding: 23px; border-radius: var(--radius-lg); }
.card:hover { transform: none; box-shadow: var(--shadow-sm); }
.card-header { margin-bottom: 18px; padding-bottom: 14px; border-bottom-color: var(--border); }
.card-title { font-size: .94rem; font-weight: 800; letter-spacing: -.015em; }
.card-title i { margin-right: 7px; }
.stat-card { padding: 20px; border-radius: 16px; }
.stat-card::before { width: 120px; height: 120px; top: -35px; right: -35px; background: radial-gradient(circle, rgba(197,148,53,.09), transparent 68%); }
.stat-card.emerald { background: linear-gradient(140deg, #176b59, #103f35); border: 0; }
.stat-card.gold, .stat-card.burgundy, .stat-card.turquoise { border-left: 1px solid var(--border); }
.stat-card.gold { border-top: 3px solid #d3a64e; }
.stat-card.burgundy { border-top: 3px solid #a06477; }
.stat-card.turquoise { border-top: 3px solid #4b9b9d; }
.stat-card.emerald .stat-icon { background: rgba(255,255,255,.13); color: #fff; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; font-size: 1.05rem; margin-bottom: 15px; }
.stat-value { font-family: var(--font-body); font-size: 1.85rem; letter-spacing: -.05em; font-weight: 800; }
.stat-label { font-size: .73rem; font-weight: 500; }
.grid { gap: 18px; }
.quran-progress { border-radius: 19px; background: linear-gradient(135deg, #123c35, #1a6452); box-shadow: var(--shadow-md); }
.quran-progress .arabic-verse { color: #edcb7b; }

.btn { min-height: 42px; padding: 10px 17px; border-radius: 11px; font-size: .78rem; font-weight: 700; box-shadow: none; }
.btn-primary { background: var(--emerald); box-shadow: 0 5px 12px rgba(22,113,93,.16); }
.btn-primary:hover { background: #105d4c; transform: translateY(-1px); box-shadow: 0 8px 18px rgba(22,113,93,.2); }
.btn-gold { background: #c59435; color: #fff; box-shadow: none; }
.btn-outline { border: 1px solid #cbd8d0; background: var(--surface); color: var(--emerald); }
.btn-outline:hover { background: #edf5f0; border-color: var(--emerald); color: var(--emerald); }
.btn-danger { background: #bd4e52; }
.btn-sm { min-height: 34px; padding: 7px 11px; }
.form-control { border: 1px solid #d6dfd9; border-radius: 11px; padding: 11px 13px; background: var(--surface); font-size: .85rem; }
.form-control:focus { border-color: var(--emerald); box-shadow: 0 0 0 4px rgba(22,113,93,.07); }
.form-label { font-size: .76rem; font-weight: 700; color: var(--ink); }
.table-container { border: 1px solid var(--border); border-radius: 14px; box-shadow: none; }
.table th { padding: 12px 16px; background: #f5f8f6; color: #61726a; border-bottom: 1px solid var(--border); font-size: .66rem; letter-spacing: .055em; }
.table td { padding: 13px 16px; border-bottom: 1px solid #edf1ee; font-size: .79rem; }
.table tbody tr:hover { background: #fafcfa; }
.table th:first-child, .table th:last-child { border-radius: 0; }
.badge { padding: 5px 9px; font-size: .66rem; font-weight: 700; }
.progress { height: 7px; background: #e7ede8; }
.alert { border: 1px solid currentColor; font-size: .8rem; box-shadow: var(--shadow-sm); }

.insight-card { border: 1px solid #e5d8b8; background: linear-gradient(135deg, #fffdf7, #fff); }
.insight-list { display: grid; gap: 9px; }
.insight-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--surface-soft); border: 1px solid var(--border); }
.insight-icon { width: 37px; height: 37px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 11px; background: var(--gold-pale); color: #8c6625; }
.insight-content { flex: 1; min-width: 0; }
.insight-content strong { display: block; font-size: .79rem; }
.insight-content small { display: block; color: var(--ink-light); margin-top: 2px; }
.insight-date { white-space: nowrap; font-size: .67rem; font-weight: 700; }
.insight-date.urgent { color: var(--danger); }
.insight-date.warning { color: #9a6c13; }
.insight-date.info { color: var(--info); }
.empty-state { padding: 28px 16px; text-align: center; color: var(--ink-light); }
.empty-state i { display: block; margin-bottom: 10px; font-size: 2rem; opacity: .35; }

.app-footer { margin-left: var(--sidebar-width); background: transparent; color: var(--ink-light); border-top: 0; }
.footer-content { padding: 0 30px 24px; }
.footer-top { padding-top: 18px; border-top: 1px solid var(--border); border-bottom: 0; margin-bottom: 9px; }
.footer-title-ar { color: var(--emerald-deep); }
.footer-title-fr, .footer-location, .footer-copy { color: var(--ink-light); }
.footer-links a { color: var(--ink-light); }
.footer-bottom { font-size: .72rem; }

.login-page { background: radial-gradient(circle at 15% 20%, rgba(230,190,101,.12), transparent 32%), linear-gradient(145deg, #0c3029, #123f35 55%, #0a2924); padding: 25px; }
.login-container { max-width: 450px; }
.login-language { display: flex; justify-content: center; gap: 8px; margin-bottom: 18px; }
.login-language a { padding: 7px 12px; border-radius: 9px; color: rgba(255,255,255,.65); font-size: .76rem; }
.login-language a.active { background: rgba(255,255,255,.1); color: #edcb7b; }
.login-card { border: 1px solid rgba(255,255,255,.45); border-radius: 23px; box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.login-header h1 { font-size: 1.35rem; }
.login-form .form-control { height: 48px; }
.password-toggle { position: absolute; right: 8px; top: 5px; width: 38px; height: 38px; display: grid; place-items: center; border: 0; background: transparent; color: var(--ink-light); cursor: pointer; }
.login-footer { color: rgba(255,255,255,.55); text-align: center; font-size: .72rem; }
.notification-container { max-width: calc(100vw - 24px); }

body.dark-mode {
    --surface: #19251f;
    --surface-soft: #1e2b25;
    --border: #314038;
    --papyrus: #111a16;
    --papyrus-dark: #314038;
    background: #111a16;
}
body.dark-mode .app-topbar { background: rgba(17,26,22,.9); border-color: var(--border); }
body.dark-mode .global-search input, body.dark-mode .search-shortcut { background: #19251f; border-color: var(--border); }
body.dark-mode .table th { background: #1e2b25; }
body.dark-mode .table td { border-color: var(--border); }
body.dark-mode .table tbody tr:hover { background: #223229; }
body.dark-mode .stat-card.emerald { background: linear-gradient(140deg, #176b59, #103f35); }
body.dark-mode .app-footer { background: transparent; }
body.dark-mode .footer-title-ar, body.dark-mode .footer-title-fr, body.dark-mode .footer-location, body.dark-mode .footer-copy { color: var(--ink-light); }
body.dark-mode .insight-card { background: #211f18; border-color: #51472e; }

@media (max-width: 1200px) {
    .school-year { display: none; }
    .main-content > .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}

@media (max-width: 1024px) {
    .main-content { width: 100%; margin-left: 0; padding: 0 22px 28px; }
    .app-topbar { margin: 0 -22px 24px; padding: 12px 22px 12px 76px; }
    .app-footer { margin-left: 0; }
    .topbar-context { display: none; }
    .mobile-menu-toggle { top: 16px; left: 18px; background: var(--emerald-deep); border-radius: 12px; }
}

@media (max-width: 640px) {
    body { font-size: 13px; }
    .main-content { flex: 0 0 100%; max-width: 100%; padding: 0 12px 22px; }
    .app-topbar { min-height: 67px; margin: 0 -12px 20px; padding: 10px 12px 10px 66px; gap: 8px; }
    .mobile-menu-toggle { width: 40px; height: 40px; top: 13px; left: 12px; }
    .global-search { flex: 1 1 0; width: 0; }
    .global-search input { height: 42px; padding-right: 39px; font-size: 12px; }
    .search-shortcut { display: none; }
    .topbar-meta { display: none; }
    .page-header { text-align: left !important; align-items: flex-start !important; gap: 12px; }
    .page-header > div, .page-header > div:first-child { text-align: left !important; align-items: flex-start !important; min-width: 0; }
    .page-header h1 { padding-top: 0; font-size: 1.35rem; text-align: left !important; text-transform: none; letter-spacing: -.03em; overflow-wrap: anywhere; }
    .page-header h1::before { display: none; }
    .header-actions { width: auto; }
    .header-actions > .text-muted { display: none; }
    .card { margin: 0; padding: 16px; border-radius: 15px; }
    .card-header { flex-direction: row; align-items: center; text-align: left; }
    .card-title { text-align: left; width: auto; }
    .child-metrics { display: grid !important; grid-template-columns: minmax(0, 1fr) !important; width: 100%; gap: 6px !important; }
    .child-metrics > div { display: block; min-width: 0; padding-bottom: 6px; border-bottom: 1px solid var(--border); text-align: left; }
    .child-metrics > div:last-child { border-bottom: 0; }
    .child-metrics .stat-value { display: inline; margin-right: 8px; font-size: 1.25rem; }
    .child-metrics small { display: inline; font-size: .68rem; }
    .grid { gap: 12px; }
    .grid-4.mb-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-card { padding: 14px; }
    .stat-icon { width: 35px; height: 35px; margin-bottom: 10px; }
    .stat-value { font-size: 1.45rem; }
    .table-container { margin: 0; border-radius: 11px; }
    .table th, .table td { padding: 10px 12px; }
    .btn { width: auto; }
    .form-group > .btn, form > .btn, .flex-between > .btn { max-width: 100%; }
    .login-page { padding: 12px; }
    .login-card { padding: 24px 19px; }
    .notification-dropdown { top: 67px; }
    .footer-content { padding: 0 14px 20px; }
    .footer-top { display: none; }
    .insight-item { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

.skip-link { position: fixed; top: -60px; left: 12px; z-index: 10000; padding: 10px 16px; border-radius: 8px; background: var(--surface); color: var(--emerald); box-shadow: var(--shadow-md); }
.skip-link:focus { top: 12px; }
body.large-text { font-size: 17px; }
body.large-text .nav-item, body.large-text .form-control, body.large-text .table td { font-size: 1rem; }
#networkStatus { white-space: nowrap; }
@media (max-width: 640px) { #networkStatus { display: none; } body.large-text { font-size: 16px; } }

@media print {
    .sidebar, .app-topbar, .mobile-menu-toggle, .app-footer, .header-actions, .btn { display: none !important; }
    .main-content { width: 100%; margin: 0; padding: 0; }
    .card, .stat-card { box-shadow: none; break-inside: avoid; }
}
