/* 侧边导航栏样式 */

/* 防止横向滚动，但允许纵向滚动 */
body {
    overflow-x: hidden;
    overflow-y: auto !important; /* 强制允许纵向滚动，覆盖其他CSS的overflow: hidden */
    margin: 0;
    padding: 0;
}

/* 汉堡菜单按钮 */
.menu-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    background: rgba(102, 205, 170, 0.9);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 10px rgba(255, 255, 255, 0.5);
    transition: all 0.3s;
}

/* 侧边栏打开时，按钮跟着移动 */
body.sidebar-open .menu-toggle {
    left: 300px;
}

/* 侧边栏打开时，按钮变成X图标 */
body.sidebar-open .menu-toggle span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

body.sidebar-open .menu-toggle span:nth-child(2) {
    opacity: 0;
}

body.sidebar-open .menu-toggle span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

.menu-toggle:hover {
    background: var(--miku-color);
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 3px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s;
}

.menu-toggle:hover span {
    background: #fff;
    opacity: 0.8;
}

/* 侧边栏容器 */
.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: rgba(102, 205, 170, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 2px 0 20px rgba(255, 255, 255, 0.1);
    z-index: 1000;
    transition: left 0.3s ease;
    overflow-y: auto;
}

.sidebar.active {
    left: 0;
}

/* 侧边栏头部 */
.sidebar-header {
    padding: 30px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.sidebar-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 主题切换按钮 */
.theme-toggle {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: background 0.3s;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.theme-icon {
    width: 24px;
    height: 24px;
    margin-right: 15px;
    font-size: 24px;
}

.theme-text {
    font-size: 1rem;
    color: #fff;
}

/* 导航菜单 */
.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 18px 20px;
    text-decoration: none;
    color: #fff;
    font-size: 1rem;
    transition: all 0.3s;
    position: relative;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.25);
    padding-left: 25px;
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.3);
    border-left: 4px solid #fff;
}

.nav-icon {
    width: 28px;
    height: 28px;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
}

.nav-text {
    flex: 1;
}

/* 可展开菜单 */
.nav-item.expandable .nav-link {
    cursor: pointer;
}

.expand-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s;
    color: #fff;
}

.nav-item.expanded .expand-icon {
    transform: rotate(180deg);
}

/* 子菜单 */
.sub-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0, 0, 0, 0.15);
}

.nav-item.expanded .sub-menu {
    max-height: 500px;
}

.sub-menu .nav-link {
    padding-left: 60px;
    font-size: 0.95rem;
}

.sub-menu .nav-link:hover {
    padding-left: 65px;
}

/* 遮罩层 */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        width: 250px;
        left: -250px;
    }
    
    /* 移动端内容不移动，用遮挡模式 */
    body.sidebar-open .main-content {
        margin-left: 0;
    }
    
    /* 移动端按钮不跟随移动 */
    body.sidebar-open .menu-toggle {
        left: 20px;
    }
}

/* 滚动条样式 */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

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

.sidebar::-webkit-scrollbar-thumb {
    background: var(--miku-color);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--miku-color-rgb), 0.8);
}



/* 侧边栏打开时，内容区域向右移动 */
body.sidebar-open .main-content {
    margin-left: 280px;
}

.main-content h1 {
    color: #333;
    font-size: 2.5rem;
    margin-bottom: 20px;
}

.main-content p {
    color: #666;
    font-size: 1.1rem;
    line-height: 1.8;
}

/* 深色模式 */
body.dark-mode {
    background: #1a1a1a;
}

body.dark-mode .sidebar {
    background: rgba(30, 30, 30, 0.95);
}

body.dark-mode .sidebar-title,
body.dark-mode .theme-text,
body.dark-mode .nav-link {
    color: #e0e0e0;
}

body.dark-mode .menu-toggle {
    background: rgba(50, 50, 50, 0.9);
}

body.dark-mode .menu-toggle span {
    background: #e0e0e0;
}

body.dark-mode .main-content {
    background: #1a1a1a;
}

/* ========== iframe模式（嵌入在main.html中时） ========== */
body.in-iframe .menu-toggle,
body.in-iframe .sidebar,
body.in-iframe .sidebar-overlay {
    display: none !important;
}

body.in-iframe .main-content {
    margin-left: 0 !important;
    padding-top: 0;
}
