/* File: public/css/sidebar.css */

/* Wrapper căn chỉnh */
.sidebar-toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    color: var(--text-color);
    cursor: pointer;
    width: 100%;
    transition: background-color 0.3s;
}

.sidebar-toggle-wrapper:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.sidebar-toggle-info {
    display: flex;
    align-items: center;
    gap: 5px;
}

.sidebar-toggle-info .menu-text {
    font-weight: 500;
}

/* Toggle Switch Container */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 64px;
    height: 26px;
    margin-left: auto;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* Slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

/* Checked state */
input:checked+.slider {
    /* [SỬA] Đổi từ #2196F3 sang biến màu chính (Xanh lá) */
    background-color: var(--primary-color, #198754);
}

input:checked+.slider:before {
    transform: translateX(36px);
}

/* Text Labels (ON/OFF inside switch) */
.slider::after {
    content: attr(data-off);
    color: #555;
    font-size: 10px;
    font-weight: bold;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

input:checked+.slider::after {
    content: attr(data-on);
    color: white;
    left: 8px;
    right: auto;
}

/* --- Cập nhật cho cấu trúc Menu Group mới --- */
.sidebar-content {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
    /* Trừ đi chiều cao của sidebar-header */
    padding-bottom: 20px;
}

.menu-group {
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    /* Đường gạch mờ ngăn cách các khối */
    padding-bottom: 5px;
}

.menu-group:last-child {
    border-bottom: none;
}

/* Style cho tiêu đề khối (Heading) */
.menu-heading {
    padding: 10px 15px;
    font-size: 12px;
    font-weight: bold;
    color: var(--text-color-secondary, #888);
    /* Màu chữ phụ */
    text-transform: uppercase;
    cursor: pointer;
    /* Cho phép click */
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background-color 0.2s;
}

.menu-heading:hover {
    background-color: rgba(0, 0, 0, 0.03);
    color: var(--primary-color, #333);
}

.menu-heading .toggle-icon {
    font-size: 18px;
    transition: transform 0.3s ease;
}

/* Style cho danh sách menu con */
.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    transition: max-height 0.3s ease-out;
    max-height: 500px;
    /* Đủ lớn để hiện hết các item */
}

/* Trạng thái thu hẹp */
.menu-list.collapsed {
    max-height: 0 !important;
    display: none;
    /* Ẩn hẳn để không chiếm chỗ */
}

/* Chỉnh lại padding cho các item bên trong */
/* Chỉnh lại padding cho các item bên trong */
.menu-list li a {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    /* Giảm padding */
    margin: 2px 8px;
    /* Giảm margin để tiết kiệm diện tích */
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.3s ease;
    border-radius: 10px;
    /* Bo góc nhỏ hơn một chút phù hợp với kích thước mới */
    white-space: nowrap;
    /* Đảm bảo không xuống dòng */
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-list li a:hover,
.menu-list li a.active {
    background-color: rgba(var(--primary-rgb), 0.08) !important;
    color: var(--primary-color) !important;
    box-shadow: none !important;
    transform: translateY(-1px);
    font-weight: 600;
}

.menu-list li a .menu-icon {
    margin-right: 10px;
    font-size: 20px;
}

/* Các link chưa phát triển */
a.coming-soon {
    cursor: not-allowed;
    opacity: 0.6;
}

/* --- Dark Mode Overrides for Sidebar --- */
html.dark-mode .menu-list li a:hover,
html.dark-mode .menu-list li a.active {
    background-color: rgba(var(--primary-rgb), 0.15) !important;
    color: var(--primary-color) !important;
    box-shadow: none !important;
}

/* Ensure icons also turn white/primary in dark mode active state */
html.dark-mode .sidebar-menu a.active .menu-icon,
html.dark-mode .sidebar-menu a:hover .menu-icon,
html.dark-mode .menu-list li a.active .menu-icon,
html.dark-mode .menu-list li a:hover .menu-icon {
    color: inherit !important;
}