/* =======================================================
   WooPartner Portal - Main Stylesheet
   ======================================================= */

/* --- ساختار کلی و واکنش‌گرایی --- */
.woopartner-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: inherit;
    direction: rtl;
}

/* --- فرم‌ها و فیلدهای ورودی --- */
.woopartner-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    align-items: flex-end;
}

.woopartner-form-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 200px;
}

.woopartner-form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.woopartner-form-group select,
.woopartner-form-group input {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.woopartner-form-group select:focus,
.woopartner-form-group input:focus {
    border-color: #007cba;
    box-shadow: 0 0 5px rgba(0, 124, 186, 0.2);
    outline: none;
}

/* --- دکمه‌ها --- */
.woopartner-button {
    background-color: #007cba;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

.woopartner-button:hover {
    background-color: #005a87;
}

.woopartner-button:active {
    transform: scale(0.98);
}

.woopartner-button:disabled {
    background-color: #a0c4d9;
    cursor: not-allowed;
    transform: none;
}

/* --- مدیریت جداول لیست (جلوگیری از بهم ریختگی در موبایل) --- */
.partner-invoice-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin-top: 20px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.partner-invoice-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.partner-invoice-table th,
.partner-invoice-table td {
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid #e5e5e5;
}

.partner-invoice-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.partner-invoice-table tbody tr:hover {
    background-color: #fdfdfd;
}

/* =======================================================
   استایل‌های فاکتور رسمی (Official Invoice)
   ======================================================= */
.woopartner-invoice-actions { 
    margin-bottom: 20px; 
    display: flex; 
    gap: 10px; 
}

.official-invoice-wrapper {
    direction: rtl; 
    font-family: Tahoma, Arial, sans-serif; 
    font-size: 12px;
    color: #222; 
    width: 100%; 
    max-width: 1050px; 
    margin: 0 auto; 
    background: #fff;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.official-invoice-wrapper table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-bottom: 0; 
    border-spacing: 0; 
}

.official-invoice-wrapper td, 
.official-invoice-wrapper th { 
    border: 1px solid #222; 
    padding: 6px 4px; 
    text-align: center; 
    color: #222; 
}

.official-invoice-wrapper .header-table td { border: none; }
.official-invoice-wrapper .header-table { border: 1px solid #222; border-bottom: none; }
.official-invoice-wrapper .title-cell h1 { font-size: 16px; margin: 0; text-align: center; font-weight: bold; }
.official-invoice-wrapper .meta-cell p { margin: 4px 0; text-align: left; font-size: 11px; }
.official-invoice-wrapper .meta-cell span { float: right; font-weight: bold; }
.official-invoice-wrapper .section-title { text-align: center; border: 1px solid #222; border-bottom: none; background-color: #f7f7f7; font-weight: bold; padding: 6px; font-size: 13px; }
.official-invoice-wrapper .info-table { border-bottom: none; }
.official-invoice-wrapper .info-table td { text-align: right; padding-right: 8px; font-size: 12px; }
.official-invoice-wrapper .items-table { border-top: none; }
.official-invoice-wrapper .items-table th { background-color: #f7f7f7; font-weight: bold; font-size: 11px; padding: 8px 2px; }
.official-invoice-wrapper .items-table td { font-size: 12px; height: 32px; }
.official-invoice-wrapper .footer-row td { background-color: #f7f7f7; font-weight: bold; font-size: 12px; }
.official-invoice-wrapper .footer-signature { border: 1px solid #222; margin-top: -1px; }

/* =======================================================
   استایل‌های پاپ‌آپ (Modal) ارسال مستندات
   ======================================================= */
.woopartner-modal {
    position: fixed; 
    z-index: 999999; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%;
    background-color: rgba(0,0,0,0.6); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    backdrop-filter: blur(3px);
}

.woopartner-modal-content {
    background-color: #fff; 
    padding: 30px; 
    border-radius: 8px; 
    width: 90%; 
    max-width: 500px;
    position: relative; 
    box-shadow: 0 5px 20px rgba(0,0,0,0.3); 
    direction: rtl;
}

.woopartner-close-modal {
    position: absolute; 
    top: 15px; 
    left: 20px; 
    font-size: 28px; 
    font-weight: bold; 
    cursor: pointer; 
    color: #888; 
    line-height: 1;
}

.woopartner-close-modal:hover { 
    color: #e20000; 
}

/* =======================================================
   استایل‌های اختصاصی پاپ‌آپ چاپ (Print Modal)
   ======================================================= */
.woopartner-print-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    overflow-y: auto;
}

.woopartner-print-modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 30px;
    width: 90%;
    max-width: 900px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.woopartner-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #888;
    line-height: 1;
}

.woopartner-modal-close:hover {
    color: #e20000;
}

/* =======================================================
   استایل‌های مخصوص چاپ (Print)
   ======================================================= */
@media print {
    /* تنظیمات برگه A4 */
    @page {
        size: A4 portrait;
        margin: 0.5cm; /* کاهش حاشیه برای استفاده بهتر از فضا */
    }

    /* مخفی‌سازی کامل المان‌های قالب سایت (هدر، فوتر، سایدبار) برای جلوگیری از تولید صفحات خالی */
    .no-print, header, footer, nav, aside, .site-header, .site-footer, #wpadminbar, #site-header, #site-footer, .woopartner-page-invoice {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
    }

    /* 1. ابتدا تمام المان‌های بدنه را مخفی می‌کنیم */
    body * {
        visibility: hidden;
    }

    body, html {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        height: auto !important;
    }

    /* 2. فقط پاپ‌آپ چاپ و محتویات داخل آن را قابل مشاهده می‌کنیم */
    .woopartner-print-modal,
    .woopartner-print-modal * {
        visibility: visible !important;
    }

    /* 3. پاپ‌آپ را از حالت fixed به absolute تغییر داده و دقیقاً به سقف کاغذ می‌چسبانیم */
    .woopartner-print-modal {
        display: block !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        overflow: visible !important;
    }

    /* حذف حاشیه (margin: 5%) که در حالت نمایشگر وجود داشت */
    .woopartner-print-modal-content {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-shadow: none !important;
        border: none !important;
    }

    .official-invoice-wrapper {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* مخفی کردن دکمه‌های اضافی در هنگام چاپ */
    .woopartner-modal-close,
    .woopartner-close-modal,
    .woopartner-invoice-actions,
    .woopartner-invoice-actions * {
        display: none !important;
        visibility: hidden !important;
    }

    /* جلوگیری از دو تکه شدن ردیف‌های جدول در بین صفحات چاپ */
    table {
        page-break-inside: auto;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    /* وضوح بیشتر جداول در چاپ */
    .official-invoice-wrapper th, 
    .official-invoice-wrapper td {
        border: 1px solid #000 !important;
        color: #000 !important;
    }
    
    /* چاپ رنگ پس‌زمینه هدرهای جدول */
    .official-invoice-wrapper .section-title,
    .official-invoice-wrapper th,
    .official-invoice-wrapper .footer-row td {
        background-color: #f2f2f2 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
/* ====================================================
   استایل‌های فرم درخواست عاملیت فروش (WooPartner)
   ==================================================== */

.woopartner-agency-wrapper {
    max-width: 800px;
    margin: 40px auto;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    padding: 40px;
    font-family: inherit;
    direction: rtl;
    border: 1px solid #eaeaea;
}

.woopartner-agency-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px dashed #f0f0f0;
    padding-bottom: 20px;
}

.woopartner-agency-title {
    font-size: 24px;
    color: #2c3e50;
    margin-bottom: 10px;
    font-weight: bold;
}

.woopartner-agency-desc {
    color: #7f8c8d;
    font-size: 14px;
    line-height: 1.6;
}

.woopartner-alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    font-size: 14px;
}

.woopartner-alert-success {
    background-color: #e8f8f5;
    color: #1abc9c;
    border: 1px solid #d1f2eb;
}

.woopartner-agency-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.woopartner-form-row {
    display: flex;
    gap: 20px;
}

.woopartner-form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.woopartner-form-group.full-width {
    width: 100%;
}

.woopartner-form-group label {
    font-size: 14px;
    font-weight: 600;
    color: #34495e;
    margin-bottom: 8px;
}

.woopartner-form-group label .required {
    color: #e74c3c;
}

.woopartner-form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #dcdde1;
    border-radius: 8px;
    font-size: 14px;
    color: #2f3640;
    transition: all 0.3s ease;
    background-color: #fcfcfc;
}

.woopartner-form-control:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    outline: none;
    background-color: #ffffff;
}

textarea.woopartner-form-control {
    resize: vertical;
    min-height: 100px;
}

/* فیلد آپلود فایل */
.file-upload-wrapper {
    position: relative;
    border: 2px dashed #bdc3c7;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    background: #fdfdfd;
    transition: all 0.3s ease;
}

.file-upload-wrapper:hover {
    border-color: #3498db;
    background: #f4f9fd;
}

.woopartner-file-input {
    width: 100%;
    cursor: pointer;
}

.woopartner-help-text {
    font-size: 12px;
    color: #95a5a6;
    margin-top: 8px;
    display: block;
}

/* دکمه ثبت */
.woopartner-form-submit {
    margin-top: 10px;
    text-align: center;
}

.woopartner-btn-submit {
    background-color: #2980b9;
    color: #fff;
    border: none;
    padding: 15px 40px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
    width: 100%;
    max-width: 300px;
}

.woopartner-btn-submit:hover {
    background-color: #2471a3;
}

.woopartner-btn-submit:active {
    transform: scale(0.98);
}

/* واکنش‌گرایی برای موبایل */
@media (max-width: 768px) {
    .woopartner-agency-wrapper {
        padding: 20px;
        margin: 20px 10px;
    }
    
    .woopartner-form-row {
        flex-direction: column;
        gap: 20px;
    }
    
    .woopartner-btn-submit {
        max-width: 100%;
    }
}
/* --- تنظیمات پیش‌فاکتور برای موبایل --- */
@media screen and (max-width: 768px) {
    
    /* 1. مخفی کردن جدول پیش‌فاکتور در صفحه اصلی برای موبایل */
    .woopartner-page-invoice {
        display: none !important;
    }

    /* 2. بزرگ و تمام‌عرض کردن دکمه "مشاهده نسخه چاپ و پرینت" در موبایل */
    .woopartner-invoice-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .woopartner-invoice-actions .button-primary,
    .woopartner-invoice-actions .button {
        display: block;
        width: 100%;
        padding: 12px;
        font-size: 16px;
        text-align: center;
    }

    /* 3. تنظیم مودال برای فیت شدن عرض A4 در موبایل */
    .woopartner-print-modal-content {
        width: 95% !important; /* کمی حاشیه در اطراف */
        margin: 5% auto !important;
        padding: 10px !important;
        overflow: hidden !important; /* جلوگیری از اسکرول اضافه */
    }
    
    /* اعمال Scale برای فیت کردن عرض A4 (حدود 794px) در عرض موبایل (مثلا 350px) */
    .woopartner-print-modal-content .official-invoice-wrapper {
        width: 210mm; /* عرض ثابت A4 */
        max-width: none;
        transform-origin: top center;
        /* محاسبه مقیاس: عرض موبایل / عرض A4 
           از تابع calc و 100vw برای محاسبه اتوماتیک استفاده می کنیم
           تقریبا 100vw برابر عرض صفحه است. 210mm حدود 794px است.
        */
        transform: scale(calc( (100vw - 40px) / 794 )); 
        margin: 0 auto;
        margin-bottom: -50%; /* جبران ارتفاع خالی ناشی از scale */
    }
}
