/* 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;
}

/* ✅ تراز ستون مبلغ (ستون اول از چپ) به چپ */
.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 (رفع تداخل با قالب Jannah) 🚀 */
/* ==================================== */
/* بلوک‌های قبلی چاپ با ساختار نادرست (body.spc-print-mode @media print) حذف شدند. */
/* اکنون از ساختار استاندارد "@media print" استفاده و انتخاب‌کننده‌ها مشروط به "body.spc-print-mode" شدند. */
@media print {
    
    /* 1) مخفی کردن تمام عناصر صفحه (تنها وقتی در حالت چاپ فیش هستیم) */
    body.spc-print-mode * {
        visibility: hidden !important;
    }

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

    /* 3) قرار دادن spc-wrap در بالای صفحه چاپ به صورت مطلق برای حذف حاشیه و اجزای ناخواسته */
    body.spc-print-mode .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) مخفی کردن فرم‌ها و دکمه‌های داخلی در فیش چاپ شده */
    body.spc-print-mode #sazmand-payroll-form,
    body.spc-print-mode .spc-submit-row,
    body.spc-print-mode .spc-print-row,
    body.spc-print-mode .spc-disclaimer {
        display: none !important;
    }

    /* 5) استایل جدول و هدر برای چاپ تمیز و رنگی */
    body.spc-print-mode #spc_payroll_header {
        background-color: #e0f7fa !important;
        border: 1px solid #b2ebf2 !important;
        color: #004d40 !important;
        padding: 8px !important;
        margin-bottom: 10px !important;
    }
    body.spc-print-mode .spc-result-table {
        border-collapse: collapse !important;
        width: 100% !important;
        margin: 0 auto !important; 
        min-width: 100%;
    }
    body.spc-print-mode .spc-result-table th, 
    body.spc-print-mode .spc-result-table td {
        border: 1px solid #000 !important; /* حاشیه مشکی برای چاپ */
        padding: 7px !important;
        background-color: transparent !important;
        color: #000 !important;
        text-align: center !important;
    }
    body.spc-print-mode .spc-result-table th {
        background-color: #bbdefb !important;
        color: #0d47a1 !important;
    }
    body.spc-print-mode .spc-total-row td, 
    body.spc-print-mode .spc-net-row td {
        background-color: #e8f5e9 !important;
        color: #000 !important;
        font-weight: bold !important;
    }
    /* جهت‌دهی اعداد به چپ (LTR) */
    body.spc-print-mode .spc-result-table td[data-field] {
        direction: ltr !important;
    }


    /* 6) اطمینان از نمایش صحیح فونت/اندازه در چاپ */
    body.spc-print-mode body, 
    body.spc-print-mode p, 
    body.spc-print-mode table, 
    body.spc-print-mode th, 
    body.spc-print-mode td {
        font-size: 10pt !important;
        font-family: 'Vazir', Tahoma, Arial, sans-serif !important;
    }
    
    /* 7) حذف اورفلوهای احتمالی */
    body.spc-print-mode html, 
    body.spc-print-mode body {
        height: auto !important;
        overflow: visible !important;
    }
    
    /* 8) اطمینان از نبودن دکوراسیون روی لینک‌ها در چاپ */
    body.spc-print-mode a { 
        text-decoration: none !important; 
    }
} /* پایان بلوک چاپ */


/* ==================================== */
/* --- استایل موبایل (طراحی واکنشگرا) --- */
/* ==================================== */
@media (max-width: 768px) {
    .spc-wrap {
        margin: 10px;
        padding: 10px;
    }
    .spc-wrap p {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 15px;
    }
    .spc-wrap label {
        margin-bottom: 5px;
    }
    .spc-wrap input[type="text"],
    .spc-wrap input[type="number"],
    .spc-wrap input[type="tel"],
    .spc-wrap input[type="email"],
    .spc-wrap select {
        max-width: 100%; /* استفاده از کل عرض در موبایل */
        margin-right: 0;
        margin-top: 5px;
    }
    .spc-result-table th, .spc-result-table td {
        padding: 6px;
    }
    
    /* بهبود نمایش اعداد در جدول موبایل */
    .spc-result-table td:nth-child(1), .spc-result-table th:nth-child(1) {
        min-width: 80px; /* حداقل عرض برای ستون عدد */
    }
}