/**
 * Used Vehicles ([w2r-used-vehicles]) component styles.
 * Builds on the shared card / vehicle-group / grid-layout styles and config.css tokens.
 */

/* ---------- Loading state during AJAX ---------- */
#w2r-used-vehicles-results {
    position: relative;
    transition: opacity 0.15s ease;
}

#w2r-used-vehicles-results.w2r-loading {
    opacity: 0.5;
    pointer-events: none;
}

/* ---------- Sale card: clip the promo corner-ribbon within the card ---------- */
.w2r-sale-card {
    position: relative;
    overflow: hidden;
}

/* ---------- Per-card photo gallery (in the .w2r-vehicle-img slot) ---------- */
.w2r-sale-gallery {
    position: relative;
    overflow: hidden;
}

.w2r-sale-gallery-track {
    position: relative;
    width: 100%;
}

.w2r-sale-gallery-img {
    display: none;
    width: 100%;
    cursor: zoom-in;
}

.w2r-sale-gallery-img.is-active {
    display: block;
}

.w2r-sale-gallery-empty {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--color-bg-card);
}

.w2r-sale-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.w2r-sale-gallery:hover .w2r-sale-gallery-nav {
    opacity: 1;
}

.w2r-sale-gallery-nav:hover {
    background: rgba(0, 0, 0, 0.7);
}

.w2r-sale-gallery-prev {
    left: 8px;
}

.w2r-sale-gallery-next {
    right: 8px;
}

.w2r-sale-gallery-dots {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    z-index: 2;
    display: flex;
    justify-content: center;
    gap: 6px;
}

.w2r-sale-gallery-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.w2r-sale-gallery-dot.is-active {
    background: #fff;
}

/* Touch devices: always show arrows (no hover). */
@media (hover: none) {
    .w2r-sale-gallery-nav {
        opacity: 1;
    }
}

/* ---------- Lightbox ---------- */
body.w2r-uv-lightbox-open {
    overflow: hidden;
}

.w2r-uv-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
}

.w2r-uv-lightbox[hidden] {
    display: none;
}

.w2r-uv-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
}

.w2r-uv-lightbox-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px;
}

.w2r-uv-lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    padding-bottom: 8px;
}

.w2r-uv-lightbox-title {
    font-size: 1.05rem;
}

.w2r-uv-lightbox-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    padding: 0 6px;
}

.w2r-uv-lightbox-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.w2r-uv-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Overlay the nav arrows on top of the image so they stay visible at any
   width (as flex siblings they got squeezed off-screen on narrow viewports). */
.w2r-uv-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
}

.w2r-uv-lightbox-prev {
    left: 10px;
}

.w2r-uv-lightbox-next {
    right: 10px;
}

.w2r-uv-lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.72);
}

.w2r-uv-lightbox-counter {
    text-align: center;
    color: #fff;
    padding-top: 8px;
    font-size: 0.9rem;
}

/* ---------- Generic AJAX error alert (used by the filter controller) ---------- */
.w2r-alert {
    padding: 10px 14px;
    border-radius: 4px;
    margin: 10px 0;
}

.w2r-alert-error {
    background: var(--color-error-light-bg, #f8d7da);
    border: 1px solid var(--color-error-light-border, #f5c6cb);
    color: var(--color-text-discount);
}

/* ---------- Header meta band (year · fuel · mileage) ---------- */
/* Center the header + "see more" so they line up with the centered
   features / price / share blocks (consistent card alignment). */
.w2r-sale-card .title-group {
    text-align: center;
}

.w2r-sale-card .w2r-sale-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 14px;
    margin-top: 4px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.w2r-sale-card .w2r-sale-meta-item {
    white-space: nowrap;
}

.w2r-sale-card .w2r-sale-meta-item + .w2r-sale-meta-item {
    position: relative;
    padding-left: 14px;
}

.w2r-sale-card .w2r-sale-meta-item + .w2r-sale-meta-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 12px;
    background: var(--color-border);
}

/* ---------- Consistent photo framing ---------- */
.w2r-sale-gallery-img,
.w2r-sale-gallery-empty {
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

/* ---------- "See more information" (no-JS <details>) ---------- */
.w2r-sale-extra {
    margin-top: 10px;
    text-align: center;
}

.w2r-sale-extra-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--color-text-theme);
    font-weight: 600;
    list-style: none;
}

.w2r-sale-extra-toggle::-webkit-details-marker {
    display: none;
}

.w2r-sale-extra[open] .w2r-sale-extra-toggle {
    margin-bottom: 8px;
}

.w2r-sale-extra-body {
    color: var(--color-text-detail);
    font-size: 0.92rem;
    line-height: 1.5;
    text-align: left;
}

.w2r-sale-extra-body p {
    margin: 0 0 6px;
}

/* ---------- Share buttons ---------- */
.w2r-sale-share {
    display: flex;
    gap: 8px;
    margin: 10px 0;
}

.w2r-sale-share-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: 15px;
    transition: opacity 0.15s ease;
}

.w2r-sale-share-btn:hover {
    opacity: 0.85;
}

.w2r-sale-share-fb {
    background: #1877f2;
}

.w2r-sale-share-in {
    background: #0a66c2;
}

.w2r-sale-share-wa {
    background: #25d366;
}

/* ---------- Request-more-info button ---------- */
.w2r-sale-request {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .w2r-uv-lightbox-dialog {
        padding: 10px;
    }

    .w2r-uv-lightbox-nav {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }
}

