/* Vehicle detail page (ListingDetail.razor) + VehicleGallery + the offer panel chrome.
   Dark-only. Layout is a CSS grid with named areas so the DOM order can differ from the visual
   order: desktop = gallery/details left + sticky offer panel right; <=960px = single column in the
   order gallery -> price/offer -> details (the offer is the point of the page, so it comes before
   the long spec sheet). Breakpoints: 960px, 600px. */

.listing-page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 24px 56px;
    box-sizing: border-box;
}

.listing-state {
    display: grid;
    place-items: center;
    padding: 80px 0;
}

.listing-crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    font-size: 0.88rem;
    color: var(--sa-ink-2);
}

.listing-crumbs a {
    font-weight: 700;
    color: var(--sa-primary-ink);
    text-decoration: none;
}

.listing-crumbs span {
    opacity: 0.6;
}

.listing-crumbs strong {
    color: var(--sa-ink);
}

.listing-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    grid-template-areas:
        "gallery aside"
        "details aside";
    column-gap: 32px;
    row-gap: 28px;
    align-items: start;
}

.listing-gallery-col { grid-area: gallery; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.listing-aside { grid-area: aside; min-width: 0; position: sticky; top: calc(var(--sa-header-h) + 16px); }
.listing-details-col { grid-area: details; min-width: 0; display: flex; flex-direction: column; gap: 28px; }

/* ---------- Title block ---------- */

.listing-head h1 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.6rem, 3.4vw, 2.2rem);
    letter-spacing: -0.015em;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.listing-series {
    margin-top: 4px;
    font-size: 1.05rem;
    color: var(--sa-ink-2);
}

.listing-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.listing-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--sa-surface);
    border: 1px solid var(--sa-line);
    font-size: 0.88rem;
    font-weight: 600;
}

.listing-pill .mud-icon-root {
    color: var(--sa-primary);
}

/* ---------- Detail sections ---------- */

.listing-section h2 {
    margin: 0 0 12px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.25rem;
}

.listing-description {
    margin: 0;
    max-width: 72ch;
    color: var(--sa-ink-2);
    line-height: 1.7;
    white-space: pre-line;
}

.spec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    column-gap: 40px;
    margin: 0;
    padding: 4px 22px;
    background: var(--sa-surface);
    border: 1px solid var(--sa-line);
    border-radius: var(--sa-radius-lg);
}

.spec-grid > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 0;
    border-bottom: 1px solid var(--sa-line);
}

.spec-grid dt {
    flex: none;
    color: var(--sa-ink-2);
    font-size: 0.92rem;
}

.spec-grid dd {
    margin: 0;
    min-width: 0;
    font-weight: 600;
    font-size: 0.92rem;
    text-align: right;
    overflow-wrap: anywhere;
}

.spec-grid .mono {
    font-family: var(--font-mono);
    font-weight: 500;
}

.cond-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.cond-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: var(--sa-surface);
    border: 1px solid var(--sa-line);
    border-radius: var(--sa-radius-md);
}

.cond-item span {
    font-size: 0.85rem;
    color: var(--sa-ink-2);
}

.cond-item strong {
    font-size: 1rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.feature-grid li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.92rem;
}

.feature-grid .mud-icon-root {
    flex: none;
    color: var(--sa-ok-ink);
}

/* ---------- Price + offer panel ---------- */

.listing-offer-panel {
    padding: 24px;
    box-sizing: border-box;
    background: var(--sa-surface);
    border: 1px solid var(--sa-line);
    border-radius: 20px;
    box-shadow: var(--sa-shadow);
}

.listing-offer-panel__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.listing-offer-panel__label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sa-ink-3);
}

.listing-offer-panel__price {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.9rem, 4vw, 2.5rem);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.listing-offer-panel__featured-badge {
    display: inline-block;
    margin-top: 10px;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--sa-amber);
    color: var(--sa-on-amber);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.listing-fav {
    flex: none;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--sa-line);
    border-radius: 12px;
    background: var(--sa-surface-2);
    color: var(--sa-ink-2);
    cursor: pointer;
}

.listing-fav:hover {
    border-color: #3a4d80;
}

.listing-fav.is-on {
    color: #ff6b81;
}

