/* ============================================================
   سیستم مدیریت هوشمند نامه‌های صوتی — استایل بر پایه پروژه نمونه
   شرکت فولاد و نورد سبا
   ============================================================ */

:root {
    /* ===== پالت رسمی «سبز فولادی» — بازطراحی مینیمال: سرمه‌ای-سبز آرام + سطوح خنثی ===== */
    --brand: #0d5c5f;          /* سبز فولادی عمیق و رسمی — برند */
    --brand-dark: #094649;
    --brand-light: #14787c;
    --brand-soft: #e4efee;     /* زمینهٔ ملایم برند */

    --accent: #0a7d7d;         /* عناصر تعاملی و حالت فعال */
    --accent-dark: #086767;
    --accent-soft: #ddf0ef;

    --logo-green: #2f9e44;     /* هماهنگ با سبز لوگو — وضعیت موفق */

    --surface: #ffffff;
    --surface-2: #f2f5f4;
    --surface-3: #e9efed;
    --text: #1b2626;
    --text-muted: #5d6b6a;
    --border: #dfe7e5;

    --danger: #dc3545;
    --danger-soft: #fdeeee;
    --warning: #d97706;
    --warning-soft: #fdf3e3;

    --shadow-sm: 0 1px 2px rgba(15,42,42,.05), 0 1px 3px rgba(15,42,42,.04);
    --shadow-md: 0 4px 16px rgba(15,42,42,.07), 0 12px 30px rgba(15,42,42,.05);
    --shadow-lg: 0 12px 32px rgba(15,42,42,.10), 0 24px 64px rgba(15,42,42,.08);
    --radius: 16px;
    --radius-sm: 10px;

    --font-sans: 'Vazirmatn', Tahoma, 'B Nazanin', sans-serif;
}

body.app-body {
    background: #f2f5f3;
    font-family: var(--font-sans);
    color: var(--text);
    line-height: 1.7;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('/fonts/vazir/Vazirmatn-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('/fonts/vazir/Vazirmatn-Bold.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
}

/* ---------- نوبار مینیمال رسمی (تطبیق‌پذیر روشن/تیره) ---------- */
.app-navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(15,42,42,.04), 0 4px 18px rgba(15,42,42,.05);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-navbar .app-brand {
    display: inline-flex;
    align-items: center;
    font-weight: 800;
    gap: 10px;
    color: var(--text);
    letter-spacing: -.01em;
}

.app-navbar .app-brand:hover { color: var(--brand-dark); }

.app-navbar .app-brand img {
    height: 36px;
    border-radius: 9px;
    box-shadow: 0 1px 4px rgba(15,42,42,.18);
}

.app-nav-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: 10px;
    font-weight: 600;
    transition: background .18s ease, color .18s ease, transform .18s ease;
    white-space: nowrap;
}

.app-nav-item:hover {
    background: var(--surface-2);
    color: var(--brand-dark);
    transform: translateY(-1px);
}

.app-nav-item.active {
    background: var(--brand-soft);
    box-shadow: inset 0 0 0 1px var(--border);
    color: var(--brand-dark);
}

.app-nav-item svg {
    flex-shrink: 0;
}

.app-nav-user {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
}

.app-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    border: 2px solid var(--surface);
    box-shadow: 0 1px 3px rgba(15,42,42,.2);
}

.app-role-badge {
    font-size: 11px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1px 9px;
    font-weight: 600;
}

.app-nav-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.app-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 10px;
    padding: 7px 14px;
    font-weight: 600;
    transition: background .18s ease, color .18s ease, border-color .18s ease;
}

.app-logout:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

/* ---------- صفحه ورود — چیدمان دوپنل ---------- */
body.login-body {
    background: var(--brand-dark);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
}

body.login-body main.container-fluid {
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0;
}

.login-shell {
    width: 100%;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 4fr);
    background: var(--surface);
}

/* پنل برند */
.login-brand-panel {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 82% 14%, rgba(0,153,153,.28), transparent 44%),
        radial-gradient(circle at 12% 88%, rgba(48,160,64,.16), transparent 46%),
        linear-gradient(150deg, #0b4f53 0%, #0c5a5e 55%, #0a4a4e 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.login-pattern {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
    background-size: 36px 36px;
    mask-image: radial-gradient(circle at 50% 40%, #000 20%, transparent 78%);
    pointer-events: none;
}

.login-brand-inner {
    position: relative;
    z-index: 1;
    max-width: 420px;
    animation: brand-fade .6s cubic-bezier(.2,.7,.3,1) both;
}

@keyframes brand-fade {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-brand-logo {
    width: 86px;
    height: auto;
    border-radius: 16px;
    background: #fff;
    padding: 8px;
    box-shadow: 0 14px 34px rgba(0,0,0,.35);
    margin-bottom: 22px;
}

.login-brand-title {
    font-size: 1.65rem;
    font-weight: 800;
    margin: 0 0 8px;
}

.login-brand-sub {
    font-size: .95rem;
    opacity: .82;
    margin: 0 0 28px;
}

.login-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-features li {
    display: flex;
    align-items: center;
    gap: 11px;
    font-size: .92rem;
    color: rgba(255,255,255,.92);
}

.login-features svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: #4dd8c4;
}

.login-brand-note {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: .88rem;
    color: rgba(255,255,255,.9);
    backdrop-filter: blur(4px);
}

.login-brand-note svg { flex-shrink: 0; color: #4dd8c4; }

/* پنل فرم */
.login-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--surface);
}

