:root {
    --sidebar-width: 300px;
    --sidebar-collapsed-width: 85px;
    --sidebar-bg: #ffffff;
    --sidebar-dark-bg: #1a1b1e;
    --sidebar-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --accent-color: #f72585;
    --text-primary: #2b2d42;
    --text-secondary: #6c757d;
    --border-color: rgba(0, 0, 0, 0.08);
    --hover-bg: rgba(67, 97, 238, 0.05);
    --active-bg: rgba(67, 97, 238, 0.1);
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.02);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.15);
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    --animation-bounce: 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

[data-theme="dark"] {
    --sidebar-bg: #1a1b1e;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --border-color: rgba(255, 255, 255, 0.08);
    --hover-bg: rgba(255, 255, 255, 0.05);
    --active-bg: rgba(67, 97, 238, 0.2);
}

/* Main Layout */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    overflow-x: hidden;
}

.main-content {
    /*margin-right: var(--sidebar-width);*/
    transition: margin var(--transition-base);
    min-height: 100vh;
}

[dir="ltr"] .main-content {
    margin-right: 0;
    /*margin-left: var(--sidebar-width);*/
}

.sidebar.collapsed + .mobile-menu-btn + .main-content {
    margin-right: var(--sidebar-collapsed-width);
}

/* Sidebar Base */
.sidebar {
    position: fixed;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg)!important;
    color: var(--text-primary)!important;
    transition: all var(--transition-base);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border-left: 1px solid var(--border-color);
}

[dir="ltr"] .sidebar {
    left: 0;
    border-left: none;
    border-right: 1px solid var(--border-color);
}

/* Glass Effect */
.glass-effect {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

[data-theme="dark"] .glass-effect {
    background: rgba(26, 27, 30, 0.95);
}

/* Collapsed State */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width)!important;
}

    .sidebar.collapsed .logo-text,
    .sidebar.collapsed .profile-info,
    .sidebar.collapsed .header-title,
    .sidebar.collapsed .menu-badge,
    .sidebar.collapsed .search-shortcut,
    .sidebar.collapsed .item-text,
    .sidebar.collapsed .sidebar-footer .footer-item span {
        display: none;
    }

    .sidebar.collapsed .menu-header {
        justify-content: center;
        padding: 1rem;
    }

    .sidebar.collapsed .header-icon {
        margin: 0;
    }

    .sidebar.collapsed .header-arrow {
        display: none;
    }

    .sidebar.collapsed .search-box {
        padding: 0.25rem;
        justify-content: center;
    }

    .sidebar.collapsed .search-icon {
        margin: 0;
    }

/* Sidebar Header */
.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--sidebar-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: float 3s ease-in-out infinite;
}

    .logo-icon i {
        font-size: 1.5rem;
        color: white;
    }

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.toggle-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

    .toggle-btn:hover {
        background: var(--hover-bg);
        color: var(--primary-color);
        transform: scale(1.1);
    }

.mobile-close {
    display: none;
}

/* User Profile */
.user-profile {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.profile-avatar {
    position: relative;
    width: 48px;
    height: 48px;
}

    .profile-avatar img {
        width: 100%;
        height: 100%;
        border-radius: 16px;
        object-fit: cover;
        border: 2px solid var(--primary-color);
        transition: all var(--transition-base);
    }

    .profile-avatar:hover img {
        transform: scale(1.1);
        border-color: var(--accent-color);
    }

.status-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #10b981;
    border: 2px solid var(--sidebar-bg);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.profile-info {
    flex: 1;
}

    .profile-info h6 {
        margin: 0;
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--text-primary);
    }

.profile-role {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.profile-actions {
    position: relative;
}

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--hover-bg);
    color: var(--text-secondary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

    .action-btn:hover {
        background: var(--primary-color);
        color: white;
    }

/* User Dropdown */
.user-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 220px;
    background: var(--sidebar-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-base);
    z-index: 1060;
}

