﻿/* =========================================================
   GovPMS application shell (sidebar + topbar + content)
   Uses new class names (app-*) so it doesn't fight site.css.
   Load AFTER site.css.
   ========================================================= */
:root {
    --app-navy: #0f2547;
    --app-navy-2: #1b3a6b;
    --app-sidebar-w: 268px;
    --app-topbar-h: 64px;
    --app-bg: #f3f6fb;
    --app-line: #e6ebf3;
    --app-ink: #1c2b43;
    --app-muted: #6b7a93;
    --app-accent: #3b82f6;
}

html, body {
    height: 100%;
}

body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--app-bg);
    color: var(--app-ink);
    -webkit-font-smoothing: antialiased;
}

    body.app-auth {
        background: linear-gradient(135deg, #eaf0fb 0%, #f7f9fd 60%, #e6eefc 100%);
        min-height: 100vh;
    }

/* ---------- sidebar ---------- */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--app-sidebar-w);
    z-index: 1040;
    background: linear-gradient(180deg, var(--app-navy) 0%, #0b1c38 100%);
    color: #cbd5e8;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
    box-shadow: 4px 0 24px rgba(15, 37, 71, .18);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.1rem 1.25rem;
    height: var(--app-topbar-h);
    border-bottom: 1px solid rgba(255,255,255,.08);
    text-decoration: none;
    color: #fff;
}

.app-brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #3b82f6, #22d3ee);
    color: #fff;
    font-size: 1.15rem;
    box-shadow: 0 6px 16px rgba(59,130,246,.45);
}

.app-brand strong {
    display: block;
    font-size: 1.05rem;
    letter-spacing: .01em;
    line-height: 1.1;
}

.app-brand small {
    display: block;
    font-size: .68rem;
    color: #8fa3c4;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.app-nav {
    flex: 1;
    overflow-y: auto;
    padding: .75rem .75rem 1.25rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.18) transparent;
}

    .app-nav::-webkit-scrollbar {
        width: 6px;
    }

    .app-nav::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,.18);
        border-radius: 99px;
    }

.app-nav-label {
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #6f86ad;
    padding: 1rem .75rem .4rem;
}

.app-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .75rem;
    margin-bottom: 2px;
    color: #cbd5e8;
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    border-radius: 10px;
    position: relative;
    transition: background .15s, color .15s;
}

    .app-nav a i {
        width: 20px;
        text-align: center;
        font-size: 1.02rem;
        color: #8fa3c4;
        transition: color .15s;
    }

    .app-nav a:hover {
        background: rgba(255,255,255,.07);
        color: #fff;
    }

        .app-nav a:hover i {
            color: #fff;
        }

    .app-nav a.active {
        background: linear-gradient(90deg, rgba(59,130,246,.28), rgba(59,130,246,.08));
        color: #fff;
        font-weight: 600;
    }

        .app-nav a.active i {
            color: #7db2ff;
        }

        .app-nav a.active::before {
            content: "";
            position: absolute;
            left: -.75rem;
            top: 20%;
            bottom: 20%;
            width: 4px;
            border-radius: 0 4px 4px 0;
            background: #60a5fa;
        }

.app-sidebar-foot {
    padding: .85rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: .72rem;
    color: #6f86ad;
    display: flex;
    justify-content: space-between;
}

/* ---------- topbar ---------- */
.app-topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--app-sidebar-w);
    height: var(--app-topbar-h);
    z-index: 1030;
    background: rgba(255,255,255,.92);
    backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--app-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.5rem;
    transition: left .25s ease;
}

.app-topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.app-icon-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--app-line);
    background: #fff;
    border-radius: 11px;
    color: var(--app-ink);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: .15s;
}

    .app-icon-btn:hover {
        background: #f1f5fb;
        border-color: #cfd9ea;
    }

.app-crumb {
    min-width: 0;
    line-height: 1.15;
}

    .app-crumb small {
        display: block;
        color: var(--app-muted);
        font-size: .7rem;
        letter-spacing: .06em;
        text-transform: uppercase;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .app-crumb strong {
        display: block;
        font-size: 1.05rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.app-topbar-right {
    display: flex;
    align-items: center;
    gap: .85rem;
}

.app-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    background: #eef4ff;
    color: #1d4ed8;
    border: 1px solid #d6e4ff;
    padding: .38rem .8rem;
    border-radius: 99px;
    font-size: .8rem;
    font-weight: 600;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: none;
    border: 0;
    padding: .25rem .4rem .25rem .25rem;
    border-radius: 99px;
    cursor: pointer;
}

    .app-user:hover {
        background: #f1f5fb;
    }

.app-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--app-navy-2), var(--app-accent));
    color: #fff;
    font-weight: 700;
    font-size: .9rem;
}

.app-user-meta {
    text-align: left;
    line-height: 1.15;
}

    .app-user-meta strong {
        display: block;
        font-size: .82rem;
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-user-meta small {
        color: var(--app-muted);
        font-size: .7rem;
    }

.app-menu {
    min-width: 250px;
    border: 1px solid var(--app-line);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(15,37,71,.16);
    padding: .5rem;
}

    .app-menu .app-menu-head {
        padding: .6rem .75rem;
        border-bottom: 1px solid var(--app-line);
        margin-bottom: .4rem;
    }

        .app-menu .app-menu-head strong {
            display: block;
            font-size: .88rem;
            word-break: break-all;
        }

        .app-menu .app-menu-head small {
            color: var(--app-muted);
        }

    .app-menu .dropdown-item {
        border-radius: 9px;
        font-size: .88rem;
        padding: .55rem .75rem;
        display: flex;
        align-items: center;
        gap: .6rem;
    }

        .app-menu .dropdown-item.text-danger:hover {
            background: #fde8e8;
        }

/* ---------- main content ---------- */
.app-main {
    margin-left: var(--app-sidebar-w);
    padding: calc(var(--app-topbar-h) + 1.25rem) 1.5rem 2rem;
    min-height: 100vh;
    transition: margin-left .25s ease;
}

    .app-main .pd {
        padding: 0;
        min-height: 0;
    }
    /* dashboards sit directly on the app background */
    .app-main .container-fluid {
        padding-left: 0;
        padding-right: 0;
    }

/* ---------- desktop collapse ---------- */
html.sidebar-collapsed .app-sidebar {
    transform: translateX(-100%);
}

html.sidebar-collapsed .app-topbar {
    left: 0;
}

html.sidebar-collapsed .app-main {
    margin-left: 0;
}

/* ---------- mobile / tablet ---------- */
.app-overlay {
    display: none;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-topbar {
        left: 0;
        padding: 0 1rem;
    }

    .app-main {
        margin-left: 0;
        padding: calc(var(--app-topbar-h) + 1rem) .85rem 1.5rem;
    }

    html.sidebar-open .app-sidebar {
        transform: none;
    }

    html.sidebar-open .app-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(8, 18, 38, .5);
        z-index: 1035;
    }
    /* the collapse state is a desktop-only preference */
    html.sidebar-collapsed .app-topbar, html.sidebar-collapsed .app-main {
        left: 0;
        margin-left: 0;
    }

    .app-user-meta, .app-chip span.app-chip-text {
        display: none;
    }
}

@media print {
    .app-sidebar, .app-topbar, .app-overlay {
        display: none !important;
    }

    .app-main {
        margin: 0;
        padding: 0;
    }
}
