/* App shell: sidebar + top bar. State classes on <html> are set by the script in App.razor:
   sidebar-rail  = icons-only sidebar (768px and up)
   sidebar-open  = phone drawer open (under 768px) */

:root {
    --nexus-brand: #0D4A7D;
    --sidebar-width: 240px;
    --rail-width: 64px;
    --topbar-height: 4rem;
    /* Page content stops growing past this on very wide screens and is centred; the top bar stays full width */
    --content-max-width: 1400px;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background-color: var(--nexus-brand);
    color: #d7d7d7;
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: width 0.15s ease, transform 0.2s ease;
}

.sidebar-brand {
    height: var(--topbar-height);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

    .sidebar-brand .logo-full {
        height: 2.25rem;
        width: auto;
    }

    /* NAAS globe; on a white tile because its blue disappears against the sidebar */
    .sidebar-brand .logo-mini {
        display: none;
        height: 2.1rem;
        width: 2.1rem;
        padding: 2px;
        background: #fff;
        border-radius: 8px;
    }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.1rem 0.6rem 0.75rem;
}

/* Expandable groups (Operations, People, Admin) */
.sidebar-group {
    margin-top: 0.85rem;
}

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border: 0;
    background: none;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
}

    .sidebar-group-toggle:hover {
        color: #fff;
        background-color: rgba(255, 255, 255, 0.06);
    }

.sidebar-chevron {
    font-size: 0.75rem;
    transition: transform 0.15s ease;
    transform: rotate(-90deg);
}

.sidebar-group.open .sidebar-chevron {
    transform: none;
}

.sidebar-group-items {
    display: none;
    padding-top: 0.3rem;
}

.sidebar-group.open .sidebar-group-items {
    display: block;
}

/* Separates a single-item group shown as a plain link */
.sidebar-divider {
    margin-top: 0.85rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    height: 2.75rem;
    padding: 0 0.75rem;
    margin-bottom: 0.3rem;
    border: 0;
    border-radius: 6px;
    background: none;
    color: #d7d7d7;
    font-size: 0.9rem;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
}

    .sidebar-link .bi {
        font-size: 1.2rem;
        width: 1.25rem;
        flex-shrink: 0;
        text-align: center;
    }

    .sidebar-link:hover {
        background-color: rgba(255, 255, 255, 0.1);
        color: #fff;
    }

    .sidebar-link.active {
        background-color: rgba(255, 255, 255, 0.25);
        color: #fff;
    }

.sidebar-footer {
    flex-shrink: 0;
    padding: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

/* Icons-only rail */
@media (min-width: 768px) {
    html.sidebar-rail .app-sidebar {
        width: var(--rail-width);
    }

    html.sidebar-rail .sidebar-text,
    html.sidebar-rail .sidebar-brand .logo-full {
        display: none;
    }

    html.sidebar-rail .sidebar-brand {
        justify-content: center;
        padding: 0;
    }

        html.sidebar-rail .sidebar-brand .logo-mini {
            display: block;
        }

    html.sidebar-rail .sidebar-link {
        justify-content: center;
        padding: 0;
    }

    /* Groups can't expand in the rail: show every item, with a thin divider instead of the group header */
    html.sidebar-rail .sidebar-group-items {
        display: block;
    }

    html.sidebar-rail .sidebar-group-toggle {
        pointer-events: none;
        padding: 0 0.75rem 0.5rem;
    }

        html.sidebar-rail .sidebar-group-toggle::after {
            content: "";
            display: block;
            flex: 1;
            border-top: 1px solid rgba(255, 255, 255, 0.2);
        }

    html.sidebar-rail .sidebar-chevron {
        display: none;
    }

    html.sidebar-rail .sidebar-divider {
        margin: 0.85rem 0.75rem 0.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
    }
}

/* Phone: off-canvas drawer */
.app-backdrop {
    display: none;
}

@media (max-width: 767.98px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
    }

    html.sidebar-open .app-sidebar {
        transform: none;
    }

    html.sidebar-open .app-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 1035;
    }
}

