/* ============================================================
   cbl.css —— 侧边栏（左侧导航栏）相关样式
   配套结构见 templates/cbl.html，交互见 js/cbl.js
   ============================================================ */

/* 左侧导航栏（--sb-width / --sb-bg-alpha 由设置面板动态写入） */
.sidebar {
    --sb-width: 60px;
    --sb-bg-alpha: 0.45;
    position: fixed;
    top: 50%;
    left: 24px;
    transform: translateY(-50%);
    width: var(--sb-width);
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 6px;
    box-sizing: border-box;
    background-color: rgba(20, 20, 25, var(--sb-bg-alpha));
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 22px;
    z-index: 900;
    transition: opacity 0.3s ease, transform 0.3s ease, width 0.3s ease, background-color 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.sidebar.sidebar-hidden {
    opacity: 0;
    visibility: hidden;
    transform: translate(-20px, -50%);
    pointer-events: none;
}

/* ===== 侧边栏靠右显示（设置 - 侧边栏 - 位置） ===== */
.sidebar.sidebar-right {
    left: auto;
    right: 24px;
}
.sidebar.sidebar-right.sidebar-hidden {
    transform: translate(20px, -50%);
}

/* ===== 自动隐藏：默认收起、不接收指针事件，由屏幕边缘热区唤出 ===== */
.sidebar.sidebar-autohide {
    opacity: 0;
    transform: translate(-14px, -50%);
    pointer-events: none;
}
/* 热区（或已展开的侧边栏自身）处于悬停/聚焦时保持展开 */
body.sb-autohide .sidebar-hover-zone:hover + .sidebar.sidebar-autohide,
.sidebar.sidebar-autohide:hover,
.sidebar.sidebar-autohide:focus-within {
    opacity: 1;
    transform: translateY(-50%);
    pointer-events: auto;
}
.sidebar.sidebar-right.sidebar-autohide {
    transform: translate(14px, -50%);
}
.sidebar.sidebar-right.sidebar-autohide:hover,
.sidebar.sidebar-right.sidebar-autohide:focus-within {
    transform: translateY(-50%);
}

/* 边缘唤出热区：默认不拦截任何指针事件，仅在自动隐藏模式下激活 */
.sidebar-hover-zone {
    position: fixed;
    top: 0;
    left: 0;
    width: 132px;
    height: 100vh;
    z-index: 800;
    pointer-events: none;
}
body.sb-autohide .sidebar-hover-zone { pointer-events: auto; }
/* 极简模式下侧边栏整体隐藏，热区同样禁用 */
body.simple-mode .sidebar-hover-zone { pointer-events: none; }
body.sb-autohide.sb-right .sidebar-hover-zone {
    left: auto;
    right: 0;
}

/* 三段式分区 */
.sidebar-top,
.sidebar-nav,
.sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.sidebar-nav {
    gap: 4px;
    justify-content: center;
}

.sidebar-top {
    padding-bottom: 14px;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-bottom {
    padding-top: 14px;
    margin-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    gap: 4px;
}

.sidebar-item {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 48px;
    min-height: 54px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 2px;
    border-radius: 12px;
    cursor: pointer;
    color: #fff;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.25s ease, transform 0.2s ease, color 0.2s ease;
}

.sidebar-item .icon {
    width: 20px;
    height: 20px;
    transition: transform 0.25s ease, opacity 0.2s ease;
    opacity: 0.72;
}

.sidebar-item:hover {
    background-color: rgba(255, 255, 255, 0.12);
}

.sidebar-item:hover .icon {
    opacity: 1;
    transform: scale(1.08);
}

.sidebar-item:hover .sidebar-label {
    opacity: 1;
}

/* 文字标签 */
.sidebar-label {
    width: 100%;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.2px;
    color: rgba(255, 255, 255, 0.62);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    transition: opacity 0.2s ease, color 0.2s ease;
}

/* ===== 选中（激活）态：简约——仅淡背景高亮，图标保持原色、不放大、不染色 ===== */
.sidebar-item.active {
    background: rgba(255, 255, 255, 0.14);
}

.sidebar-item.active .sidebar-label {
    color: #ffffff;
    font-weight: 600;
}

/* 顶部用户头像 */
.sidebar-avatar {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-avatar:hover {
    transform: scale(1.06);
    border-color: #ff8c1a;
    box-shadow: 0 4px 14px rgba(255, 140, 26, 0.35);
}

.sidebar-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* 头像 tooltip 向右弹出 */
.sidebar-avatar .tooltip-text {
    top: 50%;
    left: 120%;
    right: auto;
    transform: translate(10px, -50%);
    background-color: rgba(40, 40, 45, 0.95);
    color: #fff;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 8px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.sidebar-avatar .tooltip-text::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -5px;
    transform: translateY(-50%);
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 5px solid rgba(40, 40, 45, 0.95);
}

.sidebar-avatar:hover .tooltip-text {
    transform: translate(0, -50%);
}

/* 侧边栏 tooltip 向右弹出 */
.sidebar-item .tooltip-text {
    top: 50%;
    left: 120%;
    right: auto;
    transform: translate(10px, -50%);
    background-color: rgba(40, 40, 45, 0.95);
    color: #fff;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 8px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.sidebar-item .tooltip-text::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -5px;
    transform: translateY(-50%);
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 5px solid rgba(40, 40, 45, 0.95);
}

.sidebar-item:hover .tooltip-text {
    transform: translate(0, -50%);
}

/* ===== 靠右显示时：tooltip 改为向左弹出 ===== */
.sidebar.sidebar-right .sidebar-avatar .tooltip-text,
.sidebar.sidebar-right .sidebar-item .tooltip-text {
    left: auto;
    right: 120%;
    transform: translate(-10px, -50%);
}
.sidebar.sidebar-right .sidebar-avatar .tooltip-text::before,
.sidebar.sidebar-right .sidebar-item .tooltip-text::before {
    left: auto;
    right: -5px;
    border-right: none;
    border-left: 5px solid rgba(40, 40, 45, 0.95);
}
.sidebar.sidebar-right .sidebar-avatar:hover .tooltip-text,
.sidebar.sidebar-right .sidebar-item:hover .tooltip-text {
    transform: translate(0, -50%);
}

/* ===== 添加分类按钮（弱化虚线样式，区别于功能导航项） ===== */
.sidebar-item-add .icon {
    opacity: 0.6;
}
.sidebar-item-add {
    box-sizing: border-box;
    border: 1px dashed rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    margin-bottom: 4px;
}
.sidebar-item-add:hover {
    border-color: rgba(255, 255, 255, 0.6);
    background-color: rgba(255, 255, 255, 0.1);
}

/* ===== 动态分类导航项（位于“首页”下方） ===== */
.sidebar-cat-item {
    position: relative;
}
/* 长分类名截断省略（宽度跟随导航项，适配侧边栏宽度设置，基础规则已含省略样式） */
.sidebar-cat-item .sidebar-label {
    max-width: 100%;
}

/* ===== 分类右键菜单 ===== */
.cat-context-menu {
    position: fixed;
    z-index: 3000;
    min-width: 168px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--auth-menu-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--auth-line);
    border-radius: 12px;
    box-shadow: 0 12px 36px var(--auth-shadow);
    animation: cat-menu-in 0.12s ease;
}
@keyframes cat-menu-in {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1); }
}
.cat-context-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: var(--auth-text);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.cat-context-item:hover { background: var(--auth-menu-hover); color: var(--auth-brand-text); }
.cat-context-item.danger:hover { background: var(--auth-danger-hover); color: var(--auth-danger); }
.cat-context-item:disabled { opacity: 0.4; cursor: default; }
.cat-context-item:disabled:hover { background: transparent; color: var(--auth-text); }
