/* ============================================================================
   MAPBOX.CSS - Map Integration Styles
   ============================================================================

   Yellowkey Real Estate Management Platform
   Version: 1.0
   Last Updated: 2024-12-18

   Styles for Mapbox integration:
   - Map containers
   - Location picker
   - Property markers
   - Zone polygons
   - Zone selection

   Note: Uses rem units per project conventions (1rem = 16px)
   ============================================================================ */

/* ===== MAP CONTAINER STYLES ===== */

.mapbox-container {
    position: relative;
    width: 100%;
    height: 25rem; /* 400px */
    border-radius: var(--border-radius-lg, 0.75rem);
    overflow: hidden;
    border: 2px solid var(--border-light, #E4E4E4);
    background-color: var(--brand-grey-100, #F4F4F4);
}

.mapbox-container.large {
    height: 31.25rem; /* 500px */
}

.mapbox-container.small {
    height: 15.625rem; /* 250px */
}

.mapbox-container.fullscreen {
    height: 100vh;
    border-radius: 0;
    border: none;
}

/* Map loading state */
.mapbox-container.loading::after {
    content: 'Loading map...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary, #5A5F7D);
    font-size: 0.875rem;
}


/* ===== LOCATION PICKER STYLES ===== */

.map-picker-container {
    position: relative;
}

.map-picker-section {
    margin-bottom: 1.5rem;
}

.map-picker-section h3,
.map-picker-section .section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--brand-blue, #313b61);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.map-picker-section h3 i,
.map-picker-section .section-title i {
    color: var(--brand-yellow, #F3C130);
}

.map-picker-instructions {
    background: var(--brand-primary-50, #FFFEF5);
    border-left: 0.25rem solid var(--brand-yellow, #F3C130);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius-md, 0.5rem);
    font-size: 0.875rem;
    color: var(--brand-blue, #313b61);
}

.map-picker-instructions i {
    margin-right: 0.5rem;
    color: var(--brand-primary-600, #7c5f00);
}


/* ===== COORDINATE DISPLAY ===== */

.map-coordinates {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--brand-grey-100, #F4F4F4);
    border-radius: var(--border-radius-md, 0.5rem);
    font-size: 0.875rem;
}

.map-coordinates .coord-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.map-coordinates label {
    font-weight: 600;
    color: var(--text-secondary, #5A5F7D);
    margin: 0;
    min-width: 4.5rem;
}

.map-coordinates input {
    width: 9rem;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-light, #E4E4E4);
    border-radius: var(--border-radius-sm, 0.25rem);
    font-size: 0.8rem;
    background: var(--brand-white, #FFFFFF);
    color: var(--brand-black, #1C1B20);
}

.map-coordinates input:focus {
    outline: none;
    border-color: var(--brand-yellow, #F3C130);
    box-shadow: 0 0 0 0.125rem rgba(243, 193, 48, 0.2);
}


/* ===== CUSTOM MARKERS ===== */

.property-marker {
    width: 2rem;
    height: 2.5rem;
    cursor: pointer;
    background-color: var(--brand-yellow, #F3C130);
    border: 2px solid var(--brand-blue, #313b61);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.property-marker::after {
    content: '';
    width: 0.625rem;
    height: 0.625rem;
    background-color: var(--brand-blue, #313b61);
    border-radius: 50%;
    transform: rotate(45deg);
}

.property-marker:hover {
    background-color: var(--brand-primary-600, #D8A500);
    transform: rotate(-45deg) scale(1.1);
}

/* Agent marker variant */
.agent-marker {
    background-color: var(--brand-blue, #313b61);
    border-color: var(--brand-yellow, #F3C130);
}

.agent-marker::after {
    background-color: var(--brand-yellow, #F3C130);
}

/* Zone marker (red pin) */
.zone-marker {
    width: 2rem;
    height: 2.5rem;
    cursor: pointer;
    background-color: #dc3545;
    border: 2px solid #8b0000;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.3);
    animation: zonePinDrop 0.3s ease-out;
}

.zone-marker::after {
    content: '';
    width: 0.625rem;
    height: 0.625rem;
    background-color: #fff;
    border-radius: 50%;
    transform: rotate(45deg);
}

@keyframes zonePinDrop {
    0% {
        transform: rotate(-45deg) translateY(-1rem);
        opacity: 0;
    }
    100% {
        transform: rotate(-45deg) translateY(0);
        opacity: 1;
    }
}


/* ===== POPUP STYLES ===== */

.mapboxgl-popup-content {
    border-radius: var(--border-radius-md, 0.5rem);
    padding: 1rem;
    box-shadow: var(--shadow-lg, 0 0.625rem 1.5rem -0.1875rem rgba(0, 0, 0, 0.1));
    max-width: 18.75rem;
    font-family: var(--font-body, 'Inter', sans-serif);
}

.mapboxgl-popup-close-button {
    font-size: 1.25rem;
    color: var(--text-secondary, #5A5F7D);
    padding: 0.25rem 0.5rem;
}

.mapboxgl-popup-close-button:hover {
    color: var(--brand-blue, #313b61);
    background: var(--brand-grey-100, #F4F4F4);
    border-radius: var(--border-radius-sm, 0.25rem);
}

.property-popup {
    font-family: var(--font-body, 'Inter', sans-serif);
}

.property-popup h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--brand-blue, #313b61);
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
}

.property-popup p {
    font-size: 0.875rem;
    color: var(--text-secondary, #5A5F7D);
    margin: 0 0 0.25rem 0;
}

.property-popup p i {
    margin-right: 0.375rem;
    color: var(--brand-yellow, #F3C130);
}

.property-popup .popup-footer {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light, #E4E4E4);
}

.property-popup .popup-link {
    color: var(--brand-blue, #313b61);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    transition: color 0.2s ease;
}

.property-popup .popup-link:hover {
    color: var(--brand-primary-600, #7c5f00);
}

.property-popup .popup-link i {
    font-size: 0.75rem;
}


/* ===== ZONE POLYGON LEGEND ===== */

.zone-legend {
    position: absolute;
    bottom: 2rem;
    right: 1rem;
    background: var(--brand-white, #FFFFFF);
    padding: 1rem;
    border-radius: var(--border-radius-md, 0.5rem);
    box-shadow: var(--shadow-lg, 0 0.625rem 1.5rem -0.1875rem rgba(0, 0, 0, 0.1));
    z-index: 1;
    max-height: 15rem;
    overflow-y: auto;
    min-width: 10rem;
}

.zone-legend h5 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--brand-blue, #313b61);
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light, #E4E4E4);
}

.zone-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.8rem;
    color: var(--brand-black, #1C1B20);
}

.zone-legend-color {
    width: 1rem;
    height: 1rem;
    border-radius: var(--border-radius-sm, 0.25rem);
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}


/* ===== ZONE SELECTION COMPONENT ===== */

.zone-selection-section {
    margin-bottom: 1.5rem;
}

.zone-selection-section h4,
.zone-selection-section .section-subtitle {
    font-size: 1rem;
    font-weight: 600;
    color: var(--brand-blue, #313b61);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.zone-selection-section h4 i,
.zone-selection-section .section-subtitle i {
    color: var(--brand-yellow, #F3C130);
}

.zone-selection {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.zone-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    background: var(--brand-grey-100, #F4F4F4);
    border-radius: var(--border-radius-md, 0.5rem);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.zone-checkbox:hover {
    background: var(--brand-primary-50, #FFFEF5);
    border-color: var(--brand-primary-200, #FFF4B8);
}

.zone-checkbox.selected,
.zone-checkbox:has(input:checked) {
    background: var(--brand-primary-100, #FFFAE0);
    border-color: var(--brand-yellow, #F3C130);
}

.zone-checkbox input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    accent-color: var(--brand-yellow, #F3C130);
    cursor: pointer;
    flex-shrink: 0;
}

.zone-checkbox .zone-color-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.zone-checkbox label,
.zone-checkbox span:last-child {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--brand-blue, #313b61);
    cursor: pointer;
    margin: 0;
    line-height: 1.3;
}


/* ===== MAP ERROR STATES ===== */

.map-error-icon {
    font-size: 3rem;
}


/* ===== MAP CONTROLS CUSTOMIZATION ===== */

.mapboxgl-ctrl-group {
    border-radius: var(--border-radius-md, 0.5rem) !important;
    box-shadow: var(--shadow-md, 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1)) !important;
}

.mapboxgl-ctrl-group button {
    background-color: var(--brand-white, #FFFFFF) !important;
}

.mapboxgl-ctrl-group button:hover {
    background-color: var(--brand-grey-100, #F4F4F4) !important;
}

.mapboxgl-ctrl-geolocate {
    background-color: var(--brand-white, #FFFFFF) !important;
}


/* ===== RESPONSIVE STYLES ===== */

@media (max-width: 768px) {
    .mapbox-container {
        height: 18.75rem; /* 300px */
    }

    .mapbox-container.large {
        height: 25rem; /* 400px */
    }

    .map-coordinates {
        flex-direction: column;
        gap: 0.5rem;
    }

    .map-coordinates .coord-group {
        width: 100%;
    }

    .map-coordinates input {
        flex: 1;
        width: auto;
    }

    .zone-legend {
        max-width: 10rem;
        font-size: 0.75rem;
        padding: 0.75rem;
        bottom: 1rem;
        right: 0.5rem;
    }

    .zone-legend h5 {
        font-size: 0.8rem;
    }

    .zone-selection {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .mapbox-container {
        height: 15rem; /* 240px */
    }

    .mapbox-container.large {
        height: 18.75rem; /* 300px */
    }

    .zone-legend {
        position: relative;
        bottom: auto;
        right: auto;
        margin-top: 1rem;
        max-width: none;
        max-height: none;
    }
}


/* ===== PRINT STYLES ===== */

@media print {
    .mapbox-container {
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    .zone-legend {
        position: relative;
        bottom: auto;
        right: auto;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
