/* مکاتبات اداری — کشوی ناوبری (چسبیدن پوشه‌های کاری به هدر) */
.mud-drawer.correspondence-nav-drawer {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
}

.mud-drawer.correspondence-nav-drawer > .mud-drawer-content {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    padding: 0 !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    overflow: hidden !important;
}

.correspondence-page-container > .mud-drawer.correspondence-nav-drawer {
    align-self: flex-start !important;
    height: 100% !important;
}

.correspondence-nav-drawer-inner {
    justify-content: flex-start !important;
}

.correspondence-nav-top,
.correspondence-nav-work,
.correspondence-drawer-head {
    margin-top: 0 !important;
}

.correspondence-nav-work .mud-button-root {
    margin-bottom: 2px;
}

/* مکاتبات اداری — ظاهر صندوق پستی (الگوی MudBlazor Mailbox Dropzone) */

.corr-mailbox-root {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 0;
}

.corr-mailbox-root > .mud-drop-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.corr-mailbox-shell {
    flex: 1;
    min-height: 0;
    border-radius: 12px;
    overflow: hidden;
    direction: rtl;
    align-items: stretch;
}

.corr-mailbox-shell--no-rail .corr-mailbox-list-panel {
    width: 100%;
}

.corr-mailbox-folders {
    flex: 0 0 min(280px, 34vw);
    max-width: 300px;
    padding: 0 !important;
    background: linear-gradient(180deg, rgba(21, 101, 192, 0.06), rgba(255, 255, 255, 0.98));
    border-left: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-content: flex-start;
}

.corr-mailbox-folders-head,
.corr-mailbox-folders .mud-list-subheader {
    padding: 6px 12px 4px !important;
    margin: 0 !important;
    min-height: unset !important;
    line-height: 1.35;
    font-weight: 800;
    text-align: right;
}

.corr-mailbox-folders .corr-folder-drop-hit {
    flex: 0 0 auto !important;
    min-height: unset !important;
    height: auto !important;
}

.corr-mailbox-folders .corr-folder-drop-hit.mud-drop-zone {
    flex-grow: 0 !important;
}

.corr-mailbox-folders .mud-list-item {
    min-height: 40px;
    padding-top: 2px;
    padding-bottom: 2px;
}

.corr-mailbox-list-panel {
    min-width: 0;
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--mud-palette-surface);
}

.corr-mailbox-drop-container {
    min-height: 0;
    flex: 1;
}

.corr-mailbox-drop-container > .mud-drop-container {
    align-content: flex-start !important;
    justify-content: flex-start !important;
}

.corr-mailbox-action-strip {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient(180deg, rgba(25, 118, 210, 0.06), transparent);
    padding: 6px 8px;
    flex-shrink: 0;
}

.corr-mailbox-toolbar {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: var(--mud-palette-background-gray);
    flex-shrink: 0;
}

.corr-mailbox-root > .mud-drop-container {
    align-items: stretch;
}

.corr-mail-list-zone {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    flex: 1 1 auto;
    height: 100%;
    max-height: 100%;
    padding: 4px 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start !important;
    align-content: flex-start !important;
    align-self: stretch;
}

.corr-mailbox-root .mud-drop-zone.corr-mail-list-zone {
    justify-content: flex-start !important;
    align-content: flex-start !important;
    align-items: stretch !important;
    min-height: 0 !important;
}

.corr-mailbox-root .mud-drop-zone.corr-mail-list-zone:empty {
    min-height: 120px;
}

.corr-bulk-move-selected {
    background: rgba(25, 118, 210, 0.12);
    border-radius: 8px;
}

.corr-bulk-move-folder-list {
    max-height: 320px;
    overflow-y: auto;
}

.corr-mailbox-root .mud-drop-zone.corr-mud-drop-valid {
    outline: 2px dashed rgba(46, 125, 50, 0.65);
    outline-offset: -2px;
    background: rgba(129, 199, 132, 0.12) !important;
}

