/**
 * TalkStock V2 - 可摺疊側邊欄樣式
 * 參考 Claude.ai 設計
 */

/* ==========================================================================
   側邊欄基礎結構
   ========================================================================== */
.collapsible-sidebar {
    width: var(--sidebar-width-collapsed);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1001;
    transition: width var(--sidebar-transition);
    overflow: visible;  /* 改為 visible 讓 Tooltip 可以顯示 */
}

/* 展開狀態恢復 overflow hidden（避免內容溢出） */
.collapsible-sidebar.expanded {
    width: var(--sidebar-width-expanded);
    overflow: hidden;
}

/* 全局 SVG 精緻化 — 確保所有圖示清晰銳利 */
.collapsible-sidebar svg {
    shape-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    stroke-width: 2;
}

/* Logo SVG 保留自身 stroke-width（不受全局 2px 覆蓋） */
.collapsible-sidebar .sidebar-logo-icon {
    stroke-width: initial;
}

/* ==========================================================================
   側邊欄頭部（Logo）
   ========================================================================== */
.sidebar-logo {
    height: 52px;
    min-height: 52px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-bottom: 1px solid var(--sidebar-border);
}

/* Logo 點擊區（回首頁） */
.sidebar-logo-clickable {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex: 1;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    color: var(--color-accent);
    transition: transform 200ms ease, filter 200ms ease;
    filter: drop-shadow(0 1px 2px var(--color-accent-subtle));
    animation: logo-breathe 4s ease-in-out infinite;
}

/* 呼吸脈動：輕微縮放 + 光暈明暗交替 */
@keyframes logo-breathe {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 1px 2px var(--color-accent-subtle));
    }
    50% {
        transform: scale(1.06);
        filter: drop-shadow(0 2px 8px rgba(249, 115, 22, 0.35));
    }
}

/* --- Logo 子元素間歇性動畫（不同週期交錯觸發） --- */

/* AI 圓點：脈搏閃爍（雙跳 scale），12s 週期，~8% 活躍 */
@keyframes logo-dot-sparkle {
    0%, 91%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    93% {
        transform: scale(1.4);
        opacity: 0.85;
    }
    95% {
        transform: scale(1.05);
        opacity: 1;
    }
    97% {
        transform: scale(1.3);
        opacity: 0.9;
    }
    99% {
        transform: scale(1);
        opacity: 1;
    }
}

/* AI 弧線：掃描亮起 + glow，15s 週期，~15% 活躍 */
@keyframes logo-arc-sweep {
    0%, 79%, 100% {
        opacity: 0.6;
        filter: none;
    }
    85% {
        opacity: 1;
        filter: drop-shadow(0 0 3px rgba(249, 115, 22, 0.50));
    }
    92% {
        opacity: 0.85;
        filter: drop-shadow(0 0 1px var(--color-accent-subtle));
    }
    96% {
        opacity: 0.6;
        filter: none;
    }
}

/* 趨勢線：筆劃繪製，18s 週期，~13% 活躍 */
@keyframes logo-line-draw {
    0%, 71%, 100% {
        stroke-dashoffset: 0;
    }
    72% {
        stroke-dashoffset: 40;
    }
    85% {
        stroke-dashoffset: 0;
    }
}

/* 箭頭：與趨勢線同步，18s 週期 */
@keyframes logo-arrow-pop {
    0%, 71%, 90%, 100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    72% {
        transform: translateY(0) scale(0.3);
        opacity: 0;
    }
    83% {
        transform: translateY(0) scale(0.3);
        opacity: 0;
    }
    85% {
        transform: translateY(-1.5px) scale(1.15);
        opacity: 1;
    }
    88% {
        transform: translateY(0.3px) scale(1);
        opacity: 1;
    }
}

/* 套用動畫到 SVG 子元素 */
.logo-ai-dot {
    animation: logo-dot-sparkle 12s ease-in-out 2s infinite;
    transform-origin: center;
}

.logo-ai-arc {
    animation: logo-arc-sweep 15s ease-in-out 5s infinite;
}

.logo-stock-line {
    stroke-dasharray: 40;
    stroke-dashoffset: 0;
    animation: logo-line-draw 18s ease-in-out 3s infinite;
}

.logo-stock-arrow {
    animation: logo-arrow-pop 18s ease-in-out 3s infinite;
    transform-origin: center;
}

/* Hover 時暫停所有子元素動畫 */
.sidebar-logo-clickable:hover .logo-ai-dot,
.sidebar-logo-clickable:hover .logo-ai-arc,
.sidebar-logo-clickable:hover .logo-stock-line,
.sidebar-logo-clickable:hover .logo-stock-arrow {
    animation-play-state: paused;
}

/* 無障礙：減少動態偏好 */
@media (prefers-reduced-motion: reduce) {
    .logo-ai-dot,
    .logo-ai-arc,
    .logo-stock-line,
    .logo-stock-arrow {
        animation: none !important;
    }
    .logo-stock-line {
        stroke-dasharray: none !important;
    }
    .sidebar-logo-text {
        animation: none !important;
    }
}

