/**
 * Robnety Wholesale — Widget Styles
 * Neutral, minimal baseline. All values are overridable via Elementor style controls.
 *
 * Class reference (canonical):
 *  .rw-product-grid        — CSS grid wrapper
 *  .rw-product-card        — single card
 *    .rw-out-of-stock      — modifier on card when OOS
 *  .rw-product-image       — image container (aspect-ratio trick via padding-bottom)
 *    img                   — product image
 *    .rw-discount-badge    — "−XX%" label (top-left)
 *    .rw-stock-badge       — in/out stock label (top-right)
 *      .rw-in / .rw-out    — state modifiers
 *  .rw-product-info        — info column (flex)
 *  .rw-product-title       — h3
 *  .rw-product-sku         — SKU paragraph
 *  .rw-product-pricing     — price row
 *    .rw-regular-price     — crossed-out regular
 *    .rw-wholesale-price   — bold wholesale price
 *  .rw-min-qty             — minimum quantity note
 *  .rw-accordion           — description accordion wrapper
 *    .rw-accordion-trigger — button
 *    .rw-accordion-icon    — +/× character
 *    .rw-accordion-body    — collapsible body
 *  .rw-add-to-cart         — ATC wrapper
 *    .rw-qty-row           — qty + button row
 *    .rw-qty-input         — number input
 *    .rw-btn               — base button class
 *    .rw-btn-atc           — ATC button (applies to both simple & variations)
 *    .rw-btn-add-to-cart   — simple product ATC button
 *    .rw-btn-variations    — variable product "choose options" button
 *    .rw-atc-feedback      — success/error message
 *  #rw-variation-modal     — variation modal
 *    .rw-modal-overlay     — backdrop
 *    .rw-modal-content     — white box
 *    .rw-modal-close       — × button
 *    .rw-modal-title       — h3 inside modal body
 *    .rw-variation-attr    — attribute row (label + select)
 *    #rw-modal-pricing     — pricing area
 *    #rw-modal-qty         — qty input in modal
 *    .rw-modal-atc         — ATC button in modal
 *  .rw-loading             — spinner element
 *  .rw-wholesale-badge     — order item badge
 */

/* ── Elementor widget full-width ──────────────────────────────── */
.elementor-widget-rw_wholesale_products,
.elementor-widget-rw_wholesale_products .elementor-widget-container {
    width: 100%;
}

/* ── Grid ─────────────────────────────────────────────────────── */
.rw-product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 1024px) {
    .rw-product-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}
@media (max-width: 640px) {
    .rw-product-grid { grid-template-columns: 1fr; gap: 12px; }
}

/* ── Card ─────────────────────────────────────────────────────── */
.rw-product-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow .18s ease, transform .18s ease;
}
.rw-product-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, .10);
    transform: translateY(-2px);
}
.rw-product-card.rw-out-of-stock { opacity: .6; }

/* ── Image ────────────────────────────────────────────────────── */
/*
 * The Elementor image_ratio control outputs: padding-bottom: X%; height: 0;
 * This collapses the container, hiding a normal-flow img (height:100% = 0).
 * Fix: img is absolutely positioned to fill the padding-based intrinsic height.
 */
.rw-product-image {
    position: relative;
    overflow: hidden;
    background: #f3f4f6;
    /* Default 1:1 — same technique Elementor applies so no layout jump */
    padding-bottom: 100%;
    height: 0;
}
.rw-product-image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform .3s ease;
}
.rw-product-card:hover .rw-product-image img { transform: scale(1.04); }

