/* ── Wallily AI Preview — preview.css ─────────────────────────────────────── */

/* ── Wrap ──────────────────────────────────────────────────────────────────── */
.wap-wrap { margin: 10px 0 16px; }

/* ── Preview button ─────────────────────────────────────────────────────────── */
.wap-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 13px 22px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    /* Modern violet sheen — darker ends, bright lilac highlight through the middle */
    background: linear-gradient(110deg, #2C2546 0%, #3D3270 28%, #6E5DC6 48%, #8E7BE6 52%, #5B4DA8 66%, #2C2546 100%);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: opacity .2s ease, transform .15s ease, box-shadow .2s ease;
    box-shadow: 0 2px 14px rgba(110, 93, 198, .38);
    margin-bottom: 8px;
}
.wap-btn:hover:not(:disabled) {
    opacity: .88;
    transform: translateY(-1px);
    box-shadow: 0 4px 18px rgba(61, 50, 112, .42);
}
.wap-btn:active:not(:disabled) { transform: translateY(0); opacity: .95; }
.wap-btn:disabled              { opacity: .5; cursor: not-allowed; }

/* Saved-preview variant — same violet sheen as the default button (no green) */
.wap-btn--saved { /* inherits .wap-btn gradient — no override needed */ }

/* Icon inside the button (✨ emoji stays text; eye / saved state uses inline SVG) */
.wap-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.wap-progress { margin: 4px 0 12px; }

.wap-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}
.wap-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #3D3270, #8E7BE6);
    border-radius: 999px;
    transition: width .55s ease;
}
/* Animated shimmer sweeping across the bar while generation is in progress */
.wap-fill--active {
    background-image:
        linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.55) 50%, rgba(255,255,255,0) 100%),
        linear-gradient(90deg, #3D3270, #8E7BE6);
    background-size: 35% 100%, 100% 100%;
    background-repeat: no-repeat, no-repeat;
    animation: wap-shimmer 1.1s linear infinite;
}
@keyframes wap-shimmer {
    0%   { background-position: -35% 0, 0 0; }
    100% { background-position: 135% 0, 0 0; }
}
.wap-msg {
    font-size: 12px;
    color: #6b7280;
    text-align: center;
    margin: 6px 0 0;
    min-height: 1.4em;
}

/* ── History thumbnails row — Etsy-style cards ───────────────────────────── */
.wap-history { margin: 10px 0 6px; }

/* AI disclaimer note — Etsy "climate solutions" style: soft lilac box + icon */
.wap-hist-note {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    background: #ecebf6;
    border-radius: 10px;
    padding: 11px 13px;
    margin: 0 0 12px;
    font-size: 13px;
    line-height: 1.45;
    color: #1a1a2e;
}
.wap-hist-note svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #3D3270;
    margin-top: 1px;
}
.wap-hist-note strong { font-weight: 600; }

/* Up to 4 cards per row; each fixed at a quarter width so 1, 2 or 3 previews
   stay the same small thumbnail size (left-aligned) instead of stretching. */
.wap-hist-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin-bottom: 10px;
}

/* Card: image on top + field text below — hover/selected = gray bg covers both */
.wap-hist-thumb-wrap {
    position: relative;
    cursor: pointer;
    border-radius: 10px;
    overflow: visible;
    transition: background-color .15s;
    flex: 0 0 auto;
    width: calc(25% - 4.5px); /* 4 items + three 6px gaps = 100% */
    min-width: 0;             /* allow shrink below content width on tiny phones */
    padding: 8px 6px 9px;
    background: transparent;
    text-align: center;
    box-sizing: border-box;
}
.wap-hist-thumb-wrap:hover,
.wap-hist-selected {
    background-color: rgb(238 238 238);
}

/* Inner wrapper: positions check badge relative to image edge */
.wap-hist-img-wrap {
    position: relative;
    display: block;
    width: 100%;
    margin-bottom: 7px;
}

.wap-hist-thumb {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;   /* square regardless of rendered width */
    object-fit: cover;
    border-radius: 8px;
    border: none;
}

/* Field value text(s) below image */
.wap-hist-field {
    font-size: 11px;
    color: #1a1a2e;
    line-height: 1.35;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    margin: 0 auto 2px;
}

