/* ════════════════════════════════════════════════════════════════
   AISAR App Shell — sidebar + topbar
   Structure mirrors hr-system's employee-view shell.
   Coloring matches the designer dashboard: light surface, navy ink,
   teal/coral accent. The sidebar is light too (no dark theme).
════════════════════════════════════════════════════════════════ */

:root {
    /* Layout dimensions (match hr-system) */
    --sb-width:        260px;
    --sb-collapsed:    72px;
    --tb-height:       64px;

    /* Sidebar surface — light, dashboard-matching. */
    --shell-side-bg:     #FFFFFF;
    --shell-side-border: var(--c-border, #E2E8F0);

    /* Transitions */
    --shell-fast:   150ms ease;
    --shell-normal: 220ms ease;
}

/* ── App Shell layout ─────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--c-surface-2, #F1F5F9);
}

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
    width: var(--sb-width);
    min-height: 100vh;
    background: var(--shell-side-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--shell-normal);
    border-inline-end: 1px solid var(--shell-side-border);
    /* Pin the sidebar so the long nav scrolls inside .sb-nav, not the page */
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
}
.sidebar.collapsed { width: var(--sb-collapsed); }

/* brand — logo only, standalone (no wordmark / subtitle text). */
.sb-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    min-height: var(--tb-height);
    border-bottom: 1px solid var(--shell-side-border);
    flex-shrink: 0;
    overflow: hidden;
}
.sb-logo {
    max-width: calc(100% - 12px);
    max-height: 56px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    flex-shrink: 1;
}
.sidebar.collapsed .sb-brand { padding: 0; }
.sidebar.collapsed .sb-logo { max-height: 40px; max-width: 90%; }

