@font-face {
    font-family: 'Vazirmatn';
    src: url('Vazirmatn-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body { 
    font-family: 'Vazirmatn', 'Tahoma', 'Arial', sans-serif; 
    background-color: #f4f6f9; 
    color: #333; 
    margin: 0; 
    padding: 15px; 
    direction: rtl;
    font-size: 14px;
    line-height: 1.6;
}

.container { 
    max-width: 900px; 
    margin: 0 auto; 
    background-color: #fff; 
    padding: 20px; 
    border-radius: 8px; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); 
}

h1, h3 { 
    color: #2c3e50; 
    margin-bottom: 20px;
}

h1 { 
    border-bottom: 2px solid #eee; 
    padding-bottom: 15px; 
}

.loader { 
    text-align: center; 
    padding: 40px; 
    font-size: 1.2em; 
    color: #888; 
}

.error { 
    color: #dc3545; 
    font-weight: bold; 
}

hr { 
    border: 0; 
    border-top: 1px solid #eee; 
    margin: 20px 0; 
}

/* Form Styles */
.form-group { 
    margin-bottom: 20px; 
}

.form-row { 
    display: flex; 
    gap: 20px; 
}

.form-row .form-group { 
    flex: 1; 
}

label { 
    display: block; 
    margin-bottom: 8px; 
    font-weight: 600; 
}

input[type="text"], 
input[type="number"], 
textarea, 
select { 
    width: 100%; 
    padding: 10px; 
    border: 1px solid #ddd; 
    border-radius: 4px; 
    box-sizing: border-box; 
    background: #fff; 
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

textarea { 
    resize: vertical; 
}

#save-changes-btn { 
    background-color: #28a745; 
    color: white; 
    padding: 12px 20px; 
    font-size: 1em; 
    width: 100%; 
    border: none; 
    cursor: pointer;
}

#save-changes-btn:disabled { 
    background-color: #aaa; 
}

.hidden { 
    display: none !important; 
}

/* Product Card Styles */
.product-card { 
    display: flex; 
    align-items: center; 
    border: 1px solid #ddd; 
    border-radius: 8px; 
    padding: 15px; 
    margin-bottom: 15px; 
    background: #fafafa; 
}

.product-select-box {
    margin-left: 15px;
    display: flex;
    align-items: center;
}

.product-select-box input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.product-image { 
    width: 80px; 
    height: 80px; 
    object-fit: cover; 
    border-radius: 6px; 
    margin-left: 20px; 
    flex-shrink: 0; 
}

.product-info { 
    flex-grow: 1; 
}

.product-title { 
    margin: 0 0 5px 0; 
    font-size: 1.1em; 
}

.product-price { 
    margin: 0; 
    color: #555; 
}

.product-actions { 
    display: flex; 
    gap: 10px; 
    flex-wrap: wrap;
    justify-content: center;
    flex-shrink: 0;
}

.action-btn { 
    padding: 8px 15px; 
    border: none; 
    border-radius: 5px; 
    cursor: pointer; 
    text-decoration: none; 
    color: white; 
    font-size: 0.9em; 
}

.action-btn.edit { 
    background-color: #007bff; 
}

.action-btn.view { 
    background-color: #6c757d; 
}

.action-btn.delete { 
    background-color: #dc3545; 
}

/* Variation Card Styles */
.variation-card { 
    border: 1px solid #e0e0e0; 
    border-radius: 6px; 
    padding: 20px; 
    margin-bottom: 20px; 
    background: #f9f9f9; 
}

.variation-attributes { 
    font-weight: bold; 
    margin-bottom: 15px; 
    border-bottom: 1px dashed #ccc; 
    padding-bottom: 10px; 
}

/* Modal Styles */
.modal-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0, 0, 0, 0.6); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 1000; 
    overflow: scroll
}

.modal-content { 
    background: white; 
    padding: 30px; 
    border-radius: 8px; 
    width: 90%; 
    max-width: 400px; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); 
}

.modal-actions { 
    display: flex; 
    justify-content: flex-end; 
    gap: 10px; 
    margin-top: 20px; 
}

/* Stock Status */
.product-stock {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 15px;
    color: white;
    font-size: 0.8em;
    font-weight: bold;
    margin-top: 8px;
}

.in-stock {
    background-color: #28a745;
}

.out-of-stock {
    background-color: #dc3545;
}

/* Pagination */
#pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 30px;
    gap: 8px;
}

.page-btn {
    padding: 10px 15px;
    border: 1px solid #ddd;
    background-color: #fff;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.2s;
}

