/*
 * Housing Page Styles - Rosewood Ridge Site
 */

@import url('variables.css');

.housing-page .container {
    max-width: 1600px; /* Wider container for grid */
    background: var(--gradient-dark); /* Use a gradient */
    border: 1px solid var(--accent-color);
    padding: 2rem 2.5rem;
}

.housing-page h1 {
    text-align: center;
    color: var(--highlight-color);
    margin-bottom: 0.5rem;
    font-size: 2.8rem;
    font-weight: 700;
}

.housing-page .page-description {
    text-align: center;
    color: var(--text-secondary-color);
    margin-bottom: 1.5rem; /* Reduced margin */
    font-size: 1.1rem;
}

/* Filter and Sort Controls Section - Refined */
.housing-controls {
    background-color: var(--inner-bg);
    padding: 1rem 1.5rem; /* Reduced padding */
    border-radius: var(--border-radius-std);
    margin-bottom: 2rem;
    display: grid;
    /* Adjust grid columns - increase min width slightly */
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); /* Adjusted min width slightly for new group */
    gap: 1rem 1.5rem; /* Adjust gap if needed */
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--box-shadow-light);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem; /* Reduced gap within group */
}

.filter-group label {
    font-weight: 500;
    color: var(--text-secondary-color);
    font-size: 0.85rem; /* Smaller label */
    margin-bottom: 0; /* Remove bottom margin */
    text-transform: uppercase; /* Optional: Uppercase labels */
    letter-spacing: 0;
}

.filter-group select,
.filter-group input[type="number"] {
    min-width: 0; /* Allow inputs/selects to shrink below their intrinsic minimum width */
}

/* New group for location filters */
.filter-group.location-filters {
    display: grid; /* Use grid for the two dropdowns */
    grid-template-columns: 1fr; /* Stack them initially */
    gap: 0.5rem; /* Gap between region and locale */
    /* Span across grid columns if needed, or let auto-fit handle it */
    /* grid-column: span 2; */ /* Example if you want it wider */
}

/* Style for subgroups within the location filter group */
.filter-group.location-filters .filter-subgroup {
    display: flex;
    flex-direction: column;
    gap: 0.3rem; /* Match other filter groups */
}

.filter-group.location-filters .filter-subgroup label {
    /* Inherits from .filter-group label */
}

.filter-group.location-filters .filter-subgroup select {
    /* Inherits from .filter-group select */
    width: 100%; /* Ensure selects fill their container */
}

/* Style disabled locale filter */
#localeFilter:disabled {
    background-color: rgba(50, 50, 50, 0.7); /* Dim background */
    cursor: not-allowed;
    opacity: 0.6;
}

/* Sort Group */
.filter-group.sort-group {
    /* Styles are likely fine, inherits from general .filter-group */
}

/* Reset Button Group */
.filter-group.reset-group {
    /* Align button to the bottom of the grid cell */
    justify-content: flex-end; /* Push content (button) down */
    padding-top: 1.2rem; /* Add space above button, roughly aligns baseline with inputs */
}

.filter-group.reset-group label {
    display: none; /* Hide the placeholder label visually */
}

.filter-group.reset-group button {
    width: 100%; /* Make button fill the grid cell */
    padding: 0.5rem 1rem; /* Match other button padding */
    font-size: 0.9rem; /* Match other button font */
    background-color: var(--accent-color); /* Style reset button */
}
.filter-group.reset-group button:hover {
    background-color: var(--highlight-color);
}

/* Specific styling for range inputs */
.filter-group.price-range,
.filter-group.storage-range {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.5rem; /* Ensure sufficient gap */
}

.filter-group.price-range label,
.filter-group.storage-range label {
    grid-column: 1 / -1;
    margin-bottom: 0;
}

.filter-group.price-range span,
.filter-group.storage-range span {
    text-align: center;
    color: var(--text-secondary-color);
    font-size: 0.9rem;
}

.filter-group.price-range input[type="number"],
.filter-group.storage-range input[type="number"] {
    min-width: 60px; /* Optional: Set a minimum practical width for number inputs */
}

/* Grid and Card Styles */
.housing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); /* Responsive grid */
    gap: 2rem;
}

.house-card {
    background-color: var(--inner-bg);
    border-radius: var(--border-radius-std);
    box-shadow: var(--box-shadow-std);
    overflow: hidden; /* Ensure image corners are rounded */
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative; /* For the badge */
}

.house-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.house-image-container {
    width: 100%;
    height: 200px; /* Fixed height for uniform look */
    overflow: hidden;
    position: relative; /* For badge positioning */
    background-color: #222; /* Placeholder bg */
    cursor: pointer; /* Indicate images are clickable */
}