/* ── Badges ───────────────────────────────────────────────────── */
.rw-discount-badge,
.rw-stock-badge {
    position: absolute;
    top: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
}
.rw-discount-badge { left: 10px; background: #ef4444; color: #fff; }
.rw-stock-badge    { right: 10px; }
.rw-stock-badge.rw-in  { background: #22c55e; color: #fff; }
.rw-stock-badge.rw-out { background: #9ca3af; color: #fff; }

/* ── Product info column ──────────────────────────────────────── */
.rw-product-info {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 6px;
}

/* ── Title ────────────────────────────────────────────────────── */
.rw-product-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    line-height: 1.4;
}

/* ── SKU ──────────────────────────────────────────────────────── */
.rw-product-sku {
    margin: 0;
    font-size: 11px;
    color: #9ca3af;
}
.rw-product-sku code {
    background: #f3f4f6;
    color: #6b7280;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: inherit;
}

/* ── Pricing ──────────────────────────────────────────────────── */
.rw-product-pricing {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
}
.rw-regular-price s {
    color: #9ca3af;
    font-size: 12px;
    text-decoration: line-through;
}
.rw-wholesale-price {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
}

/* ── Min qty ──────────────────────────────────────────────────── */
.rw-min-qty {
    margin: 0;
    font-size: 11px;
    color: #9ca3af;
}

/* ── Accordion ────────────────────────────────────────────────── */
.rw-accordion {
    border-top: 1px solid #e5e7eb;
    margin-top: 4px;
}
.rw-accordion-trigger {
    all: unset;
    box-sizing: border-box;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 9px 0;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .05em;
    transition: color .15s;
}
.rw-accordion-trigger:hover         { color: #111827; }
.rw-accordion-icon {
    font-size: 18px;
    font-weight: 300;
    line-height: 1;
    flex-shrink: 0;
    transition: transform .15s;
}
.rw-accordion-trigger[aria-expanded="true"] .rw-accordion-icon { transform: rotate(45deg); }
.rw-accordion-body[hidden]      { display: none; }
.rw-accordion-body:not([hidden]) {
    display: block;
    padding-bottom: 10px;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.6;
}

/* ── Add to cart ──────────────────────────────────────────────── */
.rw-add-to-cart { margin-top: auto; padding-top: 12px; }

.rw-qty-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.rw-qty-input {
    width: 60px;
    padding: 9px 6px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
    color: #111827;
    background: #fff;
    -moz-appearance: textfield;
    transition: border-color .15s;
}
.rw-qty-input:focus { outline: none; border-color: #111827; }
.rw-qty-input::-webkit-inner-spin-button,
.rw-qty-input::-webkit-outer-spin-button { opacity: 1; }

/* Base button */
.rw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 9px 16px;
    border: 2px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    line-height: 1;
    transition: background .15s, color .15s, border-color .15s;
    white-space: nowrap;
}
.rw-btn:focus-visible { outline: 3px solid #111827; outline-offset: 2px; }
.rw-btn:active        { transform: scale(.97); }

/* Add to cart button (shared for simple + modal ATC) */
.rw-btn-add-to-cart {
    flex: 1;
    background: #111827;
    border-color: #111827;
    color: #fff;
}
.rw-btn-add-to-cart:hover:not(:disabled) {
    background: #374151;
    border-color: #374151;
}
.rw-btn-add-to-cart:disabled { opacity: .45; cursor: not-allowed; }

/* Variations button */
.rw-btn-variations {
    width: 100%;
    background: #111827;
    border-color: #111827;
    color: #fff;
}
.rw-btn-variations:hover:not(:disabled) {
    background: #374151;
    border-color: #374151;
}
.rw-btn-variations:disabled { opacity: .45; cursor: not-allowed; }

/* Feedback */
.rw-atc-feedback {
    min-height: 18px;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 600;
}
.rw-atc-feedback.success { color: #16a34a; }
.rw-atc-feedback.error   { color: #dc2626; }

/* ── Order item badge ─────────────────────────────────────────── */
.rw-wholesale-badge {
    display: inline-block;
    padding: 2px 7px;
    background: #111827;
    color: #fff;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    vertical-align: middle;
    margin-left: 5px;
}

/* ── Variation modal ──────────────────────────────────────────── */
.rw-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
}
.rw-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(2px);
}
.rw-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    width: 90%;
    max-width: 520px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .18);
}
.rw-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: #f3f4f6;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
    padding: 4px 10px;
    border-radius: 6px;
    transition: background .15s, color .15s;
}
.rw-modal-close:hover { background: #e5e7eb; color: #111827; }
.rw-modal-title {
    margin: 0 0 20px;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    padding-right: 40px;
    line-height: 1.3;
}
.rw-variation-attr        { margin-bottom: 14px; }
.rw-variation-attr label  { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.rw-variation-attr select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    color: #111827;
    cursor: pointer;
    outline: none;
    transition: border-color .15s;
}
.rw-variation-attr select:focus { border-color: #111827; }
#rw-modal-pricing {
    padding: 12px 14px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 14px;
}
.rw-modal-qty-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}
/* Modal ATC button inherits .rw-btn — add sizing */
.rw-modal-atc {
    width: 100%;
    background: #111827;
    border-color: #111827;
    color: #fff;
    margin-top: 4px;
}
.rw-modal-atc:hover:not(:disabled) { background: #374151; border-color: #374151; }
.rw-modal-atc:disabled             { opacity: .45; cursor: not-allowed; }

/* ── Loading spinner ──────────────────────────────────────────── */
.rw-loading {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: rw-spin .5s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}
@keyframes rw-spin { to { transform: rotate(360deg); } }

/* Dark loading (used in modal body placeholder) */
.rw-loading-dark {
    border-color: rgba(0, 0, 0, .15);
    border-top-color: #111827;
}