.corr-mailbox-root .mud-drop-zone.corr-mud-drop-invalid {
    outline: 2px dashed rgba(211, 47, 47, 0.5);
    background: rgba(239, 83, 80, 0.08) !important;
}

.corr-mailbox-root .mud-drop-zone.corr-mud-drop-dragging {
    background: rgba(25, 118, 210, 0.06) !important;
}

.corr-mailbox-root .mud-dropitem-placeholder:not(.d-none) {
    min-height: 52px;
    margin: 4px 8px;
    border-radius: 10px !important;
    border: 2px dashed rgba(25, 118, 210, 0.55) !important;
    background: rgba(25, 118, 210, 0.08) !important;
}

.corr-mail-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.12s ease;
    text-align: right;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}

.corr-mail-envelope {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
}

.corr-mail-row--read .corr-mail-subject {
    font-weight: 500;
    color: var(--mud-palette-text-secondary);
}

.corr-mail-status-chip {
    height: auto;
    padding: 0 4px;
}

.corr-mail-row:hover {
    background: rgba(25, 118, 210, 0.06);
}

.corr-mail-row--unread {
    background: rgba(25, 118, 210, 0.04);
    font-weight: 600;
}

.corr-mail-row--unread .corr-mail-subject {
    font-weight: 700;
    color: #0d47a1;
}

.corr-mail-row-body {
    flex: 1;
    min-width: 0;
}

.corr-mail-subject {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.corr-mail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 2px;
}

.corr-folder-drop-hit {
    border-radius: 8px;
}

.corr-mailbox-root .corr-folder-drop-hit.mud-drop-zone-over {
    box-shadow: inset 0 0 0 2px rgba(25, 118, 210, 0.35);
}

.corr-mailbox-folders .mud-text.caption {
    padding: 0 12px 8px;
    margin-top: 0 !important;
}

/* نامه جدید — فرم نگارش */
.corr-compose-dialog-content {
    padding: 12px 16px !important;
    max-height: min(78dvh, 820px);
    min-width: min(920px, 94vw);
    overflow-y: auto;
    direction: rtl;
}

.corr-compose-dialog-actions {
    padding: 8px 16px 12px !important;
    direction: rtl;
}

.corr-compose-org-select-popover {
    z-index: 1700 !important;
    max-height: min(360px, 50dvh);
    overflow-y: auto;
}

.corr-compose-form .mud-input-control {
    text-align: right;
}

.corr-compose-meta-row {
    margin-bottom: 4px;
}

.corr-compose-meta-compact {
    gap: 8px 16px;
    margin-bottom: 6px;
}

.corr-compose-meta-compact .corr-meta-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.corr-compose-meta-compact .corr-meta-label {
    font-weight: 700;
    opacity: 0.85;
    min-width: 52px;
    text-align: right;
}

.corr-compose-meta-compact .corr-meta-btns .mud-icon-button-root {
    padding: 4px;
}

.corr-compose-meta-compact .corr-meta-card {
    border-radius: 12px;
    min-width: min(100%, 220px);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.corr-compose-meta-compact .corr-meta-selected.mud-icon-button-root {
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.45);
    transform: scale(1.06);
}

.corr-ai-topic,
mark.corr-ai-topic {
    background: linear-gradient(180deg, #fff9c4 0, #ffe082 100%);
    color: #4a3900;
    padding: 0 4px;
    border-radius: 3px;
}

.corr-ai-review-bar .mud-alert-message {
    width: 100%;
}

.corr-compose-compact-field .mud-input-label {
    font-size: 0.78rem;
}

.corr-compose-compact-field .mud-input-slot {
    font-size: 0.85rem;
    min-height: 34px;
}

.corr-rich-editor-frame {
    min-height: 300px;
    overflow: visible;
}

.corr-rich-editor-loading {
    min-height: 280px;
}

/* CKEditor 5 — متن نامه و قالب */
.corr-ckeditor-shell {
    overflow: visible;
}

.corr-ckeditor-host {
    width: 100%;
}

.corr-ckeditor-host--hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    padding: 0;
    margin: 0;
}

