/* ----------------------------------------------
   فاکتور حرفه‌ای ووکامرس
   نسخه: 2.0
---------------------------------------------- */

/* === روت متغیرها === */
:root {
    --ws-primary: #2c7da0;
    --ws-secondary: #61a5c2;
    --ws-success: #2a9d8f;
    --ws-danger: #e63946;
    --ws-warning: #f4a261;
    --ws-dark: #1e293b;
    --ws-gray: #64748b;
    --ws-light: #f8fafc;
    --ws-border: #e2e8f0;
    --ws-border-radius: 12px;
    --ws-box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    --ws-transition: all 0.3s ease;
}

/* === چاپ === */
@media print {
    body { background: white; }
    .factor_navtop, .ws-print-hide, .woocommerce, .wp-admin-bar { display: none !important; }
    #factors { margin: 0; padding: 0; box-shadow: none; }
    .ws-invoice-actions { display: none; }
    @page { margin: 2cm; size: A4; }
}

/* === کانتینر اصلی فاکتور === */
#factors, .ws-invoice-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    background: white;
    border-radius: var(--ws-border-radius);
    box-shadow: var(--ws-box-shadow);
    direction: rtl;
    font-family: 'yekanbakh', 'Vazir', Tahoma, sans-serif;
}

.ws-invoice-paper {
    background: white;
    padding: 30px;
}

/* === هدر فاکتور === */
.ws-invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 25px;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--ws-border);
    flex-wrap: wrap;
    gap: 20px;
}

.ws-logo-area {
    flex: 0 0 150px;
}

.ws-logo-area img {
    max-width: 100%;
    max-height: 80px;
    object-fit: contain;
}

.ws-company-info {
    flex: 2;
    text-align: right;
}

.ws-company-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--ws-dark);
    margin-bottom: 5px;
}

.ws-company-slogan {
    font-size: 13px;
    color: var(--ws-gray);
}

.ws-invoice-title-area {
    text-align: center;
}

.ws-invoice-badge {
    background: linear-gradient(135deg, var(--ws-primary), var(--ws-secondary));
    padding: 10px 25px;
    border-radius: 30px;
    color: white;
}

.ws-invoice-badge h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.ws-invoice-badge span {
    font-size: 12px;
    opacity: 0.9;
}

.ws-invoice-meta {
    background: var(--ws-light);
    padding: 12px 20px;
    border-radius: var(--ws-border-radius);
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.ws-meta-item {
    display: flex;
    gap: 8px;
    font-size: 13px;
}

.ws-meta-item .label {
    color: var(--ws-gray);
    font-weight: 500;
}

.ws-meta-item .value {
    color: var(--ws-dark);
    font-weight: 600;
}

/* === بخش فروشنده و خریدار === */
.ws-parties-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
}

.ws-party-card {
    background: var(--ws-light);
    border-radius: var(--ws-border-radius);
    padding: 18px;
    border-right: 4px solid var(--ws-primary);
}

.ws-party-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--ws-primary);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--ws-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ws-party-title .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.ws-party-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ws-party-row {
    display: flex;
    gap: 10px;
    font-size: 13px;
    line-height: 1.5;
}

.ws-party-row .label {
    min-width: 70px;
    color: var(--ws-gray);
}

.ws-party-row .value {
    color: var(--ws-dark);
}

/* === جدول محصولات === */
.ws-invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin: 25px 0;
    font-size: 13px;
}

.ws-invoice-table th {
    background: var(--ws-light);
    padding: 12px 10px;
    text-align: center;
    font-weight: 600;
    color: var(--ws-dark);
    border-bottom: 2px solid var(--ws-border);
}

.ws-invoice-table td {
    padding: 12px 10px;
    text-align: center;
    border-bottom: 1px solid var(--ws-border);
    vertical-align: middle;
}

.ws-invoice-table tr:hover {
    background: rgba(44, 125, 160, 0.03);
}

.ws-product-info {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: right;
}

.ws-product-img {
    width: 45px;
    height: 45px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--ws-border);
}

.ws-product-name {
    font-weight: 500;
    color: var(--ws-dark);
}

.ws-product-sku {
    font-size: 11px;
    color: var(--ws-gray);
    margin-top: 3px;
}

.ws-variation-meta {
    font-size: 11px;
    color: var(--ws-gray);
    margin-top: 5px;
}

/* === ردیف جمع === */
.ws-totals-section {
    background: var(--ws-light);
    border-radius: var(--ws-border-radius);
    padding: 20px;
    margin-top: 20px;
}

.ws-totals-table {
    width: 100%;
    max-width: 350px;
    margin-right: auto;
}

.ws-totals-table td {
    padding: 8px 0;
}

.ws-totals-table .label {
    color: var(--ws-gray);
    font-weight: 500;
}

.ws-totals-table .value {
    font-weight: 600;
    color: var(--ws-dark);
}

.ws-grand-total {
    font-size: 18px;
    color: var(--ws-primary);
}

.ws-amount-in-words {
    background: #fef3c7;
    padding: 12px 15px;
    border-radius: var(--ws-border-radius);
    margin-top: 15px;
    border-right: 3px solid var(--ws-warning);
    font-size: 13px;
    color: #92400e;
}

/* === فوتر و یادداشت === */
.ws-invoice-footer {
    margin-top: 30px;
}

