/**
 * Jacket Builder — Front-end Styles
 * Layout: WooCommerce single product 2-column (image left, config right).
 */

/* ============================================================
   PAGE WRAPPER — mirrors .woocommerce div.product
   ============================================================ */


/* Ensure configurator is not squeezed by WC's default column float layout */
.woocommerce .type-product .jb-configurator,
.woocommerce div.product .jb-configurator {
    width: 100%;
    float: none;
    clear: both;
}

/* Override WC's default thumbnail column float (it floats images left at ~48%) */
.woocommerce .type-product .jb-layout,
.woocommerce div.product .jb-layout {
    display: flex !important;
    gap: 48px;
    align-items: flex-start;
    float: none !important;
    width: 100% !important;
}

.jb-configurator {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    font-family: inherit;
}

/* ============================================================
   2-COLUMN LAYOUT  (image left | options right)
   Mimics WooCommerce single product layout exactly
   ============================================================ */

.jb-layout {
    display: flex;
    gap: 48px;
    align-items: flex-start;
}

@media (max-width: 768px) {
    .jb-layout {
        flex-direction: column;
        gap: 28px;
    }
}

/* ============================================================
   LEFT — PREVIEW PANEL
   ============================================================ */

.jb-preview-panel {
    flex: 0 0 42%;
    max-width: 440px;
    position: sticky;
    top: 80px;
}

.jb-preview-inner {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 24px 20px;
    text-align: center;
}

.jb-jacket-preview {
    display: inline-block;
    max-width: 100%;
    width: 100%;
}

.jb-preview-svg {
    max-width: 100%;
    height: auto;
    filter: drop-shadow( 0 6px 18px rgba(0,0,0,0.12) );
}

.jb-preview-label {
    display: block;
    margin-top: 10px;
    font-size: 0.78rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

@media (max-width: 768px) {
    .jb-preview-panel {
        flex: none;
        width: 100%;
        max-width: 100%;
        position: static;
    }
    .jb-preview-inner {
        padding: 14px;
    }
}

/* ============================================================
   RIGHT — OPTIONS PANEL  (mimics .woocommerce-product-details)
   ============================================================ */

.jb-options-panel {
    flex: 1;
    min-width: 0;
}

/* Product title area (only shown inside shortcode / page template) */
.jb-product-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #333;
    margin: 0 0 6px;
    line-height: 1.2;
}

.jb-product-price {
    font-size: 1.4rem;
    color: #1a5c2a;
    font-weight: 700;
    margin-bottom: 16px;
}

.jb-product-desc {
    font-size: 0.92rem;
    color: #555;
    margin-bottom: 20px;
    line-height: 1.6;
}

/* ============================================================
   OPTION ROWS
   ============================================================ */

.jb-options-list {
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}

.jb-option-row {
    border-bottom: 1px solid #e5e5e5;
    background: #fff;
}

.jb-option-row:last-child {
    border-bottom: none;
}

.jb-option-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #f7f7f7;
    cursor: default;
    user-select: none;
    border-bottom: 1px solid #e5e5e5;
}

.jb-option-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.jb-option-selected-value {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: #666;
    font-weight: 500;
}

.jb-color-dot,
.jb-inline-color-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.18);
    flex-shrink: 0;
    vertical-align: middle;
}

/* ============================================================
   SWATCH GRID
   ============================================================ */

.jb-swatch-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 10px 16px 14px;
    background: #fff;
}

.jb-swatch {
    width: 28px;
    height: 28px;
    border-radius: 3px;
    border: 2px solid transparent;
    cursor: pointer;
    position: relative;
    padding: 0;
    transition: transform 0.1s ease, border-color 0.12s ease;
    outline: none;
    background-clip: padding-box;
    box-sizing: border-box;
}

.jb-swatch:hover {
    transform: scale(1.2);
    border-color: #444;
    z-index: 2;
}

.jb-swatch--selected {
    border-color: #1a5c2a !important;
    box-shadow: 0 0 0 2px #1a5c2a;
    transform: scale(1.12);
    z-index: 1;
}

/* White swatch needs a border so it's visible */
/* White swatch needs a visible border */
.jb-swatch[data-color="white"],
.jb-swatch[data-color="silver"],
.jb-swatch[style*="#FFFFFF"],
.jb-swatch[style*="#ffffff"],
.jb-swatch[style*="#FFF"],
.jb-swatch[style*="#fff"],
.jb-swatch[style*="#BBBBBB"] {
    border-color: #bbb !important;
}
.jb-swatch[data-color="white"].jb-swatch--selected,
.jb-swatch[data-color="silver"].jb-swatch--selected {
    border-color: #1a5c2a !important;
}

.jb-swatch-check {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: rgba(255,255,255,0.95);
    text-shadow: 0 0 3px rgba(0,0,0,0.7);
    pointer-events: none;
}

