/* General Page Layout */
.page-container {
    display: grid;
    /* Default mobile layout: single column, rows for header, content, nav */
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
    container-type: inline-size; /* Enable container queries */
}

.main-content {
    grid-column: 1 / 2; /* Takes full width on mobile */
    grid-row: 2 / 3; /* Positioned below mobile header */
    padding: 1rem; /* Mobile padding */
    background-color: #f9fafb; /* Light background */
    overflow-y: auto;
}

/* --- Shared Elements --- */
.icon-button {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: #6b7280; /* Gray */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-button:hover {
    color: #111827; /* Darker gray */
}

.export-button,
.view-details-button,
.filter-button,
.chip,
.sort-button {
    padding: 0.5rem 1rem;
    border-radius: 9999px; /* Pill shape */
    border: 1px solid #fecaca; /* Light red border */
    background-color: #fff; /* White background */
    color: #ef4444; /* Red text */
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem; /* Consistent font size */
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.export-button {
    background-color: #feefea; /* Very light orange/red */
    color: #d95d39; /* Darker orange/red */
    border: none;
}

.export-button:hover {
    background-color: #fddace;
}

.view-details-button:hover,
.filter-button:hover,
.chip:hover,
.sort-button:hover {
    background-color: #fef2f2; /* Lighter red background on hover */
}

.chip.active {
    background-color: #ef4444; /* Red background */
    color: #fff; /* White text */
    border-color: #ef4444;
}

/* --- Headers --- */
.mobile-header {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1rem 0 1rem; /* Padding for mobile header */
    background-color: #f9fafb; /* Match main content background */
}

.mobile-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.desktop-header {
    display: none; /* Hidden by default, shown in media query */
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0.5rem 0; /* Add some padding */
}

.desktop-header h1 {
    font-size: 1.875rem; /* Larger for desktop */
    font-weight: 700;
    margin: 0 1rem; /* Spacing around title */
}

.desktop-header .back-button {
    /* Style if needed */
}

.desktop-header .notification-button {
    margin-left: auto; /* Push notification to the right */
}

/* --- User Management Section --- */
.user-management-section {
    background-color: #fff;
    border-radius: 0.75rem; /* Rounded corners */
    padding: 1rem; /* Mobile padding */
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    container-type: inline-size; /* Container for table/controls */
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.25rem; /* Mobile heading size */
    font-weight: 600;
}

/* --- Controls --- */
.controls-container {
    margin-bottom: 1.5rem;
}

.mobile-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-button {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.desktop-controls {
    display: none; /* Hidden by default, shown in container query */
    grid-template-columns: 1fr auto auto; /* Search, Filters, Sort */
    gap: 1rem;
    align-items: center;
}

.search-bar {
    position: relative;
    display: flex;
    align-items: center;
}

.search-bar .search-icon {
    position: absolute;
    left: 0.75rem;
    color: #9ca3af; /* Medium gray */
    pointer-events: none; /* Allow clicking through icon */
}

.search-bar input[type="search"] {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem; /* Padding left for icon */
    border-radius: 9999px;
    border: 1px solid #e5e7eb; /* Light gray border */
    background-color: #f9fafb; /* Very light gray background */
    font-size: 0.875rem;
}

.filter-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap; /* Allow chips to wrap */
}

.sort-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-control label {
    color: #6b7280;
    font-size: 0.875rem;
}

.sort-button {
    padding: 0.5rem; /* Make it more square */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* --- User Table --- */
.table-container {
    overflow-x: auto; /* Allow horizontal scroll on small screens if needed */
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    container-type: inline-size; /* Enable container queries for the table */
}

.table-header {
    background-color: #feebea; /* Light pink/orange */
    color: #6b7280; /* Gray text */
    font-size: 0.875rem;
    text-align: left;
    display: none; /* Hide header by default for mobile-first */
}

.table-header th {
    padding: 0.75rem 1rem;
    font-weight: 500;
}

.table-body tr {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Mobile: 3 columns */
    gap: 0.5rem;
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb; /* Light gray border */
    align-items: center;
}

.table-body tr:last-child {
    border-bottom: none;
}

.table-body td {
    /* Mobile styles */
    text-align: left;
}

/* Add labels for mobile view using data attributes */
.table-body td::before {
    content: attr(data-label);
    font-weight: 500;
    display: block; /* Show labels on mobile */
    margin-bottom: 0.25rem;
    color: #6b7280;
    font-size: 0.8rem;
}

.table-body td[data-label="User Name"] {
    grid-column: 1 / 2;
    font-weight: 500;
    color: #111827;
}

.table-body td[data-label="User ID"] {
    grid-column: 2 / 3;
    color: #6b7280;
}

.table-body td[data-label="Status"] {
    grid-column: 3 / 4;
    justify-self: end; /* Align status badge to the right */
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.status-active {
    background-color: #dcfce7; /* Light green */
    color: #16a34a; /* Green */
}

.status-new {
    background-color: #dbeafe; /* Light blue */
    color: #2563eb; /* Blue */
}

.status-most-active {
    background-color: #fef9c3; /* Light yellow */
    color: #ca8a04; /* Yellow */
}

.status-default {
    background-color: #f3f4f6; /* Light gray */
    color: #6b7280; /* Gray */
}

.desktop-only {
    display: none; /* Hide desktop columns by default */
}

/* --- Responsive Adjustments --- */

/* Styles for the user management section container */
@container (min-width: 600px) {
    .user-management-section {
        padding: 1.5rem; /* Increase padding */
    }

    .section-header h2 {
        font-size: 1.5rem; /* Increase heading size */
    }

    .mobile-controls {
        display: none;
    }

    .desktop-controls {
        display: grid; /* Show desktop controls */
    }

    .table-header {
        display: table-header-group; /* Show table header */
    }

    .table-body tr {
        display: table-row; /* Switch back to standard table rows */
        border-bottom: 1px solid #e5e7eb;
    }

    .table-body td {
        display: table-cell; /* Switch back to standard table cells */
        padding: 0.75rem 1rem;
        vertical-align: middle;
        text-align: left;
    }

    .table-body td::before {
        display: none; /* Hide data-label pseudo-elements */
    }

    .table-body td[data-label="Status"] {
        justify-self: start; /* Reset alignment */
    }

    .desktop-only {
        display: table-cell; /* Show desktop columns */
    }
}

/* Styles for the main page container (affecting Sidebar/BottomNav visibility) */
@media (min-width: 768px) {
    .page-container {
        grid-template-columns: 250px 1fr; /* Fixed sidebar width */
        grid-template-rows: 1fr; /* Single row */
    }

    .main-content {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        padding: 2rem;
    }

    .mobile-header {
        display: none;
    }

    .desktop-header {
        display: flex;
    }

    .sidebar-container {
        /* Assuming Sidebar has this container class */
        display: block; /* Show sidebar */
    }

    .bottom-nav-container {
        /* Assuming BottomNav has this container class */
        display: none; /* Hide bottom nav */
    }
}

@media (max-width: 767.98px) {
    .sidebar-container {
        /* Assuming Sidebar has this container class */
        display: none; /* Hide sidebar */
    }
    .bottom-nav-container {
        /* Assuming BottomNav has this container class */
        display: block; /* Show bottom nav */
        grid-column: 1 / 2;
        grid-row: 3 / 4;
    }
}
