/* استایل کامل برای مدیریت محصولات */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --border-color: #e5e7eb;
    --bg-light: #f9fafb;
    --text-gray: #6b7280;
    --text-dark: #1f2937;
}
.cat-toggle, 
.cat-name, 
#category-dropdown-btn, 
#product-category-btn {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent; /* حذف هاله سیاه هنگام لمس در موبایل */
}
.mvp-card h3 i,
#form-title i {
    margin-left: 10px;
    color: var(--primary-color);
}

.mvp-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.mvp-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.mvp-btn i {
    margin-left: 5px;
}

.form-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-dark);
}

.form-field label i {
    margin-left: 8px;
    color: var(--text-gray);
    width: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.form-field.full-width {
    grid-column: 1 / -1;
}

input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* استایل آپلود تصویر */
.image-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-light);
}

.image-upload-area:hover {
    border-color: var(--primary-color);
    background: #f3f4f6;
}

.image-upload-area i {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 10px;
    display: block;
}

.image-upload-area p {
    margin: 10px 0;
    color: var(--text-gray);
}

.image-upload-area small {
    color: var(--text-gray);
    font-size: 12px;
}

/* گالری تصاویر - اصلاح شده */
.image-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 12px;
    min-height: 120px;
}

.image-item {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    background: white;
    transition: all 0.3s ease;
}

.image-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-color: var(--primary-color);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-item .remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.image-item .remove-image:hover {
    background: var(--danger-hover);
    transform: scale(1.1);
}

.image-item .remove-image i {
    font-size: 12px;
    margin: 0;
}

/* پیام خالی بودن گالری */
.image-gallery:empty::before {
    content: "هیچ تصویری انتخاب نشده است";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    color: var(--text-gray);
    font-size: 14px;
    padding: 30px;
}

/* استایل کارت‌های محصول */
.products-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.product-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.product-card:hover {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.product-card-header {
    background: var(--bg-light);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
}

.product-name i {
    margin-left: 5px;
    color: var(--primary-color);
}

.product-id {
    font-size: 12px;
    color: var(--text-gray);
}

.product-id i {
    margin-left: 3px;
}

.product-card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.product-info .label {
    font-weight: 600;
    color: var(--text-gray);
}

.product-info .label i {
    margin-left: 5px;
    width: 20px;
}

.product-card-actions {
    padding: 12px 16px;
    background: var(--bg-light);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.mvp-btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.mvp-btn-danger {
    background: var(--danger-color);
}

.mvp-btn-danger:hover {
    background: var(--danger-hover);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input {
    width: auto;
    margin: 0;
}

.stock-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 10px;
    background: white;
}

.stock-input-wrapper i {
    color: var(--text-gray);
}

.stock-input-wrapper input {
    border: none;
    padding: 10px 0;
    width: 100%;
}

.stock-input-wrapper input:focus {
    box-shadow: none;
}

.empty-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-gray);
}

.empty-message i:first-child {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
    color: var(--text-gray);
}

.empty-message p {
    margin-top: 15px;
}

/* ریسپانسیو - اصلاح شده برای نمایش افقی در موبایل */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .products-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* اصلاح: نمایش اطلاعات به صورت ردیفی (برچسب و مقدار کنار هم) */
    .product-card-body {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 15px;
        padding: 12px 16px;
    }
    
    .product-info {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 14px;
        padding: 4px 0;
        border-bottom: 1px dashed #f0f0f0;
    }
    
    .product-info:last-child {
        border-bottom: none;
    }
    
    .product-info .label {
        font-weight: 600;
        color: var(--text-gray);
        font-size: 13px;
        white-space: nowrap;
    }
    
    .product-info .label i {
        margin-left: 5px;
        width: 18px;
    }
    
    .product-info span:last-child {
        font-weight: 500;
        color: var(--text-dark);
    }
    
    /* اصلاح: دکمه‌های ویرایش و حذف کنار هم */
    .product-card-actions {
        flex-direction: row;
        justify-content: center;
        gap: 10px;
        padding: 10px 16px;
    }
    
    .product-card-actions button {
        width: auto;
        flex: 1;
        justify-content: center;
    }
    
    .image-gallery {
        justify-content: center;
    }
    
    .image-item {
        width: 80px;
        height: 80px;
    }
}

@media (max-width: 480px) {
    /* ۱. حذف فاصله‌های قاب اصلی برای چسبیدن به لبه‌های موبایل */
    .mvp-card {
        padding: 10px 5px !important; /* کاهش شدید فاصله داخلی کارت اصلی */
        margin: 0 -10px !important;  /* منفی کردن مارجین برای خنثی کردن پدینگ پوسته مادر و چسبیدن به لبه‌ها */
        border-radius: 0 !important;   /* حذف گردی گوشه‌ها در موبایل برای ظاهر نیتیو */
        border-left: none !important;
        border-right: none !important;
    }

    /* ۲. اصلاح قاب فرم افزودن/ویرایش محصول */
    #mvp-product-form-container {
        padding: 12px 10px !important;
        margin: 15px -5px 0 -5px !important; /* چسباندن فرم به لبه‌های کارت اصلی */
        border-radius: 8px !important;       /* گردی ملایم‌تر برای قاب داخلی */
        border-left: none !important;
        border-right: none !important;
    }

    /* ۳. اصلاح نوار فیلترها */
    .products-filter-bar {
        padding: 12px 10px !important;
        margin: 15px -5px !important;
        border-radius: 8px !important;
    }

    /* ۴. بهینه‌سازی ساختار کارت‌های محصول */
    .product-card-header {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
        padding: 10px;
    }
    
    .product-card-body {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 10px;
    }
    
    .product-info {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        padding: 6px 0;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .product-info .label {
        font-size: 12px;
        min-width: 70px;
    }
    
    .product-info span:last-child {
        font-size: 13px;
        text-align: left;
    }
    
    .product-card-actions {
        flex-direction: row;
        gap: 8px;
        padding: 8px 10px;
    }
    
    .product-card-actions button {
        font-size: 12px;
        padding: 6px 10px;
        flex: 1;
    }
    
    .image-upload-area {
        padding: 20px 10px;
    }
    
    .image-upload-area i {
        font-size: 36px;
    }
    
    .image-item {
        width: 70px;
        height: 70px;
    }
}
/* ========== استایل درخت دسته‌بندی ========== */
.category-dropdown,
.category-selector-wrapper {
    position: relative;
    min-width: 200px;
}

