:root {
    --sidebar-width: 240px;
    --primary: #0d6efd;
    --sidebar-bg: #0f1b33;
    --sidebar-text: #aeb8cc;
}

* { box-sizing: border-box; }

body {
    background: #f4f6fb;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: margin-left .25s ease;
    z-index: 1030;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.1rem 1.25rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-brand i { color: #6ea8fe; font-size: 1.4rem; }

.sidebar-nav {
    display: flex;
    padding: .75rem .6rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    scrollbar-width: thin;
}

.sidebar-nav .nav-link {
    color: var(--sidebar-text);
    border-radius: .5rem;
    padding: .55rem .8rem;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .92rem;
}

.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }

.sidebar-nav .nav-link.active {
    background: var(--primary);
    color: #fff;
}

.sidebar-nav .dashboard-search-nav-match {
    background: rgba(13, 110, 253, .35);
    color: #fff;
}

.sidebar-nav .sub-nav-link.dashboard-search-nav-match {
    border-left-color: #fff;
}

.sidebar-nav .badge { margin-left: auto; }

/* ---------- Grouped sidebar sections ---------- */
.sidebar-section { margin-bottom: 2px; }

.sidebar-section .section-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    font-weight: 600;
    font-size: .92rem;
    color: #7f8aa0;
    border-radius: .5rem;
    padding: .55rem .8rem;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.sidebar-section .section-toggle:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-section .section-toggle.open { color: #fff; }

/* Keep expanded dropdowns in a single column */
.sidebar-section .collapse.show {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
}

.section-right { display: inline-flex; align-items: center; gap: .5rem; }

.section-caret { font-size: .7rem; transition: transform .2s ease; }
.section-toggle[aria-expanded="true"] .section-caret { transform: rotate(180deg); }

.sub-nav-link {
    padding-left: 2.1rem;
    font-size: .92rem;
    border-left: 2px solid transparent;
    margin: 0 0 2px .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sub-nav-link.active {
    background: rgba(13, 110, 253, .22);
    border-left-color: var(--primary);
    color: #fff;
}

/* ---------- Main ---------- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: #fff;
    padding: .6rem 1.25rem;
    border-bottom: 1px solid #e5e9f2;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.content {
    padding: 1.5rem 1.25rem;
    flex: 1;
}

.footer { background: #fff; border-top: 1px solid #e5e9f2; }

/* ---------- Cards & misc ---------- */
.card { border: none; border-radius: .75rem; box-shadow: 0 1px 3px rgba(16, 24, 40, .08); }
.card-header { background: #fff; border-bottom: 1px solid #eef1f7; font-weight: 600; }

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

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

.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #667085; }
.table td { vertical-align: middle; }

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.dashboard-search {
    width: 280px;
    max-width: 100%;
    margin-left: auto;
}

.dashboard-search .form-control {
    min-width: 0;
}

.dashboard-search .input-group-text {
    background: #fff;
    color: #667085;
}

.dashboard-search-empty {
    margin-top: 0;
}

.dashboard-search-hidden {
    display: none !important;
}

/* ---------- Login page ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f1b33 0%, #1b3a6b 100%);
    padding: 1rem;
}

.auth-card { width: 100%; max-width: 420px; border-radius: 1rem; }
.auth-card .card-body { padding: 2rem 2.25rem; }

/* ---------- Mobile sidebar backdrop ---------- */
.sidebar-backdrop {
    display: none;
}

@media (max-width: 991.98px) {
    html, body { overflow-x: hidden; }
    .sidebar { margin-left: calc(var(--sidebar-width) * -1); }
    .sidebar.open { margin-left: 0; box-shadow: 4px 0 24px rgba(0, 0, 0, .28); }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 27, 51, .55);
        z-index: 1025;
        opacity: 0;
        visibility: hidden;
        transition: opacity .2s ease, visibility .2s ease;
    }
    .sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
    }
}

/* ---------- Ethiopian calendar ---------- */
.eth-date-caption { font-size: .78rem; color: #667085; }

.eth-picker-wrap { position: relative; }
.eth-picker-pop {
    position: absolute;
    z-index: 1060;
    background: #fff;
    border: 1px solid #e5e9f2;
    border-radius: .5rem;
    box-shadow: 0 8px 24px rgba(16, 24, 40, .14);
    padding: .6rem;
    width: 264px;
}
.eth-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .4rem;
}
.eth-picker-head span { font-weight: 600; font-size: .9rem; }
.eth-picker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}
.eth-dow { font-size: .7rem; color: #667085; font-weight: 600; padding: 4px 0; }
.eth-day { padding: 6px 0; border-radius: 6px; cursor: pointer; font-size: .85rem; }
.eth-day:hover { background: #eef3ff; }
.eth-day.today { background: #dbeafe; color: #1d4ed8; font-weight: 600; }
.eth-day.selected { background: #0d6efd; color: #fff; }

/* ---------- Branding ---------- */
.sidebar-logo {
    height: 34px;
    max-width: 150px;
    object-fit: contain;
}

/* Guest banner (public visitors) */
.guest-notice {
    background: linear-gradient(135deg, #0f1b33 0%, #1b3a6b 100%);
    color: #fff;
    border-radius: .75rem;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 10px rgba(16, 24, 40, .15);
}
.guest-notice-title {
    color: #ffd166;
    font-weight: 700;
}
.guest-notice-message {
    color: #e8eefc;
    line-height: 1.6;
}

.settings-logo-preview {
    max-height: 80px;
    max-width: 200px;
    object-fit: contain;
    border: 1px solid #e5e9f2;
    border-radius: .5rem;
    padding: .35rem;
    background: #fff;
}

/* ---------- Vision & Mission ---------- */
.vm-card { border-left: 4px solid var(--primary); }

.vm-label {
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--primary);
    margin-bottom: .4rem;
}

.vm-text { font-size: .92rem; color: #344054; line-height: 1.55; }

.vm-list { padding-left: 1.15rem; }
.vm-list li { font-size: .9rem; color: #344054; margin-bottom: .25rem; line-height: 1.5; }

/* ---------- Split login / auth pages ---------- */
.auth-split { flex-direction: row; align-items: stretch; padding: 0; }

.auth-info {
    flex: 1.15;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2.5rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .03));
    border-right: 1px solid rgba(255, 255, 255, .12);
    color: #fff;
}

.auth-info-inner { width: 100%; max-width: 560px; }

.auth-brand { text-align: center; }

.auth-logo { max-height: 96px; max-width: 220px; object-fit: contain; }

.auth-logo-icon { font-size: 3.4rem; color: #6ea8fe; }

.auth-brand h3 { font-weight: 700; }

.auth-sub { color: #aeb8cc; font-size: .95rem; }

.vm-block { background: rgba(255, 255, 255, .06); border-radius: .75rem; padding: 1rem 1.15rem; }

.auth-info .vm-label { color: #6ea8fe; }
.auth-info .vm-text { color: #dfe6f2; }
.auth-info .vm-list li { color: #dfe6f2; }

.auth-form {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
}

.auth-logo-small { max-height: 48px; max-width: 160px; object-fit: contain; }

.cell-box {
    border-radius: .3rem;
    padding: .2rem .35rem;
    font-size: .72rem;
    line-height: 1.15;
    min-height: 36px;
    overflow: hidden;
}

/* Smart room grid --------------------------------------------------------- */
.grid-table .cell-box { cursor: default; min-height: 46px; }

.cell-course { font-weight: 700; line-height: 1.2; }
.cell-sub { font-size: .66rem; opacity: .85; line-height: 1.15; }

.cell-reg { background: #d1e7dd; color: #0f5132; border: 1px solid #9fd6b8; }
.cell-ext { background: #cfe2ff; color: #084298; border: 1px solid #9ec5fe; }

.cell-free { text-align: center; font-weight: 600; min-height: 46px; }
.cell-free-reg { background: #eaf7ef; color: #1a7f4e; border: 1px dashed #9fd6b8; }
.cell-free-ext { background: #e9f2ff; color: #1d5fb0; border: 1px dashed #9ec5fe; }

.cell-na { background: #e9ecef; color: #adb5bd; min-height: 46px; }

.cell-clash { background: #f8d7da; color: #842029; border: 1px solid #f1aeb5; }
.cell-clash-note { font-size: .64rem; font-weight: 700; color: #dc3545; margin-top: .1rem; }

.cell-draggable { cursor: grab; }
.cell-draggable:hover { box-shadow: 0 0 0 2px rgba(13, 110, 253, .35); }
.cell-draggable:active { cursor: grabbing; }
.cell-droptarget { outline: 2px solid #0d6efd; outline-offset: 1px; background: #fff3cd !important; }
.opacity-50 { opacity: .5; }


@media (max-width: 991.98px) {
    .auth-split { flex-direction: column; }
    .auth-info { display: none; }
    .auth-form { padding: 2rem 1rem; }
}

/* ---------- Public materials repository ---------- */
.public-body { background: #f4f6fb; }

.public-header {
    background: linear-gradient(135deg, #0f1b33 0%, #1b3a6b 100%);
    padding: .9rem 1.25rem;
}

.public-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.public-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    text-decoration: none;
    color: #fff;
}

.public-brand:hover { color: #fff; }

.public-brand small { color: #aeb8cc; }

.public-logo { max-height: 44px; max-width: 160px; object-fit: contain; }

.repo-hero {
    background: linear-gradient(135deg, #1b3a6b 0%, #274b8f 100%);
    color: #fff;
    padding: 2.5rem 1.25rem;
    text-align: center;
}

.repo-hero h1 { font-weight: 700; }

.repo-hero p { color: #d5def0; max-width: 720px; margin-left: auto; margin-right: auto; }

.repo-body {
    max-width: 1200px;
    margin: 2rem auto 3rem;
    padding: 0 1.25rem;
}

.repo-card { transition: transform .15s ease, box-shadow .15s ease; }

.repo-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16, 24, 40, .12); }

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

/* ---------- Signature pad ---------- */
.sig-pad { position: relative; }
.sig-pad canvas {
    border: 1px dashed #b0b7c3;
    border-radius: 6px;
    background: #fff;
    width: 100%;
    height: 130px;
    cursor: crosshair;
    touch-action: none;
}
.sig-pad .sig-draw { position: relative; }
.sig-pad .sig-clear {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    font-size: .72rem;
    padding: .15rem .5rem;
}
.sig-pad .sig-typed input[type="text"] {
    font-family: "Segoe Script", "Brush Script MT", cursive;
    font-size: 1.6rem;
    height: 130px;
    border: 1px dashed #b0b7c3;
    border-radius: 6px;
    background: #fff;
    padding: .5rem .75rem;
    text-align: center;
}
.sig-pad .sig-toggle { font-size: .78rem; }
.sig-preview img { max-height: 90px; border: 1px solid #e2e6ec; border-radius: 6px; background: #fff; padding: 4px; }
.sig-preview.typed-sig {
    font-family: "Segoe Script", "Brush Script MT", cursive;
    font-size: 1.7rem;
    color: #0f1b33;
}

/* =========================================================
 * Responsive & mobile-friendly refinements
 * ========================================================= */
html, body {
    overflow-x: hidden;
}

.main-content,
.content {
    min-width: 0;
}

.table-responsive {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

/* Keep wide dropdown menus inside the viewport on small screens. */
@media (max-width: 575.98px) {
    .notif-menu,
    .dropdown-menu {
        width: min(340px, calc(100vw - 1.5rem)) !important;
        max-width: calc(100vw - 1.5rem);
    }

    .content {
        padding: 1rem .85rem;
    }

    .topbar {
        padding: .55rem .85rem;
        gap: .5rem;
    }

    .topbar h6 { font-size: .95rem; }

    .auth-card .card-body { padding: 1.5rem 1.25rem; }
    .auth-page { padding: .75rem; }
    .auth-form { padding: 1.5rem .75rem; }

    .page-heading h4 { font-size: 1.25rem; }
    .page-heading { gap: .6rem; }

    .dashboard-search {
        width: 100%;
        margin-left: 0;
    }

    /* Stack heading action buttons so they never overflow. */
    .page-heading .btn { white-space: normal; }
    .page-heading .d-flex.gap-2 { flex-wrap: wrap; }

    .stat-card .icon {
        width: 40px;
        height: 40px;
        font-size: 1.15rem;
        border-radius: .6rem;
    }

    .avatar {
        width: 32px;
        height: 32px;
    }

    .sidebar {
        width: min(var(--sidebar-width), 88vw);
        margin-left: calc(min(var(--sidebar-width), 88vw) * -1);
    }
    .sidebar.open { margin-left: 0; }

    /* Room / schedule grid cells become roomier on phones. */
    .cell-box,
    .cell-free,
    .cell-na {
        min-height: 34px;
    }

    .eth-picker-pop {
        width: min(264px, calc(100vw - 1.5rem));
    }

    .card-body { padding: 1rem; }
}

/* Ensure tables scroll within their card on small screens. */
@media (max-width: 767.98px) {
    .card .table-responsive {
        margin: 0 -1px;
    }
}

/* Neutralize responsive wrappers when printing. */
@media print {
    .table-responsive {
        display: table;
        overflow: visible !important;
        width: 100%;
    }
    .sidebar,
    .sidebar-backdrop,
    .topbar .dropdown,
    .footer {
        display: none !important;
    }
    .content { padding: 0 !important; }
}

/* ---------- Public landing pages (index / about) ---------- */
.site-navbar {
    background: #fff;
    border-bottom: 1px solid #e5e9f2;
    padding: .7rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.site-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
    font-weight: 700;
    color: #0f1b33;
}

.site-brand img {
    height: 40px;
    max-width: 170px;
    object-fit: contain;
}

.site-brand-icon {
    font-size: 1.6rem;
    color: #6ea8fe;
}

.site-brand-text { white-space: nowrap; }

.site-nav-links {
    display: flex;
    align-items: center;
    gap: .15rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.site-nav-links .nav-item {
    padding: .45rem .85rem;
    color: #344054;
    font-weight: 500;
    text-decoration: none;
    border-radius: .5rem;
    font-size: .95rem;
}

.site-nav-links .nav-item:hover { background: #eef3ff; color: #0d6efd; }
.site-nav-links .nav-item.active { color: #0d6efd; background: #eef3ff; }

.landing-main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 2.75rem 1.5rem 3rem;
}

.landing-hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.landing-hero h1 { font-weight: 700; color: #0f1b33; }
.landing-hero .lead { color: #667085; max-width: 680px; margin: .75rem auto 0; }

.dash-card { height: 100%; transition: transform .15s ease, box-shadow .15s ease; }
.dash-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(16, 24, 40, .12); }

.dash-icon {
    width: 52px;
    height: 52px;
    border-radius: .85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.landing-footer {
    background: #fff;
    border-top: 1px solid #e5e9f2;
    padding: 1.25rem 1.5rem;
    text-align: center;
    color: #667085;
}

@media (max-width: 575.98px) {
    .site-navbar { padding: .6rem 1rem; }
    .site-brand-text { display: none; }
    .landing-main { padding: 2rem 1rem 2.5rem; }
}

/* Mobile-friendly file picker (created by assets/js/main.js) */
.file-pick-wrap {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    overflow: visible;
    max-width: 100%;
}
.file-pick-btn {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    min-height: 2.75rem;
    min-width: 11rem;
    justify-content: flex-start;
    text-align: left;
}
.file-pick-btn .file-pick-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-pick-wrap .file-pick-input {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 2.5rem;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    font-size: 16px;
}
.file-pick-wrap:focus-within {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Signature shown inline, directly in front of the signer's name on printouts. */
.sig-inline {
    max-height: 34px;
    max-width: 200px;
    vertical-align: middle;
    margin: 0 6px 4px 0;
}
