/* ═══════════════════════════════════════════════════════════
   سربرگ نامه رسمی هیئت اندیشه‌ورز
   نسخه: 1.0
   ═══════════════════════════════════════════════════════════ */

/* ═══ تنظیمات پایه ═══ */
.td-letterhead {
    background: #fff;
    direction: rtl;
    font-family: Vazirmatn, Tahoma, sans-serif;
    color: #0f172a;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.15);
    border-radius: 4px;
    margin: 20px auto;
    overflow: hidden;
    position: relative;
    line-height: 2;
}

/* ═══ اندازه A4 ═══ */
.td-letterhead.td-lh-a4 {
    width: 210mm;
    min-height: 297mm;
    padding: 8mm 12mm 45mm 12mm;
    font-size: 13.5px;
}

/* ═══ اندازه A5 ═══ */
.td-letterhead.td-lh-a5 {
    width: 148mm;
    min-height: 210mm;
    padding: 6mm 9mm 35mm 9mm;
    font-size: 11.5px;
    line-height: 1.9;
}

/* ═══ هدر سربرگ ═══ */
.td-lh-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding-bottom: 10px;
    margin-bottom: 18px;
    position: relative;
    min-height: 90px;
}

/* ═══ خط نستعلیق (راست) ═══ */
.td-lh-top-right {
    flex: 1;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    padding-top: 4mm;
}

.td-lh-title-img {
    max-width: 100%;
    height: auto;
    max-height: 70px;
    object-fit: contain;
}

.td-lh-a5 .td-lh-title-img {
    max-height: 50px;
}

/* ═══ لوگو (وسط) ═══ */
.td-lh-top-center {
    flex: 0 0 90px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 2mm;
}

.td-lh-logo-img {
    width: 85px;
    height: 85px;
    object-fit: contain;
    filter: drop-shadow(0 3px 8px rgba(30, 58, 138, 0.2));
}

.td-lh-a5 .td-lh-logo-img {
    width: 60px;
    height: 60px;
}

/* ═══ فیلدها (چپ) ═══ */
.td-lh-top-left {
    flex: 1;
    text-align: left;
    padding-top: 4mm;
    direction: rtl;
}

.td-lh-field {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 12px;
}

.td-lh-label {
    font-weight: 800;
    color: #1e3a8a;
    white-space: nowrap;
}

.td-lh-value {
    color: #334155;
    border-bottom: 1px dashed #cbd5e1;
    min-width: 110px;
    padding: 0 4px 2px;
    font-family: 'Courier New', monospace;
    direction: ltr;
    text-align: left;
    font-weight: 600;
    flex: 1;
}

.td-lh-a5 .td-lh-field { font-size: 10.5px; }
.td-lh-a5 .td-lh-value { min-width: 80px; }

/* ═══ خط جداکننده زیر سربرگ ═══ */
.td-lh-header::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #1e3a8a 0%, #1e40af 50%, #1e3a8a 100%);
    border-radius: 2px;
}

/* ═══ بدنه نامه ═══ */
.td-lh-body {
    min-height: 120mm;
    color: #1e293b;
    line-height: 2;
    font-size: 13.5px;
    text-align: justify;
    padding: 4mm 0;
}

.td-lh-a5 .td-lh-body {
    font-size: 11.5px;
    min-height: 80mm;
}

.td-lh-body p {
    margin: 0 0 12px;
}

.td-lh-body h1, 
.td-lh-body h2, 
.td-lh-body h3 {
    color: #1e3a8a;
    font-weight: 800;
    margin: 16px 0 10px;
}

.td-lh-body ul, 
.td-lh-body ol {
    padding-right: 24px;
    margin: 10px 0;
}

.td-lh-body li {
    margin: 6px 0;
}

.td-lh-body blockquote {
    border-right: 4px solid #1e3a8a;
    background: #f8fafc;
    padding: 10px 16px;
    margin: 14px 0;
    color: #475569;
    border-radius: 0 8px 8px 0;
}

.td-lh-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 10px 0;
}

.td-lh-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 12.5px;
}

.td-lh-body table th,
.td-lh-body table td {
    border: 1px solid #cbd5e1;
    padding: 8px 10px;
    text-align: right;
}

.td-lh-body table th {
    background: #eff6ff;
    color: #1e3a8a;
    font-weight: 800;
}

.td-lh-body a {
    color: #1e40af;
    text-decoration: underline;
}

/* ═══ امضا ═══ */
.td-lh-signature {
    margin-top: 40px;
    margin-bottom: 20px;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-right: auto;
    margin-left: 20px;
    width: fit-content;
    min-width: 200px;
}

.td-lh-sig-img {
    max-width: 180px;
    max-height: 80px;
    height: auto;
    object-fit: contain;
    margin-bottom: 6px;
    mix-blend-mode: multiply;
}

