/* SFM Dealer Display - Premium Design System */

/* WRAPPER: Force 98vw to overcome Elementor constraints */
.sfm-dealer-wrapper {
    width: 98vw !important;
    position: relative !important;
    left: 50% !important;
    right: 50% !important;
    margin-left: -49vw !important;
    margin-right: -49vw !important;
    padding: 0 1vw !important;
    box-sizing: border-box !important;
}

/* CONTENT ROW: Solid Grid for Desktop */
/* CONTENT ROW: Solid Grid for Desktop */
.sfm-dealer-content {
    display: flex;
    flex-direction: column;
    /* Mobile: Column Stack */
    gap: 30px;
    margin-top: 20px;
}

/* Mobile: Force Map to Top */
.sfm-dealer-map-container {
    order: -1;
    height: 450px;
    /* Ensure height on mobile */
}

.sfm-dealer-list-sidebar {
    order: 1;
}

@media (min-width: 992px) {
    .sfm-dealer-content {
        display: grid;
        /* Reset to Grid for Desktop */
        grid-template-columns: 420px 1fr;
        /* Ultra-wide layout: List on left, Big Map on right */
        height: calc(100vh - 250px);
        min-height: 650px;
    }

    /* Reset Order for Desktop Grid default (Source Order) or specify if needed */
    .sfm-dealer-map-container {
        order: unset;
        height: 100% !important;
    }

    .sfm-dealer-list-sidebar {
        order: unset;
    }
}

/* FILTERS SECTION */
.sfm-dealer-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    background: #ffffff;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #edf2f7;
}

/* Base styles for both inputs and selects */
.sfm-dealer-filters select,
.sfm-dealer-filters input#sfm-search-input {
    flex: 1 !important;
    width: 0 !important;
    /* Force equal width distribution */
    min-width: 0 !important;
    /* Prevent flex overflow */
    padding: 0 16px !important;
    /* Exact padding */
    height: 50px !important;
    /* Fixed height for alignment */
    border: 2px solid #e2e8f0 !important;
    border-radius: 10px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #334155 !important;
    background-color: #ffffff !important;
    box-sizing: border-box !important;
    outline: none !important;
    line-height: normal !important;
    box-shadow: none !important;
    margin: 0 !important;
    /* Remove margins that break layout */
    -webkit-appearance: none !important;
    appearance: none !important;
    /* Remove default styling */
}

/* Specific Focus State */
.sfm-dealer-filters select:focus,
.sfm-dealer-filters input#sfm-search-input:focus {
    border-color: #03b2b1 !important;
    box-shadow: 0 0 0 3px rgba(3, 178, 177, 0.1) !important;
    z-index: 10;
}

/* Custom Arrow for Selects */
.sfm-dealer-filters select {
    cursor: pointer !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2303b2b1'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 20px !important;
    padding-right: 40px !important;
    /* Space for arrow */
}

/* Search Icon Styling */
.sfm-dealer-filters input#sfm-search-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2303b2b1' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 20px !important;
    padding-right: 40px !important;
    /* Make room for icon */
}

/* Placeholder Styling */
.sfm-dealer-filters input#sfm-search-input::placeholder {
    color: #94a3b8 !important;
    font-weight: 500 !important;
    opacity: 1 !important;
}

/* MAP STYLING */
.sfm-dealer-map-container {
    border-radius: 12px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.15);
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    height: 450px;
    /* Default for mobile */
}

@media (min-width: 992px) {
    .sfm-dealer-map-container {
        height: 100% !important;
    }
}

/* SIDE LIST Polish */
.sfm-dealer-list-sidebar {
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#sfm-dealer-list {
    list-style: none;
    margin: 0;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* CARD STYLING */
.sfm-dealer-item {
    background: #ffffff;
    border-radius: 12px;
    padding: 15px;
    border: 1px solid #edf2f7;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    gap: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.sfm-dealer-item:hover {
    transform: translateY(-3px);
    border-color: #03b2b1;
    box-shadow: 0 8px 16px rgba(3, 178, 177, 0.1);
}

.sfm-item-thumb {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    background-size: cover;
    /* Thumbnail stays covered for neatness */
    background-position: center;
    flex-shrink: 0;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
    cursor: pointer;
    /* Indicate clickable */
}

/* EXPAND CARD ON ACTIVE */
.sfm-dealer-item.active-dealer {
    border-color: #03b2b1;
    background: #f0fdfa;
    box-shadow: 0 4px 12px rgba(3, 178, 177, 0.15);
    flex-direction: column;
    /* Stack vertically when active */
}

.sfm-dealer-item.active-dealer .sfm-item-thumb {
    width: 100%;
    height: 200px;
    background-size: contain;
    /* Fit whole image */
    background-repeat: no-repeat;
    background-color: #e2e8f0;
    /* Gray background for empty space */
}

.sfm-item-info {
    flex: 1;
    min-width: 0;
    /* Important for truncation */
}

.sfm-item-header h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: #1e293b;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sfm-item-city {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
}

.sfm-item-address {
    font-size: 13px;
    color: #475569;
    line-height: 1.4;
    margin-bottom: 12px;
    /* 2 Line Truncation */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sfm-item-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid #f1f5f9;
    padding-top: 10px;
}

