/**
 * Dealers Map Page — Стили страницы дилеров
 *
 * @package avtostart2026
 */

/* ── Карта (Leaflet) ───────────────────────────────────────── */
#dealers-map {
    height: 450px;
    border: 1px solid var(--as-border);
    border-radius: var(--as-radius);
    background: var(--as-light-bg, #f8f9fa);
    z-index: 1;
}

#dealers-map .map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--as-text-muted);
    font-size: .95rem;
}

/* Кастомный маркер (SVG капля) */
.dealer-marker-icon {
    background: none !important;
    border: none !important;
}

/* Leaflet popup стилизация */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.leaflet-popup-content {
    margin: 0;
    font-family: 'Montserrat', sans-serif;
}

/* ── Тулбар ─────────────────────────────────────────────────── */
.dealers-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}

.dealers-count {
    font-weight: 600;
    color: var(--as-secondary);
}

/* ── Сайдбар фильтров ──────────────────────────────────────── */
.dealers-sidebar {
    background: #fff;
    border: 1px solid var(--as-border);
    border-radius: var(--as-radius);
    padding: 1.25rem;
    position: sticky;
    top: 88px;
}

.dealer-filter-group {
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--as-border);
}

.dealer-filter-group:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.dealer-filter-title {
    font-weight: 700;
    color: var(--as-secondary);
    font-size: .9rem;
    margin-bottom: .6rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.dealer-filter-group .form-check {
    margin-bottom: .25rem;
}

.dealer-filter-group .form-check-label {
    font-size: .9rem;
    cursor: pointer;
}

.dealer-filter-group .form-check-input:checked {
    background-color: var(--as-primary);
    border-color: var(--as-primary);
}

/* ── Карточка дилера ────────────────────────────────────────── */
.dealer-card {
    background: #fff;
    border: 1px solid var(--as-border);
    border-radius: var(--as-radius);
    overflow: hidden;
    transition: var(--as-transition);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.dealer-card:hover {
    box-shadow: var(--as-shadow-hover);
    border-color: var(--as-primary);
    transform: translateY(-3px);
}

.dealer-card.is-highlighted {
    border-color: var(--as-primary);
    box-shadow: 0 0 0 3px rgba(240, 95, 35, .2);
}

.dealer-img {
    height: 160px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--as-light-bg, #f8f9fa);
}

.dealer-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s;
}

.dealer-card:hover .dealer-img img {
    transform: scale(1.05);
}

.dealer-img .dealer-placeholder {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(240, 95, 35, .1);
    color: var(--as-primary);
    font-size: 1.5rem;
}

.dealer-body {
    padding: 1rem 1.15rem 1.15rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.dealer-type {
    display: inline-block;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    background: rgba(240, 95, 35, .1);
    color: var(--as-primary);
    padding: .15rem .5rem;
    border-radius: 3px;
    margin-bottom: .35rem;
    align-self: flex-start;
}

.dealer-name {
    font-size: .95rem;
    font-weight: 700;
    color: var(--as-secondary);
    margin: 0 0 .4rem;
    line-height: 1.3;
}

.dealer-info {
    font-size: .82rem;
    color: var(--as-text-muted);
    margin-bottom: .2rem;
    display: flex;
    align-items: flex-start;
    gap: .35rem;
}

.dealer-info i {
    flex-shrink: 0;
    margin-top: 2px;
}

.dealer-actions {
    display: flex;
    gap: .5rem;
    margin-top: auto;
    padding-top: .75rem;
    flex-wrap: wrap;
}

.dealer-actions .btn {
    font-size: .78rem;
    padding: .3rem .6rem;
}

.btn-show-map {
    font-size: .8rem;
    font-weight: 600;
    color: var(--as-primary);
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}

.btn-show-map:hover {
    text-decoration: underline;
}

/* ── Попап 2GIS ─────────────────────────────────────────────── */
.dealer-popup {
    font-family: 'Montserrat', sans-serif;
    max-width: 260px;
    padding: .75rem;
    line-height: 1.4;
}

.dealer-popup-type {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--as-primary, #F05F23);
    margin-bottom: .2rem;
}

.dealer-popup-name {
    font-weight: 700;
    font-size: .95rem;
    margin-bottom: .3rem;
    color: #2D3444;
}

.dealer-popup-address {
    font-size: .8rem;
    color: #666;
}

.dealer-popup-phone {
    font-size: .85rem;
    margin-top: .3rem;
}

.dealer-popup-phone a {
    color: var(--as-primary, #F05F23);
    font-weight: 600;
    text-decoration: none;
}

.dealer-popup-links {
    display: flex;
    gap: .75rem;
    margin-top: .5rem;
}

.dealer-popup-links a {
    font-size: .8rem;
    font-weight: 600;
    color: var(--as-primary, #F05F23);
    text-decoration: none;
}

.dealer-popup-links a:hover {
    text-decoration: underline;
}

/* ── Логотип дилера (над названием) ─────────────────────────── */
.dealer-logo-wrap {
    margin-bottom: .4rem;
}

.dealer-logo {
    max-width: 100%;
    max-height: 48px;
    object-fit: contain;
    border-radius: 4px;
}

/* ── Бейдж галереи на превью ───────────────────────────────── */
.dealer-gallery-trigger {
    position: relative;
    display: block;
}

.dealer-img-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: .7rem;
    padding: .15rem .4rem;
    border-radius: 4px;
    line-height: 1;
}

/* ── Лайтбокс (галерея) ───────────────────────────────────── */
.dealer-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
}

.dealer-lightbox.is-open {
    display: flex;
}

.dealer-lb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.85);
    cursor: pointer;
}

.dealer-lb-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90vw;
    height: 85vh;
}

.dealer-lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

.dealer-lb-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    opacity: .8;
    transition: opacity .2s;
}
.dealer-lb-close:hover { opacity: 1; }

.dealer-lb-prev,
.dealer-lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}
.dealer-lb-prev:hover,
.dealer-lb-next:hover { background: rgba(255,255,255,.3); }

.dealer-lb-prev { left: -56px; }
.dealer-lb-next { right: -56px; }

.dealer-lb-counter {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,.7);
    font-size: .85rem;
}

/* ── Пустое состояние ───────────────────────────────────────── */
.dealers-empty {
    text-align: center;
    padding: 3rem 1rem;
}

.dealers-empty-icon {
    font-size: 3.5rem;
    opacity: .2;
}

/* ── Мобильные ──────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    #dealers-map {
        height: 300px;
    }

    .dealers-sidebar {
        display: none;
        position: static;
        margin-bottom: 1rem;
    }

    .dealers-sidebar.sidebar-open {
        display: block;
    }
}

@media (max-width: 575.98px) {
    .dealer-img {
        height: 100px;
    }

    .dealer-body {
        padding: .75rem;
    }

    .dealer-name {
        font-size: .85rem;
    }

    .dealer-lb-prev { left: 8px; }
    .dealer-lb-next { right: 8px; }
    .dealer-lb-close { top: 8px; right: 8px; }
    .dealer-lb-content { width: 96vw; height: 75vh; }
}
