
:root {
    --primary-color: #d15c22;
    --primary-light: #f26522;
    --primary-dark: #a84310;
    --primary-bg: #fff8f5;
    --secondary-color: #2c3e50;
    --text-color: #2b2b2b;
    --text-muted: #6c757d;
    --bg-color: #eef0f4;
    --border-color: #dde1e7;
    --light-gray: #f0f2f5;
    --white: #ffffff;
    --success-color: #2e7d32;
    --success-bg: #e8f5e9;
    --danger-color: #c62828;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.16);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: 0.25s ease;
}

@font-face { font-family: 'B Yekan'; src: local('B Yekan'), local('BYekan'); }
@font-face { font-family: 'IranNastaliq'; src: local('IranNastaliq'), local('Nastaliq'); }
@font-face { font-family: 'B Yagut'; src: local('B Yagut'), local('BYagut'); }
@font-face { font-family: 'B Zar'; src: local('B Zar'), local('BZar'); }

.yagut-bold { font-family: 'B Yagut', Tahoma, sans-serif !important; font-weight: bold; }
.zar-text { font-family: 'B Zar', Tahoma, sans-serif !important; }
.zar-text strong { font-weight: bold; }

body {
    font-family: 'B Yekan', Tahoma, sans-serif;
    background: linear-gradient(135deg, #e8ecf1 0%, #d5dbe4 100%);
    margin: 0;
    padding: 20px 16px;
    direction: rtl;
    color: var(--text-color);
    min-height: 100vh;
}

.container {
    max-width: 96%;
    margin: 0 auto;
    background: var(--white);
    padding: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transition: max-width 0.4s ease;
}

.container.wide-report-mode {
    max-width: 98%;
}

h1, h2, h3 { color: var(--secondary-color); margin: 0 0 10px 0; }
.hidden { display: none !important; }
.mt-15 { margin-top: 15px; }

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--secondary-color) 0%, #3d5166 100%);
    padding: 12px 24px;
    position: relative;
    overflow: hidden;
}

.main-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(209,92,34,0.15) 0%, transparent 70%);
    pointer-events: none;
}

.main-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light), var(--primary-color));
}

.header-right {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: flex-start;
}

.header-right-logo img {
    width: 65px;
    height: auto;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
    transition: transform var(--transition);
}

.header-right-logo img:hover { transform: scale(1.05); }

.header-right-texts h2 {
    font-size: 1.15rem;
    color: rgba(255,255,255,0.95);
    margin: 0 0 5px 0;
    font-weight: normal;
    letter-spacing: 0.5px;
}

.header-right-texts h3 {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.65);
    font-weight: normal;
    margin: 0;
}

.header-center {
    flex: 1;
    text-align: center;
}

.brand-title {
    font-size: 2.2rem;
    color: var(--primary-light);
    margin: 0 0 6px 0;
    text-shadow: 0 2px 12px rgba(209,92,34,0.5);
    letter-spacing: 1px;
}

.acronym-title {
    font-size: 1rem;
    color: rgba(255,255,255,0.7);
    font-weight: normal;
    margin: 0;
    line-height: 1.6;
}

.highlight-letter {
    color: var(--primary-light);
    font-weight: bold;
    font-size: 1.25em;
    margin-left: -1px;
    text-shadow: 0 1px 6px rgba(242,101,34,0.4);
}

.header-left {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    padding-left: 15px; 
}

.date-version-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.date-widget {
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(8px);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: bold;
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.version-badge {
    font-size: 12px;
    background: #e53935;
    color: white;
    padding: 3px 14px;
    border-radius: 8px;
    font-weight: normal;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.upload-section {
    margin: 0;
    padding: 36px 30px;
    text-align: center;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
}

.upload-section label.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
    font-size: 15px;
    padding: 14px 32px;
    border-radius: 50px;
    box-shadow: 0 4px 16px rgba(209,92,34,0.3);
    transition: transform var(--transition), box-shadow var(--transition);
}
.upload-section label.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(209,92,34,0.4);
}

#dashboard { margin-top: 20px; }

