/* Where to Buy - Crumbl & Papa Banh Bao Split-Screen Styles */

.where-to-buy {
    position: relative;
    width: 100%;
    background-color: #f8fafc;
    min-height: calc(100vh - 100px);
}

/* ========================================================
   Mobile Elements Hidden on Desktop
   ======================================================== */
.where-to-buy__mobile-nav,
.where-to-buy__mobile-preview {
    display: none;
}

@media (min-width: 992px) {
    .where-to-buy__mobile-nav,
    .where-to-buy__mobile-preview {
        display: none !important;
    }
}

/* ========================================================
   Split Screen Layout Container
   ======================================================== */
.where-to-buy__container {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: calc(100vh - 100px);
    min-height: 640px;
    overflow: hidden;
    position: relative;
}

/* ========================================================
   Left Side: Interactive Map Pane
   ======================================================== */
.where-to-buy__map-pane {
    flex: 1 1 54%;
    height: 100%;
    position: relative;
    background-color: #e2e8f0;
    overflow: hidden;
}

.where-to-buy__map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
}

/* Mobile Floating Store Preview Bottom Sheet on Map */
.where-to-buy__mobile-preview {
    display: none;
    position: absolute;
    bottom: 24px;
    left: 16px;
    right: 16px;
    z-index: 1000;
    background-color: #ffffff;
    border-radius: 20px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
    padding: 16px 18px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.where-to-buy__mobile-preview--visible {
    display: block;
    animation: previewSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes previewSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.where-to-buy__mobile-preview-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #f1f5f9;
    border: none;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.15s ease;
    z-index: 2;
}

.where-to-buy__mobile-preview-close:hover {
    background-color: #e2e8f0;
    color: #0f172a;
}

/* Mobile Preview Content Inside Bottom Sheet */
.mobile-store-preview {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-store-preview__header {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding-right: 28px;
}

.mobile-store-preview__media {
    width: 60px;
    height: 60px;
    min-width: 60px;
    border-radius: 12px;
    overflow: hidden;
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-store-preview__thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mobile-store-preview__thumb-placeholder {
    color: #94a3b8;
    font-size: 22px;
}

.mobile-store-preview__info {
    flex: 1;
    min-width: 0;
}

.mobile-store-preview__badges {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.mobile-store-preview__name {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 4px;
    line-height: 1.3;
}

.mobile-store-preview__address {
    font-size: 13px;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
}

.mobile-store-preview__hours {
    font-size: 12px;
    color: #94a3b8;
    margin: 4px 0 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.mobile-store-preview__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 4px;
    border-top: 1px solid #f1f5f9;
}

.mobile-store-preview__btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mobile-store-preview__btn--primary {
    background-color: #0f172a;
    color: #ffffff;
}

.mobile-store-preview__btn--primary:hover {
    background-color: #ef4444;
}

.mobile-store-preview__btn--secondary {
    background-color: #f1f5f9;
    color: #334155;
}

.mobile-store-preview__btn--secondary:hover {
    background-color: #e2e8f0;
}

/* ========================================================
   Right Side: Store List & Search Panel
   ======================================================== */
.where-to-buy__panel {
    flex: 1 1 46%;
    max-width: 640px;
    min-width: 400px;
    height: 100%;
    overflow-y: auto;
    background-color: #ffffff;
    border-left: 1px solid #edf2f7;
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
}

/* Custom Scrollbar for Panel */
.where-to-buy__panel::-webkit-scrollbar {
    width: 6px;
}

.where-to-buy__panel::-webkit-scrollbar-track {
    background: #f8fafc;
}

.where-to-buy__panel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.where-to-buy__panel::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Panel Header */
.where-to-buy__panel-header {
    padding: 30px 32px 18px;
    border-bottom: 1px solid #f1f5f9;
    background-color: #ffffff;
    position: sticky;
    top: 0;
    z-index: 20;
}

.where-to-buy__header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.where-to-buy__title {
    font-size: 32px;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
    line-height: 1.15;
    letter-spacing: -0.025em;
}

.where-to-buy__pill-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 9999px;
    background-color: #fee2e2;
    color: #ef4444;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.where-to-buy__subtitle {
    font-size: 14px;
    color: #64748b;
    margin: 0 0 18px;
    line-height: 1.45;
}

/* Search Box */
.where-to-buy__search-box {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.where-to-buy__search-icon {
    position: absolute;
    left: 18px;
    color: #94a3b8;
    font-size: 16px;
    pointer-events: none;
    user-select: none;
}

.where-to-buy__search-input {
    width: 100%;
    height: 50px;
    padding: 0 44px 0 48px;
    font-size: 15px;
    color: #0f172a;
    background-color: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 9999px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
    box-sizing: border-box;
}

.where-to-buy__search-input:focus {
    background-color: #ffffff;
    border-color: #0f172a;
    box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.08);
}

.where-to-buy__search-clear {
    position: absolute;
    right: 14px;
    width: 26px;
    height: 26px;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: #e2e8f0;
    border: none;
    border-radius: 50%;
    color: #475569;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    transition: background-color 0.15s ease;
}

.where-to-buy__search-clear:hover {
    background-color: #cbd5e1;
    color: #0f172a;
}

/* Quick Bar: Geolocation & State Filter */
.where-to-buy__quick-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 4px;
}

.where-to-buy__geo-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 4px 0;
    color: #475569;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: opacity 0.15s ease;
}

.where-to-buy__geo-action:hover {
    opacity: 0.85;
}

.where-to-buy__geo-icon-wrap {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background-color: #fee2e2;
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.where-to-buy__geo-text {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}

.where-to-buy__geo-link {
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 600;
    color: #0f172a;
}

.where-to-buy__geo-desc {
    color: #64748b;
}

.where-to-buy__state-select-wrap {
    position: relative;
}

.where-to-buy__filter-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 7px 32px 7px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 9999px;
    border: 1px solid #e2e8f0;
    background: #ffffff url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6"><polygon fill="%2364748b" points="0,0 10,0 5,6"/></svg>') no-repeat right 12px center;
    color: #334155;
    outline: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.where-to-buy__filter-select:focus {
    border-color: #0f172a;
}

/* ========================================================
   Store List
   ======================================================== */
.where-to-buy__list {
    flex: 1;
    padding: 16px 24px 40px;
    list-style: none;
    margin: 0;
}

/* Dealer Card (BEM) */
.dealer-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    margin-bottom: 14px;
    background-color: #ffffff;
    border: 1.5px solid #f1f5f9;
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.dealer-card:hover {
    border-color: #cbd5e1;
    background-color: #fcfcfd;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

.dealer-card--active {
    border-color: #0f172a;
    background-color: #fafbfc;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.dealer-card__body {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.dealer-card__media {
    width: 68px;
    height: 68px;
    min-width: 68px;
    border-radius: 14px;
    overflow: hidden;
    background-color: #f8fafc;
    border: 1px solid #f1f5f9;
}

.dealer-card__thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dealer-card__thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f5f9;
    color: #94a3b8;
    font-size: 24px;
}

.dealer-card__content {
    flex: 1;
    min-width: 0;
}

.dealer-card__badges {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

/* Badges */
.dealer-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.2;
}

.dealer-badge--status {
    background-color: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.dealer-badge__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #10b981;
    display: inline-block;
}

.dealer-badge--featured {
    background-color: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.dealer-badge--distance {
    background-color: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.dealer-card__name {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 6px;
    line-height: 1.3;
}

.dealer-card__address {
    font-size: 13.5px;
    color: #475569;
    margin: 0 0 6px;
    line-height: 1.45;
    display: flex;
    align-items: flex-start;
    gap: 7px;
}

.dealer-card__address-icon {
    font-size: 14px;
    color: #94a3b8;
    margin-top: 2px;
    flex-shrink: 0;
}

.dealer-card__hours {
    font-size: 12.5px;
    color: #64748b;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dealer-card__hours-icon {
    font-size: 13px;
    color: #94a3b8;
    flex-shrink: 0;
}

.dealer-card__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.dealer-card__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.2;
}

.dealer-card__btn--primary {
    background-color: #0f172a;
    color: #ffffff;
}

.dealer-card__btn--primary:hover {
    background-color: #ef4444;
    color: #ffffff;
}

.dealer-card__btn--secondary {
    background-color: #f1f5f9;
    color: #334155;
}

.dealer-card__btn--secondary:hover {
    background-color: #e2e8f0;
    color: #0f172a;
}

.dealer-card__btn--map-view {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    color: #475569;
}

.dealer-card__btn--map-view:hover {
    background-color: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.dealer-card__chevron {
    display: flex;
    align-items: center;
    color: #94a3b8;
    font-size: 20px;
    padding-left: 12px;
    transition: transform 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.dealer-card:hover .dealer-card__chevron {
    transform: translateX(3px);
    color: #0f172a;
}

/* ========================================================
   Empty State
   ======================================================== */
.where-to-buy__empty {
    text-align: center;
    padding: 48px 24px;
    background-color: #fafbfc;
    border: 2px dashed #e2e8f0;
    border-radius: 18px;
    margin: 16px 0;
    list-style: none;
}

.where-to-buy__empty-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #f1f5f9;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    color: #94a3b8;
    font-size: 24px;
}

.where-to-buy__empty-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 6px;
}

.where-to-buy__empty-text {
    font-size: 14px;
    color: #64748b;
    margin: 0;
}

.where-to-buy__empty--hidden {
    display: none !important;
}

/* ========================================================
   Custom Leaflet Marker & Popup
   ======================================================== */
.custom-dealer-pin-wrapper {
    background: transparent !important;
    border: none !important;
}

.custom-dealer-pin {
    width: 40px;
    height: 40px;
    background-color: #0f172a;
    border: 3px solid #ffffff;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.custom-dealer-pin__icon {
    transform: rotate(45deg);
    color: #ffffff;
    font-size: 16px;
}

.custom-dealer-pin:hover,
.custom-dealer-pin--active {
    background-color: #ef4444;
    transform: rotate(-45deg) scale(1.18);
    box-shadow: 0 10px 28px rgba(239, 68, 68, 0.45);
    z-index: 1000 !important;
}

.leaflet-popup-content-wrapper {
    border-radius: 18px !important;
    padding: 0 !important;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.16) !important;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0 !important;
    line-height: 1.4 !important;
}

.map-popup-card {
    padding: 18px 20px;
    min-width: 250px;
    max-width: 290px;
    background-color: #ffffff;
}

.map-popup-card__title {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 6px;
    line-height: 1.3;
}

.map-popup-card__address {
    font-size: 13px;
    color: #475569;
    line-height: 1.4;
    margin: 0 0 8px;
}

.map-popup-card__hours {
    font-size: 12px;
    color: #64748b;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.map-popup-card__actions {
    display: flex;
    gap: 8px;
}

.map-popup-card__btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
}

.map-popup-card__btn--primary {
    background-color: #0f172a;
    color: #ffffff;
}

.map-popup-card__btn--primary:hover {
    background-color: #ef4444;
}

.map-popup-card__btn--secondary {
    background-color: #f1f5f9;
    color: #334155;
}

.map-popup-card__btn--secondary:hover {
    background-color: #e2e8f0;
    color: #0f172a;
}

/* User Location Pin Radar Pulse */
.user-pin-wrapper {
    background: transparent !important;
    border: none !important;
}

.user-pin {
    width: 18px;
    height: 18px;
    background-color: #3b82f6;
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.4);
    position: relative;
}