.house-image {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Crop image to fit container */
    display: block;
    transition: transform 0.3s ease;
}

.house-card:hover .house-image {
    transform: scale(1.05); /* Slight zoom on hover */
}

.house-status-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.house-card.status-available .house-status-badge {
    background-color: rgba(40, 167, 69, 0.85); /* Green */
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.house-card.status-sold .house-status-badge {
    background-color: rgba(220, 53, 69, 0.85); /* Red */
    border: 1px solid rgba(255, 255, 255, 0.3);
}
/* Optional: Dim sold houses slightly */
.house-card.status-sold {
   opacity: 0.8;
}
.house-card.status-sold .house-image-container::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.2); /* Slight dark overlay */
    z-index: 1;
}

.house-card-content {
    padding: 1.25rem;
    flex-grow: 1; /* Allows content to fill space */
    display: flex;
    flex-direction: column;
    position: relative; /* Needed for absolute positioning of map icon */
}

/* Map Icon Button on Grid Card */
.locate-on-map-btn {
    position: absolute;
    bottom: 10px; /* Position near the bottom */
    right: 10px;  /* Position on the right */
    background: none;
    border: none;
    font-size: 1.8rem; /* Make emoji larger */
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    transition: transform 0.2s ease;
    opacity: 0.7;
}

.locate-on-map-btn:hover {
    transform: scale(1.2);
    opacity: 1.0;
}

.house-title {
    margin: 0 0 0.3rem 0;
    font-size: 1.4rem;
    color: var(--text-color);
    font-weight: 600;
}

.house-location {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--text-secondary-color);
    font-style: italic;
}

.house-details {
    margin-bottom: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.detail-label {
    color: rgba(243, 231, 216, 0.8); /* Slightly dimmer label */
    font-weight: 500;
}

.detail-value {
    color: var(--text-color);
    font-weight: 600;
}

.detail-item.price .detail-value {
    color: var(--bright-accent); /* Highlight price */
}

.house-notes {
    margin-top: auto; /* Push notes to the bottom */
    padding-top: 0.75rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
    font-size: 0.9rem;
    color: rgba(243, 231, 216, 0.7);
    line-height: 1.4;
}

.no-houses, .loading-message { /* Style for loading/no results */
    grid-column: 1 / -1; /* Span full width */
    text-align: center;
    color: var(--text-secondary-color);
    font-size: 1.2rem;
    padding: 3rem;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius-std);
}

/* Page Layout with Sidebar - Updated */
.housing-page {
    display: flex;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

.filter-sidebar {
    width: 300px; /* Fixed width */
    background-color: var(--inner-bg);
    padding: 1.5rem 1rem;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto; /* Allow sidebar itself to scroll if content overflows */
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.filter-sidebar h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--highlight-color);
    font-size: 1.4rem;
}

.main-content {
    flex-grow: 1;
    padding: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    overflow: hidden; /* Prevent main content itself from scrolling */
}

/* Filter Controls within Sidebar */
.housing-controls {
    flex-grow: 1; /* Allow controls to fill space */
}

/* Tab Styles */
.view-tabs {
    display: flex;
    background-color: var(--inner-bg); /* Match sidebar */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0; /* Prevent tabs from shrinking */
    /* Add margin-bottom to push grid content down */
    margin-bottom: 1.5rem; /* Adjust as needed */
}

.tab-button {
    padding: 0.8rem 1.5rem;
    background-color: transparent;
    border: none;
    color: var(--text-secondary-color);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.3s, background-color 0.3s;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px; /* Overlap the container border slightly */
}

.tab-button:hover {
    color: var(--highlight-color);
    background-color: rgba(255, 255, 255, 0.05);
}

.tab-button.active {
    color: var(--text-color);
    font-weight: 600;
    border-bottom-color: var(--highlight-color);
    background-color: var(--bg-color); /* Match main content background */
}

/* View Content Area */
.view-content {
    display: none;
    flex-grow: 1;
    overflow: hidden; /* Prevent view content itself from scrolling */
    position: relative;
}

.view-content.active {
    display: flex;
    flex-direction: column;
}

/* Grid View Specific - Updated for Scrolling */
#gridView {
    overflow-y: auto; /* Enable vertical scrolling */
    overflow-x: hidden; /* Disable horizontal scrolling */
    padding: 0 1.5rem 1.5rem 1.5rem; /* Add padding inside the scrollable area, REMOVE top padding */
    flex-grow: 1; /* Allow grid view to fill available space */
}

#gridView h1, #gridView .page-description {
    padding: 0 1rem; /* Keep padding for header/desc */
    flex-shrink: 0; /* Prevent header/desc from shrinking */
    /* Add margin below description if needed */
    margin-bottom: 1.5rem;
}

