/* ============================================================
   APP SHELL — sidebar (right in RTL, left in LTR) + top bar
   ============================================================ */

.app-shell {
    display: grid;
    /* logical areas: "side" sits at inline-start in both directions (right in RTL, left in LTR) */
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-areas: "side main";
    min-height: 100vh;
}
.app-shell > .sidebar  { grid-area: side; }
.app-shell > .app-main { grid-area: main; }

.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--c-bg);
}

/* ----------- Sidebar (dark) ----------- */
.sidebar {
    background: var(--c-sidebar);
    color: var(--c-sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 22px 18px;
    gap: 8px;
    height: 100vh;
    position: sticky;
    top: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 6px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 14px;
}
.brand .brand-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-2) 100%);
    display: grid; place-items: center;
    color: #fff;
    box-shadow: 0 6px 16px rgba(107, 91, 255, 0.45);
}
.brand .brand-icon .material-symbols-rounded { font-size: 24px; }
.brand .brand-text { line-height: 1.15; }
.brand .brand-text .brand-name { font-weight: 800; font-size: 16px; color: #fff; }
.brand .brand-text .brand-sub  { color: var(--c-sidebar-text-muted); font-size: 11.5px; margin-top: 2px; }

.nav-items { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-items::-webkit-scrollbar { width: 4px; }
.nav-items::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 99px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--c-sidebar-text);
    font-weight: 500;
    font-size: 13.5px;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
    white-space: nowrap;
}
.nav-item .material-symbols-rounded {
    font-size: 21px;
    color: var(--c-sidebar-text-muted);
    transition: color 120ms ease;
}
.nav-item:hover {
    background: var(--c-sidebar-hover);
    color: #fff;
}
.nav-item:hover .material-symbols-rounded { color: #fff; }

.nav-item.active {
    background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-2) 100%);
    color: #fff;
    box-shadow: 0 8px 18px rgba(107, 91, 255, 0.35);
}
.nav-item.active .material-symbols-rounded { color: #fff; }

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 8px;
}
.dark-toggle, .collapse-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--c-sidebar-text);
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
}
.dark-toggle:hover, .collapse-toggle:hover { background: var(--c-sidebar-hover); color: #fff; }
.dark-toggle .material-symbols-rounded,
.collapse-toggle .material-symbols-rounded {
    background: var(--c-sidebar-soft);
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border-radius: 8px;
    color: var(--c-sidebar-text);
    font-size: 18px;
}

/* ----------- Top bar ----------- */
.topbar {
    height: var(--topbar-h);
    background: var(--c-surface);
    display: grid;
    grid-template-columns: auto auto 1fr auto auto;
    align-items: center;
    gap: 18px;
    padding: 0 22px;
    border-bottom: 1px solid var(--c-border);
}

.topbar .user-block {
    display: flex; align-items: center; gap: 10px;
}
.user-avatar {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #FF9F66, #FF5C7F);
    display: grid; place-items: center;
    color: #fff; font-weight: 700;
}
.user-avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }

.topbar .icon-btn {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-text-soft);
    display: grid; place-items: center;
    cursor: pointer;
    position: relative;
    transition: background 120ms ease, color 120ms ease;
}
.topbar .icon-btn:hover { background: var(--c-bg-soft); color: var(--c-text); }
.topbar .icon-btn .badge {
    position: absolute;
    top: -4px; inset-inline-end: -4px;
    background: var(--c-red);
    color: #fff;
    min-width: 18px; height: 18px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    display: grid; place-items: center;
    padding: 0 5px;
}

.search-wrap {
    display: flex; align-items: center; gap: 10px;
    background: var(--c-bg-soft);
    border-radius: 12px;
    padding: 0 16px;
    height: 44px;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
}
.search-wrap input {
    border: 0; background: transparent; outline: none;
    flex: 1;
    font-family: inherit;
    color: var(--c-text);
    font-size: 13.5px;
}
.search-wrap input::placeholder { color: var(--c-text-muted); }
.search-wrap .kbd {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    color: var(--c-text-muted);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
}

.greeting {
    display: flex; flex-direction: column; line-height: 1.2;
    text-align: end;
}
.greeting .hello { font-weight: 700; font-size: 14.5px; }
.greeting .hello .wave { display: inline-block; margin-inline-start: 4px; }
.greeting .role { color: var(--c-text-muted); font-size: 11.5px; margin-top: 2px; }

.branch-select {
    display: flex; align-items: center; gap: 8px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    height: 44px;
    padding: 0 14px;
    color: var(--c-text);
    font-weight: 600;
    cursor: pointer;
    min-width: 180px;
}
.branch-select .material-symbols-rounded { color: var(--c-text-muted); font-size: 20px; }
.branch-select .chev { color: var(--c-text-muted); }

.lang-switch {
    display: flex; gap: 4px;
    background: var(--c-bg-soft);
    padding: 4px;
    border-radius: 10px;
    height: 38px;
}
.lang-switch a {
    padding: 4px 12px;
    border-radius: 8px;
    color: var(--c-text-muted);
    font-weight: 600;
    font-size: 12px;
    display: grid; place-items: center;
    cursor: pointer;
}
.lang-switch a.active { background: var(--c-surface); color: var(--c-text); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }

/* ---------- Page area ----------- */
.page {
    padding: 22px 22px 32px;
    overflow-y: auto;
}

/* responsive */
@media (max-width: 1280px) {
    .app-shell { grid-template-columns: var(--sidebar-collapsed-w) 1fr; }
    .nav-item span:not(.material-symbols-rounded),
    .brand .brand-text,
    .dark-toggle span:not(.material-symbols-rounded),
    .collapse-toggle span:not(.material-symbols-rounded) { display: none; }
    .nav-item, .dark-toggle, .collapse-toggle { justify-content: center; }
}
@media (max-width: 900px) {
    .topbar { grid-template-columns: auto 1fr auto; }
    .topbar .user-block, .topbar .greeting, .topbar .branch-select { display: none; }
}
