:root {
    --primary-color: #000000;
    --secondary-color: #000000a3;
    --success-color: #4cc9f0;
    --warning-color: #f8961e;
    --view-btn: #2db561;
    --danger-color: rgb(245, 51, 51);
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --gray-color: #6c757d;
    --sidebar-width: 250px;
    --sidebar-width-mobile: 280px;
    --header-height: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f7fb;
    color: var(--dark-color);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Mobile Menu Toggle Button */
.menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: var(--primary-color);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.menu-toggle:hover {
    background: var(--secondary-color);
    transform: scale(1.05);
}

/* Overlay for mobile - FIXED */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999; /* Để dưới sidebar nhưng trên content */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000; /* Cao hơn overlay */
    transition: transform 0.3s ease;
    left: 0;
    top: 0;
}

.logo {
    padding: 25px 20px;
    text-align: center;
    border-bottom: 1px solid #eee;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.logo h2 {
    color: white;
    font-size: 1.8rem;
    font-weight: 600;
}

.logo span {
    color: #ffd166;
}

.menu {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.menu::-webkit-scrollbar {
    width: 5px;
}

.menu::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 10px;
}

.menu-item {
    padding: 15px 25px;
    display: flex;
    align-items: center;
    color: var(--dark-color);
    text-decoration: none;
    transition: all 0.3s;
    border-left: 4px solid transparent;
    margin: 5px 10px;
    border-radius: 8px;
}

.menu-item:hover, .menu-item.active {
    background-color: rgba(67, 97, 238, 0.1);
    color: var(--primary-color);
    /* border-left-color: var(--primary-color); */
}

.menu-item i {
    width: 25px;
    margin-right: 15px;
    font-size: 1.1rem;
    text-align: center;
}

.logout {
    padding: 20px 25px;
    border-top: 1px solid #eee;
    background: #f8f9fa;
}

.logout-btn {
    display: flex;
    align-items: center;
    color: var(--gray-color);
    text-decoration: none;
    transition: all 0.3s;
    padding: 10px 15px;
    border-radius: 8px;
}

.logout-btn:hover {
    background-color: rgba(245, 51, 51, 0.1);
    color: var(--danger-color);
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width-mobile);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 80px 20px 20px 20px;
    }

    .menu-toggle {
        display: block;
    }

    .overlay {
        display: block;
    }

    /* Khi sidebar mở, vẫn có thể tương tác với main content */
    body.sidebar-active .main-content {
        transform: translateX(var(--sidebar-width-mobile));
        pointer-events: all; /* Cho phép tương tác */
    }
}

@media (max-width: 768px) {
    .sidebar.active {
        width: 100%;
        max-width: 320px;
    }

    body.sidebar-active .main-content {
        transform: translateX(320px);
    }

    .logo h2 {
        font-size: 1.5rem;
    }

    .menu-item {
        padding: 12px 20px;
    }

    .menu-item span {
        font-size: 0.95rem;
    }

    .menu-toggle {
        width: 40px;
        height: 40px;
        top: 15px;
        left: 15px;
    }
}

@media (max-width: 480px) {
    .sidebar.active {
        width: 100%;
        max-width: 280px;
    }

    body.sidebar-active .main-content {
        transform: translateX(280px);
    }

    .logo {
        padding: 20px 15px;
    }

    .logo h2 {
        font-size: 1.4rem;
    }

    .menu-item {
        padding: 10px 15px;
        margin: 3px 8px;
    }

    .menu-item i {
        font-size: 1rem;
        margin-right: 10px;
    }

    .menu-toggle {
        width: 40px;
        height: 40px;
        top: 12px;
        left: 12px;
        font-size: 1.2rem;
    }

    .main-content {
        padding: 70px 15px 15px 15px;
    }
}

/* Hiệu ứng cho main content khi sidebar mở */
@media (min-width: 1025px) {
    .main-content {
        transition: margin-left 0.3s ease;
    }
}

/* Animation cho menu items */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sidebar.active .menu-item {
    animation: slideIn 0.3s ease forwards;
}

.sidebar.active .menu-item:nth-child(1) { animation-delay: 0.1s; }
.sidebar.active .menu-item:nth-child(2) { animation-delay: 0.2s; }
.sidebar.active .menu-item:nth-child(3) { animation-delay: 0.3s; }
.sidebar.active .menu-item:nth-child(4) { animation-delay: 0.4s; }
.sidebar.active .menu-item:nth-child(5) { animation-delay: 0.5s; }