.login-form-inner {
    width: 100%;
    max-width: 380px;
    animation: brand-fade .6s cubic-bezier(.2,.7,.3,1) .1s both;
}

.login-form-head {
    margin-bottom: 26px;
}

.login-form-head h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text);
    margin: 0 0 6px;
}

.login-form-head p {
    font-size: .85rem;
    color: var(--text-muted);
    margin: 0;
}

.login-card {
    border: none;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
}

.login-card .card-body { padding: 34px 30px !important; }

.login-logo {
    width: 84px;
    height: 84px;
    border-radius: 18px;
    box-shadow: var(--shadow-md);
    object-fit: contain;
    background: #fff;
    padding: 6px;
}

.login-card h1 {
    font-size: 1.15rem;
    font-weight: 700;
}

.login-subtitle {
    font-size: .82rem;
    color: var(--text-muted);
}

.login-card .form-control,
.login-form-inner .form-control {
    border-radius: 10px;
    padding: 11px 14px;
    border-color: var(--border);
}

.login-card .form-control:focus,
.login-form-inner .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 .22rem rgba(0,153,153,.16);
}

.login-form-inner .form-label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
}

.login-form-inner .form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

/* مراحل فعال‌سازی */
.locked-steps {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 18px;
}

.locked-steps ol {
    margin: 0;
    padding-right: 20px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    font-size: .88rem;
}

.locked-steps li::marker {
    color: var(--accent);
    font-weight: 700;
}

.ltr-dir {
    direction: ltr;
    display: inline-block;
    font-family: monospace;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0 6px;
}

@media (max-width: 860px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-brand-panel { display: none; }
    .login-form-panel { padding: 32px 22px; }
}

/* ---------- کارت‌های آمار (KPI) دشبورد ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 14px;
    margin-bottom: 8px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
    animation: kpi-rise .55s cubic-bezier(.2,.7,.3,1) both;
}

.kpi-grid .kpi-card:nth-child(2) { animation-delay: .07s; }
.kpi-grid .kpi-card:nth-child(3) { animation-delay: .14s; }
.kpi-grid .kpi-card:nth-child(4) { animation-delay: .21s; }

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: #c9d8d3;
}

.kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon svg { width: 24px; height: 24px; }

.kpi-label {
    font-size: .78rem;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

@keyframes kpi-rise {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .kpi-card { animation: none; }
}

/* ---------- تب‌های فلتر دشبورد ---------- */
.filter-tabs {
    display: inline-flex;
    gap: 6px;
    background: var(--surface-2);
    padding: 5px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.filter-tab {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 7px 16px;
    border-radius: 9px;
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    transition: background .15s ease, color .15s ease;
}

.filter-tab.active {
    background: var(--surface);
    color: var(--brand);
    box-shadow: var(--shadow-sm);
}

.filter-tab.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0,122,122,.35);
}

/* ---------- هماهنگ‌سازی دکمه‌های Bootstrap با پالت برند ---------- */
.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
}

.btn-outline-primary {
    --bs-btn-color: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);
}

/* دکمه‌ی عمل دوم — پس‌زمینه‌ی نرم برند */
.btn-soft {
    --bs-btn-bg: var(--brand-soft);
    --bs-btn-border-color: var(--brand);
    --bs-btn-color: var(--brand-dark);
    --bs-btn-hover-bg: #d3e6e4;
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-hover-color: var(--brand-dark);
    --bs-btn-active-bg: #c5dcda;
    --bs-btn-active-border-color: var(--brand-dark);
    --bs-btn-active-color: var(--brand-dark);
    --bs-btn-focus-shadow-rgb: 12, 90, 94;
}

.btn-success {
    --bs-btn-bg: var(--logo-green);
    --bs-btn-border-color: var(--logo-green);
    --bs-btn-hover-bg: #278a36;
    --bs-btn-hover-border-color: #278a36;
}

.btn-outline-success {
    --bs-btn-color: var(--logo-green);
    --bs-btn-border-color: var(--logo-green);
    --bs-btn-hover-bg: var(--logo-green);
    --bs-btn-hover-border-color: var(--logo-green);
}

/* ---------- صفحهٔ مشاهدهٔ نامه ---------- */
body:has(.sheet) {
    background: #e9eeec;
}

body:has(.sheet) main.container-fluid {
    padding-top: 18px;
}