.listing-seller {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    padding: 14px;
    border-radius: var(--sa-radius-md);
    background: var(--sa-surface-2);
    border: 1px solid var(--sa-line);
}

.listing-seller__avatar {
    width: 42px;
    height: 42px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--sa-primary-soft);
    color: var(--sa-primary-ink);
    font-weight: 800;
    font-size: 0.85rem;
}

.listing-seller__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    font-size: 0.85rem;
    color: var(--sa-ink-2);
}

.listing-seller__text strong {
    color: var(--sa-ink);
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}

.listing-seller__text .mud-icon-root {
    vertical-align: text-bottom;
}

.listing-offer-panel__divider {
    height: 1px;
    margin: 4px 0 18px;
    background: var(--sa-line);
}

.dealer-rating-badge {
    display: inline-flex;
    align-items: center;
}

/* ---------- VehicleGallery ---------- */
/* Main image + a wrapping thumbnail strip (thumbnails wrap onto more rows rather than scrolling
   sideways, whatever the photo count); clicking opens GalleryLightboxDialog full-size. */

.listing-gallery {
    height: 420px;
    border-radius: var(--sa-radius-lg);
    overflow: hidden;
    background: var(--sa-surface);
}

.listing-gallery__placeholder {
    height: 420px;
}

.vehicle-gallery__main {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    max-height: 520px;
    padding: 0;
    border: 1px solid var(--sa-line);
    border-radius: 20px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--sa-img-a), var(--sa-img-b));
    cursor: pointer;
}

.vehicle-gallery__main-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.vehicle-gallery__zoom-hint {
    position: absolute;
    right: 14px;
    bottom: 14px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(6, 13, 32, 0.7);
    color: #fff;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.vehicle-gallery__main:hover .vehicle-gallery__zoom-hint {
    opacity: 1;
}

.vehicle-gallery__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(6, 13, 32, 0.7);
    color: #fff;
}

.vehicle-gallery__nav:hover {
    background: rgba(6, 13, 32, 0.9);
}

.vehicle-gallery__nav--prev { left: 14px; }
.vehicle-gallery__nav--next { right: 14px; }

.vehicle-gallery__thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    max-height: 150px;
    overflow-y: auto;
}

.vehicle-gallery__thumbnail {
    flex: 0 0 auto;
    width: 72px;
    height: 54px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    background: var(--sa-surface);
    cursor: pointer;
    opacity: 0.7;
}

.vehicle-gallery__thumbnail:hover {
    opacity: 1;
}

.vehicle-gallery__thumbnail--active {
    border-color: var(--sa-primary);
    opacity: 1;
}

.vehicle-gallery__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
    .listing-page {
        padding: 18px 20px 40px;
    }

    .listing-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "gallery"
            "aside"
            "details";
        row-gap: 24px;
    }

    .listing-aside {
        position: static;
    }
}

@media (max-width: 600px) {
    .listing-page {
        padding: 14px 16px 32px;
    }

    .listing-offer-panel {
        padding: 18px;
        border-radius: 18px;
    }

    .vehicle-gallery__main {
        border-radius: 16px;
    }

    .vehicle-gallery__nav {
        width: 40px;
        height: 40px;
    }

    .vehicle-gallery__thumbnail {
        width: 60px;
        height: 46px;
    }

    .spec-grid {
        padding: 2px 16px;
    }
}

/* ---------- GalleryLightboxDialog ---------- */

.gallery-lightbox__title {
    font-size: 0.9rem;
    color: var(--mud-palette-text-secondary);
}

.gallery-lightbox {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 65vh;
    outline: none;
}

.gallery-lightbox__image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.gallery-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.gallery-lightbox__nav--prev {
    left: 0;
}

.gallery-lightbox__nav--next {
    right: 0;
}

.gallery-lightbox__thumbnails {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 1rem;
    max-height: 96px;
    overflow-y: auto;
}

.gallery-lightbox__thumbnail {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: var(--m3-shape-sm);
    overflow: hidden;
    cursor: pointer;
    opacity: 0.6;
}

.gallery-lightbox__thumbnail:hover {
    opacity: 1;
}

.gallery-lightbox__thumbnail--active {
    border-color: var(--m3-primary);
    opacity: 1;
}

.gallery-lightbox__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

