/** Custom Product Builder — safari-sun-configurator */

.ssc-ai-builder-wrapper ~ .single_variation_wrap,
.ssc-ai-builder-wrapper ~ .variations_form .variations,
.ssc-ai-builder-wrapper ~ .woocommerce-variation-add-to-cart {
    display: none !important;
}

.ssc-ai-builder-wrapper {
    position: relative;
    margin-top: 10px;
}

.ssc-ai-input-zone {
    margin-bottom: 0;
}

.ssc-ai-input-zone-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 16px 0;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ssc-ai-field {
    margin-bottom: 2px;
}

.ssc-ai-field-label {
    display: block;
    font-size: 14px;
    font-weight: 400;
    color: #444;
    text-align: left;
    margin-bottom: 6px;
}

.ssc-ai-field-control {
    position: relative;
    overflow: visible;
}

/* ── Text inputs ───────────────────────────────────────────────────────── */

.ssc-ai-text-input,
.ssc-ai-textarea-input,
.ssc-ai-select-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #d3d3d3;
    border-radius: 1px;
    font-size: 15px;
    font-family: inherit;
    color: #333;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.ssc-ai-text-input:focus,
.ssc-ai-textarea-input:focus,
.ssc-ai-select-input:focus {
    outline: none;
    border-color: #272727;
    box-shadow: 0 0 0 2px rgba(39, 39, 39, 0.1);
}

.ssc-ai-textarea-input {
    resize: vertical;
    min-height: 44px;
    line-height: 1.35;
    overflow-y: auto;
}

/* Character counter — positioned below the input field */
.ssc-ai-char-counter {
    display: block;
    text-align: right;
    font-size: 12px;
    color: #999;
    margin-top: 3px;
}

/* ── Text input + Generate Preview button inline row ───────────────────── */

.ssc-ai-text-input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.ssc-ai-text-input-row .ssc-ai-text-input {
    flex: 1;
    min-width: 0;
}

.ssc-ai-text-input-row .ssc-ai-preview-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 10px 22px;
    font-size: 14px;
    border-radius: 1px;
    margin: 0;
}

/* =========================================================================
   SWATCH GRID — Shared swatch rendering styles
   Used by SSCSwatchRenderer for pa, taxonomy, and recipe source swatches.
   ========================================================================= */

.ssc-swatch-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 4px;
    margin-bottom: 14px;
    overflow: visible;
}

.ssc-swatch-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.15s ease;
    width: 64px;
}

.ssc-swatch-item:hover {
    transform: translateY(-2px);
    z-index: 20;
}

/* Custom hover tooltip — dark bubble + downward caret (replaces native title) */
.ssc-swatch-item::after {
    content: attr(data-ssc-tooltip);
    position: absolute;
    left: 50%;
    bottom: 100%;
    margin-bottom: 8px;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: #333;
    color: #fff;
    font-size: 10px;
    font-weight: 400;
    line-height: 1.25;
    text-align: center;
    border-radius: 4px;
    white-space: nowrap;
    max-width: min(280px, 70vw);
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.12s ease, visibility 0.12s ease;
    z-index: 21;
}

.ssc-swatch-item::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 100%;
    margin-bottom: 1px;
    transform: translateX(-50%);
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid #333;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.12s ease, visibility 0.12s ease;
    z-index: 21;
}

.ssc-swatch-item:hover::before,
.ssc-swatch-item:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Image-based swatch thumbnail */
.ssc-swatch-image {
    width: 54px;
    height: 54px;
    overflow: hidden;
    box-shadow: 0 0 2px 1px rgba(0, 0, 0, 0.2);
}

.ssc-swatch-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Text-only swatch (when no swatch image is available) */
.ssc-swatch-text {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: #555;
    background: #f0f0f0;
    border: 2.5px solid transparent;
    text-align: center;
    padding: 4px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    word-break: break-word;
    line-height: 1.1;
}

/* Active swatch state — spread ring only (no border-color) */
.ssc-swatch-item.ssc-swatch-active .ssc-swatch-image,
.ssc-swatch-item.ssc-swatch-active .ssc-swatch-text {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.9);
}

