/* ============================================================
 * NURSX 面板 · 外壳层 v11 —— 侧边栏 + 顶栏
 * 必须在 /assets/panel-v10.css 之后加载：
 *   v10 = 设计令牌 + 组件（卡片/表单/弹层/认证页）
 *   v11 = 侧边栏外壳（本文件），只作用于 body.has-sidebar
 * 覆盖页面：admin.php / dev.php / agent.php
 * ============================================================ */

body.has-sidebar { --sb-w: 264px; }

/* ── 骨架 ── */
.shell { min-height: 100vh; }
.main {
    display: flex; flex-direction: column;
    min-height: 100vh; min-width: 0;
    margin-left: var(--sb-w);
}

/* ── 侧边栏 ── */
.sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 90;
    width: var(--sb-w);
    display: flex; flex-direction: column; gap: 4px;
    padding: 16px 14px 14px;
    background: var(--surface);
    backdrop-filter: blur(22px) saturate(1.6);
    -webkit-backdrop-filter: blur(22px) saturate(1.6);
    border-right: 1px solid var(--line);
    overflow: hidden;
    transition: transform 0.46s var(--ease-spring), background var(--t-mid) var(--ease-out);
}
/* 动态玻璃：沿边缘缓慢流动的一层高光 */
.sidebar::before {
    content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0.55;
    background: linear-gradient(115deg, transparent 0%, rgba(255, 255, 255, 0.55) 42%, transparent 58%, transparent 100%);
    background-size: 260% 100%;
    animation: ndSbSheen 9s linear infinite;
}
.sidebar > * { position: relative; z-index: 1; }

/* 品牌区 */
.sb-head { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; }
.sb-logo {
    width: 38px; height: 38px; flex: none; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand-grad); color: #fff;
    font-size: 17px; font-weight: 800; letter-spacing: 0.5px;
    box-shadow: 0 14px 28px -14px var(--brand-glow);
    animation: ndSbPop 0.52s var(--ease-spring) backwards;
}
.sb-brand { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sb-brand b { font-size: 15px; font-weight: 800; letter-spacing: 0.6px; color: var(--ink); }
.sb-brand small { font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.sb-close {
    display: none; width: 32px; height: 32px; flex: none;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface-2); color: var(--ink-2);
    font-size: 17px; line-height: 1; align-items: center; justify-content: center;
    transition: transform 0.34s var(--ease-spring), background var(--t-fast);
}
.sb-close:active { transform: scale(0.92); }

/* 导航 */
.sb-nav {
    flex: 1 1 auto; min-height: 0;
    display: flex; flex-direction: column; gap: 3px;
    padding: 2px 2px 8px;
    overflow-y: auto; overflow-x: hidden;
}
.sb-item {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: var(--radius-s);
    color: var(--ink-2); text-decoration: none;
    font-size: 13.5px; font-weight: 700; letter-spacing: 0.2px;
    transition: transform 0.34s var(--ease-spring), background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
    animation: ndSbIn 0.42s var(--ease-out) backwards;
}
.sb-item:nth-child(1) { animation-delay: 0.02s; }
.sb-item:nth-child(2) { animation-delay: 0.04s; }
.sb-item:nth-child(3) { animation-delay: 0.06s; }
.sb-item:nth-child(4) { animation-delay: 0.08s; }
.sb-item:nth-child(5) { animation-delay: 0.10s; }
.sb-item:nth-child(6) { animation-delay: 0.12s; }
.sb-item:nth-child(7) { animation-delay: 0.14s; }
.sb-item:nth-child(8) { animation-delay: 0.16s; }
.sb-item:nth-child(9) { animation-delay: 0.18s; }
.sb-item:nth-child(10) { animation-delay: 0.20s; }
.sb-item:nth-child(11) { animation-delay: 0.22s; }
.sb-item:nth-child(12) { animation-delay: 0.24s; }
.sb-item:nth-child(13) { animation-delay: 0.26s; }
.sb-item:nth-child(14) { animation-delay: 0.28s; }
.sb-item:hover { background: var(--surface-2); color: var(--brand); transform: translateX(3px); }
.sb-item:active { transform: scale(0.975); }
.sb-item.active {
    background: var(--brand-grad); color: #fff;
    box-shadow: 0 14px 30px -16px var(--brand-glow);
}
.sb-item.active:hover { transform: none; }
.sb-ico {
    width: 19px; height: 19px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 1.9;
    stroke-linecap: round; stroke-linejoin: round;
    transition: transform 0.34s var(--ease-spring);
}
.sb-item.active .sb-ico { transform: scale(1.08); }
.sb-tx { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 侧边栏底部：背景设置 / 账号 / 退出 */
.sb-foot {
    display: flex; flex-direction: column; gap: 8px;
    padding-top: 12px; border-top: 1px solid var(--line);
}
.sb-foot .bg-fab { width: 100%; justify-content: center; }
.sb-user {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 10px; border-radius: var(--radius-s);
    background: var(--surface-2); text-decoration: none;
    color: var(--ink); font-size: 13px; font-weight: 700;
    transition: background var(--t-fast) var(--ease-out), transform 0.34s var(--ease-spring);
}
.sb-user:hover { background: var(--surface-3); transform: translateY(-1px); }
.sb-ava {
    width: 28px; height: 28px; flex: none; border-radius: 50%; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand-grad); color: #fff; font-size: 12px; font-weight: 800;
}
.sb-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sb-uname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-out {
    display: block; padding: 8px; border-radius: var(--radius-s);
    text-align: center; text-decoration: none;
    font-size: 12.5px; font-weight: 700; color: var(--ink-3);
    transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.sb-out:hover { background: var(--red-soft); color: var(--red); }

/* ── 顶栏 ── */
.topbar {
    position: sticky; top: 0; z-index: 70;
    display: flex; align-items: center; gap: 12px;
    height: var(--bar-h); padding: 0 22px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(16px) saturate(1.5);
    -webkit-backdrop-filter: blur(16px) saturate(1.5);
    border-bottom: 1px solid var(--line);
}
.topbar::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.32), transparent);
    pointer-events: none;
}
.tb-title {
    flex: 0 1 auto; min-width: 0;
    font-size: 15.5px; font-weight: 800; letter-spacing: 0.6px; color: var(--ink);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-menu {
    display: none; width: 38px; height: 38px; flex: none;
    align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--surface-2); color: var(--brand);
    transition: transform 0.34s var(--ease-spring), background var(--t-fast);
}
.tb-menu:active { transform: scale(0.93); }
.tb-menu svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ── 抽屉遮罩 ── */
.sb-scrim {
    position: fixed; inset: 0; z-index: 85;
    background: rgba(11, 17, 33, 0.42);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none;
    transition: opacity var(--t-mid) var(--ease-out);
}