.sfm-footer-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sfm-item-phone {
    font-size: 13px;
    color: #03b2b1;
    font-weight: 700;
    text-decoration: none;
}

.sfm-item-type-badge {
    background: #f1f5f9;
    color: #64748b;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
}

.sfm-item-type-badge.sfm-badge-service {
    color: #f97316;
    background: #fff7ed;
}

.sfm-item-type-badge.sfm-badge-both {
    color: #03b2b1;
    background: #f0fdfa;
    border: 1px solid #ccfbf1;
}

/* Action Buttons */
.sfm-modern-popup a.leaflet-popup-close-button {
    top: 5px;
    right: 5px;
    background: #ef4444;
    /* Red background */
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    /* White X */
    font-size: 16px;
    font-weight: bold;
    text-decoration: none;
    padding: 0;
    z-index: 200;
}

.sfm-modern-popup a.leaflet-popup-close-button:hover {
    background: #dc2626;
    /* Darker red on hover */
    color: white;
}

.sfm-card-actions {
    display: flex;
    gap: 8px;
}

.sfm-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s;
}

.sfm-btn-nav {
    background: #03b2b1;
    color: white;
}

.sfm-btn-nav:hover {
    background: #028a8a;
    color: white !important;
}

.sfm-btn-nav.disabled {
    background: #cbd5e1;
    cursor: default;
}

/* Map Customizations */
.sfm-custom-pin {
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
}

.sfm-pin-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 800;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    z-index: 10;
}

.sfm-map-tooltip {
    background: #1e293b !important;
    border: none !important;
    border-radius: 6px !important;
    color: white !important;
    padding: 4px 8px !important;
    font-weight: 700 !important;
    font-size: 11px !important;
    /* Smaller text to avoid overlap */
    font-family: inherit !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.sfm-permanent-label {
    opacity: 0.8 !important;
}

.sfm-map-tooltip:before {
    border-top-color: #1e293b !important;
}

/* PHANTOM (GHOST) STYLING */
.sfm-phantom-pin {
    opacity: 0.7;
    filter: grayscale(100%);
}

.sfm-phantom-badge {
    background: #94a3b8 !important;
    border-color: #f1f5f9 !important;
}

.sfm-phantom-item {
    opacity: 0.8;
}

.sfm-phantom-item h4 {
    color: #64748b;
}

/* Removed grayscale from thumb to keep logo colors */
.sfm-phantom-item .sfm-item-thumb {
    filter: none;
}

/* PIN TYPE BADGES */
.sfm-service-badge {
    background: #f97316 !important;
    border-color: #fff7ed !important;
}

.sfm-both-badge {
    background: linear-gradient(180deg, #03b2b1 50%, #f97316 50%) !important;
    border-color: #ffffff !important;
}

/* LIGHTBOX STYLES */
.sfm-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sfm-lightbox-img {
    max-width: 80%;
    max-height: 80%;
    border: 5px solid white;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: white;
    /* Ensure transparency doesn't look bad */
}

/* Animation State */
.sfm-lightbox-overlay.active {
    opacity: 1;
}

.sfm-lightbox-overlay.active .sfm-lightbox-img {
    transform: scale(1);
}

/* MAP LEGEND STYLES */
.sfm-map-legend {
    position: absolute;
    bottom: 25px;
    left: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    font-family: inherit;
    border: 1px solid #e2e8f0;
    backdrop-filter: blur(4px);
}

.sfm-legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    white-space: nowrap;
}

.sfm-legend-item:last-child {
    margin-bottom: 0;
}

.sfm-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sfm-dot.dealer {
    background: #03b2b1;
}

.sfm-dot.service {
    background: #f97316;
}

.sfm-dot.both {
    background: linear-gradient(135deg, #03b2b1 50%, #f97316 50%);
}

.sfm-dot.phantom {
    background: #94a3b8;
}

/* Hide legend on very small screens if it covers too much */
@media (max-width: 400px) {
    .sfm-map-legend {
        padding: 8px;
        bottom: 20px;
        left: 5px;
        font-size: 10px;
    }
}

/* POPUP CARD MODERNIZATION */
.sfm-modern-popup .leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.sfm-modern-popup .leaflet-popup-content {
    margin: 0;
    width: 280px !important;
    /* Smaller width */
}

/* ... existing close button ... */

.sfm-popup-thumb {
    width: 100%;
    height: 140px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #f8fafc;
    cursor: zoom-in;
    /* Indicate clickable */
}

.sfm-popup-info {
    padding: 12px;
    /* Reduced padding */
}

.sfm-popup-info h4 {
    margin: 0 0 4px 0;
    font-size: 15px;
    /* Slightly smaller */
    color: #1e293b;
    font-weight: 800;
}

.sfm-popup-info .sfm-item-address {
    margin-bottom: 8px;
    font-size: 12px;
}

.sfm-popup-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.sfm-popup-actions {
    margin-top: 10px;
}


/* Reuse existing button styles but ensure full width */
.sfm-popup-actions .sfm-action-btn {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}