/* =====================================================================
   ARARBOT app shell — sidebar navigation (5 khu vực)
   Light-first palette. Thay thế top navbar cũ.
   Token cục bộ --sh-* để không xung đột với base.css / platform.css.
   ===================================================================== */
:root {
    --sh-side-w: 250px;
    --sh-top-h: 60px;

    --sh-app-bg: var(--bg);
    --sh-side-bg: var(--surface);
    --sh-side-border: var(--border);
    --sh-top-bg: var(--surface);
    --sh-top-border: var(--border-soft);

    --sh-brand-navy: #114473;
    --sh-brand-teal: #16625d;

    --sh-eyebrow: var(--text-faint);
    --sh-link: var(--text-light);
    --sh-link-hover-bg: var(--surface-subtle);
    --sh-active-bg: #eaf1f7;
    --sh-active-text: #114473;
    --sh-active-bar: #16625d;
    --sh-icon: var(--text-faint);

    --sh-text: var(--text);
    --sh-muted: var(--text-light);
    --sh-faint: var(--text-faint);

    --sh-ok: var(--success);
    --sh-err: var(--danger);
    --sh-shadow: var(--shadow);
}

/* ---- layout ---- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sh-side-w) 1fr;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--sh-app-bg);
}

.app-shell.app-shell--noside {
    grid-template-columns: 1fr;
}

/* ---- sidebar ---- */
.app-side {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--sh-side-bg);
    border-right: 1px solid var(--sh-side-border);
    z-index: 60;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 16px 18px 14px;
    text-decoration: none;
}

.app-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    flex: none;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    background: linear-gradient(145deg, var(--sh-brand-teal), var(--sh-brand-navy));
    box-shadow: 0 2px 10px rgba(22, 98, 93, .32);
}

.app-brand-name {
    font-weight: 800;
    font-size: 15px;
    color: var(--sh-text);
    letter-spacing: -.02em;
    line-height: 1.1;
}

.app-brand-sub {
    font-size: 11px;
    color: var(--sh-faint);
}

.app-nav {
    flex: 1;
    overflow-y: auto;
    padding: 6px 12px 18px;
}

.app-nav-group {
    margin-top: 14px;
}

.app-nav-eyebrow {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--sh-eyebrow);
    padding: 0 10px 6px;
}

.app-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--sh-link);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
}

.app-nav-item:hover {
    background: var(--sh-link-hover-bg);
    color: var(--sh-text);
}

.app-nav-item.active {
    background: var(--sh-active-bg);
    color: var(--sh-active-text);
}

.app-nav-item.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--sh-active-bar);
}

.app-nav-ico {
    width: 17px;
    height: 17px;
    flex: none;
    color: var(--sh-icon);
}

.app-nav-item:hover .app-nav-ico,
.app-nav-item.active .app-nav-ico {
    color: var(--sh-active-bar);
}

.app-nav-count {
    margin-left: auto;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 10.5px;
    background: rgba(17, 68, 115, .1);
    color: var(--sh-brand-navy);
    padding: 1px 7px;
    border-radius: 20px;
}

.app-nav-count.alert {
    background: rgba(199, 80, 74, .16);
    color: var(--sh-err);
}

@media (prefers-color-scheme: dark) {
    .app-nav-count {
        background: rgba(125, 196, 189, .16);
        color: var(--sh-active-text);
    }
}

.app-subnav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin: 2px 0 2px 27px;
    padding-left: 8px;
    border-left: 1px solid var(--sh-side-border);
}

.app-subnav a {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12.7px;
    color: var(--sh-link);
    text-decoration: none;
    font-weight: 500;
}

.app-subnav a:hover {
    background: var(--sh-link-hover-bg);
    color: var(--sh-text);
}

.app-subnav a.active {
    color: var(--sh-active-text);
    font-weight: 700;
    background: var(--sh-active-bg);
}

/* ---- sidebar footer (user) ---- */
.app-side-foot {
    border-top: 1px solid var(--sh-side-border);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex: none;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 13px;
    color: #fff;
    background: linear-gradient(145deg, var(--sh-brand-teal), var(--sh-brand-navy));
}

.app-who {
    min-width: 0;
    line-height: 1.25;
}

.app-who-name {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--sh-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-who-role {
    font-size: 11px;
    color: var(--sh-faint);
}

.app-side-foot form {
    margin-left: auto;
}

.app-logout {
    border: 1px solid var(--sh-side-border);
    background: transparent;
    color: var(--sh-muted);
    border-radius: 8px;
    padding: 6px 8px;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.app-logout:hover {
    color: var(--sh-err);
    border-color: color-mix(in srgb, var(--sh-err) 40%, var(--sh-side-border));
}

.app-logout svg {
    width: 16px;
    height: 16px;
}

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

.app-top {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: var(--sh-top-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 22px;
    background: var(--sh-top-bg);
    border-bottom: 1px solid var(--sh-top-border);
}

.app-burger {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid var(--sh-side-border);
    background: var(--sh-side-bg);
    border-radius: 9px;
    place-items: center;
    cursor: pointer;
    color: var(--sh-muted);
}

.app-burger svg {
    width: 18px;
    height: 18px;
}

.app-top-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--sh-text);
}

.app-top-spacer {
    flex: 1;
}

.app-content {
    flex: 1;
    min-width: 0;
    min-height: 0;
}

/* off-canvas overlay (mobile) */
.app-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(9, 20, 36, .45);
    z-index: 55;
}

/* ---- responsive ---- */
@media (max-width: 920px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-side {
        position: fixed;
        top: 0;
        left: 0;
        width: 82%;
        max-width: 300px;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: var(--sh-shadow);
    }

    .app-shell.nav-open .app-side {
        transform: none;
    }

    .app-shell.nav-open .app-scrim {
        display: block;
    }

    .app-shell.nav-open {
        height: 100dvh;
        overflow: hidden;
    }

    .app-burger {
        display: grid;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-side {
        transition: none;
    }
}

/* ============ Nút thu gọn + thanh bên dạng icon-rail (desktop) ============ */
.app-collapse-btn {
    display: none;
    width: 36px;
    height: 36px;
    flex: none;
    place-items: center;
    border: 1px solid var(--sh-side-border);
    background: var(--sh-side-bg);
    border-radius: 9px;
    cursor: pointer;
    color: var(--sh-muted);
}

.app-collapse-btn:hover {
    color: var(--sh-text);
}

.app-collapse-btn svg {
    width: 17px;
    height: 17px;
}

@media (min-width: 921px) {
    .app-collapse-btn {
        display: grid;
    }

    .app-shell.side-collapsed {
        grid-template-columns: 68px 1fr;
    }

    .side-collapsed .app-brand {
        justify-content: center;
        padding: 16px 0 14px;
    }

    .side-collapsed .app-brand>span {
        display: none;
    }

    .side-collapsed .app-nav {
        padding: 6px 8px 18px;
    }

    .side-collapsed .app-nav-eyebrow {
        display: none;
    }

    .side-collapsed .app-nav-label {
        display: none;
    }

    .side-collapsed .app-nav-item {
        justify-content: center;
        padding: 9px 0;
        gap: 0;
    }

    .side-collapsed .app-nav-item.active::before {
        left: -8px;
    }

    .side-collapsed .app-subnav {
        display: none;
    }

    .side-collapsed .app-side-foot {
        flex-direction: column;
        gap: 8px;
        padding: 12px 6px;
    }

    .side-collapsed .app-who {
        display: none;
    }

    .side-collapsed .app-side-foot form {
        margin-left: 0;
    }
}