.sidebar-logo-clickable:hover .sidebar-logo-icon {
    animation: none;
    transform: scale(1.1);
    filter: drop-shadow(0 2px 6px rgba(249, 115, 22, 0.30));
}

.sidebar-logo-text {
    margin-left: 10px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 200ms ease;
    line-height: 1;
    user-select: none;
    /* 品牌文字三層 Shimmer — 快慢交錯 */
    background:
        /* L1: 快速窄光點 — 柔和金白，7-stop 平滑衰減 */
        linear-gradient(90deg,
            transparent 40%,
            rgba(255, 225, 190, 0.2) 44%,
            rgba(255, 235, 205, 0.45) 47%,
            rgba(255, 245, 225, 0.6) 50%,
            rgba(255, 235, 205, 0.45) 53%,
            rgba(255, 225, 190, 0.2) 56%,
            transparent 60%
        ),
        /* L2: 慢速暖色洗 — 溫潤漸層，緩慢飄過 */
        linear-gradient(90deg,
            transparent 18%,
            rgba(255, 190, 120, 0.08) 32%,
            rgba(255, 200, 140, 0.18) 50%,
            rgba(255, 190, 120, 0.08) 68%,
            transparent 82%
        ),
        /* L3: 靜態三色 Talk(橘)Stock(深).AI(橘) */
        linear-gradient(90deg,
            var(--color-accent) 0%,
            var(--color-accent) 30%,
            var(--color-text-primary) 33%,
            var(--color-text-primary) 73%,
            var(--color-accent) 76%,
            var(--color-accent) 100%
        );
    background-size: 500% 100%, 300% 100%, 100% 100%;
    background-position: 120% center, 95% center, 0% center;
    -webkit-background-clip: text, text, text;
    background-clip: text, text, text;
    -webkit-text-fill-color: transparent;
    animation: logo-triple-shimmer 6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes logo-triple-shimmer {
    0%   { background-position: 120% center, 95% center, 0% center; }
    30%  { background-position: -20% center, 55% center, 0% center; }
    50%  { background-position: 80% center, -5% center, 0% center; }
    75%  { background-position: 120% center, 40% center, 0% center; }
    100% { background-position: 120% center, 95% center, 0% center; }
}

/* 雙色品牌名：Talk 橘色 + Stock 深色 — 高對比 */
.logo-talk {
    color: var(--color-accent);
}

.logo-stock {
    color: var(--color-text-primary);
    font-weight: 900;
}

.logo-ai {
    color: var(--color-accent);
    font-weight: 700;
}

.collapsible-sidebar.expanded .sidebar-logo-text {
    opacity: 1;
}

/* ==========================================================================
   收合狀態統一按鈕樣式（參考 Claude.ai 設計）
   ========================================================================== */
/* 統一按鈕基礎樣式 */
.sidebar-collapsed-btn-base {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--sidebar-icon);
    cursor: pointer;
    transition: all 150ms ease;
    flex-shrink: 0;
    position: relative;
}

.sidebar-collapsed-btn-base:hover {
    background: var(--sidebar-bg-hover);
    color: var(--color-text-primary);
}

.sidebar-collapsed-btn-base svg {
    width: 18px;
    height: 18px;
}

/* Toggle 按鈕 */
.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--sidebar-icon);
    cursor: pointer;
    transition: all 150ms ease;
    flex-shrink: 0;
    position: relative;
}

.sidebar-toggle-btn:hover {
    background: var(--sidebar-bg-hover);
    color: var(--color-text-primary);
}

/* Toggle 按鈕圖標樣式 */
.sidebar-toggle-btn svg {
    width: 18px;
    height: 18px;
}

/* === 展開狀態 === */
/* 展開時：顯示雙面板圖標 */
.collapsible-sidebar.expanded .toggle-icon-expanded {
    display: block;
}

.collapsible-sidebar.expanded .toggle-icon-collapsed {
    display: none;
}

/* === 收合狀態 === */
/* 收合時：Logo 點擊區只顯示 icon（隱藏文字由 opacity 控制） */
.collapsible-sidebar:not(.expanded) .sidebar-logo-clickable {
    display: flex;
    justify-content: center;
    flex: none;
    width: 100%;
}

/* 收合時 icon 置中 */
.collapsible-sidebar:not(.expanded) .sidebar-logo-icon {
    width: 28px;
    height: 28px;
}

/* 收合時文字完全不佔空間 */
.collapsible-sidebar:not(.expanded) .sidebar-logo-text {
    width: 0;
    overflow: hidden;
    margin-left: 0;
}

/* 收合時：垂直排列，按鈕居中對齊 */
.collapsible-sidebar:not(.expanded) .sidebar-logo {
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    height: auto;
    min-height: auto;
    border-bottom: none;
    overflow: visible;  /* 允許 Tooltip 溢出 */
}

/* 收合時：顯示單面板圖標 */
.collapsible-sidebar:not(.expanded) .toggle-icon-expanded {
    display: none;
}

.collapsible-sidebar:not(.expanded) .toggle-icon-collapsed {
    display: block;
}

/* ==========================================================================
   新對話按鈕（醒目版）
   ========================================================================== */
.sidebar-new-chat-wrapper {
    display: none;
    padding: 8px 12px 0 12px;
}

