/* 左侧导航栏样式 - 苹果风格 */
.sidebar {
    width: 60px; /* 缩小至原来的3/4 */
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0;
    box-shadow: none;
    position: relative;
    z-index: 2000;
}

/* 导航菜单项 */
.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px; /* 与宽度保持一致 */
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: none;
    background: transparent;
}

/* 图标容器 - 用于创建悬停和选中的背景效果 */
.nav-item::before {
    content: '';
    position: absolute;
    width: 40px; /* 比图标略大 */
    height: 40px;
    background-color: rgba(0, 0, 0, 0.06); /* 统一使用浅灰色背景 */
    border-radius: 8px; /* 倒圆角效果 */
    transition: all 0.3s ease;
    z-index: 0;
    opacity: 0; /* 默认隐藏 */
}

.nav-item:hover::before {
    opacity: 1; /* 悬停时显示 */
}

.nav-item.active::before {
    opacity: 1; /* 选中时显示 */
}

.nav-icon {
    width: 24px;
    height: 24px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    position: relative;
    z-index: 1; /* 确保图标在背景之上 */
}

.home-icon {
    width: 36px !important;
    height: 36px !important;
}

/* 首页图标的背景尺寸与其他导航项保持一致 */
.nav-item:has(.home-icon)::before {
    width: 40px;
    height: 40px;
}

/* 首页图标容器 - 移除overflow以显示tooltip */
.nav-item:has(.home-icon) {
    overflow: visible; /* 允许tooltip显示在外部 */
}

/* 首页图标本身需要裁剪,但不影响tooltip */
.nav-item:has(.home-icon) .home-icon {
    clip-path: inset(0 0 0 0 round 8px); /* 使用clip-path代替overflow来裁剪图标 */
}

.nav-item:hover .nav-icon {
    opacity: 1;
}

.nav-item.active .nav-icon {
    opacity: 1;
}

.nav-tooltip {
    position: absolute;
    left: 100%;
    top: 50%;
    margin-left: 10px;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 9999999;
    pointer-events: none;
}

.nav-item:hover .nav-tooltip {
    visibility: visible;
    opacity: 1;
}

/* 禁用的导航项样式 */
.nav-item-disabled {
    cursor: not-allowed !important;
    position: relative;
}

.nav-item-disabled .nav-icon {
    opacity: 0.3 !important;
}

/* 禁用项悬停时不显示背景 */
.nav-item-disabled:hover::before {
    background-color: transparent !important;
}

.nav-item-disabled:hover .nav-icon {
    opacity: 0.3 !important; /* 图标保持浅灰色，不变亮 */
}

/* 禁用项的提示文字正常显示 */
.nav-item-disabled:hover .nav-tooltip {
    visibility: visible;
    opacity: 1;
}

/* 底部设置和邮件图标 */
.sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0; /* 减小间距，使消息按钮更靠近设置按钮 */
}

.admin-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 45px;
    width: 100%;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1001;
    background: none;
    border: none;
    outline: none;
    padding: 0;
    margin-bottom: -5px; /* 向下移动，更靠近消息按钮 */
}

.mail-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 45px; /* 稍微减小高度 */
    width: 100%;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1001;
    background: none;
    border: none;
    outline: none;
    padding: 0;
    margin-bottom: -5px; /* 向下移动，更靠近设置按钮 */
}

.settings-button {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 50px;
    width: 100%;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1001;
    background: none;
    border: none;
    outline: none;
    padding: 0;
}

/* 底部图标的背景效果 */
.admin-icon::before, .mail-icon::before, .settings-button::before {
    content: '';
    position: absolute;
    width: 36px;
    height: 36px;
    background-color: rgba(0,0,0,0.06); /* 统一使用浅灰色背景 */
    border-radius: 8px; /* 倒圆角效果 */
    transition: all 0.3s ease;
    z-index: 0;
    opacity: 0; /* 默认隐藏 */
}

.admin-icon:hover::before, .mail-icon:hover::before, .settings-button:hover::before {
    opacity: 1; /* 悬停时显示 */
}

.admin-icon-symbol, .mail-icon-symbol, .settings-icon {
    width: 22px;
    height: 22px;
    opacity: 0.6;
    transition: opacity 0.3s ease;
    position: relative;
    z-index: 1;
}

.admin-icon:hover .admin-icon-symbol,
.mail-icon:hover .mail-icon-symbol,
.settings-button:hover .settings-icon {
    opacity: 1;
}

/* 底部按钮的悬停提示文字 */
.admin-icon .nav-tooltip,
.mail-icon .nav-tooltip,
.settings-button .nav-tooltip {
    position: absolute;
    left: 100%;
    top: 50%;
    margin-left: 10px;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 9999999;
    pointer-events: none;
}

.admin-icon:hover .nav-tooltip,
.mail-icon:hover .nav-tooltip,
.settings-button:hover .nav-tooltip {
    visibility: visible;
    opacity: 1;
}

/* 禁用状态的消息图标 */
.mail-icon-disabled {
    cursor: not-allowed !important;
    opacity: 0.4;
}

.mail-icon-disabled:hover::before {
    background-color: transparent !important;
}

.mail-icon-disabled .mail-icon-symbol {
    opacity: 0.3 !important;
}

/* 禁用状态的消息图标也显示提示文字 */
.mail-icon-disabled:hover .nav-tooltip {
    visibility: visible;
    opacity: 1;
}

.message-count {
    position: absolute;
    top: 8px;
    right: 12px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 13.5px; /* 缩小至3/4: 18px * 0.75 = 13.5px */
    height: 13.5px; /* 缩小至3/4: 18px * 0.75 = 13.5px */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.525rem; /* 缩小至3/4: 0.7rem * 0.75 = 0.525rem */
    font-weight: bold;
    border: 1px solid white;
    opacity: 1; /* 不透明 */
}

/* 设置菜单样式 */
.settings-menu {
    position: absolute;
    bottom: 0; /* 底部与设置按钮底部对齐 */
    left: 100%; /* 定位在导航栏右侧 */
    margin-left: 3px; /* 与导航栏保持一定间距 */
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 120px; /* 减小宽度 */
    z-index: 1003; /* 高于其他元素 */
    display: none;
    padding: 8px 0;
}

.settings-menu.show {
    display: block;
}

.settings-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 0.9rem;
    color: #333;
    text-align: center; /* 文字居中 */
}

.settings-item:hover {
    background-color: #f5f5f5;
}

/* ==================== 深色模式适配 ==================== */

/* 导航项背景 */
body.dark-mode .nav-item::before {
    background-color: rgba(255, 255, 255, 0.1);
}

/* 底部图标背景 */
body.dark-mode .admin-icon::before,
body.dark-mode .mail-icon::before,
body.dark-mode .settings-button::before {
    background-color: rgba(255, 255, 255, 0.1);
}

/* 设置菜单 */
body.dark-mode .settings-menu {
    background: #2a2a2a;
    border-color: #444;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

body.dark-mode .settings-item {
    color: #e0e0e0;
}

body.dark-mode .settings-item:hover {
    background-color: #333;
}

/* 消息计数 */
body.dark-mode .message-count {
    border-color: #2a2a2a;
}