/* ═══════════════════════════════════════════════════════════════
   اتوماسیون اداری — استایل اصلی
   RTL | فارسی | پرینت A4 | دارک/لایت تِم
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100..900&display=swap');

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
    --font-fa: 'Vazirmatn', 'Tahoma', sans-serif;

    /* Light theme */
    --bg-base:      #F7F8FC;
    --bg-surface:   #FFFFFF;
    --bg-elevated:  #EEF0F8;
    --bg-sidebar:   #1E2A3A;
    --bg-sidebar-hover: #29394D;
    --bg-sidebar-active: #2F6FED;

    --text-primary:   #1A1F36;
    --text-secondary: #5A6278;
    --text-muted:     #9EA8BC;
    --text-sidebar:   #C8D4E8;
    --text-sidebar-active: #FFFFFF;

    --border-color:   #DDE1EC;
    --border-focus:   #2F6FED;

    --accent-blue:    #2F6FED;
    --accent-blue-light: #EBF1FD;
    --accent-green:   #0D9B6C;
    --accent-green-light: #E6F7F2;
    --accent-orange:  #E8830A;
    --accent-orange-light: #FEF3E2;
    --accent-red:     #E84040;
    --accent-red-light: #FEECEC;
    --accent-purple:  #7B5EA7;
    --accent-purple-light: #F2EEF9;

    --shadow-sm:  0 1px 3px rgba(26,31,54,0.08);
    --shadow-md:  0 4px 12px rgba(26,31,54,0.10);
    --shadow-lg:  0 8px 24px rgba(26,31,54,0.12);

    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  16px;

    --sidebar-width: 240px;
    --header-height: 60px;
    --transition: 200ms cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
    --bg-base:      #0F1520;
    --bg-surface:   #1A2235;
    --bg-elevated:  #222D42;
    --bg-sidebar:   #111827;
    --bg-sidebar-hover: #1F2D42;

    --text-primary:   #E8ECF4;
    --text-secondary: #8A96B0;
    --text-muted:     #4A5568;

    --border-color:   #2D3A52;
    --accent-blue-light: #1E3562;
    --accent-green-light: #0D3628;
    --accent-orange-light: #3D2808;
    --accent-red-light: #3D1010;
    --accent-purple-light: #2D2040;
}

/* ─── AppBar عنوان/breadcrumb — بریده‌شدن با ... به‌جای سرریز افقی
   روی صفحات باریک؛ min-width:0 روی خودِ MudStack والد در OALayout.razor
   تنظیم شده تا این کوچک‌شدن داخل فلکس‌باکس اصلاً امکان‌پذیر باشد ────── */
.oa-appbar-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 55vw;
}

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    direction: rtl;
    font-family: var(--font-fa);
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.7;
    transition: background var(--transition), color var(--transition);
}

/* ─── Layout ────────────────────────────────────────────────── */
.oa-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────── */
.oa-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: width var(--transition);
    overflow: hidden;
}

.oa-sidebar-logo {
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.oa-sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-blue);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.oa-sidebar-logo-text {
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
}

.oa-sidebar-logo-text span {
    display: block;
    font-weight: 400;
    font-size: 11px;
    color: var(--text-sidebar);
    margin-top: 1px;
}

.oa-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.oa-sidebar-section {
    margin-bottom: 20px;
}

.oa-sidebar-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 10px;
    margin-bottom: 4px;
}

.oa-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-sidebar);
    font-size: 13px;
    transition: background var(--transition), color var(--transition);
    text-decoration: none;
    margin-bottom: 2px;
    border: none;
    background: none;
    width: 100%;
    text-align: right;
}

.oa-nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: #FFFFFF;
}

.oa-nav-item.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    font-weight: 600;
}