.page-btn:hover {
    background-color: #e9ecef;
    border-color: #ccc;
}

.page-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    font-weight: bold;
}

.page-btn:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

.pagination-dots {
    padding: 10px 0;
    color: #6c757d;
}

/* Search Container */
.search-container {
    display: flex;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #ddd;
}

#search-input {
    flex-grow: 1;
    border: none;
    padding: 12px 15px;
    font-size: 16px;
    outline: none;
}

#search-btn {
    border: none;
    background-color: #007bff;
    color: white;
    padding: 0 20px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

#search-btn:hover {
    background-color: #0056b3;
}

/* Bulk selection */
.bulk-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
    flex-wrap: wrap;
}

.select-all-control {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

#bulk-delete-btn {
    background-color: #dc3545;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 8px 18px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#bulk-delete-btn:disabled {
    background-color: #f3b8be;
    cursor: not-allowed;
    opacity: 0.7;
}

#selected-count {
    font-size: 0.9rem;
    color: #555;
}

/* Image Styles */
.upload-area { 
    border: 2px dashed #ccc; 
    border-radius: 8px; 
    padding: 20px; 
    text-align: center; 
    cursor: pointer; 
    min-height: 150px; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    position: relative; 
}

.upload-area:hover { 
    border-color: #007bff; 
    background-color: #f8f9fa; 
}

.upload-area img { 
    max-width: 100%; 
    max-height: 150px; 
    border-radius: 4px; 
}

.upload-area span { 
    color: #888; 
}

.image-list { 
    margin-top: 15px; 
    display: flex; 
    flex-wrap: wrap; 
    gap: 10px; 
}

.image-item { 
    position: relative; 
    display: inline-block; 
    border: 2px solid #ddd; 
    border-radius: 8px; 
    overflow: hidden; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); 
}

.image-item:hover { 
    border-color: #007bff; 
}

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

.image-item .delete-image-btn { 
    position: absolute; 
    top: 5px; 
    right: 5px; 
    background: rgba(220, 53, 69, 0.9); 
    color: white; 
    border: none; 
    padding: 5px 10px; 
    border-radius: 4px; 
    cursor: pointer; 
    font-size: 12px; 
    font-weight: bold; 
    transition: all 0.2s; 
}

.image-item .delete-image-btn:hover { 
    background: #c82333; 
}

.upload-btn { 
    background-color: #007bff; 
    color: white; 
    padding: 10px 20px; 
    border: none; 
    border-radius: 4px; 
    cursor: pointer; 
    margin-bottom: 10px; 
    transition: all 0.2s; 
}

.upload-btn:hover { 
    background-color: #0056b3; 
}

.gallery-preview { 
    margin-top: 15px; 
    display: flex; 
    flex-wrap: wrap; 
    gap: 10px; 
}

.gallery-preview img { 
    width: 100px; 
    height: 100px; 
    object-fit: cover; 
    border-radius: 8px; 
    border: 1px solid #ddd; 
}

/* Attribute Styles */
.action-buttons { 
    display: flex; 
    gap: 15px; 
}

.add-attribute-btn { 
    background-color: #ff9800; 
    width: auto; 
    margin-bottom: 20px; 
}

.add-variation-btn { 
    background-color: #28a745; 
    width: auto; 
    margin-bottom: 20px; 
}

.attribute-box { 
    background-color: #f5f5f5; 
    padding: 15px; 
    border-radius: 8px; 
    margin-bottom: 15px; 
    border: 2px solid #ddd; 
    position: relative; 
}

.attribute-box.variation-box { 
    border-color: #28a745; 
}

.attribute-box.regular-attribute-box { 
    border-color: #ff9800; 
}

.attribute-box .form-group { 
    margin-bottom: 15px; 
}

.remove-attribute-btn { 
    position: absolute; 
    top: 10px; 
    left: 10px; 
    background: #dc3545; 
    color: white; 
    border: none; 
    padding: 5px 10px; 
    border-radius: 4px; 
    cursor: pointer; 
    font-size: 12px; 
}

.attribute-type-label { 
    position: absolute; 
    top: 10px; 
    right: 10px; 
    background: #007bff; 
    color: white; 
    padding: 5px 15px; 
    border-radius: 15px; 
    font-size: 12px; 
    font-weight: bold; 
}

.attribute-type-label.variation-type { 
    background: #28a745; 
}

.attribute-type-label.regular-type { 
    background: #ff9800; 
}

.input-with-button { 
    display: flex; 
}

