/* Additions for the Nuxt port of the conversion-html prototype.
 *
 * Kept OUT of style.css / tailwind.css on purpose: those two are copied verbatim from
 * conversion-html/assets/css whenever the prototype is updated, which would wipe any
 * edit made to them. Everything here is something the prototype does not have.
 * Loaded after style.css by the configurator and summary pages.
 */

/* ---- Header: model/grade on the left, view-switcher pills on the right -------------- */
#box-conversion .box-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: calc(var(--spacing) * 3);
}
#box-conversion .box-head-info { min-width: 0; }
#box-conversion .box-head .btn-change-model { cursor: pointer; }

/* Pills ("รูปแบบการดัดแปลง" / "ส่วนตกแต่งเพิ่มเติม"). */
#box-conversion .list-view-tab {
    display: flex;
    flex-wrap: wrap;
    gap: calc(var(--spacing) * 1.2);
    margin: 0;
    padding: 0;
    list-style: none;
}
#box-conversion .list-view-tab .item {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--spacing) * 1) calc(var(--spacing) * 3);
    background: var(--grey-4);
    color: var(--grey);
    font-family: var(--font-bd);
    border-radius: calc(var(--spacing) * 10);
    transition: all 0.3s ease;
    white-space: nowrap;
}
#box-conversion .list-view-tab .item:hover { color: var(--black-2); }
#box-conversion .list-view-tab .item.active { background: var(--black); color: #fff; }

@media (max-width: 767.98px) {
    /* the pills take their own full-width row under the model name */
    #box-conversion .list-view-tab { width: 100%; flex-wrap: nowrap; }
    #box-conversion .list-view-tab .item {
        flex: 1 1 0;
        padding: calc(var(--spacing) * 1.2) calc(var(--spacing) * 1);
        white-space: normal;
        text-align: center;
    }
}

/* ---- Angle strip (.list-car-view): configurator + summary ------------------------- */
/* Angles come from the API (a grade can have up to ~7), so the strip scrolls sideways
   instead of overflowing the bar. The vertical padding leaves room for the glow below. */
.list-car-view {
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
    padding: calc(var(--spacing) * 0.6) 0 calc(var(--spacing) * 1);
    --thumb-w: 12;
    --thumb-h: 7;
}
.list-car-view .item {
    position: relative;
    flex: 0 0 auto;
    padding-bottom: calc(var(--spacing) * 1);
}
.list-car-view .item img { position: relative; }

/* API thumbnails are wide studio photos, so crop them into a fixed box (the demo icons
   are transparent cut-outs and keep their natural shape). */
.list-car-view .item .thumb-ai {
    display: block;
    margin: 0 auto;
    width: calc(var(--spacing) * var(--thumb-w));
    height: calc(var(--spacing) * var(--thumb-h));
    object-fit: cover;
    border-radius: calc(var(--spacing) * 0.6);
}
#box-summarize .list-car-view {
    --thumb-w: 15.4;
    --thumb-h: 9;
    /* the strip is centred in the prototype; "safe" keeps it scrollable when it overflows
       (plain centring would push the first items off the left edge, out of reach) */
    justify-content: safe center;
}
@media (max-width: 767.98px) {
    #box-conversion .list-car-view { --thumb-w: 15.4; --thumb-h: 9; }
    #box-summarize .list-car-view { --thumb-w: 13.7; --thumb-h: 8; }
}

/* Active angle highlight: a white ellipse with a red glow under the thumbnail, drawn in
   CSS. It replaces the prototype's aura-active.webp background image, which was sized for
   narrow car icons and got cropped on the wider photo thumbnails. It sits behind the
   thumbnail (::before + the img being positioned). */
.list-car-view .item.selected { background: none; }
.list-car-view .item::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(var(--spacing) * 0.2);
    width: 78%;
    height: calc(var(--spacing) * 1.5);
    border-radius: 50%;
    background: var(--white);
    box-shadow: 0 0 calc(var(--spacing) * 0.9) calc(var(--spacing) * 0.25) var(--red);
    opacity: 0;
    transform: translateX(-50%) scale(0.6);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
