@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: 20px; 
    direction: rtl;
    font-size: 14px;
    line-height: 1.6;
}
.container { max-width: 1000px; margin: 0 auto; background-color: #fff; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
h1 { color: #2c3e50; border-bottom: 2px solid #eee; padding-bottom: 15px; }
h1 i { margin-left: 10px; }
.hidden { display: none !important; }
.loader { text-align: center; padding: 40px; font-size: 1.2em; color: #888; }

/* Filter Styles */
.filter-container { margin: 20px 0; display: flex; gap: 10px; flex-wrap: wrap; }
.filter-btn { padding: 10px 20px; border: 1px solid #ddd; background: #f9f9f9; border-radius: 20px; cursor: pointer; transition: all 0.2s; }
.filter-btn.active { background-color: #007bff; color: white; border-color: #007bff; }

/* Order List Styles */
.order-card { display: grid; grid-template-columns: 1fr 1.5fr 1fr 1fr; align-items: center; border: 1px solid #ddd; border-radius: 8px; padding: 20px; margin-bottom: 15px; cursor: pointer; transition: box-shadow 0.2s; }
.order-card:hover { box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.order-card strong { display: block; font-size: 0.9em; color: #888; }

/* Status Badges */
.status-badge { padding: 5px 12px; border-radius: 15px; color: white; font-weight: bold; text-align: center; }
.status-completed { background-color: #28a745; }
.status-processing { background-color: #007bff; }
.status-on-hold { background-color: #ffc107; color: #333; }
.status-cancelled { background-color: #dc3545; }
.status-pending { background-color: #6c757d; }

/* Order Detail Styles */
#back-to-list-btn { float: left; margin-bottom: 15px; }
.detail-section { margin-bottom: 25px; border: 1px solid #eee; padding: 20px; border-radius: 8px; }
.detail-section h3 { margin-top: 0; }
.line-items-table { width: 100%; border-collapse: collapse; }
.line-items-table th, .line-items-table td { text-align: right; padding: 10px; border-bottom: 1px solid #eee; }
.order-actions-footer { display: flex; justify-content: flex-end; align-items: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid #ddd; }
.status-update-container { display: flex; gap: 10px; }

/* Styles for select dropdown */
#status-changer {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 15px;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    background-color: #fff;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    flex: 1;
    min-width: 150px;
}

#update-status-btn {
    padding: 10px 20px;
    white-space: nowrap;
}

.action-btn { 
    padding: 8px 15px; 
    border: none; 
    border-radius: 5px; 
    cursor: pointer; 
    text-decoration: none; 
    color: white; 
    font-size: 0.9em; 
    background-color: #007bff; 
}
.action-btn.view { background-color: #6c757d; }

/* رسید کارت به کارت */
.receipt-image-container {
    text-align: center;
    margin-top: 15px;
}

.receipt-image {
    max-width: 100%;
    height: auto;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.receipt-image:hover {
    transform: scale(1.05);
    cursor: zoom-in;
}


/* =================================== */
/* استایل‌های واکنش‌گرا برای صفحه سفارشات */
/* =================================== */

@media (max-width: 768px) {

    /* --- اصلاحات کلی --- */
    body {
        padding: 10px;
    }
    .container {
        padding: 15px;
    }
    h1 {
        font-size: 1.5em;
    }

    /* --- اصلاحات بخش لیست سفارش‌ها --- */

    /* وسط‌چین کردن دکمه‌های فیلتر */
    .filter-container {
        justify-content: center;
    }

    /* مهم‌ترین بخش: تغییر ساختار کارت سفارش از گرید به بلاک */
    .order-card {
        display: grid;
        /* تعریف یک گرید دو ستونه: لیبل و مقدار */
        grid-template-columns: auto 1fr;
        gap: 10px 20px; /* فاصله عمودی و افقی */
        align-items: center;
        padding: 15px;
    }

    .order-card > div {
        /* هر آیتم در گرید در جای خود قرار می‌گیرد */
        grid-column: span 2; /* به صورت پیش‌فرض هر آیتم تمام عرض را بگیرد */
    }

    /* استایل‌دهی مجدد به وضعیت سفارش برای نمایش بهتر */
    .order-card > div:last-child {
        margin-top: 10px;
        justify-self: center; /* وضعیت در وسط قرار بگیرد */
    }
    
    /* --- اصلاحات بخش جزئیات سفارش --- */

    /* افزودن قابلیت اسکرول افقی به جدول محصولات */
    .detail-section {
        overflow-x: auto; /* کلید حل مشکل جدول */
    }

    .line-items-table {
        min-width: 600px; /* تعیین یک عرض حداقلی برای جدول تا بهم نریزد */
        width: 100%;
    }
    
    /* دکمه بازگشت را تمام‌عرض می‌کنیم */
    #back-to-list-btn {
        width: 100%;
        text-align: center;
        margin-bottom: 20px;
        float: none;
    }

    /* چیدمان عمودی برای بخش بروزرسانی وضعیت */
    .order-actions-footer, .status-update-container {
        flex-direction: column;
        width: 100%;
        gap: 15px;
    }

    #status-changer, #update-status-btn {
        width: 100%;
        text-align: center;
    }
    
    #status-changer {
        padding: 12px 15px;
        font-size: 16px;
        font-family: 'Vazirmatn', 'Tahoma', sans-serif;
        border: 1px solid #ddd;
        border-radius: 8px;
        background-color: #fff;
        cursor: pointer;
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: left 15px center;
        padding-right: 40px;
        padding-left: 15px;
    }
    
    #update-status-btn {
        padding: 12px 20px;
        font-size: 16px;
        font-weight: bold;
        height: auto;
        min-height: 48px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 18px;
    }
    
    .filter-btn {
        padding: 8px 15px;
        font-size: 13px;
    }
}

/* ===================================== */
/* استایل برای نمایش عکس در لیست سفارشات */
/* ===================================== */

/* تغییر ساختار کارت سفارش برای جا دادن عکس */
.order-card {
    display: flex; /* استفاده از فلکس برای چیدمان افقی */
    align-items: center;
    gap: 15px; /* فاصله بین عکس و اطلاعات */
}

/* استایل کانتینر عکس */
.order-image-container {
    width: 80px;
    height: 80px;
    flex-shrink: 0; /* جلوگیری از کوچک شدن عکس */
    background-color: #f0f0f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* عکس‌های بزرگ را برش می‌دهد */
}

.order-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* استایل اطلاعات سفارش */
.order-info {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr;
    gap: 8px 15px;
    width: 100%;
    align-items: center;
}

.order-info > div:last-child {
    grid-column: span 3; /* وضعیت سفارش تمام عرض را بگیرد */
    justify-self: start;
}

/* استایل لودر کوچک */
.mini-loader {
    width: 24px;
    height: 24px;
    border: 3px solid #ddd;
    border-top-color: #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* واکنش‌گرایی برای موبایل */
@media (max-width: 768px) {
    .order-info {
        grid-template-columns: 1fr; /* در موبایل همه چیز زیر هم */
        gap: 10px;
    }
    .order-info > div:last-child {
        grid-column: span 1; /* بازنشانی مقدار بالا */
    }
}

/* ===================================== */
/* استایل‌های جدید برای صفحه‌بندی */
/* ===================================== */

#pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 30px;
    gap: 8px;
    flex-wrap: wrap; /* برای نمایش بهتر در موبایل */
}
.page-btn {
    padding: 10px 15px;
    border: 1px solid #ddd;
    background-color: #fff;
    color: #333;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.2s;
}
.page-btn:hover:not(:disabled) {
    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 5px;
    color: #6c757d;
}
.error {
    color: #dc3545;
    font-weight: bold;
    text-align: center;
    padding: 20px;
}