/* toggle */
.sb-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--c-border, #E2E8F0);
    background: var(--c-surface, #fff);
    cursor: pointer;
    color: var(--c-ink-3, #94A3B8);
    margin: 12px auto 4px;
    flex-shrink: 0;
    transition: background var(--shell-fast), color var(--shell-fast), border-color var(--shell-fast);
}
.sb-toggle:hover {
    background: var(--c-surface-2, #F1F5F9);
    color: var(--c-coral, #14B8A6);
    border-color: var(--c-coral, #14B8A6);
}
.sb-toggle svg { display: block; transition: transform .22s; }
.sidebar.collapsed .sb-toggle svg { transform: scaleX(-1); }
[dir="rtl"] .sb-toggle svg { transform: scaleX(-1); }
[dir="rtl"] .sidebar.collapsed .sb-toggle svg { transform: none; }

/* nav scroll area */
.sb-scroll {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.sb-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 10px 12px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}
.sb-nav::-webkit-scrollbar { width: 0; }

/* section label */
.sb-section-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--c-ink-3, #94A3B8);
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 10px 8px 4px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--shell-fast);
}
.sidebar.collapsed .sb-section-label { opacity: 0; }

/* nav link */
.sb-link {
    display: flex;
    align-items: center;
    gap: 11px;
    height: 40px;
    border-radius: 8px;
    padding: 0 12px;
    text-decoration: none;
    color: var(--c-ink-2, #64748B);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    transition: background var(--shell-fast), color var(--shell-fast);
    position: relative;
}
.sb-link:hover {
    background: var(--c-surface-2, #F1F5F9);
    color: var(--c-ink, #0F2A4A);
    text-decoration: none;
}
.sb-link.active {
    background: var(--c-coral-soft, #CCFBF1);
    color: var(--c-coral-text, #0F766E);
    font-weight: 600;
}
.sb-link.active::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--c-coral, #14B8A6);
}
[dir="rtl"] .sb-link.active::before {
    border-radius: 3px 0 0 3px;
}

.sb-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: .75;
    transition: opacity var(--shell-fast), color var(--shell-fast);
}
.sb-link.active .sb-icon { opacity: 1; color: var(--c-coral, #14B8A6); }
.sb-link:hover .sb-icon { opacity: 1; }
.sb-icon .material-symbols-outlined { font-size: 20px; line-height: 1; }

.sb-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--shell-fast), width var(--shell-fast);
}
.sidebar.collapsed .sb-label { opacity: 0; width: 0; pointer-events: none; }

/* tooltip on collapsed */
.sidebar.collapsed .sb-link { justify-content: center; padding: 0; }
.sidebar.collapsed .sb-link::after {
    content: attr(data-label);
    position: absolute;
    inset-inline-start: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--c-ink, #0F2A4A);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--shell-fast);
    box-shadow: 0 4px 14px rgba(15, 42, 74, 0.18);
    z-index: 200;
}
.sidebar.collapsed .sb-link:hover::after { opacity: 1; }

/* footer */
.sb-footer {
    border-top: 1px solid var(--shell-side-border);
    padding: 12px 10px;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--c-surface, #fff);
}
.sb-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--shell-fast);
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none;
    flex: 1;
    min-width: 0;
}
.sb-user:hover { background: var(--c-surface-2, #F1F5F9); text-decoration: none; }
.sb-user-av {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--c-coral, #14B8A6);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: -0.01em;
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.25);
}
.sb-user-info { flex: 1; overflow: hidden; min-width: 0; }
.sb-user-name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--c-ink, #0F2A4A);
    overflow: hidden;
    text-overflow: ellipsis;
}
.sb-user-role {
    font-size: 10.5px;
    color: var(--c-ink-3, #94A3B8);
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar.collapsed .sb-user-info { display: none; }
.sidebar.collapsed .sb-user { justify-content: center; padding: 8px; }

/* logout button in footer */
.sb-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--c-border, #E2E8F0);
    background: var(--c-surface, #fff);
    color: var(--c-ink-3, #94A3B8);
    cursor: pointer;
    transition: background var(--shell-fast), color var(--shell-fast), border-color var(--shell-fast);
    flex-shrink: 0;
}
.sb-logout:hover {
    background: var(--c-danger-soft, #FEE2E2);
    color: var(--c-danger, #DC2626);
    border-color: var(--c-danger, #DC2626);
}
.sidebar.collapsed .sb-logout { display: none; }

/* ── MAIN CONTENT ─────────────────────────────────────────── */
.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--c-surface-2, #F1F5F9);
}

/* ── TOPBAR ───────────────────────────────────────────────── */
.topbar {
    height: var(--tb-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--c-border, #E2E8F0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}
.topbar-start {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}
.topbar-page-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--c-ink, #0F2A4A);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}
.topbar-end {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* topbar icon button */
.tb-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--c-border, #E2E8F0);
    background: var(--c-surface, #fff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--c-ink-2, #64748B);
    transition: background var(--shell-fast), color var(--shell-fast), border-color var(--shell-fast);
    position: relative;
    flex-shrink: 0;
    text-decoration: none;
}
.tb-icon-btn:hover {
    background: var(--c-coral-soft, #CCFBF1);
    color: var(--c-coral-text, #0F766E);
    border-color: var(--c-coral, #14B8A6);
    text-decoration: none;
}
.tb-icon-btn .material-symbols-outlined { font-size: 18px; line-height: 1; }

.tb-notif-dot {
    position: absolute;
    top: 7px;
    inset-inline-end: 7px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--c-coral, #14B8A6);
    border: 1.5px solid #fff;
}

.tb-divider {
    width: 1px;
    height: 22px;
    background: var(--c-border, #E2E8F0);
    margin: 0 4px;
    flex-shrink: 0;
}

/* search */
.tb-search {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    border: 1px solid var(--c-border, #E2E8F0);
    border-radius: 8px;
    background: var(--c-surface-2, #F1F5F9);
    padding: 0 12px;
    max-width: 360px;
    width: 220px;
    transition: border-color var(--shell-fast), background var(--shell-fast), width .22s, box-shadow var(--shell-fast);
}
.tb-search:focus-within {
    border-color: var(--c-coral, #14B8A6);
    background: #fff;
    width: 280px;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}
.tb-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    color: var(--c-ink, #0F2A4A);
    flex: 1;
    min-width: 0;
    height: 100%;
    font-family: inherit;
}
.tb-search input::placeholder { color: var(--c-ink-3, #94A3B8); }
.tb-search .material-symbols-outlined { color: var(--c-ink-3, #94A3B8); font-size: 18px; }

/* language toggle */
.tb-lang-btn {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
}

/* user block in topbar */
.tb-user {
    display: flex;
    align-items: center;
    gap: 9px;
    height: 36px;
    padding: 0 10px 0 4px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--shell-fast), border-color var(--shell-fast);
    text-decoration: none;
}
.tb-user:hover { background: var(--c-surface-2, #F1F5F9); border-color: var(--c-border, #E2E8F0); text-decoration: none; }
.tb-user-av {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--c-coral, #14B8A6);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    letter-spacing: -0.01em;
}
.tb-user-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--c-ink, #0F2A4A);
    white-space: nowrap;
}
.tb-user-role {
    font-size: 10.5px;
    color: var(--c-ink-3, #94A3B8);
    white-space: nowrap;
}
.tb-user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.tb-user-arrow { color: var(--c-ink-3, #94A3B8); flex-shrink: 0; }

/* ── PAGE BODY ────────────────────────────────────────────── */
.page-body {
    padding: 24px;
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
}
.page-body-inner {
    max-width: 1440px;
    margin: 0 auto;
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 980px) {
    .app-shell { flex-direction: column-reverse; }
    .sidebar, .sidebar.expanded, .sidebar.collapsed {
        width: 100%;
        min-height: auto;
        height: auto;
        border-inline-end: none;
        border-top: 1px solid var(--shell-side-border);
        flex-direction: row;
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        z-index: 90;
        background: var(--c-surface, #fff);
        box-shadow: 0 -4px 16px rgba(15, 42, 74, 0.08);
    }
    .sb-brand,
    .sb-toggle,
    .sb-section-label,
    .sb-footer { display: none; }
    .sb-scroll { flex: 1; overflow: hidden; }
    .sb-nav {
        flex-direction: row;
        padding: 6px;
        gap: 4px;
        overflow-x: auto;
        overflow-y: hidden;
        flex: 1;
    }
    .sb-link {
        flex-direction: column;
        height: auto;
        padding: 6px 12px;
        gap: 2px;
        font-size: 10px;
        min-width: 64px;
    }
    .sb-link.active::before { display: none; }
    .sidebar.collapsed .sb-label { opacity: 1; width: auto; }
    .sidebar.collapsed .sb-link { justify-content: center; padding: 6px 12px; flex-direction: column; }
    .sidebar.collapsed .sb-link::after { display: none; }
    .main-content { min-height: 0; padding-bottom: 76px; }
}

@media (max-width: 640px) {
    .page-body { padding: 16px; }
    .topbar { padding: 0 14px; }
    .tb-search { display: none; }
    .topbar-page-title { font-size: 16px; }
    .tb-user-meta { display: none; }
}

@media (max-width: 480px) {
    .page-body { padding: 12px; }
    .topbar-end .tb-divider:nth-of-type(2) { display: none; }
}
