/* public.css - استایل‌های ماشین حساب سازماند */

/* --- تنظیمات کلی و فونت --- */
.spc-wrap {
    direction: rtl;
    font-family: 'Vazir', Tahoma, Arial, sans-serif !important;
    font-size: 12px;
    max-width: 1200px; 
    margin: 20px auto;
    padding: 15px;
    border: 2px solid #007bff; /* باکس کلی آبی رنگ */
    border-radius: 10px;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* --- تنظیمات تیترها و باکس‌های داخلی --- */
.spc-wrap h1, 
.spc-wrap h3,
.spc-wrap h4 {
    font-family: 'Vazir', Tahoma, Arial, sans-serif !important;
    font-size: 14px !important;
    font-weight: bold;
    color: #004d99;
    padding-bottom: 5px;
    margin-top: 15px;
    border-bottom: 1px solid #e0e0e0;
}

/* استایل دهی به هر بخش به عنوان یک باکس رنگی مجزا */
#sazmand-payroll-form > h3 {
    background-color: #e3f2fd; /* رنگ آبی بسیار روشن */
    color: #0d47a1;
    padding: 10px 15px;
    margin: 20px -15px 15px -15px;
    border-radius: 8px 8px 0 0;
    font-size: 14px;
}
#spc_result h3 {
    /* این تیتر در HTML جدید حذف شده و با h2 در هدر فیش جایگزین شده است */
    background-color: #e8f5e9; 
    color: #1b5e20;
    padding: 10px 15px;
    margin: 20px -15px 15px -15px;
    border-radius: 8px 8px 0 0;
    font-size: 14px;
}

/* --- استایل فرم و فیلدها --- */
.spc-wrap p {
    display: flex; 
    align-items: center; 
    margin-bottom: 8px;
    line-height: 1.6;
}
.spc-wrap label {
    display: flex;
    align-items: center;
    width: 100%;
}

.spc-wrap input[type="text"],
.spc-wrap input[type="number"],
.spc-wrap input[type="tel"],
.spc-wrap input[type="email"],
.spc-wrap select {
    flex-grow: 1; 
    padding: 6px;
    margin-right: 15px; 
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    box-sizing: border-box; 
    max-width: 55%;
    /* مهم برای نمایش جداکننده هزارگان در فیلدهای ورودی */
    direction: ltr; 
    text-align: left;
    font-family: 'Vazir', Tahoma, Arial, sans-serif !important;
}

/* استایل رادیو باتن ها */
.spc-wrap p:has(input[type="radio"]) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}
.spc-wrap p:has(input[type="radio"]) label {
    width: auto;
    margin-left: 20px;
    font-weight: normal;
}

/* --- استایل متن توضیحات --- */
.spc-disclaimer {
    text-align: center; 
    font-size: 12px; 
    margin: 15px 0 25px 0;
    padding: 10px;
    border: 1px solid #ffcc80; /* رنگ نارنجی ملایم */
    border-radius: 6px;
    background-color: #fff3e0;
    line-height: 1.6;
    font-family: 'Vazir', Tahoma, Arial, sans-serif !important;
}

/* ==================================== */
/* --- استایل دهی بخش اطلاعات ورودی در فیش حقوقی (جدید) --- */
/* ==================================== */
#spc_payroll_header {
    background-color: #e0f7fa; /* آبی بسیار روشن */
    border: 1px solid #b2ebf2;
    padding: 10px 15px;
    margin-bottom: 15px;
    border-radius: 6px;
}

#spc_payroll_header h2 {
    font-size: 16px !important;
    color: #00838f;
    margin: 0 0 10px 0 !important;
    padding: 0 !important;
    border: none !important;
    text-align: center;
}

#spc_payroll_header p {
    justify-content: flex-start; /* Align text to the start */
    line-height: 1.8;
    margin: 3px 0;
    font-size: 13px;
}

#spc_payroll_header strong {
    min-width: 150px;
    display: inline-block;
}

#spc_payroll_header hr {
    border-top: 1px solid #b2ebf2;
    margin: 10px 0;
}


/* --- استایل جدول نتایج --- */
.spc-result-table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
    font-size: 12px;
}
.spc-result-table th, .spc-result-table td {
    border: 1px solid #c5cae9; /* حاشیه جدول آبی کم‌رنگ */
    padding: 8px;
    text-align: right; /* تراز پیش‌فرض: ستون شرح */
    font-family: 'Vazir', Tahoma, Arial, sans-serif !important;
}

/* ✅ اصلاح دوم: تراز ستون مبلغ (ستون اول از چپ) به چپ (مطابق pic 1) */
.spc-result-table td:nth-child(1), .spc-result-table th:nth-child(1) {
    text-align: left;  
    direction: ltr; /* برای خوانایی بهتر اعداد */
}

.spc-result-table th {
    background-color: #bbdefb; /* پس‌زمینه تیتر جدول */
    font-weight: bold;
    color: #0d47a1;
}
.spc-result-table tr:nth-child(even) {
    background-color: #f5f5f5;
}

/* ردیف های خاص */
.spc-total-row td {
    font-weight: bold;
    background-color: #e0f2f1; /* فیروزه‌ای روشن */
    color: #004d40;
}
.spc-deduction-row td {
    color: #b71c1c; /* قرمز تیره برای کسورات */
}
.spc-net-row td {
    font-weight: bold;
    background-color: #c8e6c9; /* سبز ملایم برای خالص پرداختی */
    font-size: 1.2em;
    color: #1b5e20;
}

/* --- استایل دکمه ها --- */
.spc-submit-row {
    justify-content: space-around;
    padding: 15px 0;
}
.spc-print-row {
    text-align: center;
    padding: 15px 0 5px 0;
}