/* ---------- Main column and top bar ---------- */

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

    .app-main > article {
        flex: 1;
    }

    .app-main > article,
    .app-main > .app-footer {
        width: 100%;
        max-width: var(--content-max-width);
        margin-left: auto;
        margin-right: auto;
    }

.app-topbar {
    height: var(--topbar-height);
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.75rem 0 1.25rem;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

.topbar-toggle {
    border: 0;
    background: none;
    color: #333;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.35rem 0.45rem;
    border-radius: 6px;
}

    .topbar-toggle:hover {
        background: #f1f3f5;
    }

.topbar-spacer {
    flex: 1;
}

/* Search */
.topbar-search {
    position: relative;
    flex: 0 1 30rem; /* takes up to 30rem before the spacer gets any room */
    min-width: 0;
}

    .topbar-search .bi-search {
        position: absolute;
        left: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
        color: #6c757d;
        pointer-events: none;
    }

    .topbar-search input {
        padding-left: 2.25rem;
    }

.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 70vh;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1050;
    padding: 0.25rem 0;
}

    .search-results .search-group {
        font-size: 0.7rem;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: #6c757d;
        padding: 0.5rem 0.9rem 0.25rem;
    }

    .search-results .search-item {
        display: block;
        padding: 0.4rem 0.9rem;
        color: #212529;
        text-decoration: none;
        cursor: pointer;
        font-size: 0.9rem;
    }

        .search-results .search-item.highlighted,
        .search-results .search-item:hover {
            background: #e9f2fb;
        }

        .search-results .search-item small {
            color: #6c757d;
        }

    .search-results .search-empty {
        padding: 0.6rem 0.9rem;
        color: #6c757d;
        font-size: 0.9rem;
    }

/* User menu */
.user-menu {
    position: relative;
}

.user-menu-button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border: 0;
    background: none;
    border-radius: 8px;
    padding: 0.3rem 0.6rem 0.3rem 0.3rem;
    color: #212529;
}

    .user-menu-button:hover,
    .user-menu-button[aria-expanded="true"] {
        background: #f1f3f5;
    }

.user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--nexus-brand);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
}

.user-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 15rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1050;
    overflow: hidden;
}

    .user-menu-dropdown .user-menu-header {
        padding: 0.75rem 1rem;
        background: #f8f9fa;
        border-bottom: 1px solid #e9ecef;
    }

    .user-menu-dropdown .user-menu-item {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        width: 100%;
        padding: 0.6rem 1rem;
        border: 0;
        background: none;
        color: #212529;
        text-decoration: none;
        font-size: 0.9rem;
        text-align: left;
    }

        .user-menu-dropdown .user-menu-item:hover {
            background: #f1f3f5;
        }

        .user-menu-dropdown .user-menu-item.text-danger:hover {
            background: #fdecec;
        }

/* Transparent layer that closes an open dropdown when clicking elsewhere */
.click-away {
    position: fixed;
    inset: 0;
    z-index: 1045;
}

@media (max-width: 767.98px) {
    .app-topbar {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    .topbar-new-label,
    .user-menu-name {
        display: none;
    }
}

/* ---------- Blazor error bar (moved from MainLayout.razor.css) ---------- */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

/* ---------- Printing (Reports: Print → Save as PDF) ---------- */

.print-only {
    display: none;
}

@media print {
    .app-sidebar,
    .app-topbar,
    .app-backdrop,
    .app-footer,
    .no-print {
        display: none !important;
    }

    .print-only {
        display: block;
    }

    .app-main > article {
        max-width: none;
        padding: 0 !important;
    }

    .report-table {
        font-size: 0.75rem;
    }

    .report-table a {
        color: inherit;
        text-decoration: none;
    }

    .card {
        border: 0;
    }
}

/* Report tables: one line per cell; the card scrolls sideways on narrow screens */
.report-table th,
.report-table td:not(.wrap) {
    white-space: nowrap;
}

.report-table {
    font-size: 0.85rem;
}

/* Report summary tiles */
.report-stat .card-body {
    padding: 1rem 1.1rem;
}

.report-stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6c757d;
    margin-bottom: 0.35rem;
}

.report-stat-value {
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.2;
}