.collapsible-sidebar.expanded .sidebar-new-chat-wrapper {
    display: block;
}

.sidebar-new-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--color-accent);
    border-radius: 10px;
    background: transparent;
    color: var(--color-accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms ease;
}

.sidebar-new-chat-btn:hover {
    background: var(--color-accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.25);
}

.sidebar-new-chat-btn:active {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color: #fff;
    transform: scale(0.98);
}

.sidebar-new-chat-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-new-chat-text {
    white-space: nowrap;
}

/* --- Pencil 書寫動畫 --- */

/* 底線：紙張不動，始終顯示 */
/* （pencil-line 無動畫） */

/* 筆身：書寫搖擺動畫 */
.sidebar-new-chat-icon .pencil-body {
    transform-origin: 3px 20px;   /* 筆尖位置為旋轉軸心 */
    animation: pencil-writing 5s ease-in-out 1s infinite;
}

@keyframes pencil-writing {
    /* 書寫階段 0~50%（2.5s）— 搖擺 + 漸進右移 */
    0%   { transform: rotate(0deg) translateX(0); }
    6%   { transform: rotate(-3deg) translateX(0.3px); }
    12%  { transform: rotate(2deg) translateX(0.6px); }
    18%  { transform: rotate(-2.5deg) translateX(0.9px); }
    24%  { transform: rotate(1.5deg) translateX(1.2px); }
    30%  { transform: rotate(-2deg) translateX(1.5px); }
    36%  { transform: rotate(1deg) translateX(1.8px); }
    42%  { transform: rotate(-1.5deg) translateX(2.0px); }
    48%  { transform: rotate(0.5deg) translateX(2.2px); }

    /* 靜止階段 50~100%（2.5s）— 停筆 + 平滑回位 */
    50%  { transform: rotate(0deg) translateX(2.2px); }
    55%  { transform: rotate(0deg) translateX(0); }
    100% { transform: rotate(0deg) translateX(0); }
}

/* Hover 時暫停動畫 */
.sidebar-new-chat-btn:hover .pencil-body {
    animation-play-state: paused;
}

/* 無障礙：減少動態偏好 */
@media (prefers-reduced-motion: reduce) {
    .sidebar-new-chat-icon .pencil-body {
        animation: none !important;
    }
}

/* ==========================================================================
   收合狀態快捷按鈕
   ========================================================================== */
/* 收合狀態快捷按鈕容器 */
.sidebar-collapsed-actions {
    display: none;  /* 預設隱藏 */
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

/* 收合狀態時顯示 */
.collapsible-sidebar:not(.expanded) .sidebar-collapsed-actions {
    display: flex;
}

/* 展開狀態時隱藏 */
.collapsible-sidebar.expanded .sidebar-collapsed-actions {
    display: none;
}

/* 收合狀態快捷按鈕 - 統一為 36x36px 圓角方形 */
.sidebar-collapsed-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--sidebar-icon);
    cursor: pointer;
    transition: all 150ms ease;
    position: relative;
}

.sidebar-collapsed-btn:hover {
    background: var(--sidebar-bg-hover);
    color: var(--color-text-primary);
}

.sidebar-collapsed-btn svg {
    width: 18px;
    height: 18px;
}

/* 收合狀態：accent 版本（新對話按鈕醒目化） */
.sidebar-collapsed-btn--accent {
    color: var(--color-accent);
}

.sidebar-collapsed-btn--accent:hover {
    background: var(--color-accent);
    color: #fff;
}

/* 收合狀態快捷按鈕的 Tooltip - 使用 fixed 定位避免被裁切 */
.sidebar-collapsed-btn .sidebar-tooltip {
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--color-text-primary);
    color: var(--color-text-on-accent);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease;
    z-index: 9999;
    box-shadow: var(--shadow-md);
}

.sidebar-collapsed-btn:hover .sidebar-tooltip {
    opacity: 1;
}

/* ==========================================================================
   側邊欄內容區（聊天記錄 + 最近組合）
   ========================================================================== */
.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;  /* 收合狀態允許 Tooltip 溢出 */
}

/* 展開狀態恢復 overflow hidden */
.collapsible-sidebar.expanded .sidebar-content {
    overflow: hidden;
}

/* 自訂 scrollbar（簡約細線風格） */
.sidebar-section-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-section-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-section-content::-webkit-scrollbar-thumb {
    background: var(--color-scrollbar-thumb);
    border-radius: 4px;
}

.sidebar-section-content::-webkit-scrollbar-thumb:hover {
    background: var(--color-scrollbar-thumb-hover);
}

/* 收合狀態：區塊只顯示標題（圖標），隱藏內容 */
.collapsible-sidebar:not(.expanded) .sidebar-section-content {
    display: none;
}

/* 區塊標題 */
.sidebar-section {
    display: flex;
    flex-direction: column;
}

.sidebar-section + .sidebar-section {
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    transition: background-color 120ms ease;
    position: relative;
}

.sidebar-section-header:hover {
    background-color: var(--sidebar-bg-hover);
}

.sidebar-section-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--sidebar-icon);
}