/* ========================================================
   Responsive Breakpoints (Mobile & Tablet)
   ======================================================== */
@media (max-width: 991px) {
    .where-to-buy__mobile-nav {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 12px 16px;
        background-color: #ffffff;
        border-bottom: 1px solid #f1f5f9;
        position: sticky;
        top: 0;
        z-index: 30;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    }

    .where-to-buy__mobile-tab {
        flex: 1;
        max-width: 260px;
        height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        border-radius: 9999px;
        background-color: #f1f5f9;
        border: none;
        color: #64748b;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        padding: 0 16px;
    }

    .where-to-buy__mobile-tab--active {
        background-color: #0f172a;
        color: #ffffff;
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.2);
    }

    .where-to-buy__mobile-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 20px;
        height: 20px;
        padding: 0 6px;
        border-radius: 9999px;
        font-size: 11px;
        font-weight: 700;
        line-height: 1;
        background-color: rgba(255, 255, 255, 0.25);
        color: inherit;
    }

    .where-to-buy__mobile-tab:not(.where-to-buy__mobile-tab--active) .where-to-buy__mobile-badge {
        background-color: #e2e8f0;
        color: #475569;
    }

    .where-to-buy__container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 120px);
        position: relative;
    }

    /* Mobile View Switching via data-mobile-view:
       Keep map pane in DOM with real pixel dimensions so Leaflet initializes & calculates tiles/markers accurately */
    .where-to-buy[data-mobile-view="list"] .where-to-buy__map-pane {
        position: absolute;
        top: -99999px;
        left: -99999px;
        width: 100%;
        height: calc(100vh - 140px);
        min-height: 480px;
        visibility: hidden;
        pointer-events: none;
        opacity: 0;
        z-index: -1;
    }

    .where-to-buy[data-mobile-view="list"] .where-to-buy__panel {
        display: flex;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        height: auto;
        box-shadow: none;
        border-left: none;
        position: relative;
    }

    .where-to-buy[data-mobile-view="map"] .where-to-buy__map-pane {
        position: relative;
        top: 0;
        left: 0;
        width: 100%;
        height: calc(100vh - 140px);
        min-height: 480px;
        visibility: visible;
        pointer-events: auto;
        opacity: 1;
        display: block;
        z-index: 10;
    }

    .where-to-buy[data-mobile-view="map"] .where-to-buy__panel {
        display: none;
    }

    .where-to-buy__panel-header {
        padding: 20px 16px 14px;
    }

    .where-to-buy__title {
        font-size: 24px;
    }

    .where-to-buy__list {
        padding: 12px 14px calc(var(--nav-height, 65px) + 30px);
    }

    .dealer-card {
        padding: 16px;
        margin-bottom: 12px;
    }

    .dealer-card__media {
        width: 58px;
        height: 58px;
        min-width: 58px;
    }

    .dealer-card__name {
        font-size: 16px;
    }

    .dealer-card__address {
        font-size: 13px;
    }

    .dealer-card__chevron {
        display: none;
    }

    .where-to-buy__mobile-preview {
        bottom: calc(var(--nav-height, 65px) + 16px);
        z-index: 10000;
    }
}

@media (max-width: 480px) {
    .where-to-buy__search-input {
        height: 46px;
        font-size: 14px;
    }

    .where-to-buy__quick-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .where-to-buy__state-select-wrap {
        width: 100%;
    }

    .where-to-buy__filter-select {
        width: 100%;
    }

    .dealer-card__actions {
        width: 100%;
    }

    .dealer-card__btn {
        flex: 1 1 auto;
        justify-content: center;
        min-height: 36px;
    }
}
