/* ===== 側邊選單 - Herb 清新綠色風格 ===== */

/* 側邊選單基本樣式 */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 300px;
    height: 100vh;
    background: #ffffff;
    color: #333;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1050;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
}

/* 側邊選單開啟狀態 */
.sidebar.active {
    transform: translateX(0);
}

/* 捲軸樣式 */
.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-primary-light);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--border-primary);
}

.sidebar::-webkit-scrollbar-track {
    background: #f5f5f5;
}

/* 側邊選單標題區 ===== */
.sidebar-header {
    padding: 18px 20px;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--primary-color);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ===== 關閉按鈕 ===== */
.sidebar-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    display: block !important;
    transition: all 0.3s ease;
    border-radius: 8px;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: rotate(90deg);
}

/* ===== 側邊選單導航 ===== */
.sidebar-nav {
    padding: 15px 0;
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ===== 選單項目 ===== */
.menu-item {
    margin: 2px 12px;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    color: #555;
    text-decoration: none;
    transition: all 0.25s ease;
    position: relative;
    border-radius: 10px;
    font-weight: 500;
}

.menu-link:hover {
    background: var(--bg-primary-lightest);
    color: var(--primary-darker);
}

.menu-link:hover i:first-child {
    color: var(--primary-color);
}

.menu-link.active {
    background: linear-gradient(135deg, var(--bg-primary-lightest) 0%, var(--border-primary-light) 100%);
    color: var(--primary-darker);
    border-left: 3px solid var(--primary-color);
}

.menu-link i:first-child {
    width: 22px;
    margin-right: 14px;
    font-size: 17px;
    text-align: center;
    flex-shrink: 0;
    color: #888;
    transition: color 0.25s ease;
}

.menu-link.active i:first-child {
    color: var(--primary-color);
}

.menu-link span {
    flex: 1;
    white-space: nowrap;
    font-size: 15px;
}

.menu-link .arrow {
    margin-left: auto;
    font-size: 11px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    color: #aaa;
}

/* 已開啟狀態的選單項目 */
.menu-item.active>.menu-link {
    background: #f1f8e9;
    color: #33691e;
}

.menu-item.active>.menu-link i:first-child {
    color: var(--primary-color);
}

.menu-item.active>.menu-link .arrow {
    transform: rotate(90deg);
    color: var(--primary-color);
}

/* ===== 子選單 ===== */
.submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #fafafa;
    border-radius: 8px;
    margin-top: 4px;
}

.menu-item.active>.submenu {
    max-height: 1000px;
}

.submenu li {
    margin: 0;
}

.submenu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px 11px 50px;
    color: #666;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.25s ease;
    position: relative;
    border-radius: 6px;
    margin: 2px 6px;
}

.submenu a::before {
    content: '';
    position: absolute;
    left: 28px;
    width: 6px;
    height: 6px;
    background: #ccc;
    border-radius: 50%;
    transition: all 0.25s ease;
}

.submenu a:hover {
    background: var(--bg-primary-lightest);
    color: var(--primary-darker);
}

.submenu a:hover::before {
    background: var(--primary-color);
    transform: scale(1.2);
}

.submenu a.active {
    background: var(--bg-primary-lightest);
    color: var(--primary-darker);
    font-weight: 500;
}

.submenu a.active::before {
    background: var(--primary-color);
}

.submenu i {
    font-size: 12px;
    flex-shrink: 0;
}

/* 子選單保持正常流動 */
.sidebar .submenu {
    position: static !important;
    width: 100% !important;
}

/* ===== 分隔線 ===== */
.menu-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #e0e0e0, transparent);
    margin: 16px 24px;
}

/* ===== 載入中樣式 ===== */
.sidebar-loading-item a {
    color: #999 !important;
    font-style: italic;
}

.sidebar-loading-item i {
    margin-right: 8px;
}

/* ===== 用戶資訊區塊 ===== */
.user-info-item {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid var(--bg-primary-lightest);
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--bg-primary-lightest) 0%, var(--bg-primary-soft) 100%);
}

.sidebar-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    flex-shrink: 0;
    box-shadow: var(--shadow-primary);
}

.sidebar-user-details {
    flex: 1;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-darker);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 12px;
    color: var(--primary-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 登入連結樣式 */
.login-link {
    background: var(--primary-gradient);
    color: white !important;
    margin: 12px 12px 8px 12px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.login-link:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-primary);
}

.login-link i {
    color: white !important;
}

/* 登出連結樣式 */
.logout-link {
    color: #d32f2f !important;
}

.logout-link:hover {
    background: #ffebee;
    color: #c62828 !important;
}

.logout-link i {
    color: #d32f2f !important;
}

/* ===== 多語系選單樣式 ===== */
#languageMenu li {
    position: relative;
}

#languageMenu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px 10px 56px;
}

.language-check {
    position: absolute;
    left: 36px;
    font-size: 12px;
    color: var(--primary-color);
    transition: opacity 0.3s ease;
}

#languageMenu li a:hover .language-check {
    opacity: 0.5 !important;
}

/* ===== 選單區塊標題（可選） ===== */
.menu-section-title {
    padding: 12px 20px 6px;
    font-size: 11px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* ===== 遮罩層 ===== */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1040;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(3px);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ===== 響應式設計 ===== */
@media (max-width: 576px) {
    .sidebar {
        width: 85vw;
        max-width: 300px;
    }

    .sidebar-header h3 {
        font-size: 18px;
    }

    .menu-link {
        padding: 12px 14px;
    }

    .menu-link span {
        font-size: 14px;
    }
}

/* ===== 防止 body 捲動 ===== */
body.sidebar-open {
    overflow: hidden;
    height: 100vh;
}