.list-car-view .item.selected::before {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* ---- Decoration tiles ------------------------------------------------------------- */
/* The prototype's demo tiles were all the same size. The real artwork (stickers, logos)
   ranges from ~3.2:1 banners to ~1.7:1, which made the grid ragged (tiles 160-320px
   tall). Give every tile the demo tile's shape (370x160) and fit the artwork inside it
   without cropping. */
#box-decoration .list-decoration .item .pic {
    aspect-ratio: 37 / 16;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
#box-decoration .list-decoration .item .pic img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ---- Colour popups on phones ------------------------------------------------------- */
/* The prototype demo had 5 colours; the API gives the "more colours" popup 12. It opens
   upwards from its button, so without a cap a tall list can run off the top of the page
   (where it can't be scrolled to). Cap the list instead; it scrolls inside the popup. */
@media (max-width: 767.98px) {
    [class*="popup-color-"] .box-overflow { max-height: 45vh; }
}

@media (min-width: 768px) {
    .popup-change-model .detail > .box-overflow { overflow: hidden; }
    .popup-change-model .detail > .box-overflow > div:first-child {
        min-height: 0;
        overflow-y: auto;
    }
    .popup-change-model .detail > .box-overflow > div:first-child::-webkit-scrollbar {
        width: calc(var(--spacing) * .5);
        border-radius: calc(var(--spacing) * .5);
    }
    .popup-change-model .detail > .box-overflow > div:first-child::-webkit-scrollbar-track { border-radius: calc(var(--spacing) * .5); }
    .popup-change-model .detail > .box-overflow > div:first-child::-webkit-scrollbar-thumb { background: #aaa; border-radius: calc(var(--spacing) * .5); }
    .popup-change-model .detail > .box-overflow > div:first-child::-webkit-scrollbar-track-piece { background: #e8e8e8; border-radius: calc(var(--spacing) * .5); }
    .popup-change-model .detail > .box-overflow > div:last-child {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    .popup-change-model .detail > .box-overflow,
    #box-conversion .popup-change-model .detail > .box-overflow { max-height: 78vh; }
    .popup-change-model .detail > .box-overflow > div:last-child > .box-overflow,
    #box-conversion .popup-change-model .detail > .box-overflow > div:last-child > .box-overflow {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
    }
}

/* ---- Desktop bottom bar: the angle strip may shrink (and scroll) beside the pickers --- */
/* Desktop: keep the bottom bar stuck to the viewport bottom (phones already do via utilities) */
@media (min-width: 768px) {
    /* short pages: push the bar down to the viewport bottom; long pages: sticky takes over */
    #box-conversion {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        min-height: 100dvh;
    }
    .bar-views-sticky {
        margin-top: auto;
        position: sticky;
        bottom: 0;
        left: 0;
        z-index: 10;
        background: #fff;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    }
}

#box-conversion .bar-views-wrap,
#box-conversion .bar-views { min-width: 0; }
#box-conversion .bar-views .list-car-view { flex: 0 1 auto; }
#box-conversion .bar-colors { flex: 0 0 auto; }

/* ---- Summary: new pictures made per angle (decal) ---------------------------------- */
/* The plain render stays visible underneath while a picture is being made; a veil with a
   spinner says so. It sits under the Swiper arrows (z-index 10). */
#box-summarize .decal-pic { position: relative; }
#box-summarize .decal-status {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(var(--spacing) * 0.8);
    padding: calc(var(--spacing) * 2);
    text-align: center;
    color: var(--black-2);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(2px);
}
#box-summarize .decal-text { margin: 0; font-family: var(--font-bd); font-size: var(--text-xl); }
#box-summarize .decal-sub { margin: 0; color: var(--grey); font-size: var(--text-sm); }
@keyframes decal-spin { to { transform: rotate(360deg); } }
#box-summarize .decal-spinner,
.list-car-view .item.is-pending::after {
    content: "";
    display: block;
    border: calc(var(--spacing) * 0.5) solid rgba(0, 0, 0, 0.12);
    border-top-color: var(--red);
    border-radius: 50%;
    animation: decal-spin 0.9s linear infinite;
}
#box-summarize .decal-spinner { width: calc(var(--spacing) * 5); height: calc(var(--spacing) * 5); }
@media (prefers-reduced-motion: reduce) {
    #box-summarize .decal-spinner,
    .list-car-view .item.is-pending::after { animation-duration: 3s; }
}

/* Configurator preview: fake loading cover (solid, appears instantly, fades out). */
#box-conversion .preview-loading {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease-out;
}
#box-conversion .preview-loading.on { opacity: 1; transition: none; pointer-events: auto; }
#box-conversion .preview-loading__spinner {
    width: calc(var(--spacing) * 5);
    height: calc(var(--spacing) * 5);
    border: calc(var(--spacing) * 0.5) solid rgba(0, 0, 0, 0.12);
    border-top-color: var(--red);
    border-radius: 50%;
    animation: decal-spin 0.7s linear infinite;
}

/* Short notes over the bottom edge of a picture that stays the plain render. */
#box-summarize .decal-note {
    position: absolute;
    left: calc(var(--spacing) * 1.5);
    right: calc(var(--spacing) * 1.5);
    bottom: calc(var(--spacing) * 1.5);
    z-index: 5;
    margin: 0;
    padding: calc(var(--spacing) * 0.8) calc(var(--spacing) * 1.5);
    border-radius: calc(var(--spacing) * 0.8);
    color: #fff;
    font-size: var(--text-sm);
    text-align: center;
    background: rgba(0, 0, 0, 0.66);
}
#box-summarize .decal-note.is-error { background: rgba(235, 10, 30, 0.9); }
#box-summarize .decal-retry { margin-left: calc(var(--spacing) * 0.8); text-decoration: underline; cursor: pointer; }

/* Angle strip: a thumbnail whose picture is still being made. */
.list-car-view .item.is-pending img { opacity: 0.55; }
.list-car-view .item.is-pending::after {
    position: absolute;
    top: calc(var(--spacing) * 0.8);
    right: calc(var(--spacing) * 1.2);
    width: calc(var(--spacing) * 2);
    height: calc(var(--spacing) * 2);
    border-width: calc(var(--spacing) * 0.35);
}

/* summary notice: first bullet marker is red */
.note-notice > li.marker\:text-red::marker { color: var(--color-red); }
.note-notice { list-style: disc outside; padding: 2.1rem; background: #ededed; border-radius: 8px; }
.note-notice > li { display: list-item; list-style-type: disc; }