.dashboard {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-box {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: #fff;
    padding: 16px 28px;
    border-radius: var(--radius-md);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 16px rgba(209,92,34,0.3);
}

.stat-box strong {
    font-size: 22px;
    font-weight: bold;
}

.filters-section, .controls-section {
    background: var(--light-gray);
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 28px 30px;
}

.filters-section h3, .controls-section h3 {
    font-size: 1rem;
    color: var(--secondary-color);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.filter-box {
    background: var(--white);
    padding: 18px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.filter-box:hover { box-shadow: var(--shadow-md); }

.filter-box label {
    font-weight: bold;
    display: block;
    margin-bottom: 10px;
    color: var(--secondary-color);
    font-size: 14px;
}

.filter-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.filter-grid-4col { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.filter-grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; }
.flex-row { display: flex; gap: 10px; }

.checkbox-inline { display: flex; gap: 12px; flex-wrap: wrap; }
.checkbox-inline label {
    background: var(--light-gray);
    padding: 9px 14px;
    border-radius: 50px;
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    border: 2px solid var(--border-color);
    font-size: 13px;
    transition: all var(--transition);
}
.checkbox-inline label:hover {
    border-color: var(--primary-color);
    background: var(--primary-bg);
    color: var(--primary-color);
}
.checkbox-inline input[type="checkbox"]:checked + span,
.checkbox-inline label:has(input:checked) {
    border-color: var(--primary-color);
    background: var(--primary-bg);
}

.checkbox-grid-large {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 8px;
}
.checkbox-grid-large label {
    background: var(--white);
    padding: 9px 6px;
    text-align: center;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    cursor: pointer;
    border: 1.5px solid var(--border-color);
    font-weight: normal;
    transition: all var(--transition);
}
.checkbox-grid-large label:hover {
    border-color: var(--primary-color);
    background: var(--primary-bg);
    color: var(--primary-color);
}
.checkbox-grid-large label.highlight-cb {
    background: #fff0f0;
    border-color: #ffb3b3;
    color: #c62828;
    font-weight: bold;
}
.checkbox-grid-large label.highlight-cb:hover {
    background: #ffe0e0;
    border-color: #c62828;
}

input[type="number"], input[type="text"], select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'B Yekan', Tahoma;
    box-sizing: border-box;
    font-size: 13px;
    color: var(--text-color);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
input[type="number"]:focus, input[type="text"]:focus, select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(209,92,34,0.12);
}

.input-group label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: bold;
    color: var(--secondary-color);
}

.btn {
    padding: 11px 22px;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: 'B Yekan', Tahoma;
    font-weight: bold;
    font-size: 13.5px;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: linear-gradient(135deg, var(--primary-color), var(--primary-dark)); box-shadow: 0 3px 10px rgba(209,92,34,0.3); }
.btn-success { background: linear-gradient(135deg, #2e7d32, #1b5e20); box-shadow: 0 3px 10px rgba(46,125,50,0.25); }
.btn-secondary { background: linear-gradient(135deg, #607d8b, #455a64); box-shadow: 0 3px 10px rgba(96,125,139,0.25); }
.full-width { width: 100%; justify-content: center; font-size: 15px; padding: 13px; border-radius: var(--radius-md); }

.result-msg {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 14px;
    line-height: 1.9;
}
.success-msg {
    background: var(--success-bg);
    color: #1b5e20;
    border: 1px solid #c8e6c9;
}

.report-section {
    background: var(--white);
    padding: 28px 30px;
    border-bottom: 1px solid var(--border-color);
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    margin-top: 15px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.report-table th, .report-table td {
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    text-align: center;
}
.report-table th {
    background: var(--secondary-color);
    color: #fff;
    font-weight: bold;
    font-size: 12px;
    letter-spacing: 0.3px;
}
.report-table tr:nth-child(even) { background-color: #f8f9fb; }
.report-table tr:hover { background-color: var(--primary-bg); }

.preview-section {
    background: linear-gradient(135deg, #3a3d40, #525659);
    padding: 28px 30px;
    margin: 0;
}

.preview-controls {
    text-align: center;
    margin-bottom: 28px;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.page-counter {
    margin: 0 20px;
    font-weight: bold;
    font-size: 15px;
    color: rgba(255,255,255,0.9);
    padding: 6px 16px;
    background: rgba(255,255,255,0.08);
    border-radius: 50px;
    border: 1px solid rgba(255,255,255,0.15);
}

.preview-controls .btn-secondary {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: none;
}
.preview-controls .btn-secondary:hover { background: rgba(255,255,255,0.22); }

#batchPreviewContainer .letter-wrapper {
    margin: 0 auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    border-radius: 2px;
}

.letter-wrapper {
    background-color: #fff;
    width: 210mm;
    min-height: 297mm;
    padding: 10mm 15mm;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    page-break-after: always;
    position: relative;
    border: none;
}
.letter-header { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 40px; }
.header-logo { flex-shrink: 0; margin-right: -6mm; }
.header-logo img { width: 110px; height: auto; }
.header-content { flex: 1; display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid var(--primary-color); padding-bottom: 12px; }
.header-right-address { font-size: 9pt; line-height: 1.8; text-align: right; }
.header-right-address p { margin: 0; }
.letter-header .header-left { margin-left: -2mm; margin-bottom: 2mm; }
.header-left-content { display: inline-block; text-align: right; font-size: 13pt; padding-bottom: 10px; }
.header-field { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; direction: rtl; }
.field-label { white-space: nowrap; font-weight: bold; flex-shrink: 0; }
.field-value { white-space: nowrap; }
.field-dotted { border-bottom: 2px dotted #666; min-width: 70px; text-align: center; padding-bottom: 2px; }

.recipient { font-size: 17pt; margin-bottom: 10px; }
.greeting { font-size: 17pt; margin-bottom: 10px; }
.subject { font-size: 15.5pt; margin-bottom: 15px; }
.content { font-size: 15.5pt; line-height: 1.8; text-align: justify; margin-bottom: 20px; }
.content p { margin: 0 0 10px 0; }

.contracts-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13.5pt; }
.contracts-table th, .contracts-table td { border: 1px solid #444; padding: 5px; text-align: center !important; vertical-align: middle; }
.contracts-table th { background-color: var(--light-gray); font-weight: bold; }

.branch-signature { text-align: left; font-size: 15.5pt; margin-left: 40px; margin-top: 20px; }
.notary-info-list p { margin: 0 0 8px 0; }

.letter-footer {
    border-top: 2px solid var(--light-gray);
    padding-top: 10px;
    margin-top: auto;
    display: flex;
    flex-direction: column;
}
.customer-info-block { font-size: 13pt; line-height: 1.8; margin-bottom: 15px; }
.customer-info-block p { margin: 0; }
.branch-info-bottom {
    text-align: center;
    font-size: 12pt;
    color: var(--secondary-color);
    border-top: 1px dashed var(--border-color);
    padding-top: 8px;
    margin-top: auto;
    line-height: 1.6;
}
.branch-info-bottom p { margin: 0; }

.app-footer {
    text-align: center;
    margin: 0;
    font-family: 'Tahoma', sans-serif;
    font-size: 12px;
    color: var(--text-muted);
    direction: ltr;
    padding: 16px;
    background: var(--light-gray);
    border-top: 1px solid var(--border-color);
}

@media screen {
    .print-only { display: none !important; }
}
@media print {
    body { background-color: #fff; padding: 0; }
    .container { box-shadow: none; padding: 0; max-width: 100%; border: none; }
    .no-print { display: none !important; }
    .print-only { display: block !important; }
    .letter-wrapper { box-shadow: none; border: none; margin: 0; padding: 10mm 15mm; width: 100%; height: 100vh; page-break-after: always; }
    @page { size: A4 portrait; margin: 0; }
}

.drop-zone {
    border: 3px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 40px 20px;
    text-align: center;
    background: var(--light-gray);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary-color);
    background: var(--primary-bg);
}
.drop-zone .drop-icon {
    font-size: 40px;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
    transition: transform var(--transition);
}
.drop-zone:hover .drop-icon {
    transform: translateY(-5px);
}

.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(209, 92, 34, 0.2);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.toast-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: var(--secondary-color);
    color: #fff;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    font-size: 14px;
    font-weight: bold;
    opacity: 0;
    transform: translateX(30px);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}
.toast.show {
    opacity: 1;
    transform: translateX(0);
}
.toast.success { border-right: 5px solid var(--success-color); }
.toast.error { border-right: 5px solid var(--danger-color); }
.toast.warning { border-right: 5px solid #ff9800; background: #333; }