/* ✓ badge on selected — SVG checkmark, positioned at image top-right */
.wap-hist-check {
    position: absolute;
    top: -7px; right: -7px;
    width: 20px; height: 20px;
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
    pointer-events: none;
}
.wap-hist-check svg {
    width: 11px;
    height: 11px;
    stroke: #fff;
}


/* ── Required field validation error ────────────────────────────────────── */
/* Applied to .wapf-field-container when a required field is empty on Preview click */
.wap-required-error {
    animation: wap-field-shake 0.35s ease;
}
@keyframes wap-field-shake {
    0%,  100% { transform: translateX(0); }
    20%        { transform: translateX(-5px); }
    40%        { transform: translateX(5px); }
    60%        { transform: translateX(-3px); }
    80%        { transform: translateX(3px); }
}

/* ── Status line (Layer 2) ───────────────────────────────────────────────── */
/* Small informational note above the Add to Cart button when preview is out of sync */
.wap-status-line {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 13px;
    color: #1a1a2e;
    margin: 0 0 10px;
    line-height: 1.45;
}
.wap-status-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #3D5BC9;
    margin-top: 1px;
}
.wap-status-line[hidden] { display: none !important; }

/* ── Soft notice (capacity / billing soft-fail) ─────────────────────────────
 * Gentle reassurance shown under the Preview button when the AI service is
 * temporarily unavailable. Never alarming — the customer can still order.    */
.wap-soft-notice {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    font-size: 13px;
    color: #1a1a2e;
    background: #faf8f5;
    border: 1px solid #ece7df;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 8px 0 0;
    line-height: 1.45;
}
.wap-soft-notice svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    color: #3D5BC9;
    margin-top: 1px;
}
.wap-soft-notice[hidden] { display: none !important; }

/* ── Overlay ─────────────────────────────────────────────────────────────── */
.wap-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, .65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.wap-overlay[hidden] { display: none !important; }

/* ── Popup box ───────────────────────────────────────────────────────────── */
.wap-popup {
    position: relative;
    background: #fff;
    border-radius: 20px;
    padding: 28px 24px 24px;
    max-width: 520px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
    animation: wap-enter .22s ease;
}
@keyframes wap-enter {
    from { opacity: 0; transform: scale(.94) translateY(10px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* Close button — theme X icon */
.wap-close {
    position: absolute;
    top: 14px; right: 14px;
    background: none; border: none;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    color: #6b6b6b; cursor: pointer;
    border-radius: 50%;
    transition: background .15s, color .15s;
    padding: 0;
}
.wap-close svg { width: 18px; height: 18px; }
.wap-close:hover { background: #f3f4f6; color: #222; }

/* Preview image */
#wap-img {
    display: block;
    width: 100%;
    max-width: 440px;
    height: auto;
    margin: 0 auto 14px;
    border-radius: 12px;
}

/* Disclaimer note — forced single line */
.wap-note {
    font-size: 11px;
    color: #9ca3af;
    margin: 0 0 18px;
    white-space: nowrap;
}

/* "Looks great" / confirm button — theme black */
.wap-ok {
    display: inline-block;
    padding: 13px 32px;
    background: #222;
    color: #fff;
    border: none;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s ease, transform .15s ease;
}
.wap-ok:hover { opacity: .85; transform: translateY(-1px); }
.wap-ok:active { transform: translateY(0); }

/* ── Cart thumbnail ─────────────────────────────────────────────────────── */
.wap-cart-thumb {
    display: block;
    width: 64px !important;
    height: 64px !important;
    object-fit: cover;
    border-radius: 8px;
    margin-top: 6px;
    border: 1px solid #e5e7eb;
}

/* ── Add-to-cart pulse highlight after popup close ──────────────────────── */
@keyframes wap-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(107, 70, 193, .6); }
    50%  { box-shadow: 0 0 0 8px rgba(107, 70, 193, .1); }
    100% { box-shadow: 0 0 0 0   rgba(107, 70, 193, 0); }
}
.wap-atc-pulse {
    animation: wap-pulse .55s ease 2;
}

/* ── Admin order edit screen ────────────────────────────────────────────── */
.wap-admin-preview {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 12px;
}
.wap-admin-preview strong {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
}
