/* Dashboard Layout */
.dashboard-vh {
    height: 100vh;
    display: flex;
    overflow: hidden;
    background-color: var(--background);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    padding: 0.5rem;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.sidebar-close:hover {
    color: #ef4444;
}

.sidebar-menu {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.25rem;
    transition: var(--transition);
}

.menu-item:hover,
.menu-item.active {
    background-color: var(--surface-alt);
    color: var(--primary);
}

.menu-item i {
    width: 20px;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Main Content Area */
.main-dashboard {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dashboard-header {
    height: var(--header-height);
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
}

.header-logo {
    display: none;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    color: var(--primary);
    font-size: 1.25rem;
    transition: var(--transition);
    cursor: pointer;
}

.header-logo:hover {
    transform: scale(1.05);
}

.header-logout {
    display: none;
    color: #ef4444;
    padding: 0.5rem;
    border-radius: 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    transition: var(--transition);
    align-items: center;
    justify-content: center;
}

.header-logout:hover {
    background: #ef4444;
    color: white;
    transform: translateY(-2px);
}

.content-body {
    flex: 1;
    padding: 2.5rem;
    overflow-y: auto;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    margin-bottom: 3rem;
}

.stat-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Table Card */
.table-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background-color: var(--surface-alt);
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
}

.data-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

#sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    padding: 0.5rem;
    margin-right: 0.5rem;
}

/* Responsive */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    #sidebar-toggle {
        display: flex !important;
    }

    .header-logo {
        display: flex !important;
    }

    .header-logout {
        display: flex !important;
    }

    .sidebar {
        width: 280px;
        /* Width when active, but off-screen */
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 1000;
        overflow-y: auto;
        box-shadow: none;
        background-color: var(--surface);
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    }

    /* Reset logo and text visibility for the active mobile sidebar */
    /* Hide sidebar header (brand) on mobile/tablet */
    .sidebar-header {
        display: flex;
        /* Ensure logo is visible in mobile sidebar */
        padding: 0 1.5rem;
    }

    .sidebar-close {
        display: flex;
        margin-left: auto;
    }

    .dashboard-header .theme-toggle {
        display: none !important;
    }

    .main-dashboard {
        width: 100%;
        margin-left: 0;
        min-width: 0;
        /* Prevent overflow */
    }

    .dashboard-header {
        padding: 0 1rem;
        gap: 0.5rem;
    }

    .dashboard-header h3 {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
    }

    .user-badge span {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .content-body {
        padding: 1rem;
    }

    .table-card {
        overflow-x: auto;
        margin-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
    }

    /* Adjust cards to not touch edges if they do */
    .stat-card {
        padding: 1.5rem;
    }

    /* Show/Hide helpers */
    .hide-mobile {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .dashboard-header {
        padding: 0 0.75rem;
    }

    .dashboard-header h3 {
        max-width: 100px;
        font-size: 0.9rem;
    }

    .content-body {
        padding: 0.75rem;
    }

    .sidebar {
        width: 100%;
        /* Full screen sidebar on very small screens */
    }
}

@media (max-width: 360px) {
    .dashboard-header h3 {
        display: none;
        /* Hide title on very small screens to fit logo and toggle */
    }

    .header-logo {
        font-size: 1.1rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .dashboard-vh {
        overflow-x: hidden;
        /* Strict horizontal scroll prevention */
    }
}