:root {
    --sw-blue: #0d6efd;
    --sw-blue-dark: #0b5dd7;
    --sw-green: #24cc63;
    --sw-green-dark: #1ead54;
    --sw-bg: #f5f7fb;
    --sw-border: #e5e7eb;
}

body {
    background-color: var(--sw-bg);
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.text-primary-brand { color: var(--sw-blue); }
.text-secondary-brand { color: var(--sw-green); }

/* ---------- Brand color overrides (Scholaro) ---------- */
.btn-primary {
    background-color: var(--sw-blue);
    border-color: var(--sw-blue);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--sw-blue-dark) !important;
    border-color: var(--sw-blue-dark) !important;
}
.btn-outline-primary {
    color: var(--sw-blue);
    border-color: var(--sw-blue);
}
.btn-outline-primary:hover {
    background-color: var(--sw-blue);
    border-color: var(--sw-blue);
}
.btn-success {
    background-color: var(--sw-green);
    border-color: var(--sw-green);
}
.btn-success:hover, .btn-success:focus, .btn-success:active {
    background-color: var(--sw-green-dark) !important;
    border-color: var(--sw-green-dark) !important;
}
a { color: var(--sw-blue); }
a:hover { color: var(--sw-blue-dark); }
.form-check-input:checked {
    background-color: var(--sw-blue);
    border-color: var(--sw-blue);
}
.nav-link.active, .nav-tabs .nav-link.active { color: var(--sw-blue) !important; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid var(--sw-border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    transition: width 0.2s ease;
    overflow-x: hidden;
    /* Keep the sidebar pinned to the viewport on desktop, independent of page scroll. */
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    align-self: flex-start;
    /* Still scrollable if the nav list overflows, just without a visible scrollbar. */
    scrollbar-width: none;      /* Firefox */
    -ms-overflow-style: none;   /* Edge/IE */
}
.sidebar::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 0 0.5rem 1.5rem 0.5rem;
    position: relative;
}

.brand-logo-img {
    max-height: 40px;
    width: auto;
    max-width: 100%;
}

.brand-logo-mark {
    height: 32px;
    width: 32px;
    object-fit: contain;
    display: none;
}