/* 收合狀態：區塊標題變成 36x36px 按鈕樣式 */
.collapsible-sidebar:not(.expanded) .sidebar-section-header {
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 4px auto;
    border-radius: 8px;
    justify-content: center;
    overflow: visible;  /* 允許 Tooltip 溢出 */
}

.collapsible-sidebar:not(.expanded) .sidebar-section-header:hover {
    background-color: var(--sidebar-bg-hover);
}

/* 收合狀態：隱藏區塊標題的文字和操作按鈕 */
.collapsible-sidebar:not(.expanded) .sidebar-section-title,
.collapsible-sidebar:not(.expanded) .sidebar-section-actions {
    display: none;
}

/* 收合狀態：區塊標題的 Tooltip */
.collapsible-sidebar:not(.expanded) .sidebar-section-header .sidebar-tooltip {
    left: calc(100% + 12px);
    background-color: var(--color-text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
}

.sidebar-section-title {
    margin-left: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-tertiary);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 200ms ease;
}

.collapsible-sidebar.expanded .sidebar-section-title {
    opacity: 1;
}

.sidebar-section-actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 200ms ease;
}

.collapsible-sidebar.expanded .sidebar-section-actions {
    opacity: 1;
}

/* ==========================================================================
   Segmented Tabs（歷史紀錄類型切換）
   ========================================================================== */

.sidebar-segment-tabs {
    display: none;
    gap: 0;
    background: var(--color-bg-hover);
    border-radius: 8px;
    padding: 3px;
    margin: 8px 12px 0 12px;
}

.collapsible-sidebar.expanded .sidebar-segment-tabs {
    display: flex;
}

.sidebar-segment-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease;
    white-space: nowrap;
}

.sidebar-segment-tab:hover {
    background: var(--color-bg-subtle);
    color: var(--color-text-primary);
}

.sidebar-segment-tab.active {
    background: var(--color-accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.sidebar-segment-tab svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ==========================================================================
   Action Row（搜尋 + 操作按鈕）
   ========================================================================== */

.sidebar-action-row {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 4px 12px;
}

.collapsible-sidebar.expanded .sidebar-action-row {
    display: flex;
}

/* Inline 搜尋框 */
.sidebar-search-inline {
    flex: 1;
    position: relative;
    min-width: 0;
}

.sidebar-search-inline-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.sidebar-search-inline-input {
    width: 100%;
    padding: 5px 28px 5px 28px;
    border: 1px solid var(--color-border-default);
    border-radius: 6px;
    background: var(--color-bg-page);
    font-size: 12px;
    color: var(--color-text-primary);
    outline: none;
    transition: border-color 150ms ease;
}

.sidebar-search-inline-input:focus {
    border-color: var(--color-accent);
}

.sidebar-search-inline-input::placeholder {
    color: var(--color-text-muted);
}

.sidebar-search-inline-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px;
    border: none;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.sidebar-search-inline-clear:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-hover);
}

/* Action 按鈕 */
.sidebar-action-buttons {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.sidebar-action-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--color-text-tertiary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 120ms ease;
}

.sidebar-action-btn:hover {
    background-color: var(--sidebar-bg-hover);
    color: var(--color-text-primary);
}

.sidebar-action-btn svg {
    width: 14px;
    height: 14px;
}

/* 收合狀態：隱藏 Segmented Tabs + Action Row */
.collapsible-sidebar:not(.expanded) .sidebar-segment-tabs,
.collapsible-sidebar:not(.expanded) .sidebar-action-row {
    display: none;
}

/* Minimal Header: 展開時隱藏 */
.collapsible-sidebar.expanded .sidebar-section-header--minimal {
    display: none;
}

/* 深色主題 */
[data-theme="dark"] .sidebar-search-inline-input {
    background: var(--color-bg-hover);
}

[data-theme="dark"] .sidebar-segment-tabs {
    background: var(--color-bg-elevated);
}

.sidebar-section-btn {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--color-text-tertiary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 120ms ease;
}

.sidebar-section-btn:hover {
    background-color: var(--sidebar-bg-hover);
    color: var(--color-text-primary);
}

.sidebar-section-btn svg {
    width: 14px;
    height: 14px;
}

/* 區塊內容 */
.sidebar-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 300ms ease;
}

.collapsible-sidebar.expanded .sidebar-section-content {
    max-height: 400px;
    overflow-y: auto;
}