/* Empty state */
.ssc-swatch-empty {
    font-size: 13px;
    color: #999;
    font-style: italic;
}

/* =========================================================================
   PREVIEW BUTTON — "Generate Preview"
   Sits inline with the text input.  After generation, the button hides.
   It reappears when generation-affecting inputs change (stale state).
   ========================================================================= */

/* When the button is moved inline with the text input (via JS), the section
   becomes an empty shell.  Collapse it so it doesn't add dead whitespace. */
.ssc-ai-preview-section:empty,
.ssc-ai-preview-section {
    margin: 0;
    padding: 0;
}

.ssc-ai-preview-btn {
    display: inline-block;
    padding: 13px 28px;
    background: #272727;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease, transform 0.15s ease;
    letter-spacing: 0.3px;
}

.ssc-ai-preview-btn:hover:not(.disabled) {
    background: #444;
    transform: translateY(-1px);
}

.ssc-ai-preview-btn.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* Gallery overlay — progress during AI generation (createGalleryOverlay in ai-product-page.js) */

/* Ensure the gallery wrapper is a positioning context for our overlay */
.ssc-ai-gallery-ready {
    position: relative !important;
}

.ssc-ai-gallery-ready .woocommerce-product-gallery__image img {
    filter: blur(0px);
    transition: filter 0.6s ease;
}

.ssc-ai-gallery-ready.ssc-ai-gallery-blurred .woocommerce-product-gallery__image img {
    filter: blur(26px);
    transition: filter 0.3s ease;
}

/* Covers the gallery; centers progress UI */
.ssc-ai-gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

/* Active state — display: flex centers the overlay content */
.ssc-ai-gallery-overlay.ssc-ai-overlay-active {
    display: flex;
}

/* Frosted glass card */
.ssc-ai-overlay-content {
    text-align: center;
    padding: 28px 32px;
    max-width: 80%;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px) saturate(1.08);
    -webkit-backdrop-filter: blur(10px) saturate(1.08);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Progress message — white on gallery glass; dark on light zone when inline fallback shows */