.sidebar-collapse-btn {
    margin-left: auto;
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
.sidebar-collapse-btn:hover { background: #e5e7eb; color: var(--sw-blue); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; }

.sidebar-nav .nav-link,
.logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    color: #374151;
    font-weight: 500;
    text-decoration: none;
    width: 100%;
    border: none;
    background: none;
    text-align: left;
    white-space: nowrap;
}

.sidebar-nav .nav-link:hover { background: #f3f4f6; }
.sidebar-nav .nav-link.active { background: #eff6ff; color: var(--sw-blue); }

.sidebar-logout { margin-top: 0.5rem; border-top: 1px solid var(--sw-border); padding-top: 0.5rem; }
.logout-btn { color: #b91c1c; }
.logout-btn:hover { background: #fef2f2; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1030;
}
.sidebar-backdrop.show { display: block; }

/* ---------- Desktop: collapse sidebar to icons-only ---------- */
.app-shell.sidebar-collapsed .sidebar {
    width: 76px;
}
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .brand-logo-full {
    display: none;
}
.app-shell.sidebar-collapsed .brand-logo-mark {
    display: block;
}
.app-shell.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}
.app-shell.sidebar-collapsed .sidebar-collapse-btn {
    position: absolute;
    right: -10px;
    top: 6px;
    background: #fff;
    border: 1px solid var(--sw-border);
    transform: rotate(180deg);
}
.app-shell.sidebar-collapsed .sidebar-nav .nav-link,
.app-shell.sidebar-collapsed .logout-btn {
    justify-content: center;
    padding: 0.6rem;
}

/* ---------- Mobile: slide-in drawer ---------- */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 2px 0 12px rgba(0,0,0,0.1);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    /* The desktop collapse state shouldn't apply on mobile — drawer is always full width when open. */
    .app-shell.sidebar-collapsed .sidebar {
        width: 250px;
    }
    .app-shell.sidebar-collapsed .nav-label,
    .app-shell.sidebar-collapsed .brand-logo-full {
        display: flex;
    }
    .app-shell.sidebar-collapsed .brand-logo-mark {
        display: none;
    }
    .sidebar-collapse-btn { display: none; }
}

/* ---------- Topbar ---------- */
.main-col { flex-grow: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--sw-border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #4b5563;
    position: relative;
    padding: 8px;
    line-height: 1;
    border-radius: 8px;
}
.icon-btn:hover { background: #f3f4f6; }

.notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sw-green);
    border: 1.5px solid #fff;
}

.dropdown-item:active, .dropdown-item.active {
    background-color: var(--sw-blue);
}

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--sw-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.avatar-circle-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.page-content { padding: 1.75rem; }

@media (max-width: 576px) {
    .page-content { padding: 1rem; }
    .panel { padding: 1rem; }
    .topbar { padding: 0.6rem 1rem; }
    h2.fw-bold { font-size: 1.35rem; }
}

/* ---------- Dashboard stat cards ---------- */
.col-lg-2-4 { flex: 0 0 auto; width: 20%; }
@media (max-width: 992px) { .col-lg-2-4 { width: 50%; } }

.stat-card {
    background: #fff;
    border: 1px solid var(--sw-border);
    border-radius: 12px;
    padding: 1.25rem;
    height: 100%;
}

.stat-label { color: #6b7280; font-size: 0.9rem; margin-bottom: 0.4rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-sub { font-size: 0.9rem; color: #6b7280; font-weight: 400; }

/* ---------- Exam summary stat cards (Enter Marks) ---------- */
.stat-card-v2 {
    background: #fff;
    border: 1px solid var(--sw-border);
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
    height: 100%;
}
.stat-icon-circle {
    width: 34px; height: 34px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-card-title { font-size: 0.85rem; color: #6b7280; font-weight: 600; }
.stat-card-value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.stat-card-sub { font-size: 0.78rem; color: #9ca3af; }
.gender-icon { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.9rem; }
.gender-icon.filled-female { background: #fce7f3; color: #db2777; }
.gender-icon.filled-male { background: #dbeafe; color: #2563eb; }
.gender-icon.empty { background: #f1f3f5; color: #ced4da; }

.quick-action-btn { display: inline-flex; align-items: center; gap: 8px; }

.panel {
    background: #fff;
    border: 1px solid var(--sw-border);
    border-radius: 12px;
    padding: 1.5rem;
}

/* Long forms in modals (e.g. Enroll Student) need an unmistakable scrollbar,
   not just Bootstrap's default (which some OS/browser combos render as an
   invisible-until-hover overlay, so the cut-off content looks like a dead
   end instead of a scrollable area). Two things fix that:
   1) A real, always-visible scrollbar track (webkit + Firefox).
   2) A "scroll shadow" at the top/bottom edges — a soft shadow that only
      shows when there's more content in that direction, so the form makes
      it obvious there's more below even before you touch the scrollbar. */
.modal-dialog-scrollable .modal-body {
    max-height: 60vh;
    overflow-y: scroll;
    scrollbar-width: auto; /* Firefox: show the standard scrollbar, not "thin" */
    scrollbar-color: var(--sw-blue) #e5e7eb; /* Firefox: thumb / track colors */
    background-image:
        linear-gradient(#fff 30%, rgba(255, 255, 255, 0)),
        linear-gradient(rgba(255, 255, 255, 0), #fff 70%),
        radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, .18), rgba(0, 0, 0, 0)),
        radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, .18), rgba(0, 0, 0, 0));
    background-repeat: no-repeat;
    background-color: #fff;
    background-size: 100% 32px, 100% 32px, 100% 10px, 100% 10px;
    background-position: top, bottom, top, bottom;
    background-attachment: local, local, scroll, scroll;
}
.modal-dialog-scrollable .modal-body::-webkit-scrollbar {
    width: 12px;
}
.modal-dialog-scrollable .modal-body::-webkit-scrollbar-track {
    background: #e5e7eb;
    border-radius: 8px;
}
.modal-dialog-scrollable .modal-body::-webkit-scrollbar-thumb {
    background-color: var(--sw-blue);
    border-radius: 8px;
    border: 2px solid #e5e7eb;
}

.announcement-item {
    background: #fef2f2;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.9rem;
}
.announcement-item:last-child { margin-bottom: 0; }

.badge-audience {
    background: #dbeafe;
    color: var(--sw-blue);
    font-weight: 500;
    font-size: 0.72rem;
}

.event-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.event-item:last-child { margin-bottom: 0; }

.event-date {
    background: #eff6ff;
    border-radius: 8px;
    text-align: center;
    min-width: 52px;
    padding: 4px 6px;
}
.event-month { font-size: 0.65rem; font-weight: 700; color: var(--sw-blue); }
.event-day { font-size: 1.1rem; font-weight: 700; color: var(--sw-blue); }

/* ---------- Auth page ---------- */
.auth-body {
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-card { width: 100%; max-width: 420px; padding: 2rem 1rem; }
.auth-title { font-weight: 800; text-align: center; margin-bottom: 0.25rem; }
.auth-subtitle { text-align: center; color: #6b7280; margin-bottom: 1.75rem; }

.google-btn { padding: 0.6rem; border-radius: 8px; }

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #9ca3af;
    margin: 1.25rem 0;
}
.divider::before, .divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid var(--sw-border);
}
.divider span { padding: 0 0.75rem; font-size: 0.85rem; }

.sign-in-btn { padding: 0.6rem; border-radius: 8px; font-weight: 600; }
