/* Layout */
.app-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
}

/* Sidebar - Premium Dark Aesthetic */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-light);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
    transition: var(--transition-base);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar.closed {
    transform: translateX(-100%);
}

.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-base);
}

.sidebar-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition-base);
}

body.sidebar-closed .main-content {
    margin-left: 0;
}

/* Modern Top Header / Navbar */
.top-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-soft);
}

/* --- Rest of Styles (Unchanged but cleaned) --- */

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    margin-bottom: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 30%, var(--primary-light) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.sidebar-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 1.5rem 1rem 0.5rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    opacity: 0.6;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.25rem;
    margin: 0.25rem 0;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition-base);
    gap: 12px;
    font-weight: 500;
}

.nav-link i {
    font-size: 1.25rem;
    transition: var(--transition-base);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    transform: translateX(4px);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: #fff;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
}

.nav-link.active i {
    color: #fff;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-link.logout {
    color: #fca5a5;
}

.nav-link.logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

#sidebar-toggle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition-fast);
}

#sidebar-toggle:hover {
    background: var(--bg-body);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

#page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-header);
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.icon-btn:hover {
    color: var(--primary-color);
    background: var(--primary-soft);
}

.header-actions .badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border: 2px solid #fff;
    border-radius: 50%;
    padding: 0;
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 50%;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-profile-dropdown {
    position: relative;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px 6px 6px;
    background: transparent;
    border: none;
    border-radius: 12px;
    transition: var(--transition-fast);
    cursor: pointer;
    outline: none;
}

.user-profile:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-header);
    line-height: 1.2;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.user-profile img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: var(--shadow-sm);
}

.user-profile i {
    color: var(--text-muted);
    font-size: 1.2rem;
    margin-left: 4px;
}

.content-wrapper {
    padding: 2.5rem;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

.badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    padding: 0.1rem 0.3rem;
    border-radius: 99px;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-premium);
    min-width: 240px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition-base);
    z-index: 1000;
    border: 1px solid var(--border-soft);
    padding: 0.5rem;
}

.user-profile-dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 1rem;
    margin-bottom: 0.5rem;
}

.dropdown-header p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}

.dropdown-header strong {
    font-size: 0.85rem;
    color: var(--text-main);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.7rem 1rem;
    color: var(--text-main);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    font-size: 0.9rem;
    font-weight: 500;
}

.dropdown-item i {
    font-size: 1.1rem;
    color: var(--text-muted);
}

.dropdown-item:hover {
    background: var(--bg-body);
    color: var(--primary-color);
}

.dropdown-item:hover i {
    color: var(--primary-color);
}

.dropdown-item.logout-link {
    color: var(--danger);
}

.dropdown-item.logout-link:hover {
    background: #fff1f2;
    color: #e11d48;
}

.dropdown-item.logout-link:hover i {
    color: #e11d48;
}

/* Components */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: #f9fafb;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-blocked {
    background: #fee2e2;
    color: #991b1b;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.btn-danger {
    background: #fee2e2;
    color: #ef4444;
}

.row-disabled {
    opacity: 0.6;
    background-color: var(--bg-body) !important;
}

.action-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: var(--border-soft);
    transform: translateY(-2px);
}

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        z-index: 2000; /* Above everything */
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 10px 0 50px rgba(0, 0, 0, 0.3);
    }

    .sidebar-backdrop {
        z-index: 1999; /* Just below sidebar */
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .top-header {
        padding: 0 1rem;
        height: 60px;
        z-index: 1000;
    }

    /* Target the header profile more aggressively to fix the mess */
    .top-header .user-profile {
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        box-shadow: none !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    .top-header .user-info, 
    .top-header .user-profile i {
        display: none !important;
    }

    .top-header .user-profile img {
        width: 36px;
        height: 36px;
        border: 2px solid var(--primary-soft);
        margin: 0;
        display: block;
    }

    .content-wrapper {
        padding: 1rem;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    min-width: 300px;
    max-width: 400px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    pointer-events: auto;
    animation: toast-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-left: 4px solid var(--primary-color);
}

.toast.removing {
    animation: toast-out 0.3s ease-in forwards;
}

.toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-header);
    margin-bottom: 4px;
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: 0.2s;
    font-size: 1.1rem;
}

.toast-close:hover {
    background: var(--bg-body);
    color: var(--danger);
}

@keyframes toast-in {
    from {
        transform: translateX(100%) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes toast-out {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Global Action Buttons */
.add-btn-primary {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.add-btn-primary:hover {
    background: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.add-btn-primary:active {
    transform: translateY(0);
}

/* Modal Enhancements */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
}

.custom-modal {
    background: #fff;
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (max-width: 480px) {
    .custom-modal {
        padding: 1.5rem 1rem;
        width: 95%;
    }
}

.modal-overlay.active .custom-modal {
    transform: scale(1);
}

.modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.icon-success { background: #d1fae5; color: #10b981; }
.icon-danger { background: #fee2e2; color: #ef4444; }
.icon-warning { background: #fef3c7; color: #f59e0b; }

.modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-header);
    margin-bottom: 0.75rem;
}

.modal-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.modal-input-group {
    text-align: left;
    margin-bottom: 1.25rem;
}

.modal-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-header);
    margin-bottom: 0.5rem;
}

.modal-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.2s;
}

.modal-input:focus {
    border-color: var(--primary-color);
}

.modal-footer {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.modal-btn {
    flex: 1;
    padding: 0.75rem;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-cancel { background: var(--bg-body); color: var(--text-muted); }
.btn-confirm-success { background: #10b981; color: #fff; }
.btn-confirm-danger { background: #ef4444; color: #fff; }
.btn-confirm-warning { background: #f59e0b; color: #fff; }