/**
 * AVIV SHLUSH – Judaica Sets Manager - Frontend Styles
 * Version: 2.1.0 (Phase 1 CRO — Compact Thumbnails)
 *
 * STRUCTURE:
 *   Section A (lines 1–309):  ORIGINAL v1.2.0 — zero changes
 *   Section B (lines 311+):   NEW thumbnail strip polish
 *
 * ASTRA-PROOF: All critical layout is inline on elements.
 *   This CSS only adds visual polish — hover, selection glow,
 *   scrollbar hiding, error states, transitions.
 *   Every new rule uses ultra-specific selectors + !important.
 */

/* ==========================================================================
   Main Wrapper
   ========================================================================== */

.jsm-set-components-wrapper {
    direction: rtl;
    text-align: right;
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

/* ==========================================================================
   Title
   ========================================================================== */

.jsm-components-title {
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* ==========================================================================
   Components List
   ========================================================================== */

.jsm-components-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* ==========================================================================
   Single Component
   ========================================================================== */

.jsm-component {
    background: #fff;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #ddd;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.jsm-component:focus-within {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.15);
}

/* ==========================================================================
   Component Label
   ========================================================================== */

.jsm-component-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 15px;
    color: #333;
}

.jsm-component-label .required {
    color: #e74c3c;
    margin-right: 3px;
}

/* ==========================================================================
   Component Select (Dropdown)
   ========================================================================== */

.jsm-component-select {
    width: 100%;
    padding: 12px 15px;
    font-size: 15px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 12px;
    padding-left: 35px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    direction: rtl;
    text-align: right;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.jsm-component-select:hover {
    border-color: #999;
}

.jsm-component-select:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
}

/* ==========================================================================
   Dropdown Options
   ========================================================================== */

.jsm-component-select option {
    padding: 10px;
    direction: rtl;
}

.jsm-component-select option:disabled {
    color: #999;
    background-color: #f5f5f5;
}

.jsm-component-select option.out-of-stock {
    color: #999;
    font-style: italic;
}

/* ==========================================================================
   Component Notices
   ========================================================================== */

.jsm-component-notice {
    margin: 10px 0 0 0;
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 13px;
}

.jsm-all-out-of-stock {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

/* ==========================================================================
   Set Unavailable Message
   ========================================================================== */

.jsm-set-unavailable {
    margin-top: 20px;
    padding: 15px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    color: #721c24;
    text-align: center;
}

.jsm-set-unavailable p {
    margin: 0;
    font-weight: 600;
}

/* ==========================================================================
   Set Indicator in Cart
   ========================================================================== */

.jsm-set-indicator {
    margin-left: 5px;
}

/* ==========================================================================
   Cart Item Data Display
   ========================================================================== */

.woocommerce-cart-form .cart_item dl.variation dt,
.woocommerce-checkout .shop_table dl.variation dt {
    font-weight: 600;
    margin-left: 5px;
}

/* RTL specific for cart */
[dir="rtl"] .woocommerce-cart-form dl.variation,
[dir="rtl"] .woocommerce-checkout dl.variation {
    direction: rtl;
    text-align: right;
}

/* ==========================================================================
   Validation Styles
   ========================================================================== */

.jsm-component.has-error .jsm-component-select {
    border-color: #e74c3c;
    background-color: #fff8f8;
}

.jsm-component .jsm-error-message {
    color: #e74c3c;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.jsm-component.has-error .jsm-error-message {
    display: block;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.jsm-component-select.loading {
    opacity: 0.6;
    pointer-events: none;
}

.jsm-component.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: jsm-spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Add to Cart Button Disabled State
   ========================================================================== */

.single_add_to_cart_button.disabled,
.single_add_to_cart_button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media screen and (max-width: 768px) {
    .jsm-set-components-wrapper {
        padding: 15px;
        margin: 15px 0;
    }

    .jsm-components-title {
        font-size: 16px;
        margin-bottom: 15px;
        padding-bottom: 10px;
    }

    .jsm-component-select {
        padding: 10px 12px;
        padding-left: 30px;
        font-size: 14px;
    }

    .jsm-component-label {
        font-size: 14px;
    }
}

@media screen and (max-width: 480px) {
    .jsm-set-components-wrapper {
        padding: 12px;
        border-radius: 6px;
    }

    .jsm-component {
        padding: 12px;
    }

    .jsm-component-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .jsm-set-components-wrapper {
        background: none;
        border: 1px solid #000;
        padding: 10px;
    }

    .jsm-component-select {
        border: 1px solid #000;
    }
}


/* **************************************************************************
 * **************************************************************************
 *
 *   NEW IN v2.1.0 — COMPACT THUMBNAIL STRIPS
 *   All rules use ultra-specific selectors to survive Astra/theme CSS.
 *   Critical layout is inline on elements; this handles polish only.
 *
 * **************************************************************************
 * ************************************************************************** */


/* ==========================================================================
   Scrollbar Hiding (cosmetic — keeps native scroll behavior)
   ========================================================================== */

.jsm-set-components-wrapper .jsm-thumb-row::-webkit-scrollbar {
    display: none !important;
    height: 0 !important;
    width: 0 !important;
}

.jsm-set-components-wrapper .jsm-thumb-row {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
}

/* ==========================================================================
   Individual Thumbnail — Interaction States
   ========================================================================== */

.jsm-set-components-wrapper .jsm-thumb {
    -webkit-user-select: none !important;
    user-select: none !important;
    outline: none !important;
}

/* Hover: subtle lift */
.jsm-set-components-wrapper .jsm-thumb:not(.jsm-thumb--oos):hover .jsm-thumb-frame {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

/* Active press feedback */
.jsm-set-components-wrapper .jsm-thumb:not(.jsm-thumb--oos):active .jsm-thumb-frame {
    transform: scale(0.95) !important;
    transition: transform 0.1s ease !important;
}

/* Focus visible for keyboard */
.jsm-set-components-wrapper .jsm-thumb:focus-visible .jsm-thumb-frame {
    outline: 2px solid #2271b1 !important;
    outline-offset: 2px !important;
}

/* ==========================================================================
   Thumbnail Frame — Selection Border (set via JS inline, polish here)
   ========================================================================== */

.jsm-set-components-wrapper .jsm-thumb-frame {
    transition: border-color 0.15s ease, box-shadow 0.2s ease, transform 0.1s ease !important;
}

/* Selected glow */
.jsm-set-components-wrapper .jsm-thumb--active .jsm-thumb-frame {
    border-color: #2271b1 !important;
    box-shadow: 0 0 0 1px rgba(34, 113, 177, 0.3), 0 2px 8px rgba(34, 113, 177, 0.12) !important;
}

/* ==========================================================================
   Selection Checkmark Badge (CSS-only, no extra HTML needed)
   Small blue circle with white ✓ — top-left corner of frame.
   Uses ::after on the .jsm-thumb wrapper (which has position:relative inline).
   ========================================================================== */

.jsm-set-components-wrapper .jsm-thumb--active::after {
    content: '✓' !important;
    position: absolute !important;
    top: -3px !important;
    left: 0 !important;
    width: 20px !important;
    height: 20px !important;
    background: #2271b1 !important;
    color: #fff !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 20px !important;
    text-align: center !important;
    border-radius: 50% !important;
    pointer-events: none !important;
    z-index: 2 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
    animation: jsm-check-pop 0.2s ease !important;
}

@keyframes jsm-check-pop {
    0%   { transform: scale(0); opacity: 0; }
    70%  { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   Thumbnail Label — Selection State
   ========================================================================== */

.jsm-set-components-wrapper .jsm-thumb--active .jsm-thumb-label {
    color: #1a5c8f !important;
    font-weight: 600 !important;
}

/* ==========================================================================
   Out of Stock
   ========================================================================== */

.jsm-set-components-wrapper .jsm-thumb--oos {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
}

.jsm-set-components-wrapper .jsm-thumb--oos .jsm-thumb-frame img {
    filter: grayscale(70%) !important;
}

.jsm-set-components-wrapper .jsm-thumb--oos:hover .jsm-thumb-frame {
    box-shadow: none !important;
}

/* ==========================================================================
   Error State — Highlight the Thumbnail Row
   ========================================================================== */

.jsm-set-components-wrapper .jsm-component.has-error .jsm-thumb-row {
    background: #fff5f5 !important;
    border-radius: 10px !important;
    padding-top: 8px !important;
    padding-bottom: 12px !important;
    outline: 2px solid #e74c3c !important;
    outline-offset: -2px !important;
}

/* ==========================================================================
   Touch Optimization
   ========================================================================== */

@media screen and (max-width: 768px) {
    .jsm-set-components-wrapper .jsm-thumb {
        touch-action: manipulation !important;
    }
}

/* ==========================================================================
   Print — Hide thumbnails, show select
   ========================================================================== */

@media print {
    .jsm-set-components-wrapper .jsm-thumb-row {
        display: none !important;
    }

    .jsm-set-components-wrapper .jsm-component-select {
        position: static !important;
        width: auto !important;
        height: auto !important;
        clip: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        opacity: 1 !important;
    }
}


/* **************************************************************************
 *   CURATED SET — "Quick Pick" Section
 * ************************************************************************** */

.jsm-set-components-wrapper .jsm-curated-section {
    margin-bottom: 20px !important;
    padding: 0 !important;
}

.jsm-set-components-wrapper .jsm-curated-card {
    background: linear-gradient(135deg, #f8f9ff 0%, #eef3ff 100%) !important;
    border: 1.5px solid #d0ddf5 !important;
    border-radius: 10px !important;
    padding: 18px 16px !important;
    text-align: center !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.jsm-set-components-wrapper .jsm-curated-card:hover {
    border-color: #2271b1 !important;
    box-shadow: 0 2px 12px rgba(34, 113, 177, 0.1) !important;
}

.jsm-set-components-wrapper .jsm-curated-card.jsm-curated--applied {
    border-color: #2271b1 !important;
    background: linear-gradient(135deg, #f0f7ff 0%, #e3efff 100%) !important;
    box-shadow: 0 0 0 1px rgba(34, 113, 177, 0.2) !important;
}

.jsm-set-components-wrapper .jsm-curated-icon {
    font-size: 26px !important;
    margin-bottom: 6px !important;
    line-height: 1 !important;
}

.jsm-set-components-wrapper .jsm-curated-headline {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: #333 !important;
    margin: 0 0 4px 0 !important;
    line-height: 1.3 !important;
}

.jsm-set-components-wrapper .jsm-curated-sub {
    font-size: 12.5px !important;
    color: #777 !important;
    margin: 0 0 14px 0 !important;
    line-height: 1.3 !important;
}

.jsm-set-components-wrapper .jsm-curated-btn {
    display: inline-block !important;
    background: #2271b1 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 11px 28px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: background 0.15s ease, transform 0.1s ease !important;
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
    letter-spacing: 0.2px !important;
}

.jsm-set-components-wrapper .jsm-curated-btn:hover {
    background: #1a5c8f !important;
}

.jsm-set-components-wrapper .jsm-curated-btn:active {
    transform: scale(0.97) !important;
}

.jsm-set-components-wrapper .jsm-curated-btn.jsm-curated-btn--applied {
    background: #46a049 !important;
    pointer-events: none !important;
}

.jsm-set-components-wrapper .jsm-curated-divider {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    margin: 16px 0 4px 0 !important;
    color: #bbb !important;
    font-size: 12px !important;
}

.jsm-set-components-wrapper .jsm-curated-divider::before,
.jsm-set-components-wrapper .jsm-curated-divider::after {
    content: '' !important;
    flex: 1 !important;
    height: 1px !important;
    background: #e0e0e0 !important;
}
