/* ==========================================================================
   Aramapp Variation Swatches - Frontend
   ========================================================================== */

/* הסתרה נגישה של ה-select המקורי (נחוץ ל-WC JS פנימית) */
.variations_form .aramapp-hidden-select,
.variations table.variations .aramapp-hidden-select {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

/* מיכל הסוואצ'ים */
.aramapp-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 6px 0 14px;
    line-height: 1;
}

/* ===== סוואץ' בסיסי ===== */
.aramapp-swatch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    cursor: pointer;
    border: 1.5px solid #d8d8d8;
    border-radius: 6px;
    background: #fff;
    color: #222;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-align: center;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background-color 0.18s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 40px;
    min-width: 40px;
    padding: 8px 14px;
}

.aramapp-swatch:hover {
    border-color: #555;
    background: #fafafa;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

.aramapp-swatch:focus-visible {
    outline: none;
    border-color: #111;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.12);
}

/* מצב נבחר */
.aramapp-swatch.selected {
    border-color: #111;
    border-width: 2px;
    font-weight: 700;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    /* מונע "קפיצה" בגלל שינוי עובי המסגרת */
    padding: 7px 13px;
    transform: none;
}

/* ציון ויזואלי למצב נבחר - V קטן בפינה */
.aramapp-swatch.selected::before {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    width: 18px;
    height: 18px;
    background: #111;
    border-radius: 50%;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: 11px 11px;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2;
}

/* תמיכה ב-RTL - הצ'ק בצד ימין */
html[dir="rtl"] .aramapp-swatch.selected::before,
body.rtl .aramapp-swatch.selected::before {
    left: auto;
    right: -6px;
}

/* מצב מושבת (אין במלאי) */
.aramapp-swatch.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f5f5f5;
    border-color: #e5e5e5;
    color: #888;
    pointer-events: none;
    overflow: hidden;
}

/* קו חוצה על הסוואץ' המושבת */
.aramapp-swatch.disabled::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -5%;
    right: -5%;
    height: 1px;
    background: rgba(0, 0, 0, 0.35);
    transform: rotate(-20deg);
    transform-origin: center;
    pointer-events: none;
}

.aramapp-swatch.disabled .aramapp-swatch-label {
    text-decoration: line-through;
    text-decoration-thickness: 1px;
}

/* ===== סוואץ' צבע ===== */
.aramapp-swatches-type-color .aramapp-swatch.has-color {
    width: 40px;
    height: 40px;
    padding: 3px;
    min-width: 40px;
    min-height: 40px;
}

.aramapp-swatch-color {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.aramapp-swatches-type-color .aramapp-swatch.has-color.selected {
    padding: 2px;
}

/* תמיכה בצבעים בהירים (לבן/קרם) - מוודא שרואים את הגבול */
.aramapp-swatch-color[style*="#fff"],
.aramapp-swatch-color[style*="#ffffff"],
.aramapp-swatch-color[style*="rgb(255, 255, 255)"] {
    border-color: rgba(0, 0, 0, 0.15);
}

/* ===== סוואץ' תמונה ===== */
.aramapp-swatches-type-image .aramapp-swatch.has-image {
    width: 56px;
    height: 56px;
    padding: 2px;
    min-width: 56px;
    min-height: 56px;
    overflow: hidden;
}

.aramapp-swatch-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    pointer-events: none; /* כדי שהקליק יגיע ל-DIV ולא ל-IMG */
}

.aramapp-swatches-type-image .aramapp-swatch.has-image.selected {
    padding: 1px;
}

/* ===== Tooltip על hover ===== */
.aramapp-swatches-type-color .aramapp-swatch[title]:hover::after,
.aramapp-swatches-type-image .aramapp-swatch[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #222;
    color: #fff;
    padding: 5px 9px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    opacity: 0;
    animation: aramappTooltipIn 0.15s ease forwards;
    animation-delay: 0.3s;
}

@keyframes aramappTooltipIn {
    to { opacity: 1; }
}

/* לא מציג tooltip על מצב disabled */
.aramapp-swatch.disabled:hover::after {
    display: none;
}

/* ===== FOMO Banner ===== */
.aramapp-fomo-banner {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe9e9 100%);
    border: 1px solid #ffc1c1;
    color: #c62828;
    padding: 12px 16px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    margin: 14px 0;
    font-size: 14px;
    line-height: 1.4;
    animation: aramappFomoPulse 2.5s infinite;
}

@keyframes aramappFomoPulse {
    0%   { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.25); }
    70%  { box-shadow: 0 0 0 12px rgba(198, 40, 40, 0); }
    100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0); }
}

/* ===== שיפורי טבלת ווריאציות - מרווחים ותצוגה ===== */
.variations_form table.variations {
    border: none;
    margin-bottom: 15px;
}

.variations_form table.variations tr {
    display: block;
    margin-bottom: 10px;
}

.variations_form table.variations td,
.variations_form table.variations th {
    display: block;
    padding: 0;
    border: none;
    width: 100%;
}

.variations_form table.variations label {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    display: inline-block;
    color: #222;
}

/* ===== Mobile (עד 600px) ===== */
@media (max-width: 600px) {
    .aramapp-swatches {
        gap: 8px;
    }

    .aramapp-swatch {
        min-height: 44px; /* יעד מגע מינימלי מומלץ */
        padding: 10px 14px;
        font-size: 14px;
    }

    .aramapp-swatch.selected {
        padding: 9px 13px;
    }

    .aramapp-swatches-type-color .aramapp-swatch.has-color {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .aramapp-swatches-type-image .aramapp-swatch.has-image {
        width: 60px;
        height: 60px;
        min-width: 60px;
        min-height: 60px;
    }

    /* ב-mobile לא מציגים tooltip - זה מפריע ללחיצה */
    .aramapp-swatch[title]:hover::after {
        display: none;
    }

    .aramapp-fomo-banner {
        font-size: 13px;
        padding: 10px 14px;
    }
}

/* ===== מסכים רחבים (יותר אוורירי) ===== */
@media (min-width: 1024px) {
    .aramapp-swatches {
        gap: 12px;
    }
}

/* ===== מצב טעינה של ווקומרס (מחליף opacity) ===== */
.variations_form.processing .aramapp-swatches {
    opacity: 0.6;
    pointer-events: none;
}