/* =========================================================================
   Listing card: whole card is a click-through to the details page.
   ========================================================================= */

/* Stretched link overlays the card; interactive controls are raised above it. */
.w2r-sale-card-link {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.w2r-sale-card .w2r-vehicle-action,
.w2r-sale-card .w2r-sale-share {
    position: relative;
    z-index: 2;
}

/* Hover affordance on listing cards only (not the details gallery card). */
.w2r-used-vehicles:not(.w2r-uv-detail) .w2r-sale-card {
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.w2r-used-vehicles:not(.w2r-uv-detail) .w2r-sale-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-main);
}

/* Single cover photo (replaces the per-card slideshow). */
.w2r-sale-cover {
    position: relative;
    display: block;
}

.w2r-sale-card .w2r-sale-cover-img {
    width: 100%;
    max-height: none;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
}

.w2r-sale-cover-count {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.78rem;
}

/* =========================================================================
   Details page (?w2r_vehicle=<saleId>)
   ========================================================================= */

.w2r-uv-detail-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    color: var(--color-text-theme);
    font-weight: 600;
    text-decoration: none;
}

.w2r-uv-detail-back:hover {
    text-decoration: underline;
}

.w2r-uv-detail-top {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 24px;
    align-items: stretch; /* gallery + summary share the same height */
}

/* Gallery card fills edge-to-edge (drop the shared card padding) and lays out as
   a column so the image stage can grow to match the summary's height. */
.w2r-uv-detail-card {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.w2r-uv-detail-gallery {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.w2r-uv-detail-stage {
    position: relative;
    flex: 1;               /* grow to fill the card height (min keeps it sensible) */
    min-height: 320px;
    background: var(--color-bg-muted, #000);
}

.w2r-uv-detail-stage .w2r-sale-gallery-track {
    position: absolute;
    inset: 0;
}

.w2r-uv-detail .w2r-uv-detail-stage .w2r-sale-gallery-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none; /* override the shared .w2r-vehicle-img-el 220px cap */
    aspect-ratio: auto;
    object-fit: cover;
}

.w2r-uv-detail-count {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.8rem;
}

.w2r-uv-detail-thumbs {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    padding: 10px;
    overflow-x: auto;
}

.w2r-uv-thumb {
    flex: 0 0 auto;
    width: 84px;
    height: 60px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    background: none;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.w2r-uv-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.w2r-uv-thumb:hover {
    opacity: 1;
}

.w2r-uv-thumb.is-active {
    opacity: 1;
    border-color: var(--color-text-theme);
}

/* Summary panel */
.w2r-uv-detail-summary {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.w2r-uv-detail .w2r-uv-detail-summary .title-group {
    display: block;
    text-align: left;
}

.w2r-uv-detail-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--color-text-theme);
}

.w2r-uv-detail .w2r-uv-detail-summary .w2r-sale-meta {
    justify-content: flex-start;
}

/* Identity block grows to fill the panel; the spec list takes the slack so the
   equal-height layout never leaves a void — the rows just breathe more. */
.w2r-uv-detail-head {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.w2r-uv-detail-specs {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin: 0;
}

.w2r-uv-detail-specs .w2r-uv-spec-row:last-child {
    border-bottom: none;
}

/* …price + actions are anchored to the bottom of the (stretched) panel,
   separated by a hairline so the equal-height layout reads as intentional. */
.w2r-uv-detail-buy {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.w2r-uv-detail-price {
    text-align: left;
    width: auto;
}

.w2r-uv-detail-price .w2r-vehicle-price-total {
    font-size: 2rem;
}

.w2r-uv-detail-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.w2r-uv-detail-actions .w2r-sale-share {
    margin: 0;
}

/* Request-info uses the standard button style, not the orange contact/warning
   variant (.w2r-button-contact is kept only so the modal JS binds to it). */
.w2r-uv-detail .w2r-sale-request.w2r-button-contact {
    background: var(--color-btn-bg);
    color: var(--color-btn-text);
    border: none;
}

.w2r-uv-detail .w2r-sale-request.w2r-button-contact:hover {
    background: var(--color-btn-selected-bg);
}

/* Sections: specs / equipment / description */
.w2r-uv-detail-sections {
    margin-top: 28px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.w2r-uv-detail-heading {
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text-theme);
}

.w2r-uv-spec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0 32px;
    margin: 0;
}

.w2r-uv-spec-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px dashed var(--color-border);
}

.w2r-uv-spec-label {
    color: var(--color-text-muted);
}

.w2r-uv-spec-value {
    color: var(--color-text-main);
    font-weight: 600;
    text-align: right;
}

.w2r-uv-equipment {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px 24px;
}

.w2r-uv-equipment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-text-detail);
}

.w2r-uv-equipment-item i {
    color: var(--color-success, #2e7d32);
    font-size: 0.85rem;
}

.w2r-uv-detail-description {
    color: var(--color-text-detail);
    line-height: 1.6;
}

.w2r-uv-detail-description p {
    margin: 0 0 10px;
}

@media (max-width: 860px) {
    .w2r-uv-detail-top {
        grid-template-columns: 1fr;
    }

    /* Stacked: show the summary (title/price/CTA) first, gallery below. */
    .w2r-uv-detail-summary {
        order: -1;
    }
}