/* 項目列表 */
.sidebar-item {
    display: flex;
    align-items: center;
    padding: 6px 12px 6px 20px;
    margin: 1px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 120ms ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item:hover {
    background-color: var(--sidebar-bg-hover);
}

.sidebar-item.active {
    background-color: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
}

.sidebar-item-text {
    font-size: 13px;
    font-weight: 450;
    color: var(--color-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 時間分組標題 */
.sidebar-time-group {
    padding: 12px 12px 4px 20px;
    margin: 0 8px;
    font-size: 10px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* 載入與空狀態 */
.sidebar-loading,
.sidebar-empty {
    padding: 16px 14px 16px 46px;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* ==========================================================================
   側邊欄底部（功能區）
   ========================================================================== */
.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: 8px;
}

/* 收合狀態：只顯示一個圖示 */
.sidebar-footer-collapsed {
    display: flex;
    justify-content: center;
    position: relative;
}

.collapsible-sidebar.expanded .sidebar-footer-collapsed {
    display: none;
}

/* 收合狀態：用戶頭像 */
.sidebar-collapsed-user {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: all 150ms ease;
}

.sidebar-collapsed-user:hover {
    background: var(--sidebar-bg-hover);
}

.sidebar-collapsed-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--color-bg-active);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-collapsed-user.logged-in .sidebar-collapsed-avatar {
    background-color: var(--color-accent-subtle);
    border: 1.5px solid rgba(249, 115, 22, 0.3);
}

.sidebar-collapsed-avatar svg {
    width: 14px;
    height: 14px;
    color: var(--sidebar-icon);
}

.sidebar-collapsed-user.logged-in .sidebar-collapsed-avatar svg {
    color: var(--color-accent);
}

.sidebar-collapsed-user:hover .sidebar-tooltip {
    opacity: 1;
}

/* 展開狀態：顯示完整功能區 */
.sidebar-footer-expanded {
    display: none;
}

.collapsible-sidebar.expanded .sidebar-footer-expanded {
    display: block;
}

/* 功能按鈕列 */
.sidebar-footer-buttons {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 4px 0;
}

.sidebar-footer-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--sidebar-icon);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 120ms ease;
}

.sidebar-footer-btn:hover {
    background-color: var(--sidebar-bg-hover);
    color: var(--color-text-primary);
}

.sidebar-footer-btn-icon {
    width: 18px;
    height: 18px;
    margin-bottom: 2px;
}

.sidebar-footer-btn-label {
    font-size: 9px;
    font-weight: 500;
    color: var(--color-text-tertiary);
    letter-spacing: 0.02em;
}

/* 用戶資訊區 */
.sidebar-user {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-top: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 120ms ease;
}

.sidebar-user:hover {
    background-color: var(--sidebar-bg-hover);
}

.sidebar-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--color-bg-active);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-user-avatar svg {
    width: 16px;
    height: 16px;
    color: var(--sidebar-icon);
}

.sidebar-user-info {
    margin-left: 12px;
    flex: 1;
    min-width: 0;
}

.sidebar-user-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    display: inline-block;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    white-space: nowrap;
    line-height: 1.4;
    flex-shrink: 0;
}

.sidebar-user-role:empty {
    display: none;
}

.sidebar-user-role.role-admin {
    background: var(--color-secondary-subtle);
    color: var(--color-secondary);
}

.sidebar-user-role.role-user {
    background: var(--color-info-subtle);
    color: var(--color-info);
}

.sidebar-user-email {
    font-size: 11px;
    color: var(--color-text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-dropdown-icon {
    width: 14px;
    height: 14px;
    color: var(--color-text-tertiary);
    flex-shrink: 0;
}

/* ==========================================================================
   Tooltip（收合狀態的提示）
   ========================================================================== */
.sidebar-tooltip {
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--color-text-primary);
    color: var(--color-text-on-accent);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease;
    z-index: 1002;
}

.sidebar-section-header:hover .sidebar-tooltip,
.sidebar-footer-collapsed:hover .sidebar-tooltip {
    opacity: 1;
}

.collapsible-sidebar.expanded .sidebar-tooltip {
    display: none;
}

/* ==========================================================================
   深色主題支援
   ========================================================================== */
/* 以下 dark overrides 已由 Design Token 自動切換處理：
   - .collapsible-sidebar background → --sidebar-bg
   - .logo-stock color → --color-text-primary
   - hover backgrounds → --sidebar-bg-hover
   - .sidebar-collapsed-btn:hover → --sidebar-bg-hover
   - .sidebar-user-name → --color-text-primary
   - .sidebar-collapsed-avatar bg → --color-bg-active
   - .sidebar-collapsed-avatar svg → --sidebar-icon
   - .sidebar-collapsed-user:hover → --sidebar-bg-hover
*/

/* 深色主題：品牌文字三層 Shimmer — 金白高光 + 暖金洗 */
[data-theme="dark"] .sidebar-logo-text {
    background:
        /* L1: 快速窄光點 — 金白核心 + 金屬質感衰減 */
        linear-gradient(90deg,
            transparent 40%,
            rgba(255, 215, 170, 0.2) 44%,
            rgba(255, 235, 200, 0.55) 47%,
            rgba(255, 250, 235, 0.88) 50%,
            rgba(255, 235, 200, 0.55) 53%,
            rgba(255, 215, 170, 0.2) 56%,
            transparent 60%
        ),
        /* L2: 慢速暖金洗 — 飽和暖金，深色下清晰可辨 */
        linear-gradient(90deg,
            transparent 18%,
            rgba(255, 180, 70, 0.10) 30%,
            rgba(255, 195, 90, 0.32) 50%,
            rgba(255, 180, 70, 0.10) 70%,
            transparent 82%
        ),
        /* L3: 靜態品牌三色 */
        linear-gradient(90deg,
            var(--color-accent) 0%, var(--color-accent) 30%,
            var(--color-text-primary) 33%, var(--color-text-primary) 73%,
            var(--color-accent) 76%, var(--color-accent) 100%
        );
    background-size: 500% 100%, 300% 100%, 100% 100%;
    background-position: 120% center, 95% center, 0% center;
    -webkit-background-clip: text, text, text;
    background-clip: text, text, text;
    -webkit-text-fill-color: transparent;
}

/* 深色主題：新對話按鈕 */
[data-theme="dark"] .sidebar-new-chat-btn {
    background: var(--color-accent-muted);
}

[data-theme="dark"] .sidebar-new-chat-btn:hover {
    background: var(--color-accent);
    color: #fff;
}

/* 深色主題：Tooltip 反轉（深色背景需要淺色 tooltip） */
[data-theme="dark"] .sidebar-tooltip {
    background-color: var(--color-text-primary);
    color: var(--color-bg-secondary);
}

/* 深色主題：角色徽章（微調透明度） */
[data-theme="dark"] .sidebar-user-role.role-admin {
    background: var(--color-secondary-subtle);
}

[data-theme="dark"] .sidebar-user-role.role-user {
    background: var(--color-info-subtle);
}

/* 深色主題：已登入頭像（accent 指示器） */
[data-theme="dark"] .sidebar-collapsed-user.logged-in .sidebar-collapsed-avatar {
    background-color: var(--color-accent-subtle);
    border-color: rgba(249, 115, 22, 0.4);
}

/* ==========================================================================
   聊天記錄區額外樣式
   ========================================================================== */

/* 載入狀態 */
.sidebar-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    color: var(--color-text-muted);
    font-size: 12px;
    gap: 8px;
}

