/* TDC Core — Find a Dealer (Split-Panel: Leaflet + OpenStreetMap) */

/* ── Outer wrap ───────────────────────────────────────────────── */

#tdc-dealer-wrap {
    font-family: inherit;
    max-width: 100%;
}

/* ── Search bar ───────────────────────────────────────────────── */

#tdc-dealer-search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
}

#tdc-dealer-search {
    flex: 1;
    padding: 10px 14px;
    font-size: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.15s;
    min-width: 0;
}

#tdc-dealer-search:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.15);
}

#tdc-dealer-search-btn {
    padding: 10px 20px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

#tdc-dealer-search-btn:hover  { background: #005a87; }
#tdc-dealer-search-btn:disabled { opacity: 0.7; cursor: not-allowed; }

#tdc-dealer-locate-btn {
    padding: 10px 16px;
    background: #fff;
    color: #0073aa;
    border: 1px solid #0073aa;
    border-radius: 4px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

#tdc-dealer-locate-btn:hover   { background: #0073aa; color: #fff; }
#tdc-dealer-locate-btn:disabled { opacity: 0.7; cursor: not-allowed; }

/* ── Split layout ─────────────────────────────────────────────── */

#tdc-dealer-layout {
    display: flex;
    height: 580px;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

/* ── List panel (left, 42%) ───────────────────────────────────── */

#tdc-dealer-list-panel {
    width: 42%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ddd;
    background: #fff;
    overflow: hidden;
}

#tdc-dealer-list-header {
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    background: #f9f9f9;
    flex-shrink: 0;
}

#tdc-dealer-list-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #666;
}

#tdc-dealer-list-inner {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Dealer cards ─────────────────────────────────────────────── */

.tdc-dealer-card {
    padding: 13px 14px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    position: relative;
    transition: background 0.12s;
}

.tdc-dealer-card:last-child { border-bottom: none; }

.tdc-dealer-card:hover {
    background: #f5f9fc;
}

.tdc-dealer-card.tdc-dl-active {
    background: #eaf4fb;
    border-left: 3px solid #0073aa;
    padding-left: 11px;
}

/* distance badge — floated right, above the name */
.tdc-dl-dist {
    float: right;
    margin-left: 8px;
    margin-top: 1px;
    background: #e8f4fb;
    color: #0073aa;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 20px;
    white-space: nowrap;
}

.tdc-dl-name {
    font-size: 14px;
    font-weight: 600;
    color: #111;
    line-height: 1.35;
    overflow: hidden;  /* wrap around float */
}

.tdc-dl-subloc {
    font-size: 12px;
    color: #555;
    margin-top: 2px;
}

.tdc-dl-addr {
    font-size: 12px;
    color: #555;
    margin-top: 2px;
}

.tdc-dl-city {
    font-size: 12px;
    color: #777;
    margin-top: 1px;
}

.tdc-dl-meta {
    font-size: 12px;
    color: #555;
    margin-top: 4px;
}

.tdc-dl-meta a {
    color: #0073aa;
    text-decoration: none;
}

.tdc-dl-meta a:hover { text-decoration: underline; }

/* Loading / empty states */
.tdc-dl-loading,
.tdc-dl-empty {
    padding: 24px 16px;
    text-align: center;
    color: #888;
    font-size: 14px;
    font-style: italic;
}

/* ── Map panel (right, flex:1) ────────────────────────────────── */

#tdc-dealer-map-panel {
    flex: 1;
    position: relative;
    min-width: 0;
}

#tdc-dealer-map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #f0ede8; /* shown while tiles load */
    z-index: 0;
}

/* ── Leaflet attribution (legally required, visually minimized) ──
 * OSM's copyright policy requires visible attribution. We comply but
 * shrink to the smallest practically-readable size + low-contrast grey
 * so it doesn't compete with the dealer UI. The "Leaflet | " prefix is
 * removed in JS via setPrefix('') — Leaflet's MIT license doesn't
 * require it, only OSM's data attribution is mandatory. */
.leaflet-control-attribution {
    font-size: 9px !important;
    line-height: 1.3 !important;
    padding: 1px 5px !important;
    background: rgba(255, 255, 255, 0.65) !important;
    color: #888 !important;
}
.leaflet-control-attribution a {
    color: #888 !important;
    text-decoration: none !important;
}
.leaflet-control-attribution a:hover {
    text-decoration: underline !important;
}

/* ── Leaflet popup content ────────────────────────────────────── */

.leaflet-popup-content-wrapper {
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
    padding: 0;
}

.leaflet-popup-content {
    margin: 0;
    padding: 0;
}

.tdc-map-info {
    font-size: 14px;
    line-height: 1.55;
    padding: 14px 16px;
}

.tdc-map-info strong {
    display: block;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #111;
}

.tdc-map-info-sub {
    font-size: 12px;
    color: #555;
    margin-bottom: 4px;
}

.tdc-map-info-row {
    color: #444;
    font-size: 13px;
    margin: 3px 0;
}

.tdc-map-info-row a {
    color: #0073aa;
    text-decoration: none;
}

.tdc-map-info-row a:hover { text-decoration: underline; }

/* ── Mobile: stack list above map ─────────────────────────────── */

@media (max-width: 768px) {
    /* Stack list above map. Cancel the flex:1 on the panels so explicit
       heights below take effect — without this, flex:1 + flex-direction:column
       can collapse one of them to 0 height on iOS Safari.
       !important is used liberally here because Divi/page-builder themes
       commonly inject competing styles via .et_pb_* wrapper elements; without
       overrides, the map panel can lose its height entirely on mobile.
       Cache concerns: ?ver= is bumped on every plugin version, but server-side
       page caches (Cloudflare, WP Rocket) can serve stale CSS for hours. */
    #tdc-dealer-layout {
        flex-direction: column !important;
        height: auto !important;
        overflow: visible !important;
    }

    #tdc-dealer-list-panel {
        width: 100% !important;
        flex: 0 0 auto !important;
        border-right: none;
        border-bottom: 1px solid #ddd;
        max-height: 320px;
    }

    #tdc-dealer-map-panel {
        flex: 0 0 auto !important;
        position: relative !important;
        height: 420px !important;
        min-height: 420px !important;
        width: 100% !important;
        display: block !important;
    }

    #tdc-dealer-map {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 420px !important;
    }

    #tdc-dealer-search-bar {
        flex-wrap: wrap;
    }

    #tdc-dealer-search {
        width: 100%;
        flex-basis: 100%;
    }

    #tdc-dealer-search-btn,
    #tdc-dealer-locate-btn {
        flex: 1;
    }
}
