/* Docsify 侧边栏视觉美化 - 现代化配色方案 */

/* ================================
   侧边栏整体美化
   ================================ */
.sidebar {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%) !important;
    border-right: 1px solid rgba(99, 102, 241, 0.15) !important;
    box-shadow: 2px 0 12px rgba(99, 102, 241, 0.08) !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
    position: relative;
    z-index: 1;
}

/* 侧边栏标题美化 */
.sidebar>h1 {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    background-clip: text !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    font-weight: 700 !important;
    text-align: center !important;
    padding-bottom: 10px !important;
    border-bottom: 2px solid rgba(99, 102, 241, 0.1) !important;
    font-size: 1.2em !important;
    letter-spacing: 0.5px !important;
}

.sidebar>h1 a {
    color: inherit !important;
    text-decoration: none !important;
}

/* ================================
   搜索框美化
   ================================ */
.search input {
    border: 2px solid rgba(99, 102, 241, 0.2) !important;
    border-radius: 25px !important;
    background: white !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.search input:focus {
    outline: none !important;
    border-color: #6366f1 !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2), 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
    transform: translateY(-1px) !important;
}

.search input::placeholder {
    color: #94a3b8 !important;
    font-weight: 400 !important;
}

/* 搜索框容器 - 使用更高特异性 */
body .search {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    padding: 1rem !important;
    margin-bottom: 0.5rem !important;
    border-bottom: 1px solid rgba(99, 102, 241, 0.15) !important;
    position: relative !important;
    z-index: 9999 !important;  /* 确保搜索框在最上层 */
}

body .search .input-wrap {
    display: flex !important;
    align-items: center !important;
    position: relative !important;
    z-index: 10000 !important;  /* 确保输入框可见 */
}

/* 清除按钮 */
body .search .clear-button {
    position: absolute !important;
    right: 8px !important;
    cursor: pointer !important;
    width: 24px !important;
    height: 24px !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
}

body .search .clear-button.show {
    display: flex !important;
}

/* ================================
   搜索结果美化
   ================================ */
.results-panel {
    background: white !important;
    border: 1px solid rgba(99, 102, 241, 0.2) !important;
    border-radius: 12px !important;
    margin-top: 8px !important;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.15) !important;
    overflow: hidden !important;
}

.results-panel h2 {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    color: white !important;
    margin: 0 !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
}

.results-panel p {
    margin: 0 !important;
    padding: 12px 16px !important;
    border-bottom: 1px solid rgba(99, 102, 241, 0.1) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    color: #475569 !important;
}

.results-panel p:hover {
    background: rgba(99, 102, 241, 0.05) !important;
    color: #6366f1 !important;
    transform: translateX(4px) !important;
}

.results-panel p:last-child {
    border-bottom: none !important;
}

/* 搜索关键词高亮 */
.results-panel p em {
    background: rgba(99, 102, 241, 0.2) !important;
    color: #6366f1 !important;
    font-style: normal !important;
    font-weight: 600 !important;
    padding: 1px 3px !important;
    border-radius: 3px !important;
}

/* ================================
   导航菜单美化
   ================================ */
.sidebar ul {
    padding: 0 !important;
}

.sidebar ul li a {
    padding: 12px 16px !important;
    color: #475569 !important;
    text-decoration: none !important;
    border-radius: 10px !important;
    margin: 3px 8px !important;
    display: block !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative !important;
    overflow: hidden !important;
    border: 1px solid transparent !important;
}

.sidebar ul li a:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.05)) !important;
    color: #6366f1 !important;
    transform: translateX(4px) !important;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15) !important;
    border-color: rgba(99, 102, 241, 0.2) !important;
}

/* 激活状态美化 */
.sidebar ul li.active>a,
.sidebar ul li a.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.08)) !important;
    color: #6366f1 !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2) !important;
    border-left: 3px solid #6366f1 !important;
}

/* 左侧指示条 */
.sidebar ul li a::before {
    content: '' !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    height: 100% !important;
    width: 0 !important;
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.sidebar ul li a:hover::before {
    width: 3px !important;
}

/* 子菜单美化 */
.sidebar ul li ul li a {
    padding: 10px 16px 10px 32px !important;
    font-size: 13px !important;
    color: #64748b !important;
    font-weight: 400 !important;
    margin: 2px 8px !important;
    border-radius: 8px !important;
}

.sidebar ul li ul li a:hover {
    background: rgba(99, 102, 241, 0.08) !important;
    color: #6366f1 !important;
    transform: translateX(2px) !important;
}

.sidebar ul li ul li a::before {
    display: none !important;
}

/* ================================
   滚动条美化
   ================================ */
.sidebar::-webkit-scrollbar {
    width: 6px !important;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(99, 102, 241, 0.1) !important;
    border-radius: 3px !important;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.4) !important;
    border-radius: 3px !important;
    transition: background 0.3s ease !important;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.6) !important;
}

