/* School Management System: custom styles on top of Bootstrap 5 */

:root {
    --sidebar-width: 250px;
    --topbar-height: 64px;
}

/* ---------- Top bar ---------- */
.app-topbar {
    min-height: var(--topbar-height);
}

/* Keep the top bar on one line: a long school name shortens with "..." instead of wrapping. */
.app-topbar > .container-fluid {
    flex-wrap: nowrap;
    gap: 0.5rem;
}

.topbar-left,
.app-topbar .navbar-brand,
.brand-name {
    min-width: 0;
}

.app-topbar .navbar-brand {
    margin-right: 0;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
    --bs-offcanvas-width: 280px;
}

.sidebar .offcanvas-body {
    padding: 0;
}

.sidebar-nav {
    width: 100%;
    padding: 0.75rem;
}

.sidebar-heading {
    margin: 1rem 0.75rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--bs-body-color);
    font-size: 0.925rem;
}

.sidebar .nav-link:hover {
    background: var(--bs-tertiary-bg);
}

.sidebar .nav-link.active {
    background: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
    font-weight: 600;
}

.sidebar .nav-link.disabled {
    color: var(--bs-secondary-color);
    opacity: 0.75;
}

.sidebar .nav-link .badge {
    background: var(--bs-secondary-bg);
    color: var(--bs-secondary-color);
    font-weight: 500;
    font-size: 0.65rem;
}

@media (min-width: 992px) {
    /* On desktop the sidebar is always visible and sticks below the top bar. */
    .offcanvas-lg.sidebar {
        width: var(--sidebar-width);
        flex-shrink: 0;
        position: sticky;
        top: var(--topbar-height);
        height: calc(100vh - var(--topbar-height));
        overflow-y: auto;
        background-color: var(--bs-body-bg) !important;
    }
}

/* ---------- Main content ---------- */
.app-main {
    min-width: 0;
    padding: 1.25rem 1rem;
}

@media (min-width: 992px) {
    .app-main {
        padding: 2rem;
    }
}

.module-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 0.75rem;
    background: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
    font-size: 1.25rem;
    flex-shrink: 0;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 1rem;
}

.min-w-0 {
    min-width: 0;
}

/* Dev Mailbox: show plain-text emails with their line breaks, and wrap long links. */
.email-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.module-ready:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08) !important;
}

/* ---------- Tables ---------- */
.order-col {
    width: 4.5rem;
}

/* Highlight the row you just moved or saved (the URL ends in #class-5),
   and keep it from scrolling under the sticky top bar. */
.table > tbody > tr {
    scroll-margin-top: calc(var(--topbar-height) + 4rem);
}

.table > tbody > tr:target > * {
    --bs-table-bg-state: var(--bs-primary-bg-subtle);
}

/* ---------- Results ---------- */
.score-grid .score-input {
    width: 5.5rem;
    margin: 0 auto;
    text-align: center;
}

.score-grid [data-row-total] {
    min-width: 4rem;
}

/* Keep Save / Submit reachable at the bottom of long score sheets. */
.sticky-actions {
    position: sticky;
    bottom: 0;
    padding: 0.75rem 0;
    background: var(--bs-tertiary-bg);
    z-index: 2;
}

.rating-select {
    width: 4.5rem;
}

.broadsheet td,
.broadsheet th {
    white-space: nowrap;
}

/* The 4 steps on the admin results page. */
.result-steps li {
    position: relative;
    padding: 0.2rem 0 0.2rem 1.9rem;
    color: var(--bs-secondary-color);
}

.result-steps li::before {
    content: "";
    position: absolute;
    left: 0.25rem;
    top: 0.45rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 2px solid var(--bs-border-color);
}

.result-steps li.current {
    color: var(--bs-body-color);
    font-weight: 600;
}

.result-steps li.current::before {
    border-color: var(--bs-primary);
}

.result-steps li.done {
    color: var(--bs-body-color);
}

.result-steps li.done::before {
    background: var(--bs-success);
    border-color: var(--bs-success);
}

.report-card {
    max-width: 60rem;
}

.report-facts dt {
    font-weight: 400;
    color: var(--bs-secondary-color);
}

.report-table th,
.report-table td {
    font-size: 0.85rem;
}

.report-stat {
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    height: 100%;
}

.report-stat span {
    display: block;
    color: var(--bs-secondary-color);
}

/* ---------- Login / error pages ---------- */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(160deg, var(--bs-primary-bg-subtle) 0%, var(--bs-tertiary-bg) 55%);
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 1rem;
    background: var(--bs-primary);
    color: #fff;
    font-size: 2rem;
    box-shadow: 0 0.5rem 1rem rgba(13, 110, 253, 0.25);
}

/* ---------- Printing (report cards, receipts) ---------- */
@media print {
    .app-topbar,
    .sidebar,
    .alert,
    .no-print {
        display: none !important;
    }

    .app-main {
        padding: 0;
    }

    body {
        background: #fff !important;
    }

    /* Report cards and broadsheets print on plain paper, edge to edge. */
    .report-card,
    .card {
        box-shadow: none !important;
        border: 0 !important;
        max-width: none;
    }

    .report-card .card-body {
        padding: 0 !important;
    }

    .report-table th,
    .report-table td {
        font-size: 9pt;
        padding: 0.2rem 0.3rem;
    }

    @page {
        size: A4;
        margin: 12mm;
    }
}
