/* ================================================
   RIVENDITORI — Page-specific styles
   ================================================ */

/* ---------- Shared components (chip) ---------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ---------- Page Header ---------- */
.rv-header {
    padding: 108px 0 48px;
    background: var(--surface-0);
    border-bottom: 1px solid var(--border-soft);
}

.rv-header-grid {
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    gap: 56px;
    align-items: end;
}

.rv-header-text .chip {
    margin-bottom: 16px;
}

.rv-header-text h1 {
    font-size: clamp(1.75rem, 3.2vw, 2.625rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.rv-header-text p {
    font-size: 0.97rem;
    color: var(--text-muted);
    max-width: 500px;
    line-height: 1.6;
    margin: 0;
}

.rv-search-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rv-search-form {
    display: flex;
    gap: 8px;
}

.rv-search-input-wrap {
    position: relative;
    flex: 1;
}

.rv-search-input-wrap .rv-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--fourth-color);
    font-size: 14px;
    pointer-events: none;
}

.rv-search-input-wrap .input-lipo {
    padding-left: 40px;
    height: 46px;
}

.rv-search-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.rv-geo-status {
    font-size: 0.78rem;
    color: var(--fourth-color);
    margin: 0;
    min-height: 1rem;
}

/* ---------- Filter Bar ---------- */
.rv-filter-bar {
    position: sticky;
    top: 70px;
    z-index: 200;
    background: var(--surface-0);
    border-bottom: 1px solid var(--border-soft);
    padding: 14px 0;
    backdrop-filter: blur(12px);
}

.rv-filter-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.rv-filter-inner::-webkit-scrollbar {
    display: none;
}

.rv-filter-label {
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--fourth-color);
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    margin-right: 4px;
}

/* ---------- Filter pills ---------- */
.filter-pill {
    padding: 7px 14px;
    font-size: 12.5px;
    border-radius: 999px;
    background: var(--input-bg);
    border: 1px solid var(--border-med);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .15s;
    flex-shrink: 0;
    font-family: inherit;
    line-height: 1;
}

.filter-pill:hover:not(.active) {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-pill.active {
    background: var(--accent);
    color: #041024;
    border-color: var(--accent);
    font-weight: 600;
}

[data-bs-theme="light"] .filter-pill.active {
    color: #ffffff;
}

/* ---------- Split layout ---------- */
.rv-split {
    display: flex;
    align-items: flex-start;
}

/* ---------- Dealer list panel ---------- */
.rv-list-panel {
    width: 560px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-soft);
    background: var(--surface-0);
    min-height: calc(100vh - 116px);
    order: 1;
}

/* map is second in DOM but shown first on desktop via order */

.rv-results-count {
    padding: 12px 20px;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--fourth-color);
    font-weight: 600;
    border-bottom: 1px solid var(--border-soft);
}

/* ---------- Dealer card ---------- */
.dealer-card {
    border-bottom: 1px solid var(--border-soft);
    padding: 18px 20px;
    cursor: pointer;
    transition: background .15s;
    position: relative;
}

.dealer-card:hover {
    background: var(--input-bg);
}

.dealer-card.active {
    background: var(--accent-soft);
}

.dealer-card.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.dealer-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.dealer-card-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-strong);
    margin: 0 0 4px;
    line-height: 1.3;
}

.dealer-card-loc {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
}

.dealer-card-dist {
    font-size: 0.72rem;
    color: var(--accent);
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    padding-top: 2px;
}

.dealer-card-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 10px;
}

.dealer-card-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 10px;
    font-weight: 500;
}

.dealer-card-toggle i {
    transition: transform .2s;
    font-size: 10px;
}

.dealer-card.active .dealer-card-toggle i {
    transform: rotate(180deg);
}

/* ---------- Inline details ---------- */
.dealer-details {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--accent-soft);
    animation: slideDown .25s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dealer-details-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 14px 0 12px;
}

.dealer-details-section-label {
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--fourth-color);
    font-weight: 600;
    margin-bottom: 6px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dealer-details-hours {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

.dealer-details-closed {
    font-size: 0.75rem;
    color: var(--fourth-color);
    margin: 2px 0 0;
}

.dealer-details-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 4px;
}

/* Cat chip */
.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 6px;
    background: var(--input-bg);
    border: 1px solid var(--border-soft);
    color: var(--text-muted);
}

/* ---------- Empty state ---------- */
.empty-state {
    padding: 52px 24px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2rem;
    opacity: 0.35;
    display: block;
    margin-bottom: 12px;
}

.empty-state p {
    margin: 0 0 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-strong);
}

.empty-state small {
    font-size: 0.8rem;
    color: var(--fourth-color);
    display: block;
    margin-bottom: 16px;
}