.oa-nav-item .nav-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.oa-nav-badge {
    margin-right: auto;
    background: var(--accent-red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ─── Main Content ──────────────────────────────────────────── */
.oa-main {
    margin-right: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ─── Header ────────────────────────────────────────────────── */
.oa-header {
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.oa-header-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.oa-header-breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.oa-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.oa-theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all var(--transition);
    color: var(--text-secondary);
}

.oa-theme-toggle:hover {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

/* ─── Page Content ──────────────────────────────────────────── */
.oa-content {
    flex: 1;
    padding: 24px;
}

/* ─── Dashboard Stats ───────────────────────────────────────── */
.oa-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.oa-stat-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: box-shadow var(--transition), transform var(--transition);
}

.oa-stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.oa-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.oa-stat-icon.blue   { background: var(--accent-blue-light);   color: var(--accent-blue); }
.oa-stat-icon.green  { background: var(--accent-green-light);  color: var(--accent-green); }
.oa-stat-icon.orange { background: var(--accent-orange-light); color: var(--accent-orange); }
.oa-stat-icon.purple { background: var(--accent-purple-light); color: var(--accent-purple); }
.oa-stat-icon.red    { background: var(--accent-red-light);    color: var(--accent-red); }

.oa-stat-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.oa-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ─── Cards ─────────────────────────────────────────────────── */
.oa-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.oa-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.oa-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.oa-card-body {
    padding: 20px;
}

/* ─── Table ─────────────────────────────────────────────────── */
.oa-table-wrap {
    overflow-x: auto;
}

.oa-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.oa-table th {
    background: var(--bg-elevated);
    padding: 10px 14px;
    text-align: right;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.oa-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-primary);
}

.oa-table tr:last-child td { border-bottom: none; }

.oa-table tr:hover td {
    background: var(--bg-elevated);
}

/* ─── Form ──────────────────────────────────────────────────── */
.oa-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.oa-form-full { grid-column: 1 / -1; }

.oa-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.oa-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.oa-label .required { color: var(--accent-red); margin-right: 2px; }

.oa-input, .oa-select, .oa-textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-fa);
    font-size: 13px;
    direction: rtl;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.oa-input:focus, .oa-select:focus, .oa-textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(47,111,237,0.15);
    background: var(--bg-surface);
}

.oa-textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.8;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.oa-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-fa);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}

.oa-btn-primary   { background: var(--accent-blue);  color: #fff; }
.oa-btn-primary:hover { background: #2460C9; box-shadow: 0 4px 12px rgba(47,111,237,0.35); }

.oa-btn-success   { background: var(--accent-green); color: #fff; }
.oa-btn-success:hover { background: #0A7A56; }

.oa-btn-danger    { background: var(--accent-red);   color: #fff; }
.oa-btn-danger:hover { background: #C43030; }

.oa-btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.oa-btn-outline:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: var(--accent-blue-light);
}

.oa-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
    padding: 6px 10px;
}
.oa-btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.oa-btn-sm { padding: 6px 12px; font-size: 12px; }
.oa-btn-lg { padding: 12px 24px; font-size: 15px; }

/* ─── Badges ────────────────────────────────────────────────── */
.oa-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}
.oa-badge-draft    { background: var(--bg-elevated);       color: var(--text-secondary); }
.oa-badge-pending  { background: var(--accent-orange-light); color: var(--accent-orange); }
.oa-badge-approved { background: var(--accent-green-light);  color: var(--accent-green); }
.oa-badge-rejected { background: var(--accent-red-light);    color: var(--accent-red); }
.oa-badge-archived { background: var(--accent-purple-light); color: var(--accent-purple); }

.oa-badge-urgent   { background: var(--accent-red-light);    color: var(--accent-red); }
.oa-badge-normal   { background: var(--bg-elevated);          color: var(--text-secondary); }
.oa-badge-instant  { background: #FEE2E2; color: #B91C1C; }

/* ─── Modal ─────────────────────────────────────────────────── */
.oa-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 150ms ease;
}

.oa-modal {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 200ms ease;
}

.oa-modal-lg { max-width: 900px; }

.oa-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.oa-modal-title {
    font-size: 16px;
    font-weight: 700;
}

.oa-modal-body { padding: 24px; }

.oa-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ─── Toolbar ───────────────────────────────────────────────── */
.oa-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.oa-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    flex: 1;
    max-width: 320px;
}

.oa-search-box input {
    border: none;
    background: none;
    outline: none;
    font-family: var(--font-fa);
    font-size: 13px;
    color: var(--text-primary);
    flex: 1;
    direction: rtl;
}

.oa-search-icon { color: var(--text-muted); font-size: 15px; }

/* ─── Divider & Section ─────────────────────────────────────── */
.oa-section-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
}

.oa-section-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-blue);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent-blue-light);
    display: inline-block;
}

