@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #3b1e77;
    --primary-light: #5b21b6;
    --primary-hover: #2a1258;
    --accent-gold: #c9a227;
    --accent-gold-light: #ede9fe;
    --bg-body: #f8f7fc;
    --surface-card: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-arabic: 'Amiri', 'Traditional Arabic', serif;
    --bs-success: #3b1e77;
    --bs-success-rgb: 59, 30, 119;
    --bs-success-bg-subtle: #f5f3ff;
    --bs-success-border-subtle: #ddd6fe;
    --bs-success-text-emphasis: #2e1065;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.arabic-text {
    font-family: var(--font-arabic);
    direction: rtl;
    font-size: 1.25rem;
    line-height: 1.6;
}

/* Navbar & Header Enhancement (Royal Purple & White School Theme) */
.navbar-custom {
    background: linear-gradient(135deg, #240e4f 0%, #3b1e77 55%, #4c1d95 100%);
    box-shadow: 0 4px 18px rgba(42, 18, 88, 0.24);
    border-bottom: 2px solid #a78bfa;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    backdrop-filter: blur(8px);
}

.navbar-custom .navbar-brand {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #ffffff !important;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: calc(100vw - 80px);
    margin-right: 0.5rem;
}

.school-logo-badge {
    width: 42px;
    height: 42px;
    background-color: #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    flex-shrink: 0;
}

.school-logo-badge img {
    max-width: 36px;
    max-height: 36px;
    object-fit: contain;
}

.school-logo-badge i {
    font-size: 1.4rem;
    color: #3b1e77;
}

.school-brand-text {
    min-width: 0;
    flex: 1 1 auto;
}

.school-brand-title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.2;
    color: #ffffff;
    display: block;
}

.school-brand-subtitle {
    font-family: var(--font-arabic);
    font-size: 0.88rem;
    line-height: 1.15;
    color: #ede9fe;
    direction: rtl;
    display: block;
    margin-top: 1px;
}

.navbar-custom .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    font-size: 0.93rem;
    padding: 0.5rem 0.85rem !important;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.navbar-custom .nav-link:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

.navbar-custom .nav-link.active {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.18);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 #c4b5fd;
}