/* ---------- Map panel ---------- */
.rv-map {
    flex: 1;
    min-width: 0;
    position: sticky;
    top: 116px; /* navbar 70px + filter bar ~46px */
    height: calc(100vh - 116px);
    order: 2;
}

/* ---------- Leaflet overrides ---------- */
.leaflet-container {
    background: var(--surface-0);
    font-family: "Inter", sans-serif;
}

[data-bs-theme="dark"] .leaflet-tile {
    filter: brightness(0.68) invert(0.96) contrast(1.1) hue-rotate(180deg) saturate(0.38);
}

.leaflet-control-zoom a {
    background: var(--first-color) !important;
    color: var(--text-strong) !important;
    border-color: var(--border-med) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--third-color) !important;
}

.leaflet-popup-content-wrapper {
    background: var(--first-color);
    color: var(--text-strong);
    border: 1px solid var(--border-med);
    border-radius: 8px;
    box-shadow: 0 12px 40px -12px rgba(0,0,0,0.5);
}

.leaflet-popup-tip {
    background: var(--first-color);
}

.leaflet-popup-content {
    margin: 10px 14px;
    font-size: 13px;
    line-height: 1.4;
}

.leaflet-popup-content strong {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.leaflet-popup-content span {
    font-size: 0.72rem;
    color: var(--fourth-color);
}

/* ---------- Custom dealer pins ---------- */
.dealer-pin {
    width: 28px;
    height: 28px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 2px solid var(--dark-second, #040910);
    box-shadow: 0 4px 12px rgba(0,0,0,0.35);
    display: grid;
    place-items: center;
    transition: transform .2s;
}

.dealer-pin i {
    font-size: 11px;
    transform: rotate(45deg);
    color: #040910;
}

.dealer-pin.active {
    transform: rotate(-45deg) scale(1.3);
}

.user-location-pin {
    width: 14px;
    height: 14px;
    background: #3B82F6;
    border-radius: 999px;
    border: 3px solid #ffffff;
    box-shadow: 0 0 0 6px rgba(59,130,246,0.25), 0 4px 12px rgba(0,0,0,0.3);
    animation: userPulse 2s infinite;
}

@keyframes userPulse {
    0%, 100% { box-shadow: 0 0 0 6px rgba(59,130,246,0.25), 0 4px 12px rgba(0,0,0,0.3); }
    50% { box-shadow: 0 0 0 12px rgba(59,130,246,0.08), 0 4px 12px rgba(0,0,0,0.3); }
}

/* ---------- Light theme overrides ---------- */
[data-bs-theme="light"] .rv-header {
    background: #F6F7FA;
}

[data-bs-theme="light"] .rv-filter-bar {
    background: rgba(246,247,250,0.94);
}

[data-bs-theme="light"] .rv-list-panel {
    background: #ffffff;
}

[data-bs-theme="light"] .dealer-card {
    border-color: rgba(14,30,55,0.08);
}

[data-bs-theme="light"] .dealer-card:hover {
    background: rgba(14,30,55,0.03);
}

[data-bs-theme="light"] .dealer-details {
    border-color: rgba(14,30,55,0.08);
}

[data-bs-theme="light"] .dealer-pin {
    border-color: #F6F7FA;
}

[data-bs-theme="light"] .dealer-pin i {
    color: #ffffff;
}

[data-bs-theme="light"] .leaflet-popup-content-wrapper {
    background: #ffffff;
}

[data-bs-theme="light"] .leaflet-popup-tip {
    background: #ffffff;
}

[data-bs-theme="light"] .leaflet-control-zoom a {
    background: #ffffff !important;
    color: var(--first-color) !important;
    border-color: rgba(14,30,55,0.14) !important;
}

/* ---------- Mobile ---------- */
@media (max-width: 991px) {
    .rv-header-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .rv-header-text p {
        max-width: 100%;
    }

}

@media (max-width: 767px) {
    .rv-header {
        padding: 80px 0 28px;
    }

    .rv-header-text h1 {
        font-size: clamp(1.5rem, 5vw, 2rem);
    }

    .rv-split {
        flex-direction: column;
    }

    .rv-map {
        position: relative;
        top: 0;
        height: 300px;
        width: 100%;
        order: 0;
    }

    .rv-list-panel {
        width: 100%;
        min-height: 0;
        border-right: none;
        border-top: 1px solid var(--border-soft);
        order: 0;
    }

    .rv-search-form {
        flex-wrap: nowrap;
    }

    .dealer-details-actions {
        grid-template-columns: 1fr 1fr;
    }

    .dealer-card-name {
        font-size: 0.85rem;
    }

    .rv-results-count {
        padding: 10px 16px;
    }

    .dealer-card {
        padding: 14px 16px;
    }

    .dealer-details {
        padding: 0 16px 16px;
    }
}