/* ─── Tabs ──────────────────────────────────────────────────── */
.oa-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-elevated);
    padding: 4px;
    border-radius: var(--radius-sm);
    width: fit-content;
    margin-bottom: 20px;
}

.oa-tab {
    padding: 7px 18px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    background: none;
    border: none;
    font-family: var(--font-fa);
    transition: all var(--transition);
}

.oa-tab.active {
    background: var(--bg-surface);
    color: var(--accent-blue);
    box-shadow: var(--shadow-sm);
}

/* ─── Empty State ───────────────────────────────────────────── */
.oa-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.oa-empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.oa-empty-text { font-size: 14px; }

/* ─── Alerts ────────────────────────────────────────────────── */
.oa-alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    border: 1px solid;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.oa-alert-info    { background: var(--accent-blue-light);   border-color: var(--accent-blue);   color: var(--accent-blue); }
.oa-alert-success { background: var(--accent-green-light);  border-color: var(--accent-green);  color: var(--accent-green); }
.oa-alert-warning { background: var(--accent-orange-light); border-color: var(--accent-orange); color: var(--accent-orange); }
.oa-alert-danger  { background: var(--accent-red-light);    border-color: var(--accent-red);    color: var(--accent-red); }

/* ─── Workflow Timeline ─────────────────────────────────────── */
.oa-timeline { list-style: none; position: relative; padding-right: 20px; }
.oa-timeline::before {
    content: '';
    position: absolute;
    right: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}