/* ---------- جدول مدرن دشبورد ---------- */
.dash-table-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.dash-table-card .table thead th {
    background: var(--surface-2);
    color: var(--text);
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-size: .82rem;
}

.dash-table-card .table tbody tr {
    transition: background .15s ease;
}

.dash-table-card .table tbody tr:hover { background: var(--brand-soft); }

.dash-table-card .table td { vertical-align: middle; }

.dash-table-card .table td:first-child {
    font-variant-numeric: tabular-nums;
}

.table-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tbl-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 5px 9px;
    font-size: .78rem;
    font-weight: 600;
    transition: all .15s ease;
    text-decoration: none;
    cursor: pointer;
}

.tbl-action:hover { transform: translateY(-1px); text-decoration: none; }
.tbl-action.tbl-view:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.tbl-action.tbl-edit:hover { color: var(--warning); border-color: var(--warning); background: var(--warning-soft); }
.tbl-action.tbl-del:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.tbl-action svg { width: 15px; height: 15px; flex-shrink: 0; }

/* غربالگری ردیف‌ها طبق تب (در JS) */
tr.filter-hidden { display: none !important; }

/* ---------- حالت خالی دشبورد ---------- */
.empty-state {
    text-align: center;
    padding: 54px 20px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin-top: 14px;
}

.empty-state .empty-icon {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: var(--brand-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    color: var(--brand);
}

.dash-heading {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.dash-btn-new {
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 11px;
    padding: 9px 18px;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.dash-btn-new:hover { color: #fff; background: var(--brand-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.dash-btn-new svg { width: 18px; height: 18px; }

.search-box {
    border-radius: 11px;
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
    padding: 10px 14px;
}

.search-box:focus { border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(0,153,153,.13); }

.search-go-btn {
    border-radius: 10px;
    background: var(--brand);
    border: none;
    padding: 9px 22px;
    font-weight: 700;
}

.search-go-btn:hover { background: var(--brand-dark); }

/* سهمیه‌ی امروز */
.quota-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.quota-card .progress {
    overflow: hidden;
    border-radius: 10px;
    background: var(--surface-2);
}

.quota-card .progress-bar {
    border-radius: 10px;
    animation: quota-fill 1s cubic-bezier(.2,.7,.3,1) both;
}

@keyframes quota-fill {
    from { width: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .quota-card .progress-bar { animation: none; }
}

.pagination {
    --bs-pagination-border-radius: 9px;
    --bs-pagination-active-bg: var(--brand);
    --bs-pagination-active-border-color: var(--brand);
    --bs-pagination-color: var(--brand);
    --bs-pagination-hover-color: var(--brand);
}

/* انتقال صفحه‌بندی به سمت راست (در RTL: flex-end = چپ، پس با row-reverse) */
.pagination-wrap nav {
    display: flex;
    justify-content: flex-end;
}
.pagination-wrap nav .d-sm-flex {
    flex-direction: row-reverse;
}
.pagination-wrap .pagination {
    margin-bottom: 0;
}

.badge-draft { background: var(--surface-2); color: var(--text-muted); }
.badge-final { background: var(--accent-soft); color: var(--accent-dark); }

/* ---------- نوار فعال‌سازی صوتی (سلام سبا) ---------- */
.wake-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: 900px;
    margin: 0 auto 12px;
    padding: 8px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    text-align: center;
    transition: border-color .15s ease;
}

.wake-bar:hover {
    border-color: var(--accent);
}

.wake-status {
    color: var(--text-muted);
}

.wake-status.listening {
    color: var(--brand);
    font-weight: bold;
}

/* دایره‌ی قرمز چشمک‌زن کنار «تایپ صوتی فعال است» */
.wake-red-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #dc3545;
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.5);
    animation: red-dot-pulse 1s infinite;
    flex-shrink: 0;
}

@keyframes red-dot-pulse {
    0% { opacity: 1; box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.5); }
    50% { opacity: 0.4; box-shadow: 0 0 0 6px rgba(220, 53, 69, 0); }
    100% { opacity: 1; box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

/* ---------- هماهنگ‌سازی کارت‌ها و فرم‌های Bootstrap ---------- */
.card {
    border-color: var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
}

.form-control,
.form-select {
    border-color: var(--border);
    border-radius: 10px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem rgba(0,153,153,.12);
}

.table > :not(caption) > * > * {
    border-bottom-color: var(--border);
}

/* ---------- برگه نامه (نمایش صفحه) ---------- */
.sheet {
    background: #fff;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 30px 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    min-height: 1100px;
    position: relative;
}

.top-grid {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.logo-box .main-logo {
    height: 80px;
    width: auto;
}

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

.center-title h1 {
    font-family: 'B Titr', Tahoma, sans-serif;
    font-size: 20px;
    font-weight: bold;
    color: var(--brand);
    margin: 4px 0 0;
}

.left-info { text-align: left; }

.header-left .header-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 5px;
}

.header-left label {
    font-size: 13px;
    width: 55px;
    text-align: left;
    padding-left: 5px;
    margin: 0;
}

.header-left input,
.header-left select {
    width: 120px;
    height: 22px;
    font-size: 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0 5px;
    font-family: 'B Titr', Tahoma, sans-serif;
}

.date-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 5px;
    font-size: 14px;
}

/* ---------- گیرنده ---------- */
.section-box { margin-bottom: 14px; }

.line-row {
    display: flex;
    align-items: center;
    direction: rtl;
}

.label-text {
    font-family: 'B Titr', Tahoma, sans-serif;
    font-size: 13px;
    font-weight: bold;
}

.receiver-info {
    border: none;
    border-bottom: 1px dashed #aaa;
    background: transparent;
    font-family: 'B Titr', Tahoma, sans-serif;
    font-size: 14px;
    padding: 4px 6px;
    outline: none;
    text-align: right !important;
    direction: rtl;
}

.receiver-info:focus { border-bottom-color: var(--accent); }

.search-plus {
    cursor: pointer;
    margin-right: 5px;
    width: 30px;
    height: 30px;
    background-color: var(--logo-green);
    color: #fff;
    border: none;
    border-radius: 4px;
    flex-shrink: 0;
}

.view-value {
    font-family: 'B Titr', Tahoma, sans-serif;
    font-size: 14px;
    padding: 4px 6px;
    text-align: right !important;
    direction: rtl;
}

/* ---------- نوار ابزار ویرایشگر ---------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 10px;
    margin-bottom: 12px;
}

.tool-group { display: inline-flex; gap: 3px; }

.tool-btn {
    min-width: 30px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 7px;
    cursor: pointer;
    font-size: 12px;
    padding: 0 6px;
    line-height: 1;
    transition: background .15s ease, border-color .15s ease;
}

.tool-btn:hover { background: var(--accent-soft); border-color: var(--accent); }

.tool-select {
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 11px;
    background: var(--surface);
}

.color-picker-wrapper { position: relative; display: inline-block; }

.color-palette {
    display: none;
    position: absolute;
    top: 32px;
    right: 0;
    z-index: 50;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,.15);
    width: 190px;
}

.preset-colors { display: flex; gap: 4px; margin-bottom: 6px; }

.color-square {
    width: 22px;
    height: 22px;
    border-radius: 3px;
    border: 1px solid #ddd;
    cursor: pointer;
}

.custom-color-label { font-size: 11px; display: block; }

/* ---------- ادیتور ---------- */
.editor {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    min-height: 420px;
    background: #fff;
    direction: rtl;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.02);
}

.fixed-header-text {
    font-family: 'IranNastaliq', 'Traditional Arabic', cursive;
    font-size: 22pt;
    text-align: center;
    line-height: 1.4;
}

.salutation-text {
    font-family: 'IranNastaliq', 'Traditional Arabic', cursive;
    font-size: 22pt;
    text-align: right;
    line-height: 1.4;
}

.letter-body {
    font-family: 'B Nazanin', Tahoma, sans-serif;
    font-size: 13pt;
    font-weight: bold;
    line-height: 1.4;
    text-align: justify;
    min-height: 220px;
    outline: none;
    margin-top: 12px;
}

.letter-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}

