/**
 * HouzezHub OSM Desktop UI/UX Enhancements (v1.2.18+)
 * Sticky filter sidebar, dual-pane layout, card hover effects, marker tooltips
 * @version 1.0.0
 */

/* ============================================================
   TASK 13: ENHANCED DESKTOP FILTER SIDEBAR (280px fixed width)
   ============================================================ */

@media (min-width: 1024px) {
    .realtor-ca-inspired-interface {
        display: flex;
        flex-direction: column;
        /* The parent container already handles height */
        top: var(--theme-header-height, -180px);
    }

    /* Sticky sidebar filter panel */
    .osm-filters-panel-wrapper {
        position: relative;
        z-index: 10; /* Keep it above map content */
    }

    .osm-filters-panel.is-open {
        display: block;
    }

    /* Filter collapse toggle for desktop (hidden by default) */
    .osm-filters-panel .filters-collapse-toggle {
        display: none;
        position: absolute;
        top: 12px;
        right: 12px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 4px 8px;
        font-size: 18px;
        color: #666;
    }

    .osm-filters-panel .filters-collapse-toggle:hover {
        color: #333;
    }

    /* Filter group styling */
    .osm-filters-panel .filter-group {
        margin-bottom: 16px;
    }

    .osm-filters-panel .filter-group:last-child {
        margin-bottom: 0;
    }

    .osm-filters-panel .filter-group label {
        display: block;
        font-weight: 500;
        margin-bottom: 6px;
        font-size: 13px;
        color: #333;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .osm-filters-panel .form-control {
        width: 100%;
        padding: 10px 12px;
        border: 1px solid #ddd;
        border-radius: 4px;
        font-size: 14px;
        transition: border-color 0.2s, box-shadow 0.2s;
    }

    .osm-filters-panel .form-control:focus {
        outline: none;
        border-color: #0066cc;
        box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
    }

    /* Collapsible filter sections */
    .osm-filter-section {
        margin-bottom: 12px;
        border: 1px solid #e8e8e8;
        border-radius: 6px;
        overflow: hidden;
    }

    .osm-filter-section-header {
        background: #f9f9f9;
        padding: 12px;
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
        user-select: none;
        border-bottom: 1px solid #e8e8e8;
        transition: background-color 0.2s;
    }

    .osm-filter-section-header:hover {
        background: #f5f5f5;
    }

    .osm-filter-section-header-title {
        font-weight: 600;
        font-size: 14px;
        color: #333;
        flex: 1;
    }

    .osm-filter-section-badge {
        background: #0066cc;
        color: white;
        font-size: 11px;
        font-weight: 600;
        padding: 2px 6px;
        border-radius: 12px;
        min-width: 20px;
        text-align: center;
        margin-right: 8px;
    }

    .osm-filter-section-badge.zero {
        background: #e0e0e0;
        color: #999;
    }

    .osm-filter-section-toggle {
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        color: #666;
        transition: transform 0.3s;
    }

    .osm-filter-section.is-open .osm-filter-section-toggle {
        transform: rotate(180deg);
    }

    .osm-filter-section-content {
        padding: 12px;
        display: none;
        background: #fff;
    }

    .osm-filter-section.is-open .osm-filter-section-content {
        display: block;
        animation: slideDown 0.3s ease-out;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .osm-filter-section-content .form-control {
        margin-bottom: 10px;
    }

    .osm-filter-section-content .form-control:last-child {
        margin-bottom: 0;
    }

    /* Preset filter buttons */
    .osm-preset-filters {
        margin-bottom: 12px;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .osm-preset-btn {
        background: #f0f0f0;
        border: 1px solid #ddd;
        border-radius: 20px;
        padding: 6px 12px;
        font-size: 12px;
        cursor: pointer;
        transition: all 0.2s;
    }

    .osm-preset-btn:hover {
        background: #e0e0e0;
        border-color: #999;
    }

    .osm-preset-btn.active {
        background: #0066cc;
        color: white;
        border-color: #0066cc;
    }

    /* Clear all filters button */
    .osm-filter-clear-all {
        width: 100%;
        padding: 10px;
        background: #f5f5f5;
        border: 1px solid #ddd;
        border-radius: 4px;
        font-size: 13px;
        cursor: pointer;
        transition: all 0.2s;
        margin-top: 12px;
    }

    .osm-filter-clear-all:hover {
        background: #efefef;
        border-color: #bbb;
    }

    /* Search and apply buttons in sidebar */
    .osm-filters-panel .filter-group-actions {
        display: flex;
        gap: 8px;
        margin-top: 12px;
    }

    .osm-filters-panel .filter-group-actions .btn {
        flex: 1;
        padding: 10px;
        font-size: 13px;
        border-radius: 4px;
        border: none;
        cursor: pointer;
        transition: all 0.2s;
        font-weight: 500;
    }

    .osm-filters-panel .btn-primary {
        background: #0066cc;
        color: white;
    }

    .osm-filters-panel .btn-primary:hover {
        background: #0052a3;
        box-shadow: 0 2px 8px rgba(0, 102, 204, 0.3);
    }

    .osm-filters-panel .btn-secondary {
        background: #e0e0e0;
        color: #333;
    }

    .osm-filters-panel .btn-secondary:hover {
        background: #d0d0d0;
    }

    /* Scrollbar styling for sidebar */
    .osm-filters-panel-wrapper::-webkit-scrollbar {
        width: 6px;
    }

    .osm-filters-panel-wrapper::-webkit-scrollbar-track {
        background: #f5f5f5;
        border-radius: 3px;
    }

    .osm-filters-panel-wrapper::-webkit-scrollbar-thumb {
        background: #bbb;
        border-radius: 3px;
    }

    .osm-filters-panel-wrapper::-webkit-scrollbar-thumb:hover {
        background: #999;
    }

    /* ============================================================
       TASK 14: DUAL-PANE LAYOUT (70% map / 30% list)
       ============================================================ */

    /* Map and content panels side-by-side */
    .rci-main-content-wrapper {
        display: flex;
        flex: 1;
        min-height: 0; /* Fix for flexbox overflow issue */
        top: var(--theme-header-height, 80px);
    }

    .rci-map-panel {
        position: relative;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .rci-content-panel {
        position: relative;
        display: flex;
        flex-direction: column;
        background: #fff;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        overflow-y: auto; /* Enable vertical scrolling for the list panel */
    }

    /* Draggable divider between map and list */
    .rci-pane-divider {
        position: absolute;
        right: -6px;
        top: 0;
        width: 12px;
        height: 100%;
        cursor: col-resize;
        background: transparent;
        transition: background-color 0.2s;
        z-index: 100;
    }

    .rci-pane-divider::before {
        content: '';
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 2px;
        height: 40%;
        background: #d0d0d0;
        border-radius: 1px;
        transition: background-color 0.2s;
    }

    .rci-pane-divider:hover::before {
        background: #0066cc;
    }

    .rci-pane-divider.dragging {
        background: rgba(0, 102, 204, 0.1);
    }

    /* ============================================================
       TASK 16: PROPERTY CARD HOVER EFFECTS
       ============================================================ */

    .property-list-item {
        padding: 12px;
        border-bottom: 1px solid #f0f0f0;
        cursor: pointer;
        transition: all 0.2s;
        position: relative;
    }

    .property-list-item:hover {
        background: #f9f9f9;
        transform: translateX(4px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .property-card-preview {
        display: none;
        position: absolute;
        top: 0;
        left: 100%;
        width: 300px;
        background: white;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
        z-index: 200;
        overflow: hidden;
        margin-left: 12px;
        animation: fadeIn 0.2s ease-out;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: translateX(-10px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    .property-list-item:hover .property-card-preview {
        display: block;
    }

    .property-card-preview-header {
        height: 180px;
        background: #f0f0f0;
        position: relative;
        overflow: hidden;
    }

    .property-card-preview-image {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .property-card-preview-content {
        padding: 12px;
    }

    .property-card-preview-price {
        font-size: 16px;
        font-weight: 700;
        color: #0066cc;
        margin-bottom: 6px;
    }

    .property-card-preview-address {
        font-size: 13px;
        color: #666;
        margin-bottom: 8px;
        line-height: 1.4;
    }

    .property-card-preview-meta {
        display: flex;
        gap: 12px;
        font-size: 12px;
        color: #999;
        margin-bottom: 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid #f0f0f0;
    }

    .property-card-preview-actions {
        display: flex;
        gap: 6px;
    }

    .property-card-preview-actions button {
        flex: 1;
        padding: 8px;
        font-size: 12px;
        border: 1px solid #ddd;
        background: white;
        border-radius: 4px;
        cursor: pointer;
        transition: all 0.2s;
    }

    .property-card-preview-actions button:hover {
        background: #0066cc;
        color: white;
        border-color: #0066cc;
    }

    /* ============================================================
       TASK 17: SMART MAP MARKER TOOLTIPS
       ============================================================ */

    .leaflet-popup-content-wrapper {
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .leaflet-popup-tip {
        background: white;
    }

    /* Marker tooltip styling */
    .osm-marker-tooltip {
        background: white;
        border: 1px solid #ddd;
        border-radius: 6px;
        padding: 8px 12px;
        font-size: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
        white-space: nowrap;
        animation: tooltipFadeIn 0.15s ease-out;
    }

    @keyframes tooltipFadeIn {
        from {
            opacity: 0;
            transform: scale(0.95);
        }
        to {
            opacity: 1;
            transform: scale(1);
        }
    }

    .osm-marker-tooltip-price {
        font-weight: 700;
        color: #0066cc;
        margin-bottom: 4px;
    }

    .osm-marker-tooltip-address {
        color: #666;
        font-size: 11px;
    }

    .osm-marker-tooltip-meta {
        color: #999;
        font-size: 11px;
        margin-top: 4px;
    }

    /* Marker hover scaling */
    .leaflet-marker-icon {
        transition: transform 0.2s, filter 0.2s;
    }

    .leaflet-marker-icon:hover {
        transform: scale(1.2);
        filter: drop-shadow(0 2px 4px rgba(0, 102, 204, 0.4));
    }

    /* Cluster group styling */
    .marker-cluster {
        background-color: #0066cc;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        font-weight: 700;
        transition: all 0.2s;
        box-shadow: 0 2px 8px rgba(0, 102, 204, 0.3);
    }

    .marker-cluster:hover {
        transform: scale(1.1);
        box-shadow: 0 4px 12px rgba(0, 102, 204, 0.5);
    }

    .marker-cluster-small {
        background-color: #5fa3d8;
    }

    .marker-cluster-medium {
        background-color: #0066cc;
    }

    .marker-cluster-large {
        background-color: #003d7a;
    }
}

/* ============================================================
   RESPONSIVE: Hide desktop features on mobile
   ============================================================ */

@media (max-width: 1023px) {
    .osm-filters-panel-wrapper {
        grid-column: 1 / -1;
    }

    .rci-layout-container {
        display: flex;
        flex-direction: column;
        grid-column: 1 / -1;
    }

    .rci-map-panel {
        flex: 1;
        min-height: 400px;
    }

    .rci-content-panel {
        flex: 1;
        min-height: 300px;
    }

    .property-card-preview {
        display: none;
    }

    .osm-filter-section {
        margin-bottom: 8px;
    }
}