.oa-timeline-item {
    position: relative;
    padding-bottom: 20px;
    padding-right: 28px;
}
.oa-timeline-item::before {
    content: '';
    position: absolute;
    right: 0;
    top: 5px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-blue);
    border: 2px solid var(--bg-surface);
    box-shadow: 0 0 0 2px var(--accent-blue);
}
.oa-timeline-date { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.oa-timeline-action { font-weight: 600; font-size: 13px; }
.oa-timeline-comment { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ─── Clause Editor ─────────────────────────────────────────── */
.oa-clause-item {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
}
.oa-clause-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.oa-clause-number {
    width: 28px;
    height: 28px;
    background: var(--accent-blue);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   PRINT STYLES — A4 RTL
   ═══════════════════════════════════════════════════════════════ */
@media print {
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

    /* Hide UI */
    .oa-sidebar, .oa-header, .oa-toolbar, .oa-modal-footer,
    .no-print, .oa-btn, button:not(.print-only) { display: none !important; }

    body, .oa-main, .oa-content {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        color: black !important;
    }

    .print-container {
        display: block !important;
        width: 210mm;
        min-height: 297mm;
        margin: 0 auto;
        padding: 20mm 25mm;
        background: white;
        direction: rtl;
        font-family: var(--font-fa);
        font-size: 12pt;
        line-height: 1.8;
        color: #000;
    }

    /* سربرگ */
    .print-header {
        display: grid !important;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        border-bottom: 2.5pt solid #1A1A2E;
        padding-bottom: 14pt;
        margin-bottom: 18pt;
    }

    .print-header-logo {
        text-align: right;
    }

    .print-header-logo img {
        height: 60pt;
        max-width: 120pt;
        object-fit: contain;
    }

    .print-header-org {
        text-align: center;
        padding: 0 12pt;
    }

    .print-header-org-name {
        font-size: 14pt;
        font-weight: 900;
        letter-spacing: -0.5pt;
        margin-bottom: 2pt;
    }

    .print-header-org-sub {
        font-size: 9pt;
        color: #555;
    }

    .print-header-meta {
        text-align: left;
        font-size: 9pt;
        color: #333;
        line-height: 1.9;
    }

    /* اطلاعات نامه */
    .print-letter-meta {
        background: #F5F5F5;
        border: 1pt solid #DDD;
        border-radius: 4pt;
        padding: 10pt 14pt;
        margin-bottom: 16pt;
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 6pt 20pt;
        font-size: 10pt;
    }

    .print-letter-meta-item {
        display: flex;
        gap: 6pt;
    }

    .print-letter-meta-label {
        font-weight: 700;
        color: #333;
        white-space: nowrap;
    }

    /* موضوع */
    .print-subject {
        font-size: 13pt;
        font-weight: 900;
        text-align: center;
        margin: 14pt 0;
        padding: 8pt;
        border-bottom: 1pt solid #CCC;
        border-top: 1pt solid #CCC;
    }

    /* گیرنده/فرستنده */
    .print-addressee {
        margin-bottom: 14pt;
        font-size: 11pt;
    }

    .print-salutation { margin-bottom: 10pt; font-size: 11pt; }

    /* متن */
    .print-body {
        font-size: 12pt;
        line-height: 2;
        text-align: justify;
        margin-bottom: 20pt;
    }

    /* پیوست‌ها */
    .print-enclosures {
        border-top: 1pt solid #CCC;
        padding-top: 8pt;
        margin-top: 10pt;
        font-size: 10pt;
    }

    /* رونوشت */
    .print-cc {
        margin-top: 8pt;
        font-size: 10pt;
        color: #444;
    }

    /* امضا */
    .print-signature-area {
        margin-top: 30pt;
        display: flex !important;
        justify-content: flex-start;
        gap: 40pt;
    }

    .print-signature-box {
        text-align: center;
        min-width: 110pt;
    }

    .print-signature-line {
        border-top: 1pt solid #000;
        width: 100%;
        margin-bottom: 6pt;
    }

    .print-signature-name { font-weight: 700; font-size: 11pt; }
    .print-signature-pos  { font-size: 9pt; color: #555; }

    /* footer */
    .print-footer {
        position: fixed;
        bottom: 10mm;
        left: 25mm;
        right: 25mm;
        border-top: 0.5pt solid #CCC;
        padding-top: 4pt;
        display: flex !important;
        justify-content: space-between;
        font-size: 8pt;
        color: #888;
    }

    /* صفحه‌بندی */
    @page {
        size: A4 portrait;
        margin: 0;
    }

    .print-page-break { page-break-before: always; }

    /* قرارداد */
    .print-clause {
        margin-bottom: 12pt;
    }

    .print-clause-title {
        font-weight: 700;
        font-size: 11pt;
        margin-bottom: 4pt;
    }

    .print-clause-body {
        font-size: 11pt;
        line-height: 2;
        text-align: justify;
    }

    .print-parties-table {
        width: 100%;
        border-collapse: collapse;
        margin: 16pt 0;
        font-size: 10pt;
    }

    .print-parties-table th,
    .print-parties-table td {
        border: 1pt solid #CCC;
        padding: 6pt 10pt;
        text-align: right;
    }

    .print-parties-table th { background: #EFEFEF; font-weight: 700; }

    /* درخواست پرسنلی */
    .print-hr-box {
        border: 1.5pt solid #333;
        border-radius: 4pt;
        overflow: hidden;
        margin-bottom: 12pt;
    }

    .print-hr-box-header {
        background: #333;
        color: white;
        padding: 6pt 12pt;
        font-weight: 700;
        font-size: 11pt;
    }

    .print-hr-box-body {
        padding: 10pt 12pt;
    }

    .print-hr-fields {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8pt;
        font-size: 10pt;
    }

    .print-hr-field {
        display: flex;
        gap: 6pt;
        border-bottom: 0.5pt dotted #CCC;
        padding-bottom: 4pt;
    }
}

/* ─── Animations ────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; }           to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; }
                     to   { transform: translateY(0);    opacity: 1; } }

/* ─── Utility ───────────────────────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-small    { font-size: 12px; }
.text-center   { text-align: center; }
.d-flex        { display: flex; }
.gap-2         { gap: 8px; }
.gap-3         { gap: 12px; }
.mt-3          { margin-top: 12px; }
.mb-3          { margin-bottom: 12px; }
.flex-wrap     { flex-wrap: wrap; }
.align-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full        { width: 100%; }
.print-only    { display: none; }

/* ═══════════════════════════════════════════════════════════════
   PERSIAN RICH TEXT EDITOR — oa-rte
   ═══════════════════════════════════════════════════════════════ */

.oa-rte-wrap {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-surface);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.oa-rte-wrap:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(47,111,237,0.15);
}

/* ── Toolbar ──────────────────────────────────────── */
.oa-rte-toolbar {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
    padding: 6px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
    user-select: none;
}

.oa-rte-group {
    display: flex;
    align-items: center;
    gap: 1px;
    padding: 0 4px;
    position: relative;
}

.oa-rte-group + .oa-rte-group::before {
    content: '';
    position: absolute;
    right: -1px;
    top: 20%;
    height: 60%;
    width: 1px;
    background: var(--border-color);
}

.oa-rte-btn {
    width: 30px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 5px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: var(--font-fa);
    transition: all 120ms ease;
    flex-shrink: 0;
    position: relative;
}

.oa-rte-btn:hover {
    background: var(--bg-surface);
    color: var(--accent-blue);
    box-shadow: var(--shadow-sm);
}

.oa-rte-btn.active {
    background: var(--accent-blue);
    color: #fff;
}

.oa-rte-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -28px;
    right: 50%;
    transform: translateX(50%);
    background: #1A1F36;
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 999;
    pointer-events: none;
}

.oa-rte-select {
    height: 28px;
    padding: 0 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-primary);
    font-family: var(--font-fa);
    font-size: 12px;
    cursor: pointer;
    outline: none;
    direction: rtl;
    max-width: 120px;
}

.oa-rte-select:focus {
    border-color: var(--border-focus);
}

.oa-rte-color-input {
    width: 28px;
    height: 28px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    background: var(--bg-surface);
}

/* ── Second Row ─────────────────────────────────── */
.oa-rte-toolbar-row2 {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
    padding: 4px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
}

/* ── Content Area ───────────────────────────────── */
.oa-rte-content {
    flex: 1;
    min-height: 280px;
    padding: 20px 24px;
    outline: none;
    font-family: var(--font-fa);
    font-size: 13pt;
    line-height: 2;
    color: var(--text-primary);
    background: var(--bg-surface);
    direction: rtl;
    text-align: right;
    overflow-y: auto;
    resize: vertical;
}

.oa-rte-content:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
}

/* ── Content Styles ─────────────────────────────── */
.oa-rte-content h1 { font-size: 22pt; font-weight: 900; margin: 12px 0 8px; }
.oa-rte-content h2 { font-size: 18pt; font-weight: 800; margin: 10px 0 6px; }
.oa-rte-content h3 { font-size: 15pt; font-weight: 700; margin: 8px 0 4px; }
.oa-rte-content h4 { font-size: 13pt; font-weight: 700; margin: 6px 0 3px; }

.oa-rte-content p  { margin: 6px 0; }

.oa-rte-content blockquote {
    border-right: 4px solid var(--accent-blue);
    margin: 10px 0;
    padding: 8px 16px;
    background: var(--accent-blue-light);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.oa-rte-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 12pt;
}

.oa-rte-content table td,
.oa-rte-content table th {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    min-width: 60px;
    vertical-align: top;
}

.oa-rte-content table th {
    background: var(--bg-elevated);
    font-weight: 700;
}

.oa-rte-content table td:focus,
.oa-rte-content table th:focus {
    outline: 2px solid var(--accent-blue);
    outline-offset: -2px;
}

.oa-rte-content ul, .oa-rte-content ol {
    padding-right: 24px;
    margin: 6px 0;
}

.oa-rte-content li { margin: 3px 0; }

.oa-rte-content a {
    color: var(--accent-blue);
    text-decoration: underline;
}

.oa-rte-content hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 16px 0;
}