.sidebar-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-secondary-subtle);
    border-top-color: var(--color-secondary);
    border-radius: 50%;
    animation: sidebar-spin 0.8s linear infinite;
}

@keyframes sidebar-spin {
    to { transform: rotate(360deg); }
}

/* 空狀態 */
.sidebar-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 12px;
}

/* 搜尋框 */
.sidebar-search {
    padding: 8px 12px;
    position: relative;
}

.sidebar-search-input {
    width: 100%;
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--color-border-default);
    border-radius: 6px;
    background: var(--color-bg-page);
    font-size: 13px;
    color: var(--color-text-primary);
    outline: none;
    transition: border-color 150ms ease;
}

.sidebar-search-input:focus {
    border-color: var(--color-accent);
}

.sidebar-search-input::placeholder {
    color: var(--color-text-muted);
}

.sidebar-search-clear {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px;
    border: none;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-search-clear:hover {
    color: var(--color-text-primary);
}

/* 對話項目右側操作區 */
.sidebar-item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

/* 對話項目 meta 資訊 */
.sidebar-item-meta {
    font-size: 10px;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-top: 0;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 150ms ease;
}

.collapsible-sidebar.expanded .sidebar-item-meta {
    opacity: 1;
}

/* 刪除按鈕 - 預設隱藏 */
.sidebar-item-delete {
    display: none;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: all 150ms ease;
}

/* Hover 時顯示刪除按鈕 */
.sidebar-item:hover .sidebar-item-delete {
    display: flex;
}

/* Hover 時隱藏 meta 資訊 */
.sidebar-item:hover .sidebar-item-meta {
    display: none;
}

/* 刪除按鈕 hover 效果 */
.sidebar-item-delete:hover {
    color: var(--color-danger);
    background-color: var(--color-danger-subtle);
}

/* 深色主題：刪除按鈕 — token 自動切換（--color-text-muted / --color-danger） */

/* 右鍵選單 */
.sidebar-context-menu {
    position: fixed;
    min-width: 160px;
    background: var(--color-bg-elevated);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    z-index: 10000;
}

.sidebar-context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: background-color 150ms ease;
}

.sidebar-context-menu-item:hover {
    background-color: var(--sidebar-bg-hover);
}

.sidebar-context-menu-item.danger {
    color: var(--color-danger);
}

.sidebar-context-menu-item.danger:hover {
    background-color: var(--color-danger-subtle);
}

/* 深色主題：搜尋框 — token 自動切換，僅保留 bg 覆寫 */
[data-theme="dark"] .sidebar-search-input {
    background: var(--color-bg-hover);
}

/* 深色主題：右鍵選單 — token 自動切換 */

/* ==========================================================================
   最近查看組合區額外樣式
   ========================================================================== */

/* 組合項目 */
.sidebar-combination-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 12px 6px 20px;
    margin: 1px 8px;
    border-radius: 6px;
}

.sidebar-item-icon {
    flex-shrink: 0;
    color: var(--color-secondary);
    margin-top: 2px;
}

