/**
 * Shahin | WooCommerce UI
 */

:root {
    --shahin-qty-border: #e3e6ec;
    --shahin-qty-bg: #ffffff;
    --shahin-qty-btn-bg: #f5f6fa;
    --shahin-qty-btn-hover: #e67e22;
    --shahin-qty-text: #2c3e50;
    --shahin-qty-radius: 10px;
    --shahin-qty-size: 38px;
    --shahin-sale-bg: #e74c3c;
    --shahin-sale-text: #ffffff;
}

/* ------------------------------------------------------------------
 * فیلد تعداد
 * --------------------------------------------------------------- */

.woocommerce .quantity.shahin-qty,
.woocommerce-page .quantity.shahin-qty,
.quantity.shahin-qty,
.quantity:has(> .shahin-qty-btn) {
    display: inline-flex;
    align-items: stretch;
    direction: ltr;
    background: var(--shahin-qty-bg);
    border: 1px solid var(--shahin-qty-border);
    border-radius: var(--shahin-qty-radius);
    overflow: hidden;
    width: auto;
    max-width: 100%;
    vertical-align: middle;
}

.quantity .shahin-qty-btn {
    flex: 0 0 var(--shahin-qty-size);
    width: var(--shahin-qty-size);
    min-width: var(--shahin-qty-size);
    min-height: var(--shahin-qty-size);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: 0;
    background: var(--shahin-qty-btn-bg);
    color: var(--shahin-qty-text);
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.quantity .shahin-qty-btn:hover:not(:disabled),
.quantity .shahin-qty-btn:focus-visible:not(:disabled) {
    background: var(--shahin-qty-btn-hover);
    color: #fff;
    outline: none;
}

.quantity .shahin-qty-btn:active:not(:disabled) {
    transform: scale(0.94);
}

.quantity .shahin-qty-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* اگر یک صفحه‌ساز کنترل تعداد را دوباره تزریق کرد، دومی نمایش داده نشود. */
.quantity .shahin-qty-minus ~ .shahin-qty-minus,
.quantity .shahin-qty-plus ~ .shahin-qty-plus {
    display: none !important;
}

.quantity.shahin-qty input.qty,
.quantity:has(> .shahin-qty-btn) input.qty {
    flex: 1 1 auto;
    width: 52px;
    min-width: 44px;
    min-height: var(--shahin-qty-size);
    padding: 0 4px;
    margin: 0;
    border: 0;
    border-left: 1px solid var(--shahin-qty-border);
    border-right: 1px solid var(--shahin-qty-border);
    border-radius: 0;
    background: transparent;
    color: var(--shahin-qty-text);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    box-shadow: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.quantity.shahin-qty input.qty:focus,
.quantity:has(> .shahin-qty-btn) input.qty:focus {
    outline: none;
    box-shadow: none;
}

.quantity input.qty::-webkit-outer-spin-button,
.quantity input.qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.quantity.hidden,
.quantity.hidden .shahin-qty-btn {
    display: none !important;
}

/* هم‌ترازییی با دکمه افزودن به سبد در صفحه محصول */
.woocommerce div.product form.cart .quantity.shahin-qty {
    margin-right: 0;
    margin-left: 8px;
}

.woocommerce table.cart td.product-quantity .quantity.shahin-qty,
.woocommerce-cart table.cart td.product-quantity .quantity.shahin-qty {
    margin: 0 auto;
}

/* ------------------------------------------------------------------
 *  تعداد + افزودن به سبد در آرشیو محصولات 
 * --------------------------------------------------------------- */

.shahin-loop-cart {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.shahin-loop-cart .quantity.shahin-qty--loop {
    --shahin-qty-size: 34px;
    flex: 0 0 auto;
}

.shahin-loop-cart .quantity.shahin-qty--loop input.qty {
    width: 44px;
    font-size: 14px;
}

.shahin-loop-cart > .button,
.shahin-loop-cart > a.button {
    margin: 0 !important;
    flex: 1 1 auto;
    text-align: center;
    white-space: nowrap;
}

.shahin-loop-cart > a.added_to_cart {
    flex: 1 1 100%;
    margin: 0;
    font-size: 13px;
    text-align: center;
}

.woocommerce ul.products li.product .shahin-loop-cart a.button {
    margin-top: 0;
}

/* ------------------------------------------------------------------
 * برچسب درصد تخفیف
 * --------------------------------------------------------------- */

.woocommerce ul.products li.product,
.woocommerce div.product .woocommerce-product-gallery,
.woocommerce .product_thumbnail {
    position: relative;
}

.woocommerce span.onsale.shahin-onsale,
.woocommerce-page span.onsale.shahin-onsale,
span.onsale.shahin-onsale {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px;
    left: 12px;
    right: auto;
    bottom: auto;
    min-width: 56px;
    min-height: 56px;
    width: auto;
    height: auto;
    padding: 8px 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--shahin-sale-bg, #e74c3c) 0%, var(--shahin-sale-bg2, #b03a2e) 100%);
    color: var(--shahin-sale-text, #fff);
    font-family: inherit;
    line-height: 1.1;
    direction: rtl;
    z-index: 9;
    margin: 0;
    box-shadow:
        0 6px 16px rgba(0,0,0,0.28),
        0 0 0 3px rgba(255,255,255,0.35),
        inset 0 2px 4px rgba(255,255,255,0.35),
        inset 0 -8px 14px rgba(0,0,0,0.18);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

span.onsale.shahin-onsale:hover {
    transform: scale(1.07) rotate(-4deg);
}

/* موقعیت برچسب حراج (قابل تنظیم از پنل ابزارها) */
span.onsale.shahin-onsale.shahin-onsale--pos-top-left {
    top: 12px !important;
    left: 12px !important;
    right: auto !important;
    bottom: auto !important;
}

span.onsale.shahin-onsale.shahin-onsale--pos-top-right {
    top: 12px !important;
    right: 12px !important;
    left: auto !important;
    bottom: auto !important;
}

span.onsale.shahin-onsale.shahin-onsale--pos-bottom-left {
    bottom: 12px !important;
    left: 12px !important;
    top: auto !important;
    right: auto !important;
}

span.onsale.shahin-onsale.shahin-onsale--pos-bottom-right {
    bottom: 12px !important;
    right: 12px !important;
    top: auto !important;
    left: auto !important;
}

/* افکت حلقه ضربان‌دار */
.shahin-onsale--fx-pulse::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    border: 2px solid var(--shahin-sale-bg, #e74c3c);
    animation: shahinOnsaleRing 1.6s ease-out infinite;
    pointer-events: none;
}

@keyframes shahinOnsaleRing {
    0%   { opacity: 0.8; transform: scale(1); }
    100% { opacity: 0;   transform: scale(1.45); }
}

/* افکت برق لامع */
.shahin-onsale--fx-shine {
    overflow: hidden;
}

.shahin-onsale--fx-shine::before {
    content: "";
    position: absolute;
    top: -10%;
    bottom: -10%;
    width: 55%;
    left: -80%;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,0.55), transparent);
    transform: skewX(-20deg);
    animation: shahinOnsaleShine 2.2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes shahinOnsaleShine {
    0%        { left: -80%; }
    60%, 100% { left: 130%; }
}

/* افکت شناور */
.shahin-onsale--fx-float {
    animation: shahinOnsaleFloat 2.4s ease-in-out infinite;
}

@keyframes shahinOnsaleFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
    .shahin-onsale--fx-pulse::after,
    .shahin-onsale--fx-shine::before,
    .shahin-onsale--fx-float {
        animation: none;
    }
}

.woocommerce div.product .woocommerce-product-gallery span.onsale.shahin-onsale {
    min-width: 62px;
    min-height: 62px;
}

.shahin-onsale__value {
    font-size: 16px;
    font-weight: 900;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.shahin-onsale__value bdi {
    direction: ltr;
    unicode-bidi: isolate;
}

.shahin-onsale__text {
    font-size: 10px;
    font-weight: 700;
    opacity: 0.9;
    letter-spacing: 0.5px;
}

.shahin-onsale--variable {
    border-radius: 24px !important;
}

.shahin-onsale--variable .shahin-onsale__value {
    font-size: 13px;
}

/* ------------------------------------------------------------------
 * موبایل
 * --------------------------------------------------------------- */

@media screen and (max-width: 480px) {
    .quantity.shahin-qty {
        --shahin-qty-size: 40px;
    }

    .shahin-loop-cart {
        gap: 6px;
    }

    .shahin-loop-cart .quantity.shahin-qty--loop {
        --shahin-qty-size: 36px;
    }

    .shahin-loop-cart > .button,
    .shahin-loop-cart > a.button {
        flex: 1 1 100%;
    }

    span.onsale.shahin-onsale {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ------------------------------------------------------------------
 * شکل‌های مختلف برچسب تخفیف
 * --------------------------------------------------------------- */

span.onsale.shahin-onsale.shahin-onsale--rounded {
    border-radius: 12px !important;
}

span.onsale.shahin-onsale.shahin-onsale--square {
    border-radius: 6px !important;
}

.shahin-onsale__amount {
    font-size: 10px;
    opacity: 0.85;
    margin-top: 2px;
}

.shahin-onsale__amount .woocommerce-Price-amount {
    font-size: inherit;
    color: inherit;
}

/* ------------------------------------------------------------------
 * ویژگی‌های سفارشی محصول (فرانت)
 * --------------------------------------------------------------- */

.shahin-product-attrs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 12px 0;
    padding: 14px 16px;
    background: #f9f9f9;
    border-radius: 10px;
    border: 1px solid #eef0f5;
}

.shahin-attr-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.shahin-attr-label {
    font-weight: 700;
    color: #555;
}

.shahin-attr-value {
    color: #2c3e50;
}

.shahin-color-swatch {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.12);
    vertical-align: middle;
    flex-shrink: 0;
}

.shahin-color-swatch--md {
    width: 18px;
    height: 18px;
}

.shahin-color-code {
    font-size: 13px;
    color: #7f8c8d;
    direction: ltr;
}

.shahin-attrs-table {
    width: 100%;
    border-collapse: collapse;
}

.shahin-attrs-table th,
.shahin-attrs-table td {
    padding: 8px 12px;
    text-align: right;
    border-bottom: 1px solid #eef0f5;
    font-size: 14px;
}

.shahin-attrs-table th {
    width: 35%;
    font-weight: 700;
    color: #555;
    background: #f9f9f9;
}