/* Dark checkmark for very light swatches */
.jb-swatch[data-color="white"] .jb-swatch-check,
.jb-swatch[data-color="neon_yellow"] .jb-swatch-check,
.jb-swatch[data-color="yellow"] .jb-swatch-check,
.jb-swatch[data-color="bright_yellow"] .jb-swatch-check,
.jb-swatch[data-color="neon_green"] .jb-swatch-check,
.jb-swatch[data-color="bright_lime"] .jb-swatch-check,
.jb-swatch[data-color="lavender"] .jb-swatch-check,
.jb-swatch[data-color="light_pink"] .jb-swatch-check,
.jb-swatch[data-color="sky_blue"] .jb-swatch-check,
.jb-swatch[data-color="silver"] .jb-swatch-check,
.jb-swatch[data-color="beige"] .jb-swatch-check {
    color: rgba(0,0,0,0.7);
    text-shadow: none;
}

/* ============================================================
   PATTERN DROPDOWN
   ============================================================ */

.jb-pattern-select-wrap {
    padding: 10px 16px 14px;
    background: #fff;
}

.jb-pattern-select {
    width: 100%;
    max-width: 300px;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.9rem;
    background: #fff;
    color: #333;
    appearance: auto;
}

/* ============================================================
   QUANTITY + ADD TO CART — WooCommerce style
   ============================================================ */

.jb-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.jb-qty-wrap {
    display: flex;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 3px;
    overflow: hidden;
}

.jb-qty-wrap input[type="number"] {
    width: 50px;
    text-align: center;
    border: none;
    padding: 9px 4px;
    font-size: 0.95rem;
    -moz-appearance: textfield;
}
.jb-qty-wrap input[type="number"]::-webkit-outer-spin-button,
.jb-qty-wrap input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.jb-qty-btn {
    background: #f0f0f0;
    border: none;
    padding: 0 10px;
    font-size: 1.1rem;
    cursor: pointer;
    height: 38px;
    line-height: 1;
    color: #444;
    transition: background 0.1s;
}
.jb-qty-btn:hover { background: #e0e0e0; }

.jb-add-to-cart-btn {
    background: #1a5c2a !important;
    color: #fff !important;
    border: none !important;
    padding: 10px 26px !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.04em;
    border-radius: 3px !important;
    cursor: pointer;
    transition: background 0.18s;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    text-transform: uppercase;
    min-height: 42px;
}

.jb-add-to-cart-btn:hover:not(:disabled) {
    background: #145022 !important;
}

.jb-add-to-cart-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.jb-action-message {
    font-size: 0.88rem;
    color: #1a5c2a;
    font-weight: 600;
    flex: 1 0 100%;
}

.jb-action-message.jb-error {
    color: #c0392b;
}

/* Loading spinner (simple CSS) */
.jb-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: jb-spin 0.65s linear infinite;
    vertical-align: middle;
}

@keyframes jb-spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   CART ITEM CONFIG TABLE
   ============================================================ */

.jb-cart-config {
    margin-top: 8px;
}

.jb-config-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.jb-config-row td {
    padding: 2px 6px;
    vertical-align: middle;
}

.jb-config-key {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    color: #777;
    white-space: nowrap;
    font-size: 0.75rem;
    padding: 2px 6px !important;
}