.sidebar-item-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.sidebar-combination-item .sidebar-item-text {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--color-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-combination-item .sidebar-item-meta {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Hover 顯示完整路徑 tooltip */
.sidebar-combination-item:hover {
    background-color: var(--sidebar-bg-hover);
}

/* 深色主題：組合項目 — token 自動切換 */

/* 組合項目的 actions 容器位置調整 */
.sidebar-combination-item .sidebar-item-actions {
    margin-left: auto;
    flex-shrink: 0;
}

/* 組合項目 hover 時顯示刪除按鈕 */
.sidebar-combination-item:hover .sidebar-item-delete {
    display: flex;
}

/* 組合項目 hover 時隱藏 meta 資訊 */
.sidebar-combination-item:hover .sidebar-item-meta {
    display: none;
}

/* ==========================================================================
   統一歷史紀錄 — Section 佈局
   ========================================================================== */

#historySection {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#historyContent {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.collapsible-sidebar.expanded #historyContent {
    max-height: none;
}

/* (已移除) 舊篩選欄 + Nav Toggle — 由 Segmented Tabs 取代 */

/* ==========================================================================
   統一歷史紀錄 — Item 類型圖示
   ========================================================================== */

.sidebar-item-type-icon {
    flex-shrink: 0;
    color: var(--color-text-muted);
    margin-right: 6px;
    width: 14px;
    height: 14px;
}

.sidebar-item--chat .sidebar-item-type-icon {
    color: var(--color-accent);
    opacity: 0.7;
}

.sidebar-item--combo .sidebar-item-type-icon {
    color: var(--color-secondary, #3b82f6);
    opacity: 0.7;
}

/* 確保 sidebar-item 內 flex 對齊 */
.sidebar-item--chat,
.sidebar-item--combo {
    display: flex;
    align-items: center;
}

/* ==========================================================================
   統一歷史紀錄 — 手機版
   ========================================================================== */

@media (max-width: 767px) {
    #historyContent {
        max-height: none;
    }
}

/* ==========================================================================
   用戶下拉選單
   ========================================================================== */
.sidebar-user-dropdown {
    position: fixed;
    min-width: 200px;
    background: var(--color-bg-elevated);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 8px 0;
    z-index: 10001;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 150ms ease, transform 150ms ease;
}

.sidebar-user-dropdown.show {
    opacity: 1;
    transform: translateY(0);
}

.dropdown-content {
    display: flex;
    flex-direction: column;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: background-color 150ms ease;
}

.dropdown-item:hover {
    background-color: var(--sidebar-bg-hover);
}

.dropdown-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.dropdown-item.primary {
    color: var(--color-accent);
}

.dropdown-item.primary svg {
    stroke: var(--color-accent);
}

.dropdown-item.danger {
    color: var(--color-danger);
}

.dropdown-item.danger svg {
    stroke: var(--color-danger);
}

.dropdown-item.danger:hover {
    background-color: var(--color-danger-subtle);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--color-border-default);
    margin: 4px 0;
}

/* ==========================================================================
   語言下拉選單
   ========================================================================== */
.sidebar-language-dropdown {
    position: fixed;
    min-width: 160px;
    background: var(--color-bg-elevated);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 6px 0;
    z-index: 10001;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 150ms ease, transform 150ms ease;
}

.sidebar-language-dropdown.show {
    opacity: 1;
    transform: translateY(0);
}

.sidebar-language-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: background-color 150ms ease;
}

.sidebar-language-option:hover {
    background-color: var(--sidebar-bg-hover);
}

.sidebar-language-option.active {
    font-weight: 600;
    color: var(--color-accent);
}

.sidebar-language-check {
    width: 16px;
    font-size: 14px;
    text-align: center;
    flex-shrink: 0;
    color: var(--color-accent);
}

.sidebar-language-label {
    flex: 1;
}

/* 深色主題：語言/用戶下拉選單 — token 自動切換
   --color-bg-elevated / --color-text-primary / --sidebar-bg-hover /
   --color-accent / --color-border-default 均已自動適配深色主題 */

/* ==========================================================================
   手機版響應式設計（< 768px）
   ========================================================================== */

/* 手機版漢堡選單按鈕 */
.sidebar-mobile-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1002;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border-default);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 150ms ease;
}

.sidebar-mobile-toggle:hover {
    background: var(--sidebar-bg-hover);
}

.sidebar-mobile-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--color-text-primary);
}