/* Custom Scrollbar for Grid View */
#gridView::-webkit-scrollbar {
  width: 10px; /* Width of the scrollbar */
}

#gridView::-webkit-scrollbar-track {
  background: var(--bg-color-lighter); /* Track color */
  border-radius: 5px;
}

#gridView::-webkit-scrollbar-thumb {
  background-color: var(--accent-color); /* Thumb color */
  border-radius: 5px;
  border: 2px solid var(--bg-color-lighter); /* Padding around thumb */
}

#gridView::-webkit-scrollbar-thumb:hover {
  background-color: var(--highlight-color); /* Thumb color on hover */
}

/* Map View Specific */
.map-view-content {
    padding: 0; /* Map takes full space */
}

#map {
    width: 100%;
    height: 100%; /* Fill the container */
    background-color: #1a1a1a; /* Dark background while map loads */
    flex-grow: 1;
}

/* Leaflet Customizations */
.leaflet-popup-content-wrapper {
    background-color: var(--inner-bg);
    color: var(--text-color);
    border-radius: var(--border-radius-std);
    box-shadow: var(--box-shadow-light);
}
.leaflet-popup-content {
    font-size: 0.9rem;
    line-height: 1.4;
    margin: 10px 15px; /* Adjust padding */
}
.leaflet-popup-content h4 {
    margin: 0 0 8px 0;
    color: var(--highlight-color);
    font-size: 1.1rem;
}
.leaflet-popup-content p {
    margin: 4px 0;
}
.leaflet-popup-content strong {
    color: var(--text-secondary-color);
    margin-right: 5px;
}
.leaflet-popup-tip {
    background-color: var(--inner-bg);
}
.leaflet-control-zoom a {
    background-color: var(--inner-bg);
    color: var(--text-color);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}
.leaflet-control-zoom a:hover {
    background-color: var(--highlight-color);
    color: var(--bg-color);
}
.leaflet-container {
   font-family: 'Roboto', sans-serif; /* Match site font */
}

/* Custom Marker Icon Styles */
.custom-map-marker {
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%; /* Make it circular if using SVG circle/emoji */
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    transition: transform 0.2s ease-out, color 0.2s ease-out;
    z-index: 650 !important; /* Ensure markers are above default overlay pane (400) and tile pane (200) */
}
.custom-map-marker svg {
    display: block; /* Ensure SVG behaves correctly */
}

.custom-map-marker:hover {
    transform: scale(1.2);
    z-index: 1000 !important; /* Bring marker to front on hover */
}

.marker-available {
    color: #28a745; /* Green fill for SVG, or text color for emoji */
}
.marker-available svg circle {
    stroke: #c8e6c9; /* Lighter green stroke */
}

.marker-sold {
    color: #dc3545; /* Red fill for SVG, or text color for emoji */
}
.marker-sold svg circle {
    stroke: #f8d7da; /* Lighter red stroke */
}

/* Leaflet Customizations - Updated Popup Styles */

/* Remove default Leaflet padding and background for our custom content */
.leaflet-popup-custom-styling .leaflet-popup-content-wrapper {
    padding: 0;
    background: transparent; /* Make wrapper transparent */
    box-shadow: none; /* Remove default shadow, we'll style the inner div */
    border-radius: var(--border-radius-std); /* Apply radius to wrapper */
    overflow: hidden; /* Ensure content respects border radius */
}

.leaflet-popup-custom-styling .leaflet-popup-content {
    margin: 0; /* Remove default margin */
    padding: 0; /* Remove default padding */
    width: auto !important; /* Override Leaflet's fixed width */
    min-width: 280px; /* Set a minimum width */
    max-width: 320px; /* Set a maximum width */
}

/* Style the main custom popup container */
.custom-leaflet-popup {
    background-color: var(--inner-bg);
    color: var(--text-color);
    border-radius: var(--border-radius-std); /* Match wrapper */
    box-shadow: var(--box-shadow-std);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden; /* Keep image corners rounded */
    display: flex;
    flex-direction: column;
}

/* Popup Image */
.popup-image-container {
    position: relative;
    width: 100%;
    height: 150px; /* Adjust height as needed */
    overflow: hidden;
    background-color: #222; /* Placeholder bg */
    cursor: pointer; /* Indicate images are clickable */
}

