/* Strict brand color system using flat, solid palettes provided in blueprint */
:root {
    --brand-midnight: #0b132b;
    --brand-sky: #008ed6;
    --brand-charcoal: #1c2541;
    --brand-light: #f8f9fa;
    --brand-white: #ffffff;
}

.popup-dealer {
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #0b132b;
    padding: 8px 12px;
    min-width: 220px;
}

.popup-dealer-title {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    margin-bottom: 10px;
}

.popup-dealer-type {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: #64748b;
}

.popup-dealer-name {
    display: block;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
    color: #0b132b;
    overflow-wrap: anywhere;
}

.popup-dealer-address,
.popup-dealer-phone,
.popup-dealer-service {
    margin-top: 5px;
    color: #4b5563;
    overflow-wrap: anywhere;
}

.popup-dealer-phone a {
    color: #0b132b;
    text-decoration: none;
}

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

.popup-dealer-phone strong {
    color: #0b132b;
}

/* Remove the empty header space above the popup content */
.gm-style .gm-style-iw-chr {
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    position: relative !important;
    overflow: visible !important;
}

/* Keep the close button visible in the top-right corner */
.gm-style .gm-style-iw-chr button.gm-ui-hover-effect {
    position: absolute !important;
    top: 4px !important;
    right: 4px !important;
    width: 32px !important;
    height: 32px !important;
    margin: 0 !important;
    z-index: 10 !important;
}

/* Remove excess top padding inside the popup */
.gm-style .gm-style-iw-c {
    padding: 12px !important;
}

.gm-style .gm-style-iw-d {
    overflow: auto !important;
    padding-top: 0 !important;
}

/* Keep the dealer content compact */
.popup-dealer {
    padding: 0 !important;
    margin: 0 !important;
}

/* Map and results side by side at a fixed height */
.dealer-results-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
    gap: 20px;
    height: 500px;
    min-height: 0;
    align-items: stretch;
}

/* Map stays at the same height */
.dealer-map {
    height: 500px;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}

/* Dealer list scrolls independently */
.dealer-list {
    height: 500px;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    padding: 0 16px;
    box-sizing: border-box;
}

/* Keep individual dealer cards compact */
.dealer-list > div {
    flex-shrink: 0;
}

/* Mobile layout */
@media (max-width: 767px) {
    .dealer-results-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 350px 350px;
        height: 720px;
        gap: 12px;
    }

    .dealer-map {
        height: 350px;
    }

    .dealer-list {
        height: 350px;
    }
}

#gallery-track {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 18px;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #008ed6 #e5e7eb;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.gallery-card {
    flex: 0 0 82%;
    max-width: 360px;
    min-width: 0;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: #0b132b;
    text-decoration: none;
    overflow: hidden;
}

.gallery-card img {
    display: block;
    width: 100%;
    object-fit: cover;
    background: #1c2541;
    transition: transform 0.3s ease;
}

.gallery-card:hover img {
    transform: scale(1.035);
}

.gallery-card span {
    font-size: 14px;
    font-weight: 700;
}

#gallery-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(5, 9, 20, 0.96);
    color: white;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#gallery-lightbox.is-open {
    display: flex;
}

#gallery-lightbox figure {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin: 0;
}

#lightbox-image {
    max-width: 100%;
    max-height: 78vh;
    object-fit: contain;
}

#lightbox-caption {
    text-align: center;
    font-size: 14px;
}

#lightbox-count {
    color: #9ca3af;
    font-size: 12px;
}

#gallery-lightbox button {
    position: absolute;
    background: transparent;
    border: 0;
    color: white;
    cursor: pointer;
    padding: 8px 16px;
    font-size: 40px;
}

#lightbox-close {
    top: 12px;
    right: 12px;
}

#lightbox-prev {
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
}

#lightbox-next {
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
}

#gallery-lightbox button:hover {
    color: #008ed6;
}

@media (min-width: 640px) {
    .gallery-card {
        flex-basis: 48%;
    }

    #lightbox-prev {
        left: 20px;
    }

    #lightbox-next {
        right: 20px;
    }
}

@media (min-width: 1024px) {
    .gallery-card {
        flex-basis: 31.5%;
    }
}

@media (prefers-reduced-motion: reduce) {
    #gallery-track {
        scroll-behavior: auto;
    }

    .gallery-card img {
        transition: none;
    }
}

/* 360 Viewer Loading Indicator */
.spritespin-loader {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #1c2541;
    color: #f8f9fa;
    text-align: center;
    transition:
        opacity 0.35s ease,
        visibility 0.35s ease;
}

.spritespin-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.spritespin-spinner {
    width: 46px;
    height: 46px;
    border: 4px solid rgba(255, 255, 255, 0.18);
    border-top-color: #008ed6;
    border-right-color: #008ed6;
    border-radius: 50%;
    animation: amoray-spin 0.8s linear infinite;
}

.spritespin-loader p {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}

.spritespin-loader span {
    color: #b8c4d9;
    font-size: 12px;
}

@keyframes amoray-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .spritespin-spinner {
        animation-duration: 2s;
    }
}