/* 手機版遮罩層 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity 200ms ease;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

@media (max-width: 767px) {
    /* 顯示漢堡選單按鈕 */
    .sidebar-mobile-toggle {
        display: flex;
    }

    /* 側邊欄手機版樣式 */
    .collapsible-sidebar {
        width: 280px;
        transform: translateX(-100%);
        transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

    /* 手機版展開狀態 */
    .collapsible-sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    }

    /* 手機版：總是顯示展開內容 */
    .collapsible-sidebar .sidebar-logo-text,
    .collapsible-sidebar .sidebar-section-title,
    .collapsible-sidebar .sidebar-section-actions,
    .collapsible-sidebar .sidebar-item-meta {
        opacity: 1;
    }

    .collapsible-sidebar .sidebar-section-content {
        max-height: 400px;
        overflow-y: auto;
    }

    /* 手機版：隱藏收合狀態底部 */
    .collapsible-sidebar .sidebar-footer-collapsed {
        display: none;
    }

    .collapsible-sidebar .sidebar-footer-expanded {
        display: block;
    }

    /* 手機版：隱藏收合狀態快捷按鈕 */
    .collapsible-sidebar .sidebar-collapsed-actions {
        display: none !important;
    }

    /* 手機版：新對話按鈕強制顯示 */
    .collapsible-sidebar .sidebar-new-chat-wrapper {
        display: block;
    }

    .collapsible-sidebar .sidebar-new-chat-btn {
        padding: 12px 16px;
        font-size: 15px;
        min-height: 48px;
    }

    /* 手機版：Segmented Tabs + Action Row 強制顯示 */
    .collapsible-sidebar .sidebar-segment-tabs {
        display: flex;
    }

    .collapsible-sidebar .sidebar-action-row {
        display: flex;
    }

    /* 手機版：隱藏收合 minimal header */
    .collapsible-sidebar .sidebar-section-header--minimal {
        display: none;
    }

    /* 手機版：touch-friendly 尺寸 */
    .collapsible-sidebar .sidebar-segment-tab {
        padding: 8px;
    }

    .collapsible-sidebar .sidebar-action-btn {
        width: 36px;
        height: 36px;
    }

    .collapsible-sidebar .sidebar-action-btn svg {
        width: 16px;
        height: 16px;
    }

    /* 手機版：恢復 sidebar-logo 水平排列 */
    .collapsible-sidebar .sidebar-logo {
        flex-direction: row;
        align-items: center;
        gap: 0;
        height: 60px;
        min-height: 60px;
        border-bottom: 1px solid var(--sidebar-border);
    }

    /* 手機版：顯示 Logo 點擊區 */
    .collapsible-sidebar .sidebar-logo-clickable {
        display: flex;
    }

    /* 手機版：隱藏 tooltip */
    .collapsible-sidebar .sidebar-tooltip {
        display: none !important;
    }

    /* 手機版：主內容不需要 margin */
    .main-content {
        margin-left: 0 !important;
    }

    /* 手機版：調整觸控目標大小 */
    .sidebar-section-header {
        padding: 14px 16px;
        min-height: 48px;
    }

    .sidebar-item {
        padding: 12px 16px 12px 48px;
        min-height: 44px;
    }

    .sidebar-combination-item {
        padding: 12px 16px 12px 48px;
        min-height: 44px;
    }

    .sidebar-footer-btn {
        padding: 12px;
        min-height: 44px;
    }

    .sidebar-user {
        padding: 14px;
        min-height: 56px;
    }

    /* 手機版：語言下拉選單調整 */
    .sidebar-language-dropdown {
        left: 16px !important;
        right: 16px !important;
        min-width: auto;
    }

    /* 手機版：用戶下拉選單調整 */
    .sidebar-user-dropdown {
        position: fixed;
        bottom: auto;
        top: auto;
        left: 16px !important;
        right: 16px !important;
        width: auto !important;
        bottom: 100px !important;
    }

    .dropdown-item {
        padding: 14px 16px;
        min-height: 48px;
    }
}

/* 深色主題：手機版 — 大部分由 token 自動切換 */
[data-theme="dark"] .sidebar-overlay {
    background: rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   管理後台入口區塊（僅管理員可見）
   ========================================================================== */
.sidebar-admin-entry {
    padding: 8px 8px;
    border-top: none;
    background: transparent;
    transition: all 0.2s ease;
}

/* 側邊欄收合時 */
.collapsible-sidebar:not(.expanded) .sidebar-admin-entry {
    padding: 12px 8px;
}

/* 管理按鈕 */
.admin-entry-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border-default);
    border-radius: 8px;
    background: transparent;
    color: var(--color-text-secondary);
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: none;
}

.admin-entry-btn:hover {
    background: var(--sidebar-bg-hover);
    color: var(--color-accent);
    border-color: var(--color-accent-subtle);
    transform: none;
    box-shadow: none;
}

.admin-entry-btn:active {
    transform: none;
}

/* 圖標 */
.admin-icon {
    flex-shrink: 0;
    color: currentColor;
    transition: all 0.2s ease;
}

.admin-entry-btn:hover .admin-icon {
    transform: scale(1.1);
}

/* 文字（收合時隱藏） */
.admin-entry-text {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease;
}

.collapsible-sidebar:not(.expanded) .admin-entry-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* 徽章 */
.admin-badge {
    margin-left: auto;
    padding: 2px 6px;
    background: var(--color-secondary-subtle);
    color: var(--color-secondary);
    font-size: 9px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

.admin-entry-btn:hover .admin-badge {
    background: var(--color-secondary-subtle);
    color: var(--color-secondary-hover);
}

.collapsible-sidebar:not(.expanded) .admin-badge {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* 收合狀態：只顯示圖標 */
.collapsible-sidebar:not(.expanded) .admin-entry-btn {
    justify-content: center;
    padding: 12px;
    gap: 0;
}

/* 收合狀態：添加 Tooltip */
.collapsible-sidebar:not(.expanded) .sidebar-admin-entry {
    position: relative;
}

.collapsible-sidebar:not(.expanded) .admin-entry-btn::after {
    content: '管理後台';
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.9);
    color: var(--color-text-on-accent);
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.collapsible-sidebar:not(.expanded) .admin-entry-btn:hover::after {
    opacity: 1;
}

/* 深色主題：管理後台入口 */
[data-theme="dark"] .admin-entry-btn {
    background: var(--color-bg-hover);
    color: var(--color-text-secondary);
    border-color: var(--color-border-default);
}

[data-theme="dark"] .admin-entry-btn:hover {
    background: var(--color-accent);
    color: var(--color-text-on-accent);
}