.letter-body table, .letter-body td, .letter-body th {
    border: 1pt solid #000;
}

.letter-body td, .letter-body th {
    padding: 6px;
    font-size: 11pt;
    min-width: 50px;
}

/* ---------- امضا ---------- */
.mini-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 5px;
}

.field1 {
    border: none;
    border-bottom: 1px dashed #aaa;
    background: transparent;
    font-family: 'B Titr', Tahoma, sans-serif;
    font-size: 13px;
    padding: 4px;
    outline: none;
    text-align: center;
}

/* ---------- رونوشت ---------- */
.copy-title {
    display: block;
    margin-bottom: 5px;
    width: 300px;
    font-family: 'Zar', 'B Nazanin', sans-serif;
    font-size: 10pt;
    font-weight: bold;
}

.copy-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.copy-item .field {
    width: 300px;
    border: none;
    border-bottom: 1px dashed #aaa;
    background: transparent;
    font-family: 'Zar', 'B Nazanin', sans-serif;
    font-size: 10pt;
    font-weight: bold;
    padding: 2px 4px;
    outline: none;
}

.copy-add {
    margin-right: 5px;
    cursor: pointer;
    background: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 3px;
    padding: 2px 8px;
}

/* ---------- دکمه‌های عملیات (واکنش‌گرا) ---------- */
.actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 30px 0;
    direction: rtl;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.action-btn {
    flex: 1 1 0;
    min-width: 110px;
    padding: 10px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background .2s ease, border-color .2s ease, transform .15s ease;
}