.jb-config-value {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ============================================================
   EDIT BUTTON
   ============================================================ */

.jb-edit-btn,
a.jb-edit-btn {
    background: #1a5c2a !important;
    color: #fff !important;
    border: none !important;
    border-radius: 3px !important;
    font-size: 0.85rem !important;
    padding: 5px 14px !important;
    cursor: pointer;
    text-decoration: none !important;
    display: inline-block;
    margin-top: 6px;
}

.jb-edit-btn:hover,
a.jb-edit-btn:hover {
    background: #145022 !important;
    color: #fff !important;
}

.jb-edit-btn--small {
    font-size: 0.78rem !important;
    padding: 3px 10px !important;
}

.jb-edit-link {
    color: #1a5c2a;
    font-weight: 600;
    font-size: 0.85rem;
    margin-right: 6px;
    text-decoration: underline;
}

/* ============================================================
   CHECKOUT DESIGNS SECTION
   ============================================================ */

.jb-checkout-designs {
    margin: 30px 0;
}

.jb-checkout-designs-title {
    color: #1a5c2a;
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.jb-designs-table {
    width: auto !important;
    border-collapse: collapse;
    border: 1px solid #e0e0e0;
}

.jb-designs-table th,
.jb-designs-table td {
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    vertical-align: top;
}

.jb-designs-table th {
    background: #f5f5f5;
    font-weight: 600;
    text-align: left;
}

.jb-checkout-config-list { margin: 8px 0; }

.jb-checkout-config-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    padding: 2px 0;
}

.jb-checkout-config-label {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    color: #777;
    font-size: 0.75rem;
    padding: 1px 6px;
    white-space: nowrap;
}

.jb-checkout-config-value {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ============================================================
   ORDER DESIGNS (THANK YOU / MY ACCOUNT)
   ============================================================ */

.jb-order-designs { margin: 30px 0; }

.jb-order-designs h2 {
    color: #1a5c2a;
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.jb-order-designs-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e0e0e0;
}

.jb-order-designs-table th,
.jb-order-designs-table td {
    padding: 14px 18px;
    border: 1px solid #e0e0e0;
    vertical-align: top;
    text-align: left;
}

.jb-order-designs-table th {
    background: #f5f5f5;
    font-weight: 600;
}

.jb-order-preview { margin: 12px 0; }

.jb-order-preview .jb-preview-svg {
    max-width: 160px;
    height: auto;
}

.jb-order-config-list { margin-top: 8px; }

.jb-order-config-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    padding: 2px 0;
}

.jb-order-config-label {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    color: #777;
    font-size: 0.75rem;
    padding: 1px 6px;
    white-space: nowrap;
    min-width: 120px;
    display: inline-block;
}

/* ============================================================
   ORDER BADGE / MISC
   ============================================================ */

.jb-order-badge {
    background: #1a5c2a;
    color: #fff;
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 600px) {
    .jb-swatch {
        width: 24px;
        height: 24px;
    }

    .jb-add-to-cart-btn {
        width: 100% !important;
        justify-content: center;
    }
}

/* ── Accordion option rows ── */
.jb-option-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.jb-option-header:hover { background: #f9f9f9; }
.jb-option-header[aria-expanded="true"] {
    background: #f0f6f2;
    border-bottom: 1px solid #d0e8d8;
}
.jb-option-current {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.jb-selected-swatch {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.18);
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.jb-selected-label {
    font-size: 0.85rem;
    color: #666;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.jb-chevron {
    font-size: 1.3rem;
    color: #999;
    line-height: 1;
    transition: transform 0.2s;
}
.jb-option-panel {
    padding: 12px 16px 16px;
    border-top: 1px solid #eee;
    background: #fafafa;
}
.jb-option-panel[hidden] { display: none; }

/* ── Cart preview thumbnail ── */
.jb-cart-config {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 8px;
}
.jb-cart-preview { flex: 0 0 90px; width: 90px; }
.jb-cart-preview .jb-preview-svg {
    width: 90px !important;
    height: auto !important;
    display: block;
    border: 1px solid #eee;
    border-radius: 3px;
    padding: 4px;
    background: #fafafa;
}
.jb-cart-spec { flex: 1; }

/* ── Checkout preview thumbnail ── */
.jb-checkout-preview-cell { width: 110px; text-align: center; }
.jb-checkout-preview { display: inline-block; width: 100px; }
.jb-checkout-preview .jb-preview-svg {
    width: 100px !important;
    height: auto !important;
    display: block;
    border: 1px solid #eee;
    border-radius: 3px;
    padding: 4px;
    background: #fafafa;
}
.jb-checkout-qty-cell { text-align: center; font-weight: 600; white-space: nowrap; }

/* Ensure pattern select inside panel doesn't overflow */
.jb-option-panel .jb-pattern-select-wrap {
    padding: 4px 0 8px;
}

/* Dependent color row — smooth show/hide */
.jb-option-row.jb-depends-on {
    transition: opacity 0.2s;
}

/* Cart config — ensure SVG thumbnail and spec sit cleanly side by side */
.jb-cart-config {
    display: flex !important;
    align-items: flex-start;
    gap: 14px;
    margin-top: 10px;
    clear: both;
}

/* Remove any dl/dt/dd list WC adds for item_data (now unused) */
.woocommerce-cart-form .cart_item .jb-cart-config + dl.variation {
    display: none;
}

/* ── Professional SVG sizing ── */
.jb-preview-svg {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
}

/* Cart thumbnail */
.jb-cart-thumb .jb-preview-svg,
.jb-cart-preview .jb-preview-svg {
    width: 90px !important;
    height: auto !important;
    border: 1px solid #eee;
    border-radius: 3px;
    padding: 4px;
    background: #fafafa;
}

/* Checkout thumbnail */
.jb-checkout-preview .jb-preview-svg {
    width: 100px !important;
    height: auto !important;
    border: 1px solid #eee;
    border-radius: 3px;
    padding: 4px;
    background: #fafafa;
}

/* Block checkout designs panel */
#jb-block-checkout-designs {
    margin: 24px 0;
}

/* ===== Racing field ===== */
.jb-racing-field label {
    font-weight: 600;
}

.jb-racing-summary {
    margin-top: 12px;
    font-size: 14px;
}

#jb-block-checkout-designs .jb-checkout-designs-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

/* ── Order Summary sidebar thumbnail (block checkout) ── */
.jb-sidebar-thumb {
    display: block;
    width: 56px !important;
    height: 56px !important;
    overflow: hidden;
    border-radius: 3px;
    background: #f5f5f5;
    border: 1px solid #eee;
    flex-shrink: 0;
}

.jb-sidebar-thumb svg,
.jb-sidebar-thumb .jb-preview-svg {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* Sidebar color dot swatches */
.wc-block-order-summary-item .jb-inline-color-dot,
.wc-block-components-order-summary-item .jb-inline-color-dot,
[class*="order-summary-item"] .jb-inline-color-dot {
    display: inline-block !important;
    width: 11px !important;
    height: 11px !important;
    border-radius: 50% !important;
    vertical-align: middle !important;
    margin-left: 4px !important;
    border: 1px solid rgba(0,0,0,0.15) !important;
    flex-shrink: 0;
}