/* Base layout styles */
body {
    font-family: 'Inter', sans-serif;
    background: #f8f9fa;
    color: #333;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
    z-index: 1060; /* Always keep sidebar above navbar */
    transform: none; /* Remove default transform */
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    visibility: visible; /* Ensure always visible */
}

/* Core Sidebar styles */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
    z-index: 1060; /* Always keep sidebar above navbar */
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    text-decoration: none;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand img {
    height: 35px;
    width: 35px;
    margin-right: 0.75rem;
}

.sidebar-brand span {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar .nav-link {
    padding: 0.75rem 1.25rem;
    color: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s;
    border-left: 3px solid transparent;
    margin: 0.25rem 1rem;
    border-radius: 8px;
    position: relative;
}

.sidebar .nav-link i {
    font-size: 1.25rem;
    width: 24px;
    margin-right: 0.75rem;
    text-align: center;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.sidebar .nav-link.active {
    color: #fff;
    background: rgba(52, 152, 219, 0.3);
}

.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    left: -1rem;
    top: 50%;
    transform: translateY(-50%);
    height: 1.5rem;
    width: 4px;
    background: #3498db;
    border-radius: 0 4px 4px 0;
}

.nav-group {
    margin-bottom: 0.5rem;
}

.nav-header {
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.mt-4 {
    margin-top: 2rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}

.sidebar-footer .nav-link {
    margin: 0;
    padding: 0.75rem 1rem;
    border-radius: 8px;
}

/* Top Header Styles */
.top-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 260px;
    height: 70px;
    background: #fff;
    box-shadow: 0 1px 10px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    z-index: 1050; /* Always keep navbar below sidebar */
    transition: left 0.3s ease;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-left .menu-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #2c3e50;
    transition: all 0.3s;
}

.header-left .menu-toggle:hover {
    background: #f8f9fa;
}

.search-box {
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    gap: 0.5rem;
    width: 280px;
    transition: width 0.3s;
    border: 1px solid rgba(0,0,0,0.08);
    margin-left: 20px;
}

.search-box i {
    color: #6c757d;
    margin: 0 0.5rem;
}

.search-box input {
    border: none;
    background: none;
    outline: none;
    width: 100%;
    color: #495057;
    font-size: 0.875rem;
    padding: 0.5rem;
}

.search-box:focus-within {
    width: 300px;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-action {
    position: relative;
    background: #f8f9fa;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #2c3e50;
    transition: all 0.3s;
}

.header-action:hover {
    background: #e9ecef;
    color: #1a252f;
}

.header-action .badge {
    position: absolute;
    top: 0;
    right: 0;
    transform: translate(25%, -25%);
    background: #dc3545;
    color: white;
    font-size: 0.75rem;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px #fff;
    border: 2px solid #fff;
}

/* User Profile */
.header-profile {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    padding: 0;
    border: 2px solid rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
}

.header-profile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-profile:hover {
    transform: scale(1.05);
}

/* Dropdown Styles */
.dropdown-menu {
    border: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 0.5rem;
    animation: fadeIn 0.2s ease;
    padding: 0.5rem;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
    padding: 1rem;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.dropdown-header img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-weight: 600;
    color: #212529;
    margin-bottom: 0.25rem;
}

.user-email {
    font-size: 0.875rem;
    color: #6c757d;
}

.dropdown-body {
    padding: 0.5rem 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #495057;
    text-decoration: none;
    transition: all 0.2s;
    border-radius: 8px;
    font-size: 0.875rem;
}

.dropdown-item i {
    font-size: 1.125rem;
    color: #6c757d;
    width: 20px;
    text-align: center;
    margin-right: 0.75rem;
}

.dropdown-item:hover {
    background: #f8f9fa;
    color: #000;
}

.dropdown-item.text-danger {
    color: #dc3545;
}

.dropdown-item.text-danger i {
    color: #dc3545;
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-top: 1px solid #eee;
}

/* Menu Toggle Button */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    font-size: 1.5rem;
    color: #495057;
    cursor: pointer;
    transition: color 0.2s;
}

.menu-toggle:hover {
    color: #000;
}

/* Content Wrapper */
.wrapper {
    margin-left: 280px;
    padding-top: 70px;
    min-height: 100vh;
    width: calc(100% - 260px);
    transition: all 0.3s;
    background: #f8f9fa;
    transition: margin-left 0.3s ease;
}

.main-content {
    padding: 1.5rem;
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Responsive Styles */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1060; /* Maintain higher z-index on mobile */
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
        transition: transform 0.3s ease-in-out;
    }

    .sidebar.show {
        transform: translateX(0);
        visibility: visible;
    }

    .sidebar.show ~ .wrapper {
        pointer-events: none;
    }

    .top-header {
        left: 0;
        width: 100%;
        z-index: 1050; /* Maintain lower z-index on mobile */
    }

    .wrapper {
        margin-left: 0;
        width: 100%;
    }

    .menu-toggle {
        display: block;
    }

    .dropdown-menu {
        position: fixed !important;
        top: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: calc(100% - 2rem) !important;
        max-width: 360px;
        margin: 1rem auto !important;
        z-index: 2002; /* Above sidebar */
        pointer-events: all !important;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* Core Overlay styles */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1055; /* Between navbar and sidebar */
}

/* Desktop styles */
@media (min-width: 993px) {
    .sidebar {
        transform: none;
        display: flex !important;
        z-index: 1060; /* Maintain higher z-index on desktop */
    }
    
    .top-header {
        z-index: 1050; /* Maintain lower z-index on desktop */
    }
    
    .menu-toggle {
        display: none !important;
    }
    
    .wrapper {
        margin-left: 280px;
        width: calc(100% - 280px);
    }
}

/* Mobile styles */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1060; /* Maintain higher z-index on mobile */
    }

    .sidebar.show {
        transform: translateX(0);
    }
    
    .top-header {
        z-index: 1050; /* Maintain lower z-index on mobile */
    }
    
    .wrapper {
        margin-left: 0;
        width: 100%;
    }
    
    .menu-toggle {
        display: flex;
    }
}

@media (max-width: 768px) {
    .search-box {
        display: none;
    }

    .top-header {
        height: 60px;
        padding: 0 1rem;
    }

    .wrapper {
        padding-top: 60px;
    }

    .main-content {
        padding: 1rem;
    }

    .header-action {
        width: 36px;
        height: 36px;
    }

    .header-actions {
        gap: 0.5rem;
    }

    .header-action,
    .header-profile {
        width: 36px;
        height: 36px;
    }
}

/* Mobile Overlay - Updated styles */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: none;
    animation: none; /* Remove animation to prevent timing issues */
    backdrop-filter: blur(2px);
    pointer-events: all;
}

/* Prevent main content interaction when sidebar is open */
body.sidebar-open {
    overflow: hidden;
}

/* Remove these conflicting styles if they exist */
body.sidebar-open .wrapper {
    pointer-events: none;
}

body.sidebar-open .sidebar {
    pointer-events: auto;
}

body.sidebar-open .sidebar-overlay {
    pointer-events: auto;
    display: block;
}

/* Z-index hierarchy for modals and overlays */
.modal-backdrop {
    z-index: 1070;
}

.modal {
    z-index: 1080;
}