/* ── 内容区（v10 的 .content 是居中限宽，这里按侧边栏重算） ── */
body.has-sidebar .content { max-width: 1240px; padding: 24px 30px 72px; }

/* ── 自定义背景三种模式的玻璃适配（与 v10 的 appbar/bottomnav 规则对齐） ── */
body.user-bg .sidebar, body.user-bg .topbar { background: var(--surface); }
body.user-bg-sheer .sidebar, body.user-bg-sheer .topbar { background: rgba(255, 255, 255, 0.72); }
body.user-bg-clear .sidebar, body.user-bg-clear .topbar {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.14);
}
body.user-bg-clear .sidebar::before { opacity: 0.26; }
body.user-bg-clear .sb-user, body.user-bg-clear .sb-close, body.user-bg-clear .tb-menu {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.16);
}

/* ── 动画 ── */
@keyframes ndSbIn { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
@keyframes ndSbPop { from { opacity: 0; transform: scale(0.72); } to { opacity: 1; transform: none; } }
@keyframes ndSbSheen { 0% { background-position: 140% 0; } 100% { background-position: -40% 0; } }

/* ── 桌面端：常驻侧边栏 ── */
@media (min-width: 1024px) {
    .sidebar { transform: none !important; }
    .sb-scrim { display: none; }
}

/* ── 窄屏：侧边栏变抽屉 ── */
@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-104%);
        box-shadow: 34px 0 70px -34px rgba(15, 23, 42, 0.55);
    }
    body.sb-open .sidebar { transform: translateX(0); }
    body.sb-open .sb-scrim { opacity: 1; pointer-events: auto; }
    body.sb-open { overflow: hidden; }
    .main { margin-left: 0; }
    .tb-menu { display: inline-flex; }
    .sb-close { display: inline-flex; }
    .topbar { padding: 0 14px; }
    body.has-sidebar .content { max-width: none; padding: 16px 15px 56px; }
}

/* ── 顶栏内嵌音乐播放器的窄屏压缩（原 appbar.has-player 规则迁移） ── */
@media (max-width: 720px) {
    .topbar.has-player { gap: 8px; }
    .topbar.has-player .tb-title { font-size: 13.5px; }
    .topbar.has-player #ndp { flex: 1 1 auto; min-width: 0; padding: 3px 6px; }
    .topbar.has-player #ndp .ndp-t { max-width: 30vw; }
    .topbar.has-player #ndp .ndp-nav { padding: 3px 7px; font-size: 0; }
    .topbar.has-player #ndp .ndp-nav::before { font-size: 14px; line-height: 1; }
    .topbar.has-player #ndpPrev::before { content: "‹"; }
    .topbar.has-player #ndpNext::before { content: "›"; }
    .topbar.has-player #ndp .ndp-play { min-width: 40px; padding: 3px 8px; }
}

/* ── 无障碍：尊重系统"减弱动态效果" ── */
@media (prefers-reduced-motion: reduce) {
    .sidebar, .sidebar::before { transition: none; animation: none; }
    .sb-logo, .sb-item { animation: none; }
    .sb-item:hover, .sb-item:active, .sb-user:hover, .sb-close:active, .tb-menu:active { transform: none; }
}
