/* ══════════════════════════════════════════════════════════════════════
   Khung điều hướng chung (SEICO Hub): sidebar trái + thanh trên.
   Do js/common/layout.js dựng; mọi trang chỉ cần <header class="app-navbar">.
   - ≥ 1024px: sidebar cố định bên trái, nội dung lùi vào.
   - < 1024px: sidebar thành ngăn kéo, mở bằng nút ☰ trên thanh trên.
   ══════════════════════════════════════════════════════════════════════ */

:root {
    --sidebar-w: 248px;
    --topbar-h: 60px;

    /* Sidebar navy đậm — cùng màu khung với design.dtsc.info / dtsc.info */
    --sb-bg: #0D2B4E;
    --sb-border: rgba(255, 255, 255, 0.08);
    --sb-text: #C9D6E5;
    --sb-icon: #A9BCD3;
    --sb-label: #7F90A6;
    --sb-hover: rgba(255, 255, 255, 0.06);
    --sb-hover-text: #FFFFFF;
    --sb-active-bg: #1D4570;
    --sb-active-text: #FFFFFF;
}

body.has-shell {
    padding-left: var(--sidebar-w);
}

/* ── Sidebar ── */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sb-bg);
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 16px 12px 14px;
    overflow-y: auto;
    z-index: 1200;
}

.sb-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 8px 4px;
    text-decoration: none;
    color: var(--text);
}

/* Logo nền trắng: đặt trong ô trắng bo góc cho gọn trên nền navy */
.sb-brand img {
    height: 34px;
    width: 34px;
    object-fit: contain;
    background: #FFFFFF;
    border-radius: 8px;
    padding: 2px;
    box-sizing: border-box;
}

.sb-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.sb-brand-name {
    font-weight: 700;
    font-size: 15px;
    color: #FFFFFF;
}

.sb-brand-sub {
    font-size: 11px;
    color: #97A6BA;
}

.sb-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.sb-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sb-label);
    padding: 0 10px 6px;
}

.sb-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--sb-text);
    text-decoration: none;
    transition: background 0.12s ease, color 0.12s ease;
}

.sb-link svg {
    flex-shrink: 0;
    color: var(--sb-icon);
}

.sb-link:hover {
    background: var(--sb-hover);
    color: var(--sb-hover-text);
}

.sb-link.active {
    background: var(--sb-active-bg);
    color: var(--sb-active-text);
    font-weight: 600;
}

.sb-link.active svg {
    color: var(--sb-active-text);
}

.sb-link .sb-ext {
    margin-left: auto;
    display: flex;
    opacity: 0.7;
}

.sb-foot {
    margin-top: auto;
    padding: 10px 10px 0;
    border-top: 1px solid var(--sb-border);
    font-size: 11px;
    color: var(--sb-label);
    line-height: 1.5;
}

.sidebar-scrim {
    display: none;
}

/* ── Thanh trên ── */
.app-navbar {
    position: sticky;
    top: 0;
    z-index: 1100;
    height: var(--topbar-h);
    background: #FFFFFF;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.topbar {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
}

.topbar-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #FFFFFF;
    color: var(--text);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.topbar-crumb {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.topbar-crumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.topbar-crumb a:hover {
    color: var(--accent);
}

.topbar-crumb b {
    color: var(--text);
    font-weight: 600;
}

/* Ô tìm kiếm toàn hệ thống (Ctrl K) */
.gsearch {
    position: relative;
    margin-left: auto;
    width: 420px;
    max-width: 100%;
}

.gsearch-box {
    height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #F7F8F5;
    color: var(--text-muted);
    cursor: text;
}

.gsearch-box:focus-within {
    border-color: var(--primary);
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(28, 107, 176, 0.15);
}

.gsearch-box input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 13.5px;
    color: var(--text);
    outline: none;
}

.gsearch-kbd {
    font-family: var(--font-mono);
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1px 6px;
    background: #FFFFFF;
    color: var(--text-muted);
}

.gsearch-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 360px;
    overflow-y: auto;
    display: none;
}

.gsearch-list.open {
    display: block;
}

.gsearch-list a {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 8px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
}

.gsearch-list a span {
    font-size: 11.5px;
    color: var(--text-muted);
}

.gsearch-list a.hl,
.gsearch-list a:hover {
    background: var(--primary-light);
}

.gsearch-empty {
    padding: 10px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.topbar .user-status {
    flex-shrink: 0;
}

/* ── Footer ── */
.app-footer {
    background: transparent;
    border-top: 1px solid var(--border);
    padding: 0.9rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: auto;
}

.footer-container {
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ══ < 1024px: sidebar thành ngăn kéo ══ */
@media (max-width: 1023px) {
    body.has-shell {
        padding-left: 0;
    }

    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: none;
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(23, 33, 43, 0.25);
    }

    body.sidebar-open .sidebar-scrim {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(23, 33, 43, 0.35);
        z-index: 1150;
    }

    .topbar-menu-btn {
        display: inline-flex;
    }

    .topbar {
        padding: 0 14px;
        gap: 10px;
    }

    .gsearch {
        width: 320px;
    }
}

/* ══ ≤ 768px: điện thoại ══ */
@media (max-width: 768px) {
    :root {
        --topbar-h: 56px;
    }

    .topbar-crumb {
        display: none;
    }

    .gsearch {
        width: auto;
        flex: 1;
    }

    .gsearch-kbd {
        display: none;
    }

    /* Chỉ giữ avatar ở thanh trên cho gọn */
    .topbar #auth-nav-name,
    .topbar #auth-nav-level,
    .topbar #auth-nav-dept {
        display: none !important;
    }

    .footer-container {
        flex-direction: column;
        text-align: center;
    }
}

@media print {
    body.has-shell {
        padding-left: 0 !important;
    }
}
