@font-face {
    font-family: 'IRANSans';
    src: url('font/IRANSans-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IRANSans';
    src: url('font/IRANSans-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'IRANSans', Tahoma, Arial, sans-serif;
    direction: rtl;
    color: #111827;
}

/* =========================
   صفحه فرم
========================= */
.app-body {
    background: #f6f7fb;
}

.container {
    max-width: 760px;
    margin: 40px auto;
    padding: 24px;
}

.card-ui {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,.08);
    padding: 24px;
}

h1 {
    margin: 0 0 24px;
    font-size: 24px;
    font-weight: 700;
}

.form-grid {
    display: grid;
    gap: 18px;
}

.form-group {
    display: grid;
    gap: 8px;
}

label {
    font-size: 14px;
    font-weight: 700;
}

input[type="text"] {
    width: 100%;
    height: 48px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 0 14px;
    font-family: 'IRANSans', Tahoma, Arial, sans-serif;
    font-size: 14px;
    outline: none;
    direction: rtl;
    text-align: right;
}

input[type="text"]:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.error-text {
    min-height: 20px;
    color: #dc2626;
    font-size: 12px;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    appearance: none;
    border: none;
    cursor: pointer;
    border-radius: 10px;
    height: 46px;
    padding: 0 18px;
    font-family: 'IRANSans', Tahoma, Arial, sans-serif;
    font-size: 14px;
    font-weight: 700;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #e5e7eb;
    color: #111827;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.message {
    margin-top: 16px;
    min-height: 22px;
    font-size: 14px;
    font-weight: 700;
}

.message.success {
    color: #059669;
}

.message.error {
    color: #dc2626;
}

.notes {
    margin-top: 20px;
    padding: 14px 16px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.9;
    color: #92400e;
}

.loading {
    opacity: .65;
    pointer-events: none;
}

/* =========================
   مودال پیش‌نمایش
========================= */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(17,24,39,.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9999;
}

.modal.show {
    display: flex;
}

.modal-box {
    width: min(100%, 1100px);
    height: min(92vh, 900px);
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,.2);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 18px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
}

.modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.modal-body {
    flex: 1;
    background: #eef2f7;
}

.modal-body iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #eef2f7;
}

/* =========================
   صفحه چاپ
========================= */
.print-page {
    margin: 0;
    padding: 0;
    background: #f3f4f6;
}

.print-preview-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.card-print {
    position: relative;
    width: 85mm;
    height: 55mm;
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,.12);
    transform: scale(3);
    transform-origin: center center;
}

.field {
    position: absolute;
    direction: rtl;
    text-align: right;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.35;
    color: #000;
    margin: 0;
    padding: 0;
    z-index: 2;
    font-family: 'IRANSans', Tahoma, Arial, sans-serif;
}

.debug-box {
    outline: 1px dashed rgba(220, 38, 38, 0.8);
    background: rgba(255, 255, 255, 0.01);
}

.debug-card {
    outline: 1px solid rgba(37, 99, 235, 0.5);
}

.print-debug-info {
    position: fixed;
    left: 10px;
    bottom: 10px;
    background: rgba(17, 24, 39, 0.85);
    color: #fff;
    font-size: 12px;
    line-height: 1.7;
    padding: 8px 10px;
    border-radius: 8px;
    direction: ltr;
    z-index: 99999;
}

@page {
    size: 85mm 55mm;
    margin: 0;
}

@media print {
    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        width: 85mm;
        height: 55mm;
        overflow: hidden;
        background: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .print-page {
        background: #fff !important;
    }

    .print-preview-wrap {
        min-height: auto;
        display: block;
        padding: 0;
    }

    .card-print {
        box-shadow: none;
        transform: none;
    }

    .print-debug-info {
        display: none !important;
    }
}