.action-btn:hover:not(:disabled) {
    background: var(--surface-3);
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

/* دکمه اصلی (ثبت نامه) */
.action-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.action-primary:hover:not(:disabled) {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

/* ابزارهای هوشمند (صوتی و بازنویسی) */
.action-smart {
    flex: 1 1 0;
    min-width: 140px;
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.action-smart:hover:not(:disabled) {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

/* دکمه‌های ثانویه (چاپ، ورد، منو) */
.action-outline {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
}

.action-outline:hover:not(:disabled) {
    background: var(--surface-2);
}

/* دکمه خطر (خروج) */
.action-danger {
    background: var(--surface);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.action-danger:hover:not(:disabled) {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger);
}

.action-tone {
    flex: 0 0 auto;
    min-width: 150px;
    max-width: 180px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 12px;
    background: var(--surface);
    color: var(--text);
}

.print-disabled {
    background: var(--surface-2) !important;
    border-color: var(--border) !important;
    color: var(--text-muted) !important;
    cursor: not-allowed !important;
    font-weight: normal !important;
}

/* موبایل و تبلت کوچک */
@media (max-width: 767px) {
    .action-row {
        flex-direction: column;
    }

    .action-btn,
    .action-smart,
    .action-tone {
        width: 100%;
        min-width: 0;
        max-width: none;
        flex: 1 1 auto;
        padding: 12px 8px;
        font-size: 12px;
    }
}

/* گوشی‌های خیلی کوچک */
@media (max-width: 380px) {
    .action-btn {
        font-size: 10px;
        padding: 12px 4px;
    }
}

/* ---------- مودال جستجو ---------- */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    backdrop-filter: blur(3px);
}

.search-modal-box {
    background: #fff;
    width: 450px;
    max-width: 92%;
    margin: 50px auto;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,.3);
    overflow: hidden;
    font-family: Tahoma, sans-serif;
}

.search-modal-header {
    background: var(--brand);
    color: #fff;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.search-modal-body { padding: 20px; }

.search-modal-body input {
    width: 100%;
    padding: 12px;
    border: 2px solid #eee;
    border-radius: 8px;
    outline: none;
    font-family: Tahoma, sans-serif;
}

#modalResults {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 15px;
}

#modalResults .result-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

#modalResults .result-item:hover { background: #f0fdf4; }

/* ---------- دکمه شناور دستیار هوشمند ---------- */
.assistant-fab {
    position: fixed;
    bottom: 24px;
    left: 24px; /* در حالت RTL سمت چپ پایین برای عدم تداخل با اسکرول‌بار */
    z-index: 1050;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 28px rgba(12,90,94,.45), 0 2px 8px rgba(12,90,94,.28);
    border: 2px solid rgba(255,255,255,.35);
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
    text-decoration: none;
    cursor: pointer;
}

.assistant-fab:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 16px 38px rgba(12,90,94,.55);
    color: #fff;
    text-decoration: none;
}

.assistant-fab:active {
    transform: translateY(0) scale(.97);
}

.assistant-fab svg {
    width: 30px;
    height: 30px;
    display: block;
}

/* نقطه وضعیت (حضور آنلاین دستیار) */
.assistant-fab .fab-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border: 2px solid #fff;
    border-radius: 50%;
}

/* تپش آرام برای برجسته‌شدن آیکون */
@keyframes fab-pulse {
    0%   { box-shadow: 0 10px 28px rgba(12,90,94,.45), 0 0 0 0 rgba(19,120,125,.5); }
    70%  { box-shadow: 0 10px 28px rgba(12,90,94,.45), 0 0 0 16px rgba(19,120,125,0); }
    100% { box-shadow: 0 10px 28px rgba(12,90,94,.45), 0 0 0 0 rgba(19,120,125,0); }
}
.assistant-fab {
    animation: fab-pulse 2.4s infinite;
}
@media (prefers-reduced-motion: reduce) {
    .assistant-fab { animation: none; }
}

/* برچسب متحرک کنار دکمه */
.assistant-fab-label {
    position: fixed;
    bottom: 34px;
    left: 96px;
    z-index: 1049;
    background: var(--brand);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
    opacity: 0;
    transform: translateX(8px);
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
}
.assistant-fab:hover ~ .assistant-fab-label,
.assistant-fab-label:hover {
    opacity: 1;
    transform: translateX(0);
}

/* در صفحه خودِ دستیار، دکمه قابل کلیک نباشد (حذف) */
body.assistant-page .assistant-fab,
body.assistant-page .assistant-fab-label {
    display: none !important;
}

/* ---------- چاپ ---------- */
/* ---------- اسکلتون (لودینگ شیمر) ---------- */
.skeleton {
    display: inline-block;
    background: linear-gradient(90deg, var(--surface-2) 25%, #e5ebe9 37%, var(--surface-2) 63%);
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.4s ease infinite;
    border-radius: 6px;
}

@keyframes skeleton-shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton { animation: none; }
}

/* ============================================================
   تم شب — با سوییچ در نوبار و ذخیره در localStorage (vlm-theme)
   ============================================================ */