/* Enhanced Navigation Dropdown Menus */
.nav-dropdown-custom {
    border: none;
    border-radius: 14px;
    padding: 0.5rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    min-width: 230px;
    animation: dropdownFadeIn 0.2s ease-out;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-dropdown-custom .dropdown-header {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    padding: 0.4rem 0.75rem 0.2rem;
}

.nav-dropdown-custom .dropdown-item {
    font-size: 0.9rem;
    font-weight: 500;
    color: #334155;
    padding: 0.55rem 0.85rem;
    border-radius: 8px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-dropdown-custom .dropdown-item:hover {
    background-color: #f5f3ff;
    color: #3b1e77;
    padding-left: 1rem;
}

.nav-dropdown-custom .dropdown-item.active {
    background-color: #3b1e77;
    color: #ffffff;
}

.nav-dropdown-custom .dropdown-item i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}

/* Active Academic Session & Term Pill */
.session-term-pill {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.35rem 0.85rem;
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.status-dot-active {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.35);
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Quick Action Button in Nav */
.btn-nav-quick {
    background: rgba(254, 243, 199, 0.18);
    border: 1px solid rgba(254, 243, 199, 0.35);
    color: #fef3c7;
    font-size: 0.84rem;
    font-weight: 600;
    padding: 0.35rem 0.85rem;
    border-radius: 50px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
}

.btn-nav-quick:hover {
    background: #fef3c7;
    color: #92400e;
    border-color: #fef3c7;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

/* Role Badges */
.role-badge-admin {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 50px;
}

.role-badge-teacher {
    background-color: #ede9fe;
    color: #3b1e77;
    border: 1px solid #c4b5fd;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 50px;
}

.role-badge-viewer {
    background-color: #f5f3ff;
    color: #4c1d95;
    border: 1px solid #ddd6fe;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 50px;
}

/* Cards & Stats */
.metric-card {
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.metric-icon-students { background-color: #f5f3ff; color: #3b1e77; }
.metric-icon-classes { background-color: #eff6ff; color: #2563eb; }
.metric-icon-exams { background-color: #fef3c7; color: #d97706; }
.metric-icon-results { background-color: #ede9fe; color: #6d28d9; }

/* Status Badges */
.badge-pass {
    background-color: #f5f3ff;
    color: #3b1e77;
    border: 1px solid #c4b5fd;
    font-weight: 600;
}

.badge-fail {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    font-weight: 600;
}

/* Custom Buttons */
.btn-primary-custom {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-primary-custom:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #ffffff;
}

/* Islamic Banner (Royal Purple & White Theme) */
.islamic-header-banner {
    background: linear-gradient(135deg, #240e4f 0%, #3b1e77 55%, #5b21b6 100%);
    color: white;
    border-radius: 14px;
    padding: 1.75rem;
    box-shadow: 0 4px 15px rgba(59, 30, 119, 0.22);
    position: relative;
    overflow: hidden;
}

/* Harmonize Bootstrap success utilities with the Royal Purple & White school identity */
.btn-success {
    background-color: #3b1e77 !important;
    border-color: #3b1e77 !important;
    color: #ffffff !important;
}
.btn-success:hover, .btn-success:focus {
    background-color: #2a1258 !important;
    border-color: #2a1258 !important;
    color: #ffffff !important;
}
.btn-outline-success {
    color: #3b1e77 !important;
    border-color: #3b1e77 !important;
}
.btn-outline-success:hover, .btn-outline-success:focus {
    background-color: #3b1e77 !important;
    border-color: #3b1e77 !important;
    color: #ffffff !important;
}
.text-success {
    color: #3b1e77 !important;
}
.bg-success {
    background-color: #3b1e77 !important;
}
.border-success {
    border-color: #3b1e77 !important;
}
.bg-success-subtle {
    background-color: #f5f3ff !important;
}
.border-success-subtle {
    border-color: #ddd6fe !important;
}

.islamic-header-banner::before {
    content: "﷽";
    position: absolute;
    right: 20px;
    top: -15px;
    font-size: 6rem;
    font-family: var(--font-arabic);
    opacity: 0.1;
    pointer-events: none;
}

/* Tables */
.table-custom {
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.table-custom thead th {
    background-color: #f1f5f9;
    color: #334155;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid var(--border-color);
    padding: 0.85rem 1rem;
}

.table-custom tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table-custom tbody tr:last-child td {
    border-bottom: none;
}

.table-custom tbody tr:hover {
    background-color: #f8fafc;
}

/* Mobile Responsive Header Styles */
@media (max-width: 767.98px) {
    .navbar-custom {
        padding-top: 0.45rem;
        padding-bottom: 0.45rem;
    }

    .navbar-custom .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .navbar-custom .navbar-brand {
        gap: 0.5rem;
        max-width: calc(100vw - 72px);
    }

    .school-logo-badge {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    .school-logo-badge img {
        max-width: 30px;
        max-height: 30px;
    }

    .school-logo-badge i {
        font-size: 1.2rem;
    }

    .school-brand-title {
        font-size: 0.88rem;
        letter-spacing: -0.01em;
        line-height: 1.15;
    }

    .school-brand-subtitle {
        font-size: 0.76rem;
        line-height: 1.1;
        margin-top: 2px;
    }
}

@media (max-width: 420px) {
    .navbar-custom .navbar-brand {
        max-width: calc(100vw - 65px);
        gap: 0.4rem;
    }

    .school-logo-badge {
        width: 32px;
        height: 32px;
        border-radius: 7px;
    }

    .school-logo-badge img {
        max-width: 26px;
        max-height: 26px;
    }

    .school-logo-badge i {
        font-size: 1.05rem;
    }

    .school-brand-title {
        font-size: 0.80rem;
    }

    .school-brand-subtitle {
        font-size: 0.70rem;
    }
}

/* ==========================================================================
   Class Result Sheet
   These classes are referenced by templates/class_result_sheet.html. The page
   previously used `table-success-subtle` / `table-danger-subtle`,
   `cursor-pointer`, `border-start-md` and `hover-primary`, none of which exist
   in Bootstrap 5.3 or in this file, so they rendered nothing at all.
   ========================================================================== */

.cursor-pointer {
    cursor: pointer;
}

/* Bootstrap paints table cell backgrounds through `> *` on the row, so the
   child selector is needed to win against .table-hover / striping. */
tr.row-pass > * {
    background-color: #f0fdf4;
}

tr.row-fail > * {
    background-color: #fef2f2;
}

.hover-primary:hover {
    color: #065f46 !important;
    text-decoration: underline !important;
}

@media (min-width: 768px) {
    .border-start-md {
        border-left: 1px solid #dee2e6;
    }
}

/* One container scrolling both ways, so the sticky header has something to
   stick to. A plain .table-responsive only scrolls horizontally, which leaves
   `position: sticky; top: 0` with no vertical scroll context. */
.result-sheet-scroll {
    max-height: 72vh;
    overflow: auto;
}

.result-sheet-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background-color: #f8f9fa;
}

.result-sheet-scroll tbody td.sticky-name,
.result-sheet-scroll tfoot td.sticky-name {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: inherit;
}

/* Rows without a pass/fail tint still need an opaque backdrop while the table
   scrolls sideways underneath the frozen name column. */
.result-sheet-scroll tbody tr:not(.row-pass):not(.row-fail) td.sticky-name,
.result-sheet-scroll tfoot td.sticky-name {
    background-color: #ffffff;
}

.result-sheet-scroll tbody tr.row-pass td.sticky-name {
    background-color: #f0fdf4;
}

.result-sheet-scroll tbody tr.row-fail td.sticky-name {
    background-color: #fef2f2;
}

.result-sheet-scroll thead th.sticky-name {
    position: sticky;
    left: 0;
    z-index: 4;
    background-color: #f8f9fa;
}

/* Report Card Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    body {
        background-color: #ffffff !important;
    }

    /* The result sheet is (subjects + 8) columns wide: print it landscape, and
       undo the scroll container or only the first screenful reaches the page. */
    .result-sheet-scroll {
        max-height: none !important;
        overflow: visible !important;
    }
    #resultsTable {
        font-size: 9pt;
    }
    #resultsTable thead th,
    #resultsTable .sticky-name {
        position: static !important;
    }
    .modal,
    .dropdown,
    #tableFilter {
        display: none !important;
    }
    .report-card-container {
        border: 2px solid #333 !important;
        padding: 20px !important;
        margin: 0 !important;
        box-shadow: none !important;
    }
}