.oa-rte-content .oa-stamp {
    display: inline-block;
    border: 2px solid var(--accent-blue);
    color: var(--accent-blue);
    padding: 4px 16px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 11pt;
    transform: rotate(-10deg);
    opacity: 0.7;
    margin: 8px;
}

/* ── Status Bar ─────────────────────────────────── */
.oa-rte-statusbar {
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-color);
    padding: 4px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    gap: 16px;
    flex-wrap: wrap;
}

.oa-rte-wordcount { color: var(--accent-blue); font-weight: 600; }

/* ── Table Popover ──────────────────────────────── */
.oa-rte-table-picker {
    position: absolute;
    top: 36px;
    right: 0;
    z-index: 500;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
    box-shadow: var(--shadow-lg);
    display: none;
}

.oa-rte-table-picker.open { display: block; }

.oa-rte-table-grid {
    display: grid;
    grid-template-columns: repeat(8, 20px);
    gap: 3px;
    margin-bottom: 8px;
}

.oa-rte-table-cell {
    width: 20px;
    height: 20px;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    cursor: pointer;
    background: var(--bg-base);
    transition: background 80ms;
}

.oa-rte-table-cell.hover {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.oa-rte-table-label {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* ── Link Dialog ────────────────────────────────── */
.oa-rte-dialog {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.oa-rte-dialog-box {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 20px;
    width: 340px;
    box-shadow: var(--shadow-lg);
    direction: rtl;
}

.oa-rte-dialog-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 14px;
}

/* ── Print ──────────────────────────────────────── */
@media print {
    .oa-rte-toolbar,
    .oa-rte-toolbar-row2,
    .oa-rte-statusbar { display: none !important; }

    .oa-rte-content {
        border: none !important;
        padding: 0 !important;
        min-height: unset !important;
        font-size: 12pt;
        line-height: 2;
    }

    .oa-rte-wrap { border: none !important; box-shadow: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   LETTER PAGE DESIGNER — lpd
   ═══════════════════════════════════════════════════════════════ */

.lpd-drag-handle {
    transition: outline-color 120ms;
}

.lpd-drag-handle:hover {
    outline-color: #1A5DD6 !important;
    background: rgba(47,111,237,0.08) !important;
}

.lpd-drag-handle.dragging {
    outline-color: #E84040 !important;
    background: rgba(232,64,64,0.08) !important;
    cursor: grabbing;
}

/* ── Print: صفحه‌بندی دقیق ──────────────────────────────── */
@media print {
    #letter-page-preview {
        width: 100% !important;
        height: auto !important;
        padding: 0 !important;
        box-shadow: none !important;
        transform: none !important;
    }

    .lpd-drag-handle { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   VISUAL PAGE DESIGNER — lpd
   ═══════════════════════════════════════════════════════════════ */

/* ── Block on canvas ──────────────────────────────────────── */
.lpd-block {
    user-select: none;
    transition: outline 80ms;
}

.lpd-block:hover {
    outline: 1.5px dashed #2F6FED;
}

.lpd-selected {
    outline: 2px solid #2F6FED !important;
    outline-offset: 1px;
}

/* ── Resize Handle ────────────────────────────────────────── */
.lpd-resize-handle {
    position: absolute;
    bottom: -4px;
    left: -4px;
    width: 10px;
    height: 10px;
    background: #2F6FED;
    border: 2px solid #fff;
    border-radius: 2px;
    cursor: sw-resize;
    z-index: 999;
}

/* ── Alignment Guides ─────────────────────────────────────── */
.lpd-guide-h {
    position: absolute;
    left: 0; right: 0;
    height: 1px;
    background: #FF3B30;
    pointer-events: none;
    z-index: 9999;
}
.lpd-guide-v {
    position: absolute;
    top: 0; bottom: 0;
    width: 1px;
    background: #FF3B30;
    pointer-events: none;
    z-index: 9999;
}

/* ── Grid overlay ─────────────────────────────────────────── */
.lpd-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(to left,  rgba(47,111,237,0.08) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(47,111,237,0.08) 1px, transparent 1px);
}

/* ── Ruler ────────────────────────────────────────────────── */
.lpd-ruler-h {
    height: 20px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    margin-bottom: 0;
    font-size: 9px;
    color: var(--text-muted);
}
.lpd-ruler-v {
    width: 20px;
    background: var(--bg-elevated);
    border-left: 1px solid var(--border-color);
    position: relative;
    writing-mode: vertical-rl;
    font-size: 9px;
    color: var(--text-muted);
}

/* ── Toolbar ──────────────────────────────────────────────── */
.lpd-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    margin-bottom: 10px;
}

.lpd-sep {
    width: 1px;
    height: 22px;
    background: var(--border-color);
    margin: 0 2px;
    flex-shrink: 0;
}

.lpd-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-family: var(--font-fa);
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    transition: all 120ms;
    white-space: nowrap;
}
.lpd-tool-btn:hover {
    background: var(--accent-blue-light);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}
.lpd-tool-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
}
.lpd-tool-btn.danger:hover {
    background: var(--accent-red-light);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

/* ── Props Panel ──────────────────────────────────────────── */
.lpd-props {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    font-size: 12px;
}

.lpd-props-header {
    padding: 10px 12px;
    font-weight: 700;
    font-size: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--accent-blue);
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 1;
}

.lpd-props-section {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.lpd-props-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.lpd-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 6px;
}

.lpd-field-row.full { grid-template-columns: 1fr; }

.lpd-mini-label {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.lpd-mini-input {
    width: 100%;
    padding: 3px 6px;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-fa);
    font-size: 11px;
    direction: rtl;
    outline: none;
}
.lpd-mini-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(47,111,237,0.12);
}