.popup-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Popup Status Badge (similar to card badge) */
.popup-status-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.custom-leaflet-popup.status-available .popup-status-badge {
    background-color: rgba(40, 167, 69, 0.85); /* Green */
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.custom-leaflet-popup.status-sold .popup-status-badge {
    background-color: rgba(220, 53, 69, 0.85); /* Red */
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.custom-leaflet-popup.status-sold {
   opacity: 0.9; /* Slightly dim sold popup */
}

/* Popup Content Area */
.popup-content {
    padding: 1rem;
}

.popup-title {
    margin: 0 0 0.2rem 0;
    font-size: 1.2rem;
    color: var(--text-color);
    font-weight: 600;
}

.popup-location {
    margin: 0 0 0.8rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary-color);
    font-style: italic;
}

.popup-details {
    margin-bottom: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.8rem;
}

.popup-detail-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.popup-detail-label {
    color: rgba(243, 231, 216, 0.8);
    font-weight: 500;
    margin-right: 0.5rem;
}

.popup-detail-value {
    color: var(--text-color);
    font-weight: 600;
    text-align: right;
}

.popup-detail-item.price .popup-detail-value {
    color: var(--bright-accent);
}

.popup-notes {
    margin: 0;
    padding-top: 0.6rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
    font-size: 0.8rem;
    color: rgba(243, 231, 216, 0.7);
    line-height: 1.4;
}

/* Style the popup tip to match */
.leaflet-popup-custom-styling .leaflet-popup-tip-container {
    width: 20px;
    height: 10px;
}
.leaflet-popup-custom-styling .leaflet-popup-tip {
    background: var(--inner-bg);
    border: none;
    box-shadow: none;
}

/* Adjust close button position/style if needed */
.leaflet-popup-custom-styling .leaflet-popup-close-button {
    color: var(--text-secondary-color);
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    line-height: 24px;
    font-size: 18px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    transition: color 0.2s, background-color 0.2s;
}
.leaflet-popup-custom-styling .leaflet-popup-close-button:hover {
    color: var(--text-color);
    background: rgba(0, 0, 0, 0.5);
}

/* Image Lightbox Styles */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85); /* Dark semi-transparent background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Ensure it's above everything */
    cursor: pointer; /* Indicate clicking closes it */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    position: relative;
    max-width: 75%; /* Leave 25% margin horizontally (12.5% each side) */
    max-height: 75%; /* Leave 25% margin vertically (12.5% each side) */
    display: flex; /* Use flex to help center image if needed */
    justify-content: center;
    align-items: center;
    cursor: default; /* Prevent background cursor on the image itself */
}

.lightbox-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Ensure whole image is visible */
    border-radius: var(--border-radius-std);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .housing-controls {
        /* Adjust minmax for medium screens */
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Adjust for medium screens */
    }
    .filter-group.reset-group {
        padding-top: 0; /* Remove padding adjustment on smaller screens */
        align-self: end; /* Align the whole group to the end */
    }
    .filter-group.reset-group label {
        display: block; /* Show label again if needed for alignment, but keep it empty */
    }
}

@media (min-width: 500px) { /* Adjust breakpoint as needed */
    .filter-group.location-filters {
        grid-template-columns: 1fr 1fr; /* Side-by-side on wider screens */
        gap: 1rem; /* Adjust gap for side-by-side */
        align-items: end; /* Align items to the bottom */
    }
    .filter-group.location-filters .filter-subgroup label {
         /* Keep labels above selects */
    }
}

@media (max-width: 768px) {
    .housing-page {
        flex-direction: column;
        height: auto;
        overflow: auto;
    }
    .filter-sidebar {
        width: 100%;
        height: auto;
        max-height: none; /* Remove max-height limit */
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        overflow-y: visible; /* Let content determine height */
    }
    .main-content {
        height: auto; /* Allow content height */
        overflow: visible; /* Allow content overflow */
    }
    #gridView {
        height: auto; /* Allow grid to take natural height */
        max-height: 70vh; /* Or set a max-height if preferred */
        padding: 1rem;
    }
    .map-view-content {
        height: 70vh; /* Keep map height constrained */
        padding: 0;
    }
    .housing-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.5rem;
    }
    .housing-page .container {
        padding: 1.5rem;
    }
    .house-image-container {
        height: 180px;
    }
    .house-title {
        font-size: 1.3rem;
    }
    .housing-controls {
        /* Adjust minmax for small screens */
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); /* Adjust for small screens */
        padding: 1rem;
        gap: 0.8rem;
    }
    .filter-group.location-filters {
        grid-template-columns: 1fr; /* Stack again on small screens */
        gap: 0.8rem;
    }
    .filter-group.reset-group {
       grid-column: 1 / -1; /* Make reset span full width on smallest screens */
       margin-top: 0.5rem; /* Add some space above */
    }
    .filter-group.reset-group label {
        display: none; /* Hide label again */
    }
}

@media (max-width: 480px) {
    .housing-grid {
        grid-template-columns: 1fr; /* Single column on very small screens */
        gap: 1rem;
    }
     .house-image-container {
        height: 160px;
    }
}

.housing-page {
    margin-top: -60px!important; 
}