.input-with-button input { 
    flex-grow: 1; 
    border-left: none; 
    border-top-left-radius: 0; 
    border-bottom-left-radius: 0; 
}

.input-with-button button, 
.upload-btn { 
    border-top-right-radius: 0; 
    border-bottom-right-radius: 0; 
}

.tags-list { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
    margin-top: 10px; 
}

.tag { 
    background-color: #3498db; 
    color: white; 
    padding: 5px 10px; 
    border-radius: 15px; 
    font-size: 14px; 
    display: flex; 
    align-items: center; 
}

.remove-tag { 
    background: none; 
    border: none; 
    color: white; 
    margin-right: 5px; 
    cursor: pointer; 
    font-weight: bold; 
}

button#add-variation-btn {
    background: #2196F3;
}

/* =================================== */
/* Responsive Design for Mobile */
/* =================================== */

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
        margin: 0;
    }

    h1 {
        font-size: 20px;
        margin-bottom: 15px;
    }

    h3 {
        font-size: 18px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-row .form-group {
        flex: none;
    }

    .product-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 15px;
    }

    .product-image {
        margin-left: 0;
        width: 120px;
        height: 120px;
    }

    .product-actions {
        width: 100%;
        justify-content: space-around;
        margin-top: 10px;
    }

    .action-btn {
        padding: 10px 15px;
        flex-grow: 1;
        text-align: center;
    }

    .variation-card {
        padding: 15px;
    }

    .variation-attributes {
        font-size: 14px;
    }

    .action-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .action-buttons button {
        width: 100% !important;
    }

    .attribute-box {
        padding: 12px;
    }

    .attribute-box .form-group {
        margin-bottom: 12px;
    }

    .remove-attribute-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .attribute-type-label {
        padding: 4px 10px;
        font-size: 11px;
    }

    .input-with-button {
        flex-direction: column;
    }

    .input-with-button input {
        border: 1px solid #ddd;
        border-radius: 4px;
    }

    .input-with-button button {
        width: 100%;
        border-radius: 4px;
        margin-top: 5px;
    }

    .modal-content {
        padding: 20px;
        width: 95%;
    }

    .upload-area {
        padding: 15px;
        min-height: 120px;
    }

    .gallery-preview img {
        width: 80px;
        height: 80px;
    }

    .image-item img {
        width: 100px;
        height: 100px;
    }

    #pagination-container {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
        font-size: 13px;
    }

    .container {
        padding: 10px;
    }

    h1 {
        font-size: 18px;
    }

    .form-group {
        margin-bottom: 15px;
    }

    input[type="text"],
    input[type="number"],
    textarea,
    select {
        padding: 8px;
        font-size: 14px;
    }

    .tag {
        font-size: 12px;
        padding: 4px 8px;
    }

    .product-actions {
        flex-direction: column;
        gap: 10px;
    }

    .variation-card {
        padding: 10px;
    }

    .attribute-box {
        padding: 10px;
    }
}

/* Select2 Styles for RTL and Mobile */
.select2-container {
    width: 100% !important;
    direction: rtl;
}

.select2-container--default .select2-selection--multiple {
    border: 1px solid #ddd;
    border-radius: 4px;
    min-height: 42px;
    padding: 2px 8px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #3498db;
    border: none;
    border-radius: 15px;
    color: white;
    padding: 3px 10px;
    margin: 2px;
    direction: rtl;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: white;
    margin-left: 5px;
    margin-right: 0;
}

.select2-container--default .select2-search--inline .select2-search__field {
    direction: rtl;
    text-align: right;
}

.select2-dropdown {
    direction: rtl;
}

.select2-results__option {
    text-align: right;
    direction: rtl;
}

.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default .select2-search--dropdown .select2-search__field {
    border-color: #3498db;
}

/* Mobile Select2 adjustments */
@media (max-width: 768px) {
    .select2-container {
        font-size: 14px;
    }
    
    .select2-container--default .select2-selection--multiple {
        min-height: 38px;
        padding: 1px 6px;
    }
    
    .select2-container--default .select2-selection--multiple .select2-selection__choice {
        font-size: 13px;
        padding: 2px 8px;
        margin: 1px;
    }
}

@media (max-width: 480px) {
    .select2-container {
        font-size: 13px;
    }
    
    .select2-container--default .select2-selection--multiple {
        min-height: 36px;
        padding: 1px 5px;
    }
    
    .select2-container--default .select2-selection--multiple .select2-selection__choice {
        font-size: 12px;
        padding: 2px 6px;
    }
    
    .select2-dropdown {
        font-size: 13px;
    }
}