.corr-ckeditor-host--ready {
    display: block;
    position: relative;
}

.corr-ckeditor-host cke5-editor,
.corr-ckeditor-host .ck.ck-editor {
    width: 100%;
}

.corr-ckeditor-host .ck.ck-editor__main > .ck-editor__editable {
    min-height: 300px !important;
    max-height: min(58dvh, 640px);
    overflow-y: auto !important;
}

.corr-rich-editor--rtl .ck.ck-editor__editable {
    direction: rtl;
    text-align: right;
}

.corr-rich-editor--ltr .ck.ck-editor__editable {
    direction: ltr;
    text-align: left;
}

.corr-ckeditor-host .ck.ck-toolbar {
    position: relative;
    z-index: 1400;
    flex-wrap: wrap;
}

.corr-rich-editor--rtl .ck.ck-toolbar {
    direction: rtl;
}

.mud-dialog .corr-ckeditor-host .ck.ck-balloon-panel,
.mud-dialog .corr-ckeditor-host .ck.ck-dropdown__panel,
.mud-dialog .ck.ck-balloon-panel,
.mud-dialog .ck.ck-dropdown__panel {
    z-index: 1600 !important;
}

/* تولید متن AI داخل ادیتور */
.corr-ckeditor-shell--ai-busy .ck-editor__editable {
    outline: 2px solid rgba(156, 39, 176, 0.35);
    outline-offset: 1px;
}

.corr-ai-inline-status {
    margin-bottom: 4px;
}