.lpd-mini-select {
    width: 100%;
    padding: 3px 6px;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-fa);
    font-size: 11px;
    direction: rtl;
    outline: none;
    cursor: pointer;
}

.lpd-color-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.lpd-color-input {
    width: 32px;
    height: 24px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px;
    cursor: pointer;
    background: var(--bg-surface);
}

/* ── Layer panel ──────────────────────────────────────────── */
.lpd-layer-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    margin-bottom: 1px;
    transition: background 100ms;
}
.lpd-layer-item:hover { background: var(--bg-elevated); }
.lpd-layer-item.active { background: var(--accent-blue-light); color: var(--accent-blue); }

/* ── Status bar ───────────────────────────────────────────── */
.lpd-statusbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 4px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Canvas wrap ──────────────────────────────────────────── */
.lpd-canvas-wrap {
    flex: 1;
    background: #52525B;
    padding: 20px;
    border-radius: var(--radius-md);
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 500px;
}

/* ── Snap indicator ───────────────────────────────────────── */
.lpd-snap-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #FF3B30;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
}

/* ═══════════════════════════════════════════════════════════════
   LETTER SELECTOR — کارت‌های انتخاب مدل نامه
   ═══════════════════════════════════════════════════════════════ */

.letter-model-card {
    user-select: none;
}

