/* کانتینر کلی فیلدهای افزونه CPF */
.cpf-fields-wrapper {
    margin: 22px 0;
    border: 1px solid #e2e8f0;
    padding: 22px;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.03);
    font-family: inherit;
    direction: rtl;
}

.cpf-field-group { 
    margin-bottom: 22px; 
}
.cpf-field-group:last-child { 
    margin-bottom: 0; 
}
.cpf-field-group .cpf-label { 
    display: block; 
    margin-bottom: 8px; 
    font-size: 14px; 
    color: #1e293b; 
}
.cpf-field-group .cpf-label strong { 
    font-weight: 700; 
}

/* ورودی‌های عمومی */
.cpf-input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    background: #f8fafc;
    transition: all 0.2s ease;
    box-sizing: border-box;
}
.cpf-input:focus {
    border-color: var(--cpf-active-border, #0284c7);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* اصلاح قطعی تگ Select و دراپ‌داون سایزها (حل مشکل بریده شدن عنوان) */
select.cpf-input,
.cpf-select-full {
    width: 100% !important;
    max-width: 100% !important;
    height: 46px !important;
    line-height: 24px !important;
    padding: 8px 14px 8px 36px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    background-color: #fff !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 8px !important;
    text-align: right !important;
    direction: rtl !important;
    box-sizing: border-box !important;
    cursor: pointer !important;
    white-space: normal !important;
    text-overflow: clip !important;
    background-position: left 12px center !important;
}

/* کارت‌های انتخاب تصویر و قاب */
.cpf-image-select-container { 
    display: grid; 
    gap: 12px; 
    width: 100%; 
    margin-top: 6px; 
    box-sizing: border-box;
}
.cpf-grid-full { grid-template-columns: 1fr; }
.cpf-grid-2col { grid-template-columns: repeat(2, 1fr); }
.cpf-grid-3col { grid-template-columns: repeat(3, 1fr); }
.cpf-grid-4col { grid-template-columns: repeat(4, 1fr); }

.cpf-image-option {
    position: relative;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.cpf-image-option:hover {
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.06);
}
.cpf-image-option img {
    max-width: 100%;
    width: auto;
    height: 75px;
    max-height: 80px;
    object-fit: contain;
    display: block;
    margin: 0 auto 8px auto;
    border-radius: 6px;
    pointer-events: none;
}
.cpf-image-option span {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.4;
    display: block;
    pointer-events: none;
}
.cpf-opt-price {
    display: block;
    margin-top: 4px;
    font-size: 11.5px;
    color: #0284c7;
    font-weight: 700;
    pointer-events: none;
}

.cpf-no-frame-box {
    width: 100%;
    height: 75px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: 6px;
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
    pointer-events: none;
}

/* رادیوباتن مخفی اما با حفظ واکنش‌پذیری لمسی */
.cpf-image-option input[type="radio"],
.cpf-image-option input[type="checkbox"] { 
    position: absolute; 
    opacity: 0; 
    width: 100%; 
    height: 100%; 
    top: 0; 
    left: 0; 
    margin: 0; 
    cursor: pointer; 
    z-index: 2; 
}

/* وضعیت انتخاب‌شده قاب */
.cpf-image-option.active-selected,
.cpf-image-option:has(input:checked) {
    border-color: var(--cpf-field-border, var(--cpf-active-border, #0284c7)) !important;
    background: #f0f9ff !important;
    box-shadow: 0 0 0 1.5px var(--cpf-field-border, var(--cpf-active-border, #0284c7)), 0 4px 14px rgba(2, 132, 199, 0.15) !important;
}

/* انتخاب‌های قرصی */
.cpf-choices-container { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
}
.cpf-choice-pill {
    position: relative;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all 0.2s;
    user-select: none;
}
.cpf-choice-pill input { 
    position: absolute; 
    opacity: 0; 
}
.cpf-choice-pill:hover { 
    background: #e2e8f0; 
}
.cpf-choice-pill:has(input:checked) {
    background: #0284c7;
    border-color: #0284c7;
    color: #fff;
}

/* بهینه‌سازی ریسپانسیو موبایل */
@media (max-width: 768px) {
    .cpf-mob-1col { 
        grid-template-columns: 1fr !important; 
    }
    .cpf-mob-2col { 
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 8px !important; 
    }
    .cpf-image-option {
        padding: 8px 6px;
    }
    .cpf-image-option img {
        height: 65px;
    }
    .cpf-no-frame-box {
        height: 65px;
    }
    .cpf-fields-wrapper {
        padding: 14px;
        margin: 16px 0;
    }
}

.cpf-total-price-preview {
    margin-top: 18px;
    padding: 14px 18px;
    background: #f8fafc;
    border: 1.5px dashed #cbd5e1;
    border-radius: 10px;
    font-weight: 800;
    font-size: 15px;
    color: #0f172a;
    text-align: center;
}

/* نوار ابزارهای تعاملی */
.cpf-interactive-tools-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin: 16px 0 20px 0;
}
.cpf-btn-enquiry {
    color: #fff !important;
    border: none !important;
    padding: 0 20px !important;
    height: 42px !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    font-size: 13.5px !important;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.cpf-btn-tool {
    height: 42px !important;
    padding: 0 16px !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    border: 1px solid #cbd5e1 !important;
    background: #fff !important;
    color: #334155 !important;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.cpf-btn-tool:hover { 
    background: #f8fafc !important; 
}

/* لایه پرو قاب روی تصویر محصول ووکامرس (پشتیبانی کامل از دسکتاپ و موبایل) */
.woocommerce-product-gallery__image,
.woocommerce-product-gallery,
.woocommerce-product-gallery__wrapper {
    position: relative !important;
}

.cpf-live-frame-wrapper {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none !important;
    z-index: 9999 !important;
    display: none;
    transition: opacity 0.2s ease-in-out;
}

.cpf-live-frame-wrapper img {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    object-fit: fill !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

/* نسبت‌های کالیبره‌شده کاوریج قاب روی بوم ۸۰۰*۸۰۰ */
.cpf-is-portrait .cpf-live-frame-wrapper {
    top: -1.8% !important;
    left: 5.6% !important;
    width: 88.8% !important;
    height: 103.8% !important;
}
.cpf-is-landscape .cpf-live-frame-wrapper {
    top: 6.8% !important;
    left: -1.2% !important;
    width: 102.5% !important;
    height: 86.4% !important;
}
.cpf-is-landscape .cpf-live-frame-wrapper.cpf-frame-rotated-90 {
    transform: rotate(90deg);
    transform-origin: center center;
    top: 6.8% !important;
    left: -1.2% !important;
    width: 102.5% !important;
    height: 86.4% !important;
}
.cpf-is-portrait .cpf-live-frame-wrapper.cpf-frame-rotated-90 {
    transform: rotate(90deg);
    transform-origin: center center;
    top: -1.8% !important;
    left: 5.6% !important;
    width: 88.8% !important;
    height: 103.8% !important;
}

/* بالون راهنما */
.cpf-frontend-tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    background: #0284c7;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    margin-right: 5px;
}
.cpf-frontend-tooltip-bubble {
    display: none;
    position: absolute;
    bottom: 130%;
    right: 50%;
    transform: translateX(50%);
    background: #0f172a;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: normal;
    width: 220px;
    line-height: 1.6;
    z-index: 999;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
    text-align: right;
}
.cpf-frontend-tooltip-icon:hover .cpf-frontend-tooltip-bubble,
.cpf-frontend-tooltip-icon:focus .cpf-frontend-tooltip-bubble { 
    display: block; 
}/* کانتینر کلی فیلدهای افزونه CPF */
.cpf-fields-wrapper {
    margin: 22px 0;
    border: 1px solid #e2e8f0;
    padding: 22px;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.03);
    font-family: inherit;
    direction: rtl;
}

.cpf-field-group { 
    margin-bottom: 22px; 
}
.cpf-field-group:last-child { 
    margin-bottom: 0; 
}
.cpf-field-group .cpf-label { 
    display: block; 
    margin-bottom: 8px; 
    font-size: 14px; 
    color: #1e293b; 
}
.cpf-field-group .cpf-label strong { 
    font-weight: 700; 
}

/* ورودی‌های عمومی */
.cpf-input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    background: #f8fafc;
    transition: all 0.2s ease;
    box-sizing: border-box;
}
.cpf-input:focus {
    border-color: var(--cpf-active-border, #0284c7);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* اصلاح قطعی تگ Select و دراپ‌داون سایزها (حل مشکل بریده شدن عنوان) */
select.cpf-input,
.cpf-select-full {
    width: 100% !important;
    max-width: 100% !important;
    height: 46px !important;
    line-height: 24px !important;
    padding: 8px 14px 8px 36px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    background-color: #fff !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 8px !important;
    text-align: right !important;
    direction: rtl !important;
    box-sizing: border-box !important;
    cursor: pointer !important;
    white-space: normal !important;
    text-overflow: clip !important;
    background-position: left 12px center !important;
}

/* کارت‌های انتخاب تصویر و قاب */
.cpf-image-select-container { 
    display: grid; 
    gap: 12px; 
    width: 100%; 
    margin-top: 6px; 
    box-sizing: border-box;
}
.cpf-grid-full { grid-template-columns: 1fr; }
.cpf-grid-2col { grid-template-columns: repeat(2, 1fr); }
.cpf-grid-3col { grid-template-columns: repeat(3, 1fr); }
.cpf-grid-4col { grid-template-columns: repeat(4, 1fr); }

.cpf-image-option {
    position: relative;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.cpf-image-option:hover {
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.06);
}
.cpf-image-option img {
    max-width: 100%;
    width: auto;
    height: 75px;
    max-height: 80px;
    object-fit: contain;
    display: block;
    margin: 0 auto 8px auto;
    border-radius: 6px;
    pointer-events: none;
}
.cpf-image-option span {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.4;
    display: block;
    pointer-events: none;
}
.cpf-opt-price {
    display: block;
    margin-top: 4px;
    font-size: 11.5px;
    color: #0284c7;
    font-weight: 700;
    pointer-events: none;
}

.cpf-no-frame-box {
    width: 100%;
    height: 75px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: 6px;
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
    pointer-events: none;
}

/* رادیوباتن مخفی اما با حفظ واکنش‌پذیری لمسی */
.cpf-image-option input[type="radio"],
.cpf-image-option input[type="checkbox"] { 
    position: absolute; 
    opacity: 0; 
    width: 100%; 
    height: 100%; 
    top: 0; 
    left: 0; 
    margin: 0; 
    cursor: pointer; 
    z-index: 2; 
}

/* وضعیت انتخاب‌شده قاب */
.cpf-image-option.active-selected,
.cpf-image-option:has(input:checked) {
    border-color: var(--cpf-field-border, var(--cpf-active-border, #0284c7)) !important;
    background: #f0f9ff !important;
    box-shadow: 0 0 0 1.5px var(--cpf-field-border, var(--cpf-active-border, #0284c7)), 0 4px 14px rgba(2, 132, 199, 0.15) !important;
}

/* انتخاب‌های قرصی */
.cpf-choices-container { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
}
.cpf-choice-pill {
    position: relative;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all 0.2s;
    user-select: none;
}
.cpf-choice-pill input { 
    position: absolute; 
    opacity: 0; 
}
.cpf-choice-pill:hover { 
    background: #e2e8f0; 
}
.cpf-choice-pill:has(input:checked) {
    background: #0284c7;
    border-color: #0284c7;
    color: #fff;
}

/* بهینه‌سازی ریسپانسیو موبایل */
@media (max-width: 768px) {
    .cpf-mob-1col { 
        grid-template-columns: 1fr !important; 
    }
    .cpf-mob-2col { 
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 8px !important; 
    }
    .cpf-image-option {
        padding: 8px 6px;
    }
    .cpf-image-option img {
        height: 65px;
    }
    .cpf-no-frame-box {
        height: 65px;
    }
    .cpf-fields-wrapper {
        padding: 14px;
        margin: 16px 0;
    }
}

.cpf-total-price-preview {
    margin-top: 18px;
    padding: 14px 18px;
    background: #f8fafc;
    border: 1.5px dashed #cbd5e1;
    border-radius: 10px;
    font-weight: 800;
    font-size: 15px;
    color: #0f172a;
    text-align: center;
}

/* نوار ابزارهای تعاملی */
.cpf-interactive-tools-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin: 16px 0 20px 0;
}
.cpf-btn-enquiry {
    color: #fff !important;
    border: none !important;
    padding: 0 20px !important;
    height: 42px !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    font-size: 13.5px !important;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.cpf-btn-tool {
    height: 42px !important;
    padding: 0 16px !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    border: 1px solid #cbd5e1 !important;
    background: #fff !important;
    color: #334155 !important;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.cpf-btn-tool:hover { 
    background: #f8fafc !important; 
}

/* لایه پرو قاب روی تصویر محصول ووکامرس (پشتیبانی کامل از دسکتاپ و موبایل) */
.woocommerce-product-gallery__image,
.woocommerce-product-gallery,
.woocommerce-product-gallery__wrapper {
    position: relative !important;
}

.cpf-live-frame-wrapper {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none !important;
    z-index: 9999 !important;
    display: none;
    transition: opacity 0.2s ease-in-out;
}

.cpf-live-frame-wrapper img {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    object-fit: fill !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

/* نسبت‌های کالیبره‌شده کاوریج قاب روی بوم ۸۰۰*۸۰۰ */
.cpf-is-portrait .cpf-live-frame-wrapper {
    top: -1.8% !important;
    left: 5.6% !important;
    width: 88.8% !important;
    height: 103.8% !important;
}
.cpf-is-landscape .cpf-live-frame-wrapper {
    top: 6.8% !important;
    left: -1.2% !important;
    width: 102.5% !important;
    height: 86.4% !important;
}
.cpf-is-landscape .cpf-live-frame-wrapper.cpf-frame-rotated-90 {
    transform: rotate(90deg);
    transform-origin: center center;
    top: 6.8% !important;
    left: -1.2% !important;
    width: 102.5% !important;
    height: 86.4% !important;
}
.cpf-is-portrait .cpf-live-frame-wrapper.cpf-frame-rotated-90 {
    transform: rotate(90deg);
    transform-origin: center center;
    top: -1.8% !important;
    left: 5.6% !important;
    width: 88.8% !important;
    height: 103.8% !important;
}

/* بالون راهنما */
.cpf-frontend-tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    background: #0284c7;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    margin-right: 5px;
}
.cpf-frontend-tooltip-bubble {
    display: none;
    position: absolute;
    bottom: 130%;
    right: 50%;
    transform: translateX(50%);
    background: #0f172a;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: normal;
    width: 220px;
    line-height: 1.6;
    z-index: 999;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
    text-align: right;
}
.cpf-frontend-tooltip-icon:hover .cpf-frontend-tooltip-bubble,
.cpf-frontend-tooltip-icon:focus .cpf-frontend-tooltip-bubble { 
    display: block; 
}

/* اصلاح نهایی ابعاد مستطیلی طبیعی در مینی‌کارت، سبد خرید و تسویه‌حساب */
.woocommerce-cart .woocommerce-cart-form__cart-item .cpf-framed-box.cpf-landscape,
.woocommerce-checkout .woocommerce-checkout-review-order-table .cpf-framed-box.cpf-landscape,
.woocommerce-mini-cart .cpf-framed-box.cpf-landscape {
    width: 76px !important;
    height: 57px !important;
    aspect-ratio: 4/3 !important;
}

.woocommerce-cart .woocommerce-cart-form__cart-item .cpf-framed-box.cpf-portrait,
.woocommerce-checkout .woocommerce-checkout-review-order-table .cpf-framed-box.cpf-portrait,
.woocommerce-mini-cart .cpf-framed-box.cpf-portrait {
    width: 57px !important;
    height: 76px !important;
    aspect-ratio: 3/4 !important;
}

.cpf-framed-box img {
    max-width: none !important;
}

.cpf-image-option .cpf-zoom-trigger {
    transition: transform 0.2s ease, background-color 0.2s ease;
}
.cpf-image-option .cpf-zoom-trigger:hover {
    transform: scale(1.15);
    background: #ffffff !important;
    color: #0284c7;
}

@media (max-width: 768px) {
    .cpf-image-select-container {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    .cpf-image-option {
        padding: 8px !important;
        min-height: 130px !important;
    }
    .cpf-image-option img {
        height: 65px !important;
        object-fit: contain !important;
    }
}