.td-lh-sig-name {
    font-size: 13.5px;
    font-weight: 800;
    color: #1e293b;
    border-bottom: 1px solid #1e293b;
    padding-bottom: 3px;
    min-width: 160px;
    text-align: center;
    letter-spacing: 0.3px;
}

.td-lh-sig-title {
    font-size: 11.5px;
    color: #475569;
    text-align: center;
    min-width: 160px;
    line-height: 1.7;
    font-weight: 600;
}

.td-lh-a5 .td-lh-sig-img { max-width: 130px; max-height: 55px; }
.td-lh-a5 .td-lh-sig-name { font-size: 11px; min-width: 130px; }
.td-lh-a5 .td-lh-sig-title { font-size: 9.5px; min-width: 130px; }

/* ═══ پاورقی ═══ */
.td-lh-footer {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    padding: 8px 12mm 10px;
    background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
    border-top: 2px solid #1e3a8a;
    font-size: 10.5px;
    color: #334155;
    line-height: 1.6;
}

.td-lh-a5 .td-lh-footer {
    padding: 6px 9mm 8px;
    font-size: 9px;
}

.td-lh-footer-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 14px;
    margin-bottom: 4px;
    white-space: nowrap;
}

.td-lh-footer-address {
    display: flex;
    width: 100%;
    margin-bottom: 6px;
    font-weight: 600;
}

.td-lh-footer-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding-top: 4px;
    border-top: 1px dashed #cbd5e1;
}

.td-lh-foot-icon {
    font-size: 12px;
    color: #1e3a8a;
    flex-shrink: 0;
}

.td-lh-foot-text {
    color: #334155;
    font-weight: 600;
    white-space: nowrap;
}

/* ═══ دکمه چاپ ═══ */
.td-btn-print {
    background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 100%) !important;
    color: #fff !important;
    padding: 10px 22px !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    cursor: pointer !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3) !important;
    transition: all .2s !important;
    font-family: inherit !important;
    font-size: 13px !important;
}

.td-btn-print:hover {
    background: linear-gradient(180deg, #1e40af 0%, #1e3a8a 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 16px rgba(30, 58, 138, 0.4) !important;
}

/* ═══ انتخابگر A4/A5 ═══ */
.td-paper-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #eff6ff;
    border-radius: 10px;
    border: 1px solid #bfdbfe;
    margin-bottom: 16px;
    font-family: inherit;
}

.td-paper-selector label {
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #1e3a8a !important;
    margin: 0 !important;
    white-space: nowrap;
}

.td-paper-selector select {
    padding: 7px 14px;
    border: 1.5px solid #93c5fd;
    border-radius: 8px;
    background: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    min-width: 200px;
}

.td-paper-selector select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ═══ چاپ ═══ */
@media print {
    body.td-print-body {
        margin: 0;
        padding: 0;
        background: #fff;
        font-family: Vazirmatn, Tahoma, sans-serif;
    }

    .td-print-body .td-letterhead {
        box-shadow: none;
        margin: 0;
        border-radius: 0;
        page-break-after: always;
    }

    .td-print-body .td-letterhead.td-lh-a4 {
        width: 210mm;
        min-height: 297mm;
    }

    .td-print-body .td-letterhead.td-lh-a5 {
        width: 148mm;
        min-height: 210mm;
    }

    .td-print-body .td-lh-sig-img {
        mix-blend-mode: normal;
    }
}

@page {
    size: A4;
    margin: 0;
}

/* ═══ ریسپانسیو (نمایش توی داشبورد) ═══ */
@media (max-width: 900px) {
    .td-letterhead.td-lh-a4,
    .td-letterhead.td-lh-a5 {
        width: 100% !important;
        min-height: auto !important;
        padding: 16px 18px 100px 18px !important;
    }

    .td-lh-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        min-height: auto;
        padding-bottom: 16px;
    }

    .td-lh-top-right,
    .td-lh-top-left {
        flex: 1 1 100%;
        text-align: center;
        padding-top: 0;
        width: 100%;
    }

    .td-lh-top-center {
        order: -1;
        justify-content: center;
        margin-bottom: 10px;
        flex: 0 0 auto;
    }

    .td-lh-title-img {
        max-height: 50px;
    }

    .td-lh-logo-img {
        width: 70px;
        height: 70px;
    }

    .td-lh-field {
        justify-content: center;
    }

    .td-lh-value {
        flex: 0 0 auto;
        min-width: 130px;
    }

    .td-lh-footer {
        position: static;
        margin-top: 30px;
        border-radius: 0 0 4px 4px;
    }

    .td-lh-signature {
        margin-left: auto;
        margin-right: auto;
        align-items: center;
    }

    .td-lh-footer-row {
        gap: 8px;
        justify-content: center;
    }

    .td-paper-selector {
        flex-wrap: wrap;
    }

    .td-paper-selector select {
        min-width: 100%;
    }
}

@media (max-width: 600px) {
    .td-lh-footer-address {
        font-size: 9px;
    }

    .td-lh-foot-text {
        white-space: normal;
    }
}