.corr-ckeditor-host .corr-ai-topic,
.corr-ckeditor-host mark.corr-ai-topic {
    background: linear-gradient(180deg, #fff9c4 0%, #ffe082 100%);
    color: #4a3900;
    padding: 0 2px;
    border-radius: 3px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.corr-ckeditor-host .corr-ai-topic--loading,
.corr-ckeditor-host mark.corr-ai-topic.corr-ai-topic--loading {
    animation: corr-ai-topic-pulse 1.1s ease-in-out infinite alternate;
    box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.45);
}

@keyframes corr-ai-topic-pulse {
    from {
        background: linear-gradient(180deg, #fff9c4 0%, #ffe082 100%);
    }
    to {
        background: linear-gradient(180deg, #ffe082 0%, #ffca28 100%);
    }
}

.corr-ckeditor-host .corr-ai-draft {
    margin-top: 0.35em;
    color: var(--mud-palette-text-secondary);
}

.corr-ckeditor-host .corr-ai-draft--typing .corr-ai-draft__text {
    color: var(--mud-palette-primary);
}

.corr-ckeditor-host .corr-ai-draft__caret {
    display: inline-block;
    animation: corr-ai-caret 0.9s ease-in-out infinite alternate;
    color: var(--mud-palette-secondary);
    font-weight: 700;
    margin-inline-start: 2px;
}

.corr-ai-preview-paper {
    max-height: min(52dvh, 480px);
    overflow-y: auto;
    background: var(--mud-palette-background-gray);
}

.corr-ai-preview-html {
    line-height: 1.9;
    font-size: 0.95rem;
}

.corr-ai-type-caret {
    display: inline-block;
    animation: corr-ai-caret 0.9s ease-in-out infinite alternate;
    color: var(--mud-palette-secondary);
    font-weight: 700;
    vertical-align: -2px;
}

@keyframes corr-ai-caret {
    from { opacity: 0.25; }
    to { opacity: 0.95; }
}

.corr-rich-editor-simple textarea {
    min-height: 240px !important;
    font-family: Tahoma, Arial, sans-serif;
}

.corr-compose-file-upload {
    position: relative;
    display: block;
    width: 100%;
}

.corr-compose-dropzone-shell {
    min-height: 148px;
}

.corr-compose-dropzone {
    border: 2px dashed rgba(25, 118, 210, 0.45) !important;
    background: rgba(25, 118, 210, 0.04);
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.corr-compose-dropzone--active {
    border-color: rgba(25, 118, 210, 0.9) !important;
    background: rgba(25, 118, 210, 0.1);
    box-shadow: inset 0 0 0 1px rgba(25, 118, 210, 0.25);
}

.corr-rich-editor-frame {
    border-radius: 10px;
    direction: rtl;
}

.corr-letter-body-html {
    direction: rtl;
    text-align: right;
    line-height: 1.85;
    font-family: Tahoma, Vazirmatn, Arial, sans-serif;
}

.corr-letter-body-html img {
    max-width: 100%;
    height: auto;
}

.corr-letter-body-html table {
    width: 100%;
    border-collapse: collapse;
}

.corr-rich-editor--rtl {
    direction: rtl;
    text-align: right;
}

.corr-rich-editor--ltr {
    direction: ltr;
    text-align: left;
}

.corr-attach-preview-card {
    height: 100%;
}

.corr-attach-preview-img {
    width: 100%;
    background: rgba(0, 0, 0, 0.03);
}

.corr-template-editor-content {
    min-width: min(720px, 92vw);
    max-height: min(82dvh, 900px);
    overflow-y: auto;
    direction: rtl;
}

.corr-compose-body-editor,
.corr-template-body-editor {
    width: 100%;
}

.corr-compose-attach-list {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
}

/* ── Office-style shell ── */
.correspondence-office-shell {
    background: linear-gradient(180deg, #f3f6fb 0%, #eef2f8 48%, #f8fafc 100%);
    border: 1px solid rgba(0, 120, 212, 0.12);
}

.correspondence-office-shell .correspondence-nav-drawer {
    background: linear-gradient(180deg, #fafcff 0%, #f0f4fa 100%) !important;
    border-left: 1px solid rgba(0, 120, 212, 0.15) !important;
}

.correspondence-office-shell .correspondence-drawer-head {
    background: linear-gradient(135deg, rgba(0, 120, 212, 0.12), rgba(0, 120, 212, 0.03));
    border-bottom: 1px solid rgba(0, 120, 212, 0.14);
}

.correspondence-office-shell .correspondence-main-link.active,
.correspondence-office-shell .corr-user-folder-btn--active {
    background: linear-gradient(90deg, rgba(0, 120, 212, 0.16), rgba(0, 120, 212, 0.05));
    border: 1px solid rgba(0, 120, 212, 0.28);
    color: #004578;
}

.correspondence-nav-user-folders {
    max-height: min(42vh, 360px);
    overflow-y: auto;
    padding-bottom: 8px;
}

.corr-user-folder-tree {
    width: 100%;
}

.corr-user-folder-btn {
    justify-content: flex-start !important;
    min-height: 36px;
    border-radius: 8px;
    margin-bottom: 2px;
}

.corr-user-folder-drop-node.mud-drop-zone {
    min-height: unset !important;
}

.corr-mailbox-folder-drop-rail {
    border-bottom: 1px solid rgba(0, 120, 212, 0.12);
    background: linear-gradient(180deg, rgba(0, 120, 212, 0.05), transparent);
    max-height: 180px;
    overflow-y: auto;
    flex-shrink: 0;
}

.corr-mailbox-shell {
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

.corr-mailbox-list-panel {
    background: #fff;
}

.corr-mail-row {
    transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.corr-mail-row:hover {
    background: rgba(0, 120, 212, 0.04);
}

.corr-inbox-root-drop.mud-drop-zone {
    min-height: unset !important;
    padding: 2px 0;
}

.corr-folder-view-alert {
    text-align: right;
}

.mud-drop-zone.corr-mud-drop-valid.corr-user-folder-drop-node,
.mud-drop-zone.corr-mud-drop-valid.corr-inbox-root-drop {
    outline: 2px dashed rgba(0, 120, 212, 0.45);
    border-radius: 8px;
}

@media (max-width: 960px) {
    .corr-mailbox-shell {
        flex-direction: column !important;
    }

    .corr-mailbox-folders {
        flex: 0 0 auto;
        max-width: none;
        border-left: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }

    .correspondence-nav-user-folders {
        max-height: 220px;
    }
}