.letter-model-card:hover {
    border-color: var(--accent-blue) !important;
    box-shadow: 0 8px 28px rgba(47,111,237,0.16) !important;
    transform: translateY(-4px) !important;
}

.letter-model-card:active {
    transform: translateY(-1px) !important;
    box-shadow: 0 3px 10px rgba(47,111,237,0.12) !important;
}

/* ── انیمیشن ورود کارت‌ها ───────────────────────────────────── */
@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.letter-model-card {
    animation: cardFadeIn 250ms ease forwards;
}

.letter-model-card:nth-child(1)  { animation-delay:  0ms; }
.letter-model-card:nth-child(2)  { animation-delay: 40ms; }
.letter-model-card:nth-child(3)  { animation-delay: 80ms; }
.letter-model-card:nth-child(4)  { animation-delay:120ms; }
.letter-model-card:nth-child(5)  { animation-delay:160ms; }
.letter-model-card:nth-child(6)  { animation-delay:200ms; }
.letter-model-card:nth-child(7)  { animation-delay:240ms; }
.letter-model-card:nth-child(8)  { animation-delay:280ms; }
.letter-model-card:nth-child(9)  { animation-delay:320ms; }
.letter-model-card:nth-child(10) { animation-delay:360ms; }
.letter-model-card:nth-child(11) { animation-delay:400ms; }
.letter-model-card:nth-child(12) { animation-delay:440ms; }

/* ── باکس مدل انتخاب‌شده (بالای فرم) ──────────────────────── */
.selected-model-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    animation: cardFadeIn 200ms ease;
}

/* ── دکمه‌های لیست پایین صفحه ──────────────────────────────── */
.letter-list-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* ═══════════════════════════════════════════════════════════════
   دکمه‌های danger و success
   ═══════════════════════════════════════════════════════════════ */