.ws-customer-note {
    background: #fef9e7;
    padding: 15px;
    border-radius: var(--ws-border-radius);
    margin-bottom: 20px;
}

.ws-customer-note-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--ws-warning);
}

.ws-invoice-note {
    background: #ecfdf5;
    padding: 15px;
    border-radius: var(--ws-border-radius);
    border-right: 3px solid var(--ws-success);
    margin-bottom: 20px;
}

/* === مهر و امضا === */
.ws-signatures {
    display: flex;
    justify-content: space-between;
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px dashed var(--ws-border);
}

.ws-signature-area {
    text-align: center;
    flex: 1;
}

.ws-signature-label {
    font-size: 12px;
    color: var(--ws-gray);
    margin-bottom: 10px;
}

.ws-signature-img {
    max-height: 60px;
    opacity: 0.8;
}

.ws-signature-line {
    width: 150px;
    height: 1px;
    background: var(--ws-border);
    margin-top: 30px;
}

/* === برچسب مرسوله === */
.ws-label-wrapper {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border: 1px solid var(--ws-border);
    border-radius: 8px;
    overflow: hidden;
}

.ws-label-header {
    background: var(--ws-primary);
    color: white;
    padding: 15px;
    text-align: center;
}

.ws-label-body {
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.ws-label-section {
    border: 1px solid var(--ws-border);
    border-radius: 8px;
    padding: 15px;
}

.ws-label-section-title {
    font-weight: 700;
    color: var(--ws-primary);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--ws-border);
}

/* === نوار ابزار === */
.factor_navtop, .ws-invoice-actions {
    position: sticky;
    top: 32px;
    z-index: 1000;
    background: white;
    border-bottom: 1px solid var(--ws-border);
    padding: 10px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 20px;
}

.factor_navtop button, .ws-invoice-actions button {
    background: none;
    border: 1px solid var(--ws-border);
    border-radius: 8px;
    padding: 8px 15px;
    cursor: pointer;
    transition: var(--ws-transition);
    font-family: inherit;
}

.factor_navtop button:hover, .ws-invoice-actions button:hover {
    background: var(--ws-primary);
    color: white;
    border-color: var(--ws-primary);
}

/* === استایل چک باکس صفحه پرداخت === */
.ws-invoice-checkout-wrapper {
    background: var(--ws-light);
    border-radius: var(--ws-border-radius);
    padding: 20px;
    margin: 20px 0;
}

.ws-invoice-checkout-wrapper h4 {
    margin: 0 0 15px 0;
    color: var(--ws-dark);
}

.ws-invoice-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* === دکمه فاکتور در ادمین === */
.ws-invoice-metabox {
    padding: 10px 0;
}

.ws-status {
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.ws-status.requested {
    background: #dcfce7;
    color: #166534;
}

.ws-status.not-requested {
    background: #fee2e2;
    color: #991b1b;
}

.ws-metabox-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ws-metabox-buttons .button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* === ریسپانسیو === */
@media (max-width: 768px) {
    .ws-invoice-header {
        flex-direction: column;
        text-align: center;
    }

    .ws-parties-section {
        grid-template-columns: 1fr;
    }

    .ws-invoice-table {
        font-size: 11px;
    }

    .ws-product-img {
        width: 30px;
        height: 30px;
    }

    .ws-totals-table {
        max-width: 100%;
    }

    .ws-label-body {
        grid-template-columns: 1fr;
    }
}

/* === تمپلیت‌های مختلف === */
/* تم مدرن */
.ws-theme-modern .ws-invoice-header {
    background: linear-gradient(135deg, var(--ws-primary) 0%, var(--ws-secondary) 100%);
    margin: -30px -30px 25px -30px;
    padding: 30px 30px 25px 30px;
    border-radius: 0 0 var(--ws-border-radius) var(--ws-border-radius);
}

.ws-theme-modern .ws-company-name,
.ws-theme-modern .ws-company-slogan {
    color: white;
}

.ws-theme-modern .ws-invoice-badge {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(5px);
}

/* تم مینیمال */
.ws-theme-minimal .ws-party-card {
    border-right: none;
    background: transparent;
    border: 1px solid var(--ws-border);
}

.ws-theme-minimal .ws-invoice-table th {
    background: transparent;
    border-bottom: 1px solid var(--ws-dark);
}

/* === انیمیشن === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#factors {
    animation: fadeIn 0.4s ease-out;
}



/* استایل کانتینر اصلی چک باکس */
.ws-invoice-checkout-wrapper {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    margin: 25px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* استایل تیتر */
.ws-invoice-checkout-wrapper h4 {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

/* استایل فرم فیلد */
.ws-invoice-checkout-wrapper .form-row {
    margin: 0;
    padding: 0;
}

/* استایل لیبل چک باکس */
.ws-invoice-checkout-wrapper label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
    color: #334155;
}

/* استایل چک باکس */
.ws-invoice-checkout-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2c7da0;
}

/* استایل توضیحات */
.ws-invoice-checkout-wrapper .description {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-top: 8px;
    margin-right: 30px;
}

/* متن اختیاری */
.ws-invoice-checkout-wrapper .optional {
    color: #94a3b8;
    font-size: 11px;
    font-weight: normal;
}