/* ================================
   深色模式适配
   ================================ */
@media (prefers-color-scheme: dark),
body[data-theme="dark"] {
    .sidebar {
        background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
        border-right-color: rgba(99, 102, 241, 0.3) !important;
    }

    body .search input {
        background: #334155 !important;
        color: #e2e8f0 !important;
        border-color: rgba(99, 102, 241, 0.3) !important;
    }

    body .search input::placeholder {
        color: #94a3b8 !important;
    }

    .sidebar ul li a {
        color: #cbd5e1 !important;
    }

    .sidebar ul li a:hover {
        background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.1)) !important;
        color: #a5b4fc !important;
    }

    .sidebar ul li.active>a,
    .sidebar ul li a.active {
        background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(139, 92, 246, 0.15)) !important;
        color: #a5b4fc !important;
    }

    .sidebar ul li ul li a {
        color: #94a3b8 !important;
    }

    .results-panel {
        background: #334155 !important;
        border-color: rgba(99, 102, 241, 0.3) !important;
    }

    .results-panel p {
        color: #cbd5e1 !important;
        border-bottom-color: rgba(99, 102, 241, 0.2) !important;
    }

    .results-panel p:hover {
        background: rgba(99, 102, 241, 0.1) !important;
        color: #a5b4fc !important;
    }

    .results-panel p em {
        background: rgba(99, 102, 241, 0.3) !important;
        color: #a5b4fc !important;
    }
}

/* ================================
   响应式适配
   ================================ */
@media (max-width: 768px) {
    .sidebar ul li a {
        padding: 10px 14px !important;
        margin: 2px 6px !important;
        font-size: 14px !important;
    }

    .sidebar ul li ul li a {
        padding: 8px 14px 8px 28px !important;
    }

    body .search input {
        padding: 10px 14px !important;
        font-size: 14px !important;
    }
}

/* ================================
   细节增强效果 - 禁用动画避免刷新
   ================================ */

/* 搜索框聚焦时的脉冲效果 */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2), 0 0 0 0 rgba(99, 102, 241, 0.2);
    }
    70% {
        box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2), 0 0 0 6px rgba(99, 102, 241, 0);
    }
    100% {
        box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2), 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

body .search input:focus {
    animation: pulse 1s ease-in-out !important;
}

/* 移除菜单项加载动画，避免路由变化时重新播放 */
.sidebar ul li {
    /* animation: slideIn 0.3s ease forwards !important; */
    /* nth-child动画延迟也移除 */
}

/* 移除浮动效果，避免干扰 */
.sidebar ul li:hover {
    /* animation: float 2s ease-in-out infinite !important; */
}

/* ================================
   侧边栏稳定化优化
   ================================ */

/* 侧边栏导航项优化 */
.sidebar-nav {
    will-change: contents !important;
}

/* 减少重排的优化 */
.sidebar-nav li,
.sidebar-nav a {
    contain: layout style paint !important;
}

/* 恢复折叠功能，但使用CSS避免动画闪烁 */
.sidebar-nav li > ul {
    /* 移除强制显示，交给插件控制 */
    /* display: block !important; */
    max-height: none !important;
    opacity: 1 !important;
    overflow: visible !important;
}

.app-sub-sidebar {
    /* 移除强制显示，交给插件控制 */
    /* display: block !important; */
    max-height: none !important;
    opacity: 1 !important;
    overflow: visible !important;
}

/* 优化折叠过渡，避免闪烁 */
.sidebar-nav li > ul {
    transition: opacity 0.1s ease !important;  /* 只保留opacity过渡 */
}

.app-sub-sidebar {
    transition: opacity 0.1s ease !important;  /* 只保留opacity过渡 */
}

/* 添加折叠箭头图标 */
.sidebar-nav li.folder > a::before,
.sidebar-nav li.folder > a::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 5px solid #6366f1;  /* 箭头颜色 */
    transition: transform 0.2s ease;
    transform: translateY(-50%);
}

.sidebar-nav li.folder > a::before {
    display: none;
}

.sidebar-nav li.folder:not(.open) > a::after {
    transform: translateY(-50%) rotate(0deg);
}

.sidebar-nav li.folder.open > a::after {
    transform: translateY(-50%) rotate(90deg);
}

.sidebar-nav li.folder > a {
    position: relative;
    padding-right: 32px !important;
}

/* 深色模式下的箭头颜色 */
@media (prefers-color-scheme: dark),
body[data-theme="dark"] {
    .sidebar-nav li.folder > a::before,
    .sidebar-nav li.folder > a::after {
        border-left-color: #a5b4fc !important;  /* 深色模式下箭头颜色 */
    }
}