.ssc-ai-overlay-message,
.ssc-ai-progress-fallback-message {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 20px;
    min-height: 26px;
    opacity: 0;
    transition: opacity 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.ssc-ai-overlay-message {
    color: #fff;
}

.ssc-ai-progress-fallback-message {
    color: #272727;
}

.ssc-ai-overlay-message.ssc-ai-message-visible,
.ssc-ai-progress-fallback-message.ssc-ai-message-visible {
    opacity: 1;
}

/* Progress bar — boxy; futuristic light bar only on gallery glass card */
.ssc-ai-progress-bar-track,
.ssc-ai-progress-fallback-track {
    width: 100%;
    max-width: 280px;
    height: 6px;
    border-radius: 3px;
    margin: 0 auto;
    overflow: hidden;
}

.ssc-ai-gallery-overlay .ssc-ai-progress-bar-track {
    background: rgba(255, 255, 255, 0.25);
}

.ssc-ai-progress-fallback .ssc-ai-progress-fallback-track {
    background: rgba(0, 0, 0, 0.12);
}

.ssc-ai-progress-bar-fill,
.ssc-ai-progress-fallback-fill {
    width: 0%;
    height: 100%;
    border-radius: 2px;
    transition: width 0.15s linear;
}

.ssc-ai-gallery-overlay .ssc-ai-progress-bar-fill {
    background: linear-gradient(90deg, #f0f0f0 0%, #ffffff 50%, #e8e8e8 100%);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.55);
}

.ssc-ai-progress-fallback .ssc-ai-progress-fallback-fill {
    background: #272727;
}

/* Completion state — jumps to 100% with a smooth ease-out when
   the generation finishes successfully */
.ssc-ai-progress-bar-fill.ssc-ai-bar-complete,
.ssc-ai-progress-fallback-fill.ssc-ai-bar-complete {
    width: 100% !important;
    transition: width 0.4s ease-out;
}

/* =========================================================================
   GENERATION ZONE — Fallback and stale notice (post-generation)

   The generation zone only shows for fallback (error/timeout) and stale
   notice (inputs changed after generation).  The "Your preview is ready!"
   reveal message was removed — the gallery image swap IS the reveal.
   ========================================================================= */

.ssc-ai-generation-zone {
    background: rgb(244 244 244 / 50%);
    border: 1.5px solid #d3d3d3;
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 20px;
    text-align: center;
    min-height: 60px;
}

/* ── Inline progress fallback ────────────────────────────────────────────
   Only shown if the gallery overlay could not be mounted. */
.ssc-ai-progress-fallback {
    display: none;
    padding: 8px 0;
}

/* ── Stale preview notice ──────────────────────────────────────────────── */

.ssc-ai-preview-stale {
    border-color: #ffc107;
}

.ssc-ai-stale-notice {
    display: none;
    font-size: 13px;
    color: #856404;
    background: #fff3cd;
    border-radius: 6px;
    padding: 8px 14px;
    margin-top: 12px;
}

/* ── Fallback state ────────────────────────────────────────────────────── */

.ssc-ai-fallback {
    display: none;
    padding: 20px;
}

.ssc-ai-fallback-message {
    font-size: 15px;
    color: #666;
    margin-bottom: 12px;
    line-height: 1.5;
}

.ssc-ai-retry-link {
    color: #272727;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.ssc-ai-retry-link:hover {
    color: #555;
}

/* =========================================================================
   POST-GENERATE ZONE — After-generate recipe inputs (Notes to Artist, etc.)
   Hidden initially, shown after successful generation, hidden again when
   generation-affecting inputs change (stale state).
   ========================================================================= */

.ssc-ai-post-generate-zone {
    margin-bottom: 16px;
}

/* =========================================================================
   PURCHASE ZONE — Qty stepper/grid + pricing + Add to Cart

   Wraps the sizing zone, price display, price break notice, and ATC button.
   Hidden until a color is selected.  For simple-qty products (no attribute
   grid needed), CSS grid lays out the stepper and price side-by-side to
   match the simple-product fixed-pricing experience.
   ========================================================================= */

.ssc-ai-purchase-zone {
    margin-top: 10px;
}

/* ── Sizing zone (inside purchase zone, always visible when parent shown) */

.ssc-ai-sizing-zone {
    margin-bottom: 16px;
}

.ssc-ai-sizing-title {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ssc-ai-size-grid {
    /* Container for size input row or qty stepper */
}

/* ── Multi-size grid layout ───────────────────────────────────────────── */

.ssc-ai-size-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ssc-ai-size-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.ssc-ai-size-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
    text-align: center;
}

.ssc-ai-size-input {
    width: 56px;
    padding: 8px 4px;
    text-align: center;
    border: 1.5px solid #d3d3d3;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    background: #fff;
    transition: border-color 0.2s ease;
    -moz-appearance: textfield;
    box-sizing: border-box;
}

/* Hide spin buttons on multi-size per-size number inputs */
.ssc-ai-size-input::-webkit-outer-spin-button,
.ssc-ai-size-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ssc-ai-size-input:focus {
    outline: none;
    border-color: #272727;
}

/* ── Simple qty purchase zone layout ───────────────────────────────────────
   When .ssc-ai-simple-qty is added to the purchase zone, CSS grid arranges
   the stepper and price side-by-side, matching the simple-product layout.
   The stepper uses theme classes (.quantity/.decrease/.increase) so the
   theme's existing CSS handles the -/+ button styling. */

.ssc-ai-purchase-zone.ssc-ai-simple-qty {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 20px;
    align-items: start;
}

/* Stepper occupies the left column */
.ssc-ai-purchase-zone.ssc-ai-simple-qty .ssc-ai-sizing-zone {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 0;
}

/* Price display occupies the right column, vertically centered */
.ssc-ai-purchase-zone.ssc-ai-simple-qty .ssc-ai-price-wrapper {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
}

/* Price break notice spans full width below */
.ssc-ai-purchase-zone.ssc-ai-simple-qty .ssc-price-break-notice {
    grid-column: 1 / -1;
}

/* ATC button spans full width below but stays compact (auto-width) */
.ssc-ai-purchase-zone.ssc-ai-simple-qty .ssc-ai-addtocart {
    grid-column: 1 / -1;
    justify-self: start;
    width: auto;
}

/* ── Pricing display ──────────────────────────────────────────────────────
   Base styles for .ssc-fixed-price-display, .ssc-price-each, .ssc-cart-impact,
   and .ssc-price-break-notice live in style.css (shared across all experience
   types). Only AI-builder-specific layout overrides go here. */

.ssc-ai-price-wrapper {
    display: none;
    text-align: left;
    width: fit-content !important;
}

.ssc-ai-price-wrapper .ssc-cart-impact {
    display: none;
}

/* ── Add to Cart button ───────────────────────────────────────────────────
   Uses the theme's button classes (single_add_to_cart_button button alt)
   so the theme handles colors, padding, hover states, and cart icon.
   We only add a disabled state. */

.ssc-ai-addtocart {
    transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.ssc-ai-addtocart:hover:not(.disabled) {
    filter: brightness(1.15);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.ssc-ai-addtocart:active:not(.disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.ssc-ai-addtocart.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* =========================================================================
   PROOF NOTICE — Disclaimer below product image
   ========================================================================= */

.ssc-ai-proof-notice {
    font-size: 0.9em;
    color: #666;
    margin-top: 15px;
}

/* =========================================================================
   TOAST NOTIFICATIONS
   ========================================================================= */

.ssc-ai-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    z-index: 10000;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: #333;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 90vw;
    text-align: center;
}

.ssc-ai-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.ssc-ai-toast-success { background: #4caf50; }
.ssc-ai-toast-warning { background: #ff9800; }
.ssc-ai-toast-error   { background: #e53935; }
.ssc-ai-toast-info    { background: #333; }

/* =========================================================================
   INPUT LOCK — Disabled visual state during AI generation

   Applied via .ssc-ai-inputs-locked on the builder wrapper.  Reduces opacity
   and blocks pointer events on all input containers so the customer cannot
   change values while a generation is in flight.  The cursor change gives a
   clear "you can't interact here" signal.  Native form elements are also
   disabled via JS (.prop('disabled', true)) to block keyboard interaction.
   ========================================================================= */

.ssc-ai-inputs-locked {
    cursor: not-allowed;
}

.ssc-ai-inputs-locked .ssc-ai-input-fields,
.ssc-ai-inputs-locked .ssc-ai-post-generate-zone {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Swatch items need explicit pointer-events: none because they are <div>s,
   not native form elements.  The parent pointer-events: none should cascade,
   but some browsers allow clicks on children with their own handlers. */
.ssc-ai-inputs-locked .ssc-swatch-item {
    pointer-events: none;
}

/* =========================================================================
   RESPONSIVE — Mobile adjustments
   ========================================================================= */

@media (max-width: 768px) {
    .ssc-ai-builder-wrapper {
        margin-top: 5px;
    }

    .ssc-swatch-item {
        width: 56px;
    }

    .ssc-swatch-image,
    .ssc-swatch-text {
        width: 44px;
        height: 44px;
    }

    .ssc-ai-size-row {
        gap: 8px;
    }

    .ssc-ai-size-input {
        width: 48px;
        padding: 6px 2px;
    }

    /* Stack simple-qty purchase zone vertically on mobile */
    .ssc-ai-purchase-zone.ssc-ai-simple-qty {
        grid-template-columns: 1fr;
    }

    .ssc-ai-purchase-zone.ssc-ai-simple-qty .ssc-ai-price-wrapper {
        grid-column: 1;
        grid-row: auto;
    }

    .ssc-ai-text-input-row {
        flex-wrap: wrap;
    }

    .ssc-ai-text-input-row .ssc-ai-text-input {
        flex: 1 1 100%;
    }

    .ssc-ai-preview-btn {
        width: 100%;
        text-align: center;
    }

    .ssc-ai-overlay-content {
        padding: 20px;
        max-width: 90%;
    }

    .ssc-ai-progress-bar-track,
    .ssc-ai-progress-fallback-track {
        max-width: 220px;
    }

    .ssc-ai-overlay-message,
    .ssc-ai-progress-fallback-message {
        font-size: 15px;
    }
}
