/* --- Mobile UI Overrides (Max-width: 991px) --- */
@media (max-width: 991.98px) {

    /* 1. Navbar Fixes */
    .navbar-brand {
        font-size: 1.25rem !important; /* Readable size */
        white-space: normal; /* Allow wrapping */
        line-height: 1.2;
        max-width: 75%; /* Prevent overlapping hamburger */
        text-align: left;
    }

    .navbar-toggler {
        align-self: center;
        padding: 4px 8px;
        margin-top: 5px;
    }

    .navbar-collapse {
        text-align: center;
        background-color: #4a1a1a;
        padding-bottom: 15px;
        width: 100%;
    }

    .navbar-nav .nav-link {
        border-bottom: 1px solid rgba(255,255,255,0.1);
        padding: 12px 0;
        margin-left: 0 !important;
    }

    /* 2. Compact Page Header (Reclaim Real Estate) */
    .page-header {
        padding: 15px 0 !important;
        min-height: auto !important;
    }
    
    .header-title {
        font-size: 1.75rem !important;
        margin-bottom: 2px !important;
        line-height: 1.1;
    }
    
    .header-link {
        font-size: 0.85rem !important;
        opacity: 0.9;
    }

    /* 3. Hide Unnecessary Controls & Adjust Layout */
    .controls-right {
        display: none !important; /* Hide Wide/Narrow & Card/List buttons */
    }

    .controls-bar {
        padding: 5px 0 !important;
    }
    
    .controls-container {
        justify-content: center !important;
        min-height: 30px !important;
        flex-direction: column;
        gap: 5px;
    }

    #sticky-section-title {
        font-size: 1.2rem !important;
        margin: 0;
        text-align: center;
        opacity: 1 !important; /* Always show title on mobile */
        transform: none !important;
    }

    /* 4. Disable Main Sticky Wrapper on Mobile */
    /* We disable the main sticky header so it scrolls away, saving screen space */
    .sticky-wrapper {
        position: static !important; 
        box-shadow: none !important;
    }

    /* 5. Table Scrolling & Header Fix */
    .table-responsive-wrapper {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 20px;
    }
    
    .results-table {
        min-width: 600px; /* Force table width to trigger scroll */
    }

    /* Fix the Table Header Position */
    .results-table th {
        position: sticky;
        top: 0 !important; /* Stick to top of view, NOT 195px down */
        z-index: 10;
        background-color: #2c3e50;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }
    
    /* 6. Maximize Horizontal Space */
    .fluid-table-wrapper {
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100% !important;
    }
    
    /* 7. Card View Adjustments */
    .result-item-card {
        margin-bottom: 15px;
        height: auto !important;
        min-height: auto !important;
    }
}

/* --- Extra Small Screens (Phones < 576px) --- */
@media (max-width: 575.98px) {
    .navbar-brand {
        font-size: 1rem !important;
    }
    
    .header-title {
        font-size: 1.5rem !important;
    }
}