[dir="ltr"] .user-dropdown {
    left: auto;
    right: 0;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

    .dropdown-item:hover {
        background: var(--hover-bg);
        color: var(--primary-color);
        transform: translateX(5px);
    }

[dir="ltr"] .dropdown-item:hover {
    transform: translateX(-5px);
}

.dropdown-item i {
    font-size: 1.1rem;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

/* Impersonation Banner */
.impersonation-banner {
    margin: 0.5rem 1rem 1rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, #f59e0b20, #f9731620);
    border: 1px solid #f59e0b40;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    animation: slideInRight var(--transition-base);
}

    .impersonation-banner i {
        color: #f59e0b;
    }

    .impersonation-banner .btn-exit {
        margin-left: auto;
        width: 24px;
        height: 24px;
        border: none;
        background: transparent;
        color: #f59e0b;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all var(--transition-fast);
    }

        .impersonation-banner .btn-exit:hover {
            background: #f59e0b20;
            transform: scale(1.1);
        }

/* Search */
.search-wrapper {
    padding: 1rem 1.5rem;
    position: relative;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--hover-bg);
    border-radius: 12px;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

    .search-box:focus-within {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
    }

.search-icon {
    padding: 0.5rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

    .search-input:focus {
        outline: none;
    }

    .search-input::placeholder {
        color: var(--text-secondary);
        opacity: 0.7;
    }

.clear-search {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
    display: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

    .clear-search:hover {
        color: var(--primary-color);
        transform: scale(1.1);
    }

.search-shortcut {
    position: absolute;
    left: 2.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--hover-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    pointer-events: none;
}

[dir="ltr"] .search-shortcut {
    left: auto;
    right: 2.5rem;
}

/* Sidebar Menu */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 1rem;
}

    /* Scrollbar */
    .sidebar-menu::-webkit-scrollbar {
        width: 4px;
    }

    .sidebar-menu::-webkit-scrollbar-track {
        background: transparent;
    }

    .sidebar-menu::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 4px;
    }

        .sidebar-menu::-webkit-scrollbar-thumb:hover {
            background: var(--text-secondary);
        }

/* Menu Sections */
.menu-section {
    margin-bottom: 0.5rem;
    animation: slideInRight var(--transition-base);
    animation-fill-mode: both;
}

    .menu-section:nth-child(1) {
        animation-delay: 0.05s;
    }

    .menu-section:nth-child(2) {
        animation-delay: 0.1s;
    }

    .menu-section:nth-child(3) {
        animation-delay: 0.15s;
    }

    .menu-section:nth-child(4) {
        animation-delay: 0.2s;
    }

    .menu-section:nth-child(5) {
        animation-delay: 0.25s;
    }

    .menu-section:nth-child(6) {
        animation-delay: 0.3s;
    }

    .menu-section:nth-child(7) {
        animation-delay: 0.35s;
    }

    .menu-section:nth-child(8) {
        animation-delay: 0.4s;
    }

    .menu-section:nth-child(9) {
        animation-delay: 0.45s;
    }

.menu-header {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

    .menu-header::before {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        width: 100%;
        height: 100%;
        background: var(--hover-bg);
        transform: translateX(100%);
        transition: transform var(--transition-base);
    }

[dir="ltr"] .menu-header::before {
    right: auto;
    left: 0;
    transform: translateX(-100%);
}

.menu-header:hover::before {
    transform: translateX(0);
}

.menu-header:hover {
    color: var(--primary-color);
}

.menu-header.expanded {
    background: var(--active-bg);
    color: var(--primary-color);
}

.header-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

    .header-icon i {
        color: white;
        font-size: 1.1rem;
    }

.header-title {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.menu-badge {
    background: var(--hover-bg);
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
}

.header-arrow {
    font-size: 1rem;
    transition: transform var(--transition-base);
    position: relative;
    z-index: 1;
}

.menu-section.expanded .header-arrow {
    transform: rotate(180deg);
}

/* Menu Items */
.menu-items {
    padding: 0.25rem 2.5rem 0.25rem 0;
}

[dir="ltr"] .menu-items {
    padding: 0.25rem 0 0.25rem 2.5rem;
}

.menu-item {
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    font-size: 0.9rem;
}

    .menu-item::before {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        width: 100%;
        height: 100%;
        background: var(--hover-bg);
        transform: translateX(100%);
        transition: transform var(--transition-base);
    }

[dir="ltr"] .menu-item::before {
    right: auto;
    left: 0;
    transform: translateX(-100%);
}

.menu-item:hover::before {
    transform: translateX(0);
}

.menu-item:hover {
    color: var(--primary-color);
    transform: translateX(-5px);
}

[dir="ltr"] .menu-item:hover {
    transform: translateX(5px);
}

.menu-item.active {
    background: var(--active-bg);
    color: var(--primary-color);
    font-weight: 500;
}

    .menu-item.active::before {
        display: none;
    }

.menu-item i {
    font-size: 1.1rem;
    position: relative;
    z-index: 1;
}

.item-text {
    flex: 1;
    position: relative;
    z-index: 1;
}

.active-indicator {
    width: 4px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 50%;
    position: relative;
    z-index: 1;
    animation: pulse 2s infinite;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-around;
    border-top: 1px solid var(--border-color);
}

.footer-item {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

    .footer-item:hover {
        background: var(--hover-bg);
        color: var(--primary-color);
        transform: translateY(-2px);
    }

    /* Logout Button */
    .footer-item.logout-btn {
        background: linear-gradient(135deg, #ff6b6b, #ee5253);
        color: white;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        overflow: hidden;
    }

        .footer-item.logout-btn::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 0;
            height: 0;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.3);
            transform: translate(-50%, -50%);
            transition: width 0.6s, height 0.6s;
        }

        .footer-item.logout-btn:hover::before {
            width: 200px;
            height: 200px;
        }

        .footer-item.logout-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 20px rgba(238, 82, 83, 0.3);
        }

        .footer-item.logout-btn i {
            position: relative;
            z-index: 1;
            transition: transform 0.3s ease;
        }

        .footer-item.logout-btn:hover i {
            transform: rotate(180deg);
        }

/* Dropdown Logout Item */
.dropdown-item.logout-item {
    background: linear-gradient(135deg, #fff5f5, #fff);
    border-right: 3px solid #ee5253;
    margin: 0.25rem 0;
    border-radius: 8px;
    transition: all 0.3s ease;
}

[data-theme="dark"] .dropdown-item.logout-item {
    background: linear-gradient(135deg, #2d1a1a, #1e1e1e);
    border-right-color: #ff6b6b;
}

.dropdown-item.logout-item:hover {
    background: linear-gradient(135deg, #ff6b6b, #ee5253);
    color: white !important;
    transform: translateX(-5px);
    box-shadow: 0 5px 15px rgba(238, 82, 83, 0.3);
}

[dir="ltr"] .dropdown-item.logout-item:hover {
    transform: translateX(5px);
}

.dropdown-item.logout-item i {
    transition: transform 0.3s ease;
}

.dropdown-item.logout-item:hover i {
    transform: scale(1.2);
}

/* Floating Logout Button */
.floating-logout-btn {
    position: fixed;
    bottom: 80px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #ff6b6b, #ee5253);
    border: none;
    border-radius: 25px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(238, 82, 83, 0.3);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

[dir="ltr"] .floating-logout-btn {
    right: 20px;
    left: auto;
}

[dir="rtl"] .floating-logout-btn {
    left: 20px;
    right: auto;
}

.floating-logout-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(238, 82, 83, 0.5);
}

.floating-logout-btn i {
    transition: transform 0.3s ease;
}

.floating-logout-btn:hover i {
    transform: rotate(180deg);
}

/* Mobile Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

/* Mobile Toggle Button */
.mobile-menu-btn {
    position: fixed;
    top: 10px;
    z-index: 1045;
    width: 42px;
    height: 42px;
    background: var(--sidebar-gradient);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    display: none;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

[dir="ltr"] .mobile-menu-btn {
    left: 10px;
}

[dir="rtl"] .mobile-menu-btn {
    right: 10px;
}

.mobile-menu-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

/* Nolink Menu Item */
.menu-item.nolink {
    cursor: not-allowed;
    opacity: 0.8;
}

    .menu-item.nolink:hover {
        background: rgba(255, 107, 107, 0.1);
        color: #ff6b6b;
    }

/* Animations */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes progress {
    0% {
        width: 0%;
        left: 0;
    }

    50% {
        width: 100%;
        left: 0;
    }

    100% {
        width: 0%;
        left: 100%;
    }
}

/* Tooltip for Collapsed Mode */
.sidebar.collapsed [data-tooltip] {
    position: relative;
}

    .sidebar.collapsed [data-tooltip]:hover::after {
        content: attr(data-tooltip);
        position: fixed;
        right: var(--sidebar-collapsed-width);
        top: 50%;
        transform: translateY(-50%);
        background: var(--primary-color);
        color: white;
        padding: 0.5rem 1rem;
        border-radius: 8px;
        font-size: 0.85rem;
        white-space: nowrap;
        z-index: 1070;
        animation: fadeIn var(--transition-fast);
    }

[dir="ltr"] .sidebar.collapsed [data-tooltip]:hover::after {
    right: auto;
    left: var(--sidebar-collapsed-width);
}

/* Search Highlight */
.menu-item.highlight {
    animation: highlight 1s ease;
}

@keyframes highlight {
    0%, 100% {
        background-color: transparent;
    }

    50% {
        background-color: rgba(67, 97, 238, 0.2);
    }
}

/* No Results */
.no-search-results {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

    .no-search-results i {
        font-size: 3rem;
        opacity: 0.3;
        margin-bottom: 1rem;
    }

/* Loading State */
.menu-item.loading {
    position: relative;
    pointer-events: none;
}

    .menu-item.loading::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 1rem;
        width: 16px;
        height: 16px;
        border: 2px solid var(--border-color);
        border-top-color: var(--primary-color);
        border-radius: 50%;
        animation: spin 0.6s linear infinite;
    }

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        box-shadow: none;
    }

    [dir="ltr"] .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .mobile-menu-btn {
        display: flex;
    }

    .desktop-toggle {
        display: none;
    }

    .mobile-close {
        display: flex;
    }

    .sidebar.collapsed {
        width: var(--sidebar-width);
    }

        .sidebar.collapsed .logo-text,
        .sidebar.collapsed .profile-info,
        .sidebar.collapsed .header-title,
        .sidebar.collapsed .menu-badge,
        .sidebar.collapsed .search-shortcut,
        .sidebar.collapsed .item-text {
            display: block;
        }

        .sidebar.collapsed .menu-items {
            display: block !important;
        }

        .sidebar.collapsed .menu-header {
            justify-content: flex-start;
            padding: 0.75rem 1rem;
        }

        .sidebar.collapsed .header-icon {
            margin-left: 0.75rem;
        }

        .sidebar.collapsed .header-arrow {
            display: block;
        }

    .main-content {
        margin-right: 0 !important;
    }

    .floating-logout-btn {
        display: flex;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 85%;
        max-width: 320px;
    }

    .user-profile {
        padding: 1rem;
    }

    .profile-info h6 {
        font-size: 0.9rem;
    }

    .profile-role {
        font-size: 0.75rem;
    }

    .menu-header {
        padding: 0.6rem 0.75rem;
    }

    .header-title {
        font-size: 0.9rem;
    }

    .menu-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
}