[data-theme="dark"] {
    color-scheme: dark;

    --brand: #1b8b91;
    --brand-dark: #0f5f63;
    --brand-light: #2aa3a9;
    --brand-soft: #143536;

    --accent: #00b3b3;
    --accent-dark: #009999;
    --accent-soft: #123f3f;

    --logo-green: #3cb451;

    --surface: #13191b;
    --surface-2: #1c2527;
    --surface-3: #232e30;
    --text: #dbe7e4;
    --text-muted: #8aa09b;
    --border: #2a3738;

    --danger: #e05260;
    --danger-soft: #3a2024;
    --warning: #e0a53d;
    --warning-soft: #3a2f1a;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 4px 14px rgba(0,0,0,.45);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
}

[data-theme="dark"] body.app-body {
    background: #0f1517;
}

[data-theme="dark"] .app-navbar {
    background: var(--surface);
    background-image: none;
    border-bottom-color: var(--border);
}

[data-theme="dark"] .kpi-card:hover { border-color: #3c4f51; }

/* برگهٔ نامه و ادیتور همیشه سفید می‌مانند (دقت چاپ و ظاهر کاغذی) */
[data-theme="dark"] .sheet,
[data-theme="dark"] .editor {
    background: #fff;
    color: #111;
}

[data-theme="dark"] .letter-body,
[data-theme="dark"] .fixed-header-text,
[data-theme="dark"] .salutation-text {
    color: #111;
}

[data-theme="dark"] body:has(.sheet) { background: #0e1415; }

[data-theme="dark"] .search-modal-box { background: var(--surface); }
[data-theme="dark"] .search-modal-body input { border-color: var(--border); background: var(--surface-2); color: var(--text); }
[data-theme="dark"] #modalResults .result-item { border-bottom-color: var(--border); }
[data-theme="dark"] #modalResults .result-item:hover { background: var(--brand-soft); }
[data-theme="dark"] .color-palette { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .login-form-panel { background: var(--surface); }
[data-theme="dark"] .login-card { background: var(--surface); }

/* دکمه‌های ویرایشگر */
[data-theme="dark"] .action-btn {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .action-btn:hover:not(:disabled) {
    background: var(--brand-soft);
    border-color: var(--border);
}

[data-theme="dark"] .action-outline {
    background: var(--surface-2);
    color: var(--text);
}

[data-theme="dark"] .action-danger {
    background: var(--surface-2);
}

/* دستیار هوشمند */
[data-theme="dark"] .assistant-chat {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .assistant-msg.ai {
    background: var(--surface-2);
    color: var(--text);
}

[data-theme="dark"] .assistant-msg.user {
    background: #1b8b91;
}

[data-theme="dark"] .assistant-inputbar {
    background: transparent;
}

[data-theme="dark"] .assistant-inputbar textarea {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

[data-theme="dark"] .assistant-pending {
    background: #2c2512;
    border-color: #6b5716;
    color: #f2d78a;
}

[data-theme="dark"] .tool-chip {
    background: #232b3d;
    color: #b9c7ef;
}

/* تور راهنمای اولین‌بار */
.tour-tooltip {
    position: fixed;
    z-index: 3000;
    max-width: 320px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 16px 18px;
    font-size: 13.5px;
    line-height: 1.8;
    animation: tour-pop .28s cubic-bezier(.2,.7,.3,1) both;
}

@keyframes tour-pop {
    from { opacity: 0; transform: translateY(8px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tour-tooltip h5 {
    font-size: 1rem;
    font-weight: 800;
    margin: 0 0 6px;
    color: var(--brand);
}

.tour-tooltip p {
    margin: 0 0 12px;
    color: var(--text-muted);
}

.tour-tooltip .tour-progress {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.tour-tooltip .tour-actions {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.tour-dont-show {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
    cursor: pointer;
    user-select: none;
}

.tour-dont-show input {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.tour-tooltip .btn-tour {
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-weight: 700;
    font-size: 12.5px;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: filter .15s ease, transform .15s ease;
}

.tour-tooltip .btn-tour:hover { filter: brightness(1.08); }

.btn-tour-next {
    background: var(--brand);
    color: #fff;
}

.btn-tour-skip {
    background: transparent;
    color: var(--text-muted);
}

.tour-ring {
    position: fixed;
    z-index: 2999;
    pointer-events: none;
    border-radius: 10px;
    box-shadow: 0 0 0 3px var(--accent), 0 0 0 8px rgba(0,153,153,.25);
    animation: tour-ring-pulse 1.6s ease infinite;
    transition: all .25s ease;
}

@keyframes tour-ring-pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--accent), 0 0 0 8px rgba(0,153,153,.22); }
    50%      { box-shadow: 0 0 0 3px var(--accent), 0 0 0 14px rgba(0,153,153,.08); }
}

@media (prefers-reduced-motion: reduce) {
    .tour-tooltip, .tour-ring { animation: none; }
}

/* ============================================================
   بازطراحی v1.14 — مینیمال رسمی + ترند روز (روشن/تیره)
   ============================================================ */

/* حلقه‌ی فوکوس مشخص (دسترسی‌پذیری) */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* نوبار — غلبه بر specificity بوت‌استرپ */
.app-navbar .app-nav-item { color: var(--text-muted); }
.app-navbar .app-nav-item:hover { color: var(--brand-dark); }
.app-navbar .app-nav-item.active {
    background: var(--brand-soft);
    box-shadow: inset 0 0 0 1px var(--border);
    color: var(--brand-dark);
}
.app-navbar .app-brand { color: var(--text); }
.app-navbar .app-brand:hover { color: var(--brand-dark); }

/* تیتر صفحه */
.dash-heading {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -.01em;
    color: var(--text);
}

/* دکمه‌ی «نامه جدید» */
.dash-btn-new {
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(13,92,95,.3), 0 4px 14px rgba(13,92,95,.18);
    transition: transform .15s ease, box-shadow .15s ease;
}
.dash-btn-new:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(13,92,95,.3), 0 8px 22px rgba(13,92,95,.22);
}

/* کارت‌های آماری داشبورد کاربر */
.kpi-card {
    border-radius: var(--radius);
    padding: 20px 22px;
}
.kpi-card:hover {
    border-color: var(--brand-light);
    box-shadow: var(--shadow-md);
}
.kpi-icon {
    border-radius: 14px;
}

/* نوار سهمیه */
.quota-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

/* ===== داشبورد ادمین — کارت آماری برجسته (Bento) ===== */
.admin-stat-card {
    border-radius: var(--radius);
    padding: 20px 18px;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.admin-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand-light);
}
.stat-icon {
    border-radius: 12px;
}
.stat-num {
    font-size: 24px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

/* کارت برجسته — گرادیان تیرهٔ برند (اولین کارت: کل نامه‌ها) */
.admin-stat-card.stat-featured {
    background: linear-gradient(150deg, #0b5458 0%, #0d5c5f 55%, #0a4a4e 100%);
    border: none;
    color: #fff;
    box-shadow: 0 4px 18px rgba(13,92,95,.35);
}
.admin-stat-card.stat-featured .stat-label { color: rgba(255,255,255,.82); }
.admin-stat-card.stat-featured .stat-num { color: #fff; }
.admin-stat-card.stat-featured .stat-icon {
    background: rgba(255,255,255,.16);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}

/* لینک‌های سریع ادمین */
.admin-quick-link {
    border-radius: 14px;
    padding: 16px 18px;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.admin-quick-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand-light);
}

/* جدول‌های داشبورد — فاصله و خوانایی */
.dash-table-card .table thead th,
.admin-dash-table thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 700;
    font-size: .8rem;
    padding: 12px 14px;
    letter-spacing: .01em;
}
.dash-table-card .table td,
.admin-dash-table td {
    padding: 12px 14px;
}

/* تایم‌لاین فعالیت ادمین */
.admin-log-item {
    padding: 13px 18px;
}
.admin-log-item:hover {
    background: var(--surface-2);
}

/* اسکرول‌بار ظریف */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 8px;
    border: 2px solid var(--surface);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* دکمه‌ی همبرگری نوبار (تم روشن) */
.app-navbar .navbar-toggler { border-color: var(--border); }
.app-navbar .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%235d6b6a' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ===== مودال‌های تأیید — شیشه‌ای مات (Glassmorphism)، وسط صفحه ===== */
.swal2-container {
    backdrop-filter: blur(7px) saturate(130%);
    -webkit-backdrop-filter: blur(7px) saturate(130%);
    background: rgba(13, 40, 40, 0.30) !important;
    padding: 1rem;
}
.swal2-popup {
    background: rgba(255, 255, 255, 0.72) !important;
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px !important;
    box-shadow: 0 18px 50px rgba(8, 40, 40, 0.28) !important;
    padding: 18px 22px !important;
    width: auto !important;
    max-width: 360px !important;
}
.swal2-title { color: var(--text) !important; font-weight: 800; }
.swal2-html-container { color: var(--text-muted) !important; }
.swal2-icon { border-width: 3px; }
.swal2-styled.swal2-confirm {
    border-radius: 12px !important;
    font-weight: 700;
    padding: 9px 22px !important;
    box-shadow: 0 6px 18px rgba(220, 53, 69, 0.30) !important;
    font-size: 14px !important;
}
.swal2-styled.swal2-cancel {
    border-radius: 12px !important;
    font-weight: 700;
    padding: 9px 22px !important;
    font-size: 14px !important;
}
.swal2-title { font-size: 17px !important; }
.swal2-html-container { font-size: 13.5px !important; }
.swal2-icon { font-size: 10px !important; width: 3.5em !important; height: 3.5em !important; }
[data-theme="dark"] .swal2-popup {
    background: rgba(22, 31, 33, 0.78) !important;
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55) !important;
}
[data-theme="dark"] .swal2-title { color: #dbe7e4 !important; }
[data-theme="dark"] .swal2-html-container { color: #8aa09b !important; }

/* بج لاگ‌ها — تطبیق‌پذیر با تم */
.badge-log {
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-weight: 600;
}

/* نتیجه‌ی جستجوی RAG در ادمین — تطبیق‌پذیر با تم */
.rag-result-wrap {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

/* کارت‌های ادمین و فرم‌ها — تطبیق کامل با تم */
.admin-panel .card,
.card { background: var(--surface); border-color: var(--border); }
.card-header { border-bottom-color: var(--border); color: var(--text); }
.form-control, .form-select {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}
.form-control:focus, .form-select:focus {
    background: var(--surface);
    color: var(--text);
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem rgba(10,125,125,.15);
}
.form-control::placeholder { color: var(--text-muted); opacity: .75; }
.text-muted { color: var(--text-muted) !important; }
.page-link {
    background: var(--surface);
    border-color: var(--border);
    color: var(--brand-dark);
}
.page-item.active .page-link {
    background: var(--brand);
    border-color: var(--brand);
}

/* ---------- چاپ ---------- */
@media print {
    @page {
        size: A4;
        margin-right: 2.5cm !important;
        margin-top: 0.02cm !important;
    }

    .app-navbar, .assistant-fab, .assistant-fab-label,
    .toolbar, .actions, .no-print,
    .label-text, .label-to-hide, .logo-box, .center-title,
    .search-plus, .date-btn, .copy-add {
        display: none !important;
        visibility: hidden !important;
    }

    .sheet {
        border: none !important;
        box-shadow: none !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        min-height: 0 !important;
        position: relative !important;
    }

    .editor {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        min-height: 0 !important;
        margin-bottom: 0 !important;
    }

    .section-box {
        border: none !important;
        background: transparent !important;
        margin: 0 !important;
        margin-top: 0.7cm !important;
    }

    .left-info {
        position: absolute !important;
        left: -2cm !important;
        width: 200px !important;
        text-align: left !important;
    }

    .header-left {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .header-left .header-row {
        height: 0.4cm !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .header-left input, .header-left select {
        text-align: right !important;
        font-family: 'B Titr', sans-serif !important;
        font-size: 9pt !important;
        border: none !important;
        width: auto !important;
        height: auto !important;
        line-height: 1 !important;
        padding: 0 !important;
    }

    .line-row {
        display: block !important;
        text-align: right !important;
        margin-top: 2cm !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
    }

    .line-row ~ .line-row { margin-top: 0 !important; }

    #recipient_name, #recipient_job, #subject,
    .receiver-info, .view-value {
        font-family: 'B Titr', sans-serif !important;
        font-size: 14pt !important;
        font-weight: bold !important;
        display: block !important;
        width: 100% !important;
        text-align: right !important;
        height: 1.2cm !important;
        line-height: 1.2cm !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
    }

    .salutation-text, .fixed-header-text {
        font-family: 'IranNastaliq', cursive !important;
        font-size: 22pt !important;
        line-height: 1.2cm !important;
        display: block !important;
        width: 100% !important;
        margin-top: -2mm !important;
        margin-bottom: -2mm !important;
    }

    .salutation-text { text-align: right !important; }
    .fixed-header-text { text-align: center !important; }

    #letterBody, .letter-body, .letter-body * {
        font-family: 'B Nazanin', sans-serif !important;
        font-size: 13pt !important;
        font-weight: bold !important;
        text-align: justify !important;
        line-height: 1.2cm !important;
    }

    .letter-body {
        margin-left: 1cm !important;
        margin-top: 0.4cm !important;
    }

    .bottom-section { margin-top: 0 !important; }

    .bottom-section > div {
        display: block !important;
        clear: both !important;
        margin-top: 0.6cm !important;
    }

    #signer_name, #signer_job, .field1 {
        font-family: 'B Titr', sans-serif !important;
        font-size: 14pt !important;
        font-weight: bold !important;
        text-align: center !important;
        display: block !important;
        width: 100% !important;
        border: none !important;
        background: transparent !important;
    }

    #copy-section {
        position: absolute !important;
        bottom: 4cm !important;
        left: 0 !important;
        right: 0 !important;
        text-align: right !important;
        direction: rtl !important;
        width: 100% !important;
        margin: 0 !important;
    }

    .copy-item {
        display: block !important;
        text-align: right !important;
        margin-bottom: 2mm !important;
    }

    .copy-item .field {
        border: none !important;
        text-align: right !important;
        width: auto !important;
        font-family: 'B Zar', sans-serif !important;
    }

    table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin: 10px 0 !important;
        border: 2pt solid #000 !important;
    }

    .letter-body td, .letter-body th {
        border: 1pt solid #000 !important;
        padding: 5px !important;
        font-family: 'B Nazanin', sans-serif !important;
        font-size: 11pt !important;
    }
}