.oa-btn-danger {
    background: var(--accent-red);
    color: #fff;
    border-color: var(--accent-red);
}
.oa-btn-danger:hover {
    background: #c0392b;
    border-color: #c0392b;
}

.oa-btn-success {
    background: var(--accent-green);
    color: #fff;
    border-color: var(--accent-green);
}
.oa-btn-success:hover {
    background: #0a7a55;
    border-color: #0a7a55;
}

/* ── کلاس‌های layout اضافی ─────────────────────────────────── */
.oa-modal-lg {
    max-width: 860px;
    width: 96vw;
}

.oa-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 16px;
}

.oa-tab {
    padding: 8px 18px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-fa);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 150ms;
}

.oa-tab:hover {
    color: var(--text-primary);
}

.oa-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

/* ── بند قرارداد ───────────────────────────────────────────── */
.oa-clause-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 10px;
    background: var(--bg-elevated);
}

.oa-clause-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.oa-clause-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   CHAT — چت داخلی
   ═══════════════════════════════════════════════════════════════ */

.chat-layout {
    display: flex;
    height: calc(100vh - 120px);
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-surface);
}

/* ── Sidebar کانال‌ها ────────────────────────────────────────── */
.chat-sidebar {
    width: 280px;
    flex-shrink: 0;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
}

.chat-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-fa);
}

.chat-channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.chat-channel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 150ms;
    border-radius: 0;
}

.chat-channel-item:hover { background: var(--bg-surface); }
.chat-channel-item.active {
    background: var(--accent-blue-light);
    border-right: 3px solid var(--accent-blue);
}

.chat-channel-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--accent-blue-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

/* ── ناحیه اصلی ──────────────────────────────────────────────── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-base);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
    flex-shrink: 0;
}

/* ── پیام‌ها ─────────────────────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.chat-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 80%;
}

.chat-msg-row.mine   { align-self: flex-end;  flex-direction: row-reverse; }
.chat-msg-row.theirs { align-self: flex-start; }

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    max-width: 100%;
    word-break: break-word;
    font-family: var(--font-fa);
    font-size: 13px;
    line-height: 1.6;
}

.bubble-mine {
    background: #6C93E3;
    color: #ffffff;
    border-bottom-left-radius: 4px;
}

.bubble-theirs {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-right-radius: 4px;
}

/* ── نوار ارسال ─────────────────────────────────────────────── */
.chat-input-bar {
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
    flex-shrink: 0;
}

.chat-textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    font-family: var(--font-fa);
    font-size: 13px;
    background: var(--bg-base);
    color: var(--text-primary);
    direction: rtl;
    outline: none;
    min-height: 40px;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.5;
    transition: border-color 150ms;
}

.chat-textarea:focus { border-color: var(--border-focus); }

.chat-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-base);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 150ms;
    flex-shrink: 0;
}

.chat-icon-btn:hover {
    background: var(--accent-blue-light);
    border-color: var(--accent-blue);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: var(--accent-blue);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 150ms;
}

.chat-send-btn:hover:not(:disabled) { background: #1d4fc4; }
.chat-send-btn:disabled { opacity: 0.5; cursor: default; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

/* ═══════════════════════════════════════════════════════════════
   واکنش‌گرایی موبایل — چت داخلی
   قبل از این، .chat-sidebar عرض ثابت ۲۸۰px با flex-shrink:0 داشت،
   یعنی روی صفحهٔ ۳۷۵px تقریباً هیچ جایی برای ناحیهٔ پیام‌ها نمی‌ماند.
   زیر این breakpoint، چیدمان به‌جای کنار-هم به روی-هم تبدیل می‌شود:
   فهرست کانال‌ها بالا (با ارتفاع محدود و اسکرول)، پیام‌ها پایین.
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
    .chat-layout {
        flex-direction: column;
    }

    .chat-sidebar {
        width: 100%;
        flex-basis: 38%;
        border-left: none;
        border-bottom: 1px solid var(--border-color);
    }

    .chat-main {
        min-height: 0;
    }

    .chat-msg-row {
        max-width: 92%;
    }
}
