/* Container */
.pw-table-wrapper { font-family: inherit; background: #fff; border: 1px solid #eaeaea; border-radius: 12px; padding: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); margin-bottom: 30px; overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
.pw-table-wrapper::-webkit-scrollbar { height: 6px; }
.pw-table-wrapper::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 10px; }
.pw-table-wrapper::-webkit-scrollbar-track { background: #f7fafc; border-radius: 10px; }

/* Header & Table */
.pw-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px dashed #eaeaea; padding-bottom: 15px; margin-bottom: 15px; flex-wrap: wrap; gap: 10px; min-width: 650px; }
.pw-header h3 { margin: 0; font-size: 18px; font-weight: bold; color: #2d3748; }
.pw-discount-info { color: #718096; font-size: 13px; }
.pw-discount-info strong { color: #00b894; font-weight: bold; }
.pw-table { width: 100%; border-collapse: collapse; text-align: right; min-width: 750px !important; }
.pw-table th { color: #a0aec0; font-weight: normal; padding: 12px; border-bottom: 1px solid #edf2f7; font-size: 13px; white-space: nowrap; }
.pw-table td { padding: 15px 12px; border-bottom: 1px solid #edf2f7; vertical-align: middle; }

/* Badges & Text */
.pw-brand-name { font-weight: bold; font-size: 15px; color: #1a202c; white-space: nowrap; }
.pw-brand-desc { font-size: 11px; color: #718096; margin-top: 5px; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.pw-badge { padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: bold; display: inline-block; white-space: nowrap;}
.pw-grade { background: #ebf4ff; color: #3182ce; }
.in-stock { background: #c6f6d5; color: #22543d; }
.out-stock { background: #fed7d7; color: #822727; }
.pw-mobile-badges { display: none; } /* بصورت پیش‌فرض مخفی */

/* Form UI */
.pw-form { display: flex; flex-direction: column; gap: 8px; margin: 0; align-items: flex-start; }
.pw-form .added_to_cart { display: none !important; }
.pw-qty-container { display: inline-flex !important; align-items: stretch !important; border: 1px solid #e2e8f0 !important; border-radius: 8px !important; overflow: hidden !important; background: #fff !important; height: 40px !important; width: max-content !important; max-width: 100% !important; }
.pw-btn-minus, .pw-btn-plus { background: #f7fafc !important; border: none !important; width: 35px !important; cursor: pointer !important; color: #4a5568 !important; font-weight: bold !important; font-size: 16px !important; display: flex !important; align-items: center !important; justify-content: center !important; padding: 0 !important; margin: 0 !important; }
.pw-btn-minus:hover, .pw-btn-plus:hover { background: #edf2f7 !important; }
.pw-input-qty { border: none !important; border-left: 1px solid #e2e8f0 !important; border-right: 1px solid #e2e8f0 !important; text-align: center !important; width: 80px !important; outline: none !important; box-shadow: none !important; padding: 0 !important; background: #fff !important; margin: 0 !important; border-radius: 0 !important; font-family: inherit !important; }
.pw-input-qty::-webkit-outer-spin-button, .pw-input-qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pw-input-qty[type=number] { -moz-appearance: textfield; }
.pw-btn-add { background: #1a202c !important; color: #fff !important; border: none !important; padding: 0 20px !important; cursor: pointer !important; font-weight: bold !important; font-size: 13px !important; margin: 0 !important; border-radius: 0 !important; white-space: nowrap !important; display: flex !important; align-items: center !important; justify-content: center !important; }
.pw-btn-add:hover { background: #2d3748 !important; }
.pw-btn-add:disabled { background: #cbd5e0 !important; cursor: not-allowed !important; }
.pw-calc-res { font-size: 13px; margin-top: 5px; display: none; align-items: center; gap: 8px; white-space: nowrap; }
.pw-disc-badge { color: #22543d; background: #c6f6d5; padding: 2px 6px; border-radius: 4px; font-weight: bold; font-size: 11px; }
.pw-total-price { color: #276749; font-weight: bold; }
.pw-error-msg { color: #e53e3e; font-size: 11px; font-weight: bold; display: none; white-space: nowrap; }




/* ==========================================
   قوانین فوق قدرتمند موبایل (پیروزی بر وودمارت)
========================================== */
@media (max-width: 768px) {
    .pw-table-wrapper .pw-table { min-width: 100% !important; }
    .pw-table-wrapper .pw-header { min-width: 100%; flex-direction: column; align-items: flex-start; gap: 5px; }
    
    /* اولویت بالا برای مخفی کردن ستون‌ها در برابر قالب‌ها */
    .pw-table-wrapper table th.pw-hide-mobile,
    .pw-table-wrapper table td.pw-hide-mobile {
        display: none !important;
    }
    
    /* نمایش لیبل‌های زیر اسم با اولویت بالا */
    .pw-table-wrapper .pw-mobile-badges { 
        display: flex !important; 
        gap: 8px; margin-top: 10px; flex-wrap: wrap; 
    }
    
    .pw-table-wrapper th, .pw-table-wrapper td { padding: 15px 5px !important; font-size: 12px; }
    .pw-table-wrapper .pw-brand-name { font-size: 13px; white-space: normal; line-height: 1.5; }
    
    /* ==========================================
       تغییر ساختار فرم سفارش به حالت دو ردیفه
    ========================================== */
    .pw-table-wrapper .pw-qty-container { 
        display: grid !important; 
        grid-template-columns: 32px minmax(50px, 1fr) 32px !important; /* 3 ستون برای مثبت، منفی و کادر */
        height: auto !important; 
        width: 120px !important; /* عرض ثابت و مرتب برای کل فرم */
        border: none !important; /* حذف کادر اصلی */
        background: transparent !important; 
        gap: 8px 0 !important; /* فاصله عمودی بین کادر مقدار و دکمه افزودن */
    }

    /* بازسازی کادر برای دکمه‌های مقدار */
    .pw-table-wrapper .pw-btn-minus { 
        border: 1px solid #e2e8f0 !important; 
        border-left: none !important; 
        border-radius: 0 6px 6px 0 !important; /* گوشه گرد سمت راست */
        height: 36px !important;
    }
    .pw-table-wrapper .pw-input-qty { 
        border-top: 1px solid #e2e8f0 !important; 
        border-bottom: 1px solid #e2e8f0 !important; 
        width: 100% !important;
        height: 36px !important;
    }
    .pw-table-wrapper .pw-btn-plus { 
        border: 1px solid #e2e8f0 !important; 
        border-right: none !important; 
        border-radius: 6px 0 0 6px !important; /* گوشه گرد سمت چپ */
        height: 36px !important;
    }

    /* انتقال دکمه افزودن به ردیف پایین و کشش تمام‌عرض */
    .pw-table-wrapper .pw-btn-add { 
        grid-column: 1 / 4 !important; /* اشغال کل 3 ستون بالایی */
        height: 36px !important; 
        border-radius: 6px !important; /* در موبایل دکمه افزودن گوشه‌های گرد دارد */
        padding: 0 !important; 
        font-size: 13px !important; 
    }
}