.spc-button, .spc-button-reset, .spc-button-print {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
    font-family: 'Vazir', Tahoma, Arial, sans-serif !important;
}
.spc-button {
    background-color: #007bff;
    color: white;
}
.spc-button:hover {
    background-color: #0056b3;
}
.spc-button-reset {
    background-color: #f8d7da;
    color: #721c24;
}
.spc-button-reset:hover {
    background-color: #f5c6cb;
}
/* دکمه جدید چاپ PDF */
.spc-button-print {
    background-color: #f44336; /* قرمز برای جلب توجه بیشتر */
    color: white;
    font-size: 14px;
}
.spc-button-print:hover {
    background-color: #d32f2f;
}

/* ==================================== */
/* --- استایل‌های مخصوص چاپ PDF (اصلاح نهایی و قوی‌ترین متد) --- */
/* ==================================== */
/* --- استایل‌های مخصوص چاپ PDF (بهبود یافته) --- */
@media print {
    /* 1) مخفی کردن تمام عناصر صفحه (حفظ جایگاه) */
    body * {
        visibility: hidden !important;
    }

    /* 2) تنها spc-wrap و فرزندانش قابل رؤیت باشند */
    .spc-wrap, 
    .spc-wrap * {
        visibility: visible !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* 3) قرار دادن spc-wrap در بالای صفحه چاپ به صورت ثابت */
    .spc-wrap {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        margin: 0 !important;
        padding: 20px !important;
        width: 100% !important;
        max-width: none !important;
        box-shadow: none !important;
        border: none !important;
        background-color: #fff !important;
        z-index: 9999 !important;
    }

    /* 4) مخفی کردن فرم‌ها و دکمه‌های داخلی (اگر داخل spc-wrap هستند) */
    /* (در صورتی که خواستی فرم را هم داخل فیش چاپ نکنی، این را نگه دار) */
    #sazmand-payroll-form,
    .spc-submit-row,
    .spc-print-row,
    .spc-disclaimer {
        display: none !important;
    }

    /* 5) استایل جدول و هدر برای چاپ رنگی و تمیز */
    #spc_payroll_header {
        background-color: #e0f7fa !important;
        border: 1px solid #b2ebf2 !important;
        color: #004d40 !important;
        padding: 8px !important;
        margin-bottom: 10px !important;
    }
    .spc-result-table {
        border-collapse: collapse !important;
        width: 100% !important;
    }
    .spc-result-table th, .spc-result-table td {
        border: 1px solid #000 !important;
        padding: 7px !important;
        background-color: transparent !important;
        color: #000 !important;
    }
    .spc-result-table th {
        background-color: #bbdefb !important;
        color: #0d47a1 !important;
    }
    .spc-total-row td, .spc-net-row td {
        background-color: #e8f5e9 !important;
        color: #000 !important;
        font-weight: bold !important;
    }

    /* 6) اطمینان از نمایش صحیح فونت/اندازه در چاپ */
    body, p, table, th, td {
        font-size: 10pt !important;
        font-family: 'Vazir', Tahoma, Arial, sans-serif !important;
    }

    /* 7) جلوگیری از غیراختصاصی شدن لینک‌ها و نمایش آدرس آنها
       (در برخی مرورگرها آدرس لینک به صورت پاورقی چاپ می‌شود؛ این را نمی‌توان کامل از طریق CSS کنترل کرد،
        اما با پنهان‌سازی عناصر غیر مربوط، لینک‌های منو دیگر در چاپ ظاهر نمی‌شوند) */
    a { text-decoration: none !important; }

    /* 8) حذف اورفلوهای احتمالی */
    html, body {
        height: auto !important;
        overflow: visible !important;
    }
}
/* ===== مرکزچین کردن جدول و سلول‌ها (نمایش و چاپ) ===== */

/* 1) مرکز قرار گرفتن کل جدول در صفحه */
.spc-result-table {
    margin: 0 auto !important;      /* جدول وسط صفحه شود */
    display: table !important;
    width: auto !important;         /* اجازه می‌دهد عرض براساس محتوا تنظیم شود */
    min-width: 100%;                 /* در صورت نیاز حداقل عرض تعیین می‌کند */
}

/* 2) مرکزچین کردن متن در همهٔ سلول‌ها */
.spc-result-table th,
.spc-result-table td {
    text-align: center !important;  /* مرکز متن برای هر دو ستون */
    vertical-align: middle !important;
    padding: 8px 12px !important;
}

/* 3) جهت‌ اعداد را LTR نگه دارید اما مرکزچین باشند */
.spc-result-table td[data-field], 
.spc-result-table th[data-field] {
    direction: ltr !important;
}

/* در صورتی که مقادیر عددی با کاما نمایش داده می‌شوند، کمک می‌کند کاماها در مرکز باشند */
.spc-result-table td[data-field] span.num,
.spc-result-table td[data-field] strong span.num {
    direction: ltr;
    display: inline-block;
}

/* 4) استایل ردیف‌های تیتر/بخش برای خوانایی */
.spc-heading-row td {
    font-weight: bold !important;
    text-align: center !important;
    background: transparent !important;
}

/* 5) حفظ ظاهر ردیف‌های جمع و خالص (قابل تنظیم) */
.spc-total-row td, .spc-net-row td {
    font-weight: bold !important;
    font-size: 1.05em !important;
}

/* 6) در حالت چاپ نیز همین قوانین باید اعمال شوند */
@media print {
    .spc-result-table {
        margin: 0 auto !important;
        width: auto !important;
        min-width: 100%;
    }
    .spc-result-table th,
    .spc-result-table td {
        text-align: center !important;
    }
    .spc-result-table td[data-field] {
        direction: ltr !important;
    }
}

