:root {
    --primary-blue: #58d8ff;
    --bg-grey: #cccccc;
    --panel-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

html, body {
    height: 100%;
    margin: 0;
}

/* Page Wrapper */
.page-wrapper {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    background-color: white;
    min-height: 150vh;
}

body {
    font-family: Arial, sans-serif;
    background-color: white;
    margin: 0;
    padding: 0;
}

.no-data-msg {
    grid-column: 1 / -1;
    text-align: center;
    color: #888;
    padding: 20px;
    font-style: italic;
}

/* Main Container - Keeps your requested width and margins */
.container {
    flex: 1; 
    width: 90%;
    max-width: 1400px;
    margin: 80px auto;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Panel Design */
.panel {
    background: var(--bg-grey);
    border-radius: 8px;
    box-shadow: var(--panel-shadow);
    overflow: hidden;
}

.panel-header {
    background-color: var(--primary-blue);
    padding: 12px 20px;
    font-weight: bold;
    font-size: 1.1rem;
    border-bottom: 2px solid #444;
}

/* Controls / Filters (Main List) */
.controls {
    padding: 10px 20px;
    background: #bbb;
    display: flex;
    justify-content: center; 
}

.filter-form {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    gap: 100px;
}

.filter-select {
    padding: 4px 8px;
    border: 1px solid #999;
    border-radius: 10px;
    background-color: var(--primary-blue);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
    height: 32px;
}

.search-container {
    display: flex;
    align-items: center;
    border: 1px solid #999;
    border-radius: 20px;
    background: white;
    padding: 2px 5px;
    height: 28px;
}

.search-bar {
    border: none;
    padding: 2px 8px;
    outline: none;
    width: 280px;
    font-size: 0.9rem;
}

/* Table Styling */
.table-header, .table-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    padding: 12px 20px;
    align-items: center;
}

.table-header {
    background: linear-gradient(to bottom, #eee, #999);
    font-weight: bold;
    border-top: 2px solid #ff8c00;
    border-bottom: 2px solid #555;
}

.table-row {
    border-bottom: 1px solid #aaa;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.table-row:hover { background-color: #f5f5f5; }
.selected-row { background-color: #e3f2fd !important; border-left: 4px solid #2196f3; }

.table-body {
    max-height: 400px;
    overflow-y: auto;
}

/* Status Dots */
.status { display: flex; align-items: center; gap: 8px; }
.dot { height: 12px; width: 12px; border-radius: 50%; display: inline-block; }
.red { background: red; box-shadow: 0 0 5px red; }
.orange { background: orange; box-shadow: 0 0 5px orange; }
.green { background: #2ecc71; box-shadow: 0 0 5px #2ecc71; }

/* Details Panel Expansion Logic */
.details-panel {
    display: none; /* Hidden by default */
    width: 500px;  /* Default size when showing details only */
    transition: width 0.3s ease;
}

.details-panel.active { display: block; }

/* The class triggered by JS when "View Occupants" is clicked */
.details-panel.expanded {
    width: 100%;
}

.details-layout {
    display: flex;
    width: 100%;
}

.details-content { 
    width: 500px;
    min-width: 500px;
    padding: 20px; 
    display: grid;
    grid-template-columns: 130px 20px 1fr; 
    gap: 15px 0;
    align-items: center;
    box-sizing: border-box;
}

.details-content p { display: contents; font-weight: bold; }
.details-content span { font-weight: bold; padding-left: 5px; }

/* Occupants Section (Appears at Right) */
.occupants-section {
    flex: 1;
    padding: 20px;
    border-left: 2px solid #999;
    display: none; /* Controlled by toggleOccupants() */
    background: #e0e0e0;
}

.occ-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.occ-search, .occ-filter {
    padding: 6px;
    border: 1px solid #999;
    border-radius: 4px;
    font-size: 0.85rem;
}

.occ-list-container {
    background: white;
    border-radius: 4px;
    /* Set height to fit exactly 10 rows (approx 400px) */
    height: 400px; 
    overflow-y: auto; /* Enables vertical scrolling */
    border: 1px solid #aaa;
}

/* Optional: Make the scrollbar look professional */
.occ-list-container::-webkit-scrollbar {
    width: 8px;
}

.occ-list-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.occ-list-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.occ-list-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.occ-row-header, .occ-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.occ-row-header {
    background: #f0f0f0;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid var(--primary-blue);
}

/* View Occupants Button */
.view-btn {
    grid-column: 1 / -1;
    justify-self: end;
    margin-top: 25px;
    background: linear-gradient(to bottom, #ff9d6c, #e67e22);
    border: 1px solid #d35400;
    padding: 8px 25px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

footer { flex-shrink: 0; }


/* --- MOBILE STYLES --- */
@media screen and (max-width: 768px) {
    .container {
        width: 100%;
        margin: 100px 0 20px 0;
        padding: 10px;
        gap: 15px;
    }

    /* FIX: Make the header disappear on mobile view */
    .table-header {
        display: none;
    }

    .table-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-row {
        /* Keep rows wide enough so columns don't stack */
        min-width: 500px;
        font-size: 0.8rem;
        padding: 10px;
    }

    .filter-form {
        flex-direction: column;
        gap: 12px;
        padding: 10px;
    }

    .search-container, .filter-select {
        width: 100%;
        max-width: 300px;
    }

    .details-layout {
        flex-direction: column;
    }

    .details-panel {
        width: 100% !important;
    }

    .details-content {
        width: 100%;
        min-width: 100%;
        grid-template-columns: 100px 15px 1fr;
        font-size: 0.85rem;
        padding: 15px;
    }

    .occupants-section {
        border-left: none;
        border-top: 2px solid #999;
        width: 100%;
    }

    .occ-row-header, .occ-row {
        min-width: 300px;
        font-size: 0.75rem;
    }
}