.category-dropdown-btn,
.category-selector-btn {
    width: 100%;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    text-align: right;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    transition: all 0.3s ease;
}

.category-dropdown-btn:hover,
.category-selector-btn:hover {
    border-color: var(--primary-color);
}

.category-dropdown-menu,
.category-selector-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    display: none;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 5px;
    
    /* کدهای جدید برای حل مشکل اسکرول در موبایل */
    touch-action: pan-y;                 /* اجازه دادن به اسکرول عمودی بدون تداخل با جاوااسکریپت */
    -webkit-overflow-scrolling: touch;   /* اسکرول بسیار روان و نیتیو در آیفون */
}
.category-dropdown-menu.show,
.category-selector-dropdown.show {
    display: block;
}

/* برای اینکه المان‌های داخلی منو جلوی اسکرول انگشت را نگیرند */
.category-tree, .category-tree-item, .category-item-wrapper {
    touch-action: pan-y;
}
.category-tree {
    padding: 8px 0;
}

.category-tree-item {
    border-bottom: 1px solid #f0f0f0;
}

.category-tree-item:last-child {
    border-bottom: none;
}

.category-item-wrapper {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.category-item-wrapper:hover {
    background: #f3f4f6;
}

.cat-toggle {
    width: 25px;
    height: 25px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    padding: 5px; /* بزرگ‌تر شدن بخش لمسی دکمه */
}

.cat-toggle-placeholder {
    width: 20px;
    display: inline-block;
}

.cat-name {
    flex: 1;
    cursor: pointer;
    color: var(--text-dark);
    font-size: 14px;
}

.cat-name:hover {
    color: var(--primary-color);
}

.cat-children {
    background: #fafafa;
    border-right: 2px solid #e5e7eb;
    margin-right: 20px;
}

/* دسته انتخاب شده */
.category-tree-item.selected > .category-item-wrapper {
    background: #e0e7ff;
}

.category-tree-item.selected .cat-name {
    color: var(--primary-color);
    font-weight: 600;
}



/* استایل追加 برای دراگ و دراپ */
.image-upload-area.dragover {
    border-color: var(--primary-color);
    background: #e0e7ff;
}

/* استایل پیام toast */
.mvp-toast {
    position: fixed;
    bottom: 20px;
    left: 20px;
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mvp-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    background: var(--success-color);
}

.toast-error {
    background: var(--danger-color);
}

.mvp-toast i {
    font-size: 18px;
}



/* ========== استایل فیلتر محصولات ========== */
.products-filter-bar {
    background: #f9fafb;
    padding: 15px 20px;
    border-radius: 16px;
    margin: 20px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
}
.filter-search {
    flex: 2;
    min-width: 200px;
    position: relative;
}
.filter-search i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}
#product-search-input {
    width: 100%;
    padding: 8px 35px 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 40px;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s;
}
#product-search-input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79,70,229,0.1);
}
.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 4px 12px;
    border-radius: 40px;
    border: 1px solid #e2e8f0;
}
.filter-label {
    font-size: 0.8rem;
    color: #475569;
    font-weight: 500;
}
.filter-select {
    border: none;
    background: transparent;
    font-size: 0.8rem;
    padding: 6px 0;
    outline: none;
    cursor: pointer;
}
.filter-reset-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 6px 16px;
    border-radius: 40px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    color: #475569;
}
.filter-reset-btn:hover {
    background: #e2e8f0;
}
@media (max-width: 768px) {
    .products-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-group {
        justify-content: space-between;
    }
}

/* پیام عدم نتیجه */
.no-products-message {
    text-align: center;
    padding: 40px;
    background: #f9fafb;
    border-radius: 16px;
    margin-top: 20px;
    color: #6b7280;
}
.no-products-message i {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
}
/*نمایش پیام آپود شتدن تصاویر ئ*/
    .webp-badge {
        position: absolute;
        bottom: 5px;
        right: 5px;
        background: rgba(0,0,0,0.7);
        color: #fff;
        padding: 2px 6px;
        border-radius: 3px;
        font-size: 9px;
        font-weight: bold;
    }
    .image-item {
        position: relative;
        border: 2px solid #ddd;
        border-radius: 6px;
        overflow: hidden;
    }
    .image-item .image-info {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0,0,0,0.6);
        color: #fff;
        padding: 2px 5px;
        font-size: 10px;
        text-align: center;
    }
    .upload-msg {
        padding: 10px;
        border-radius: 4px;
        margin-bottom: 5px;
        animation: fadeIn 0.3s;
    }
    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }
