/* «بایگانی» (ar) — builds on the mailbox styles (mb-*) for lists and the letter dialog. */

.ar-page { display: flex; flex-direction: column; gap: 16px; }
.ar-page svg, .ar-popover svg, .ar-editor svg { flex-shrink: 0; }
.ar-view { display: flex; flex-direction: column; gap: 22px; }

/* ---- header ---- */
.ar-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 18px; }
.ar-head-text { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ar-headline { margin: 0; font-size: 1.02rem; font-weight: 900; line-height: 1.8; color: var(--oa-ink); }

.ar-head-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: linear-gradient(135deg, #475569, #1e293b);
    color: #fff;
    box-shadow: 0 8px 20px -10px #1e293b;
    flex-shrink: 0;
}

.ar-head-icon svg { width: 21px; height: 21px; }
.ar-search-global { flex: 0 1 460px; }

.ar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    margin: 0;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--oa-line);
    background: var(--oa-surface);
    color: var(--oa-ink-faint);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ar-search:focus-within { border-color: var(--oa-brand); box-shadow: 0 0 0 3px var(--oa-brand-glow); }
.ar-search svg { width: 17px; height: 17px; }
.ar-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--oa-ink); font-family: inherit; font-size: 0.86rem; }

/* ---- sections ---- */
.ar-section { display: flex; flex-direction: column; gap: 12px; }
.ar-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.ar-section-head h3 { margin: 0; font-size: 0.92rem; font-weight: 900; color: var(--oa-ink); }
.ar-section-head small { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; color: var(--oa-ink-faint); }
.ar-section-head small svg { width: 14px; height: 14px; }
.ar-link { display: inline-flex; align-items: center; gap: 5px; padding: 4px 6px; border: 0; background: none; color: var(--oa-brand); font-family: inherit; font-size: 0.76rem; font-weight: 800; cursor: pointer; }
.ar-link svg { width: 14px; height: 14px; }
.ar-hint { margin: 0; font-size: 0.78rem; line-height: 1.9; color: var(--oa-ink-faint); }

/* ---- category cards ---- */
.ar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }

.ar-card {
    --c: var(--oa-brand);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 152px;
    padding: 16px;
    border-radius: 18px;
    border: 1px solid var(--oa-line);
    background:
        radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--c) 11%, transparent), transparent 58%),
        var(--oa-surface);
    color: var(--oa-ink);
    font-family: inherit;
    text-align: start;
    cursor: pointer;
    outline: 0;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.ar-card:hover, .ar-card:focus-visible { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 45%, var(--oa-line)); box-shadow: 0 14px 30px -18px color-mix(in srgb, var(--c) 70%, #000); }
.ar-card:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent); }
.ar-card.is-skeleton { cursor: default; gap: 12px; }
.ar-card.is-dragging { opacity: 0.45; transform: scale(0.98); }
.ar-card.is-drop { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 28%, transparent); }
.ar-card.is-folder { cursor: grab; }
.ar-card.is-folder:active { cursor: grabbing; }

.ar-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 4px; }

.ar-card-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: color-mix(in srgb, var(--c) 14%, transparent);
    color: var(--c);
    flex-shrink: 0;
}

.ar-card-icon svg { width: 21px; height: 21px; }
body.theme-dark .ar-card-icon, body.theme-dark .ar-target .ar-card-icon { background: color-mix(in srgb, var(--c) 24%, transparent); color: color-mix(in srgb, var(--c) 62%, #fff); }

.ar-card-menu {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--oa-ink-faint);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.ar-card-menu svg { width: 18px; height: 18px; }
.ar-card:hover .ar-card-menu, .ar-card:focus-within .ar-card-menu, .ar-card-menu:focus-visible { opacity: 1; }
.ar-card-menu:hover { background: var(--oa-surface-muted); color: var(--oa-ink); }
.ar-card-name { font-size: 0.98rem; font-weight: 900; line-height: 1.6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-card-desc { margin: 0; font-size: 0.76rem; line-height: 1.8; color: var(--oa-ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-card-meta { display: flex; align-items: baseline; gap: 5px; margin-top: auto; font-size: 0.74rem; color: var(--oa-ink-faint); white-space: nowrap; overflow: hidden; }
.ar-card-meta b { font-size: 1.1rem; font-weight: 900; color: var(--oa-ink); }
.ar-card-meta i { align-self: center; width: 1px; height: 11px; margin: 0 3px; background: currentColor; opacity: 0.35; }

.ar-card-new {
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 2px dashed var(--oa-line);
    background: transparent;
    color: var(--oa-ink-faint);
    text-align: center;
}

.ar-card-new:hover, .ar-card-new:focus-visible { --c: var(--oa-brand); border-color: var(--oa-brand); background: color-mix(in srgb, var(--oa-brand) 4%, transparent); color: var(--oa-brand); }
.ar-card-new strong { font-size: 0.92rem; font-weight: 900; }
.ar-card-new small { font-size: 0.72rem; }
.ar-card-plus { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--oa-surface-muted); transition: background-color 0.15s ease, color 0.15s ease; }
.ar-card-plus svg { width: 22px; height: 22px; }
.ar-card-new:hover .ar-card-plus { background: var(--oa-brand); color: #fff; }

/* ---- tags ---- */
.ar-tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }

.ar-tag-chip {
    --t: var(--oa-ink-faint);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    border-radius: 99px;
    border: 1px solid color-mix(in srgb, var(--t) 30%, var(--oa-line));
    background: color-mix(in srgb, var(--t) 8%, var(--oa-surface));
    color: var(--oa-ink);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button.ar-tag-chip:hover { border-color: var(--t); }
.ar-tag-chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--t); flex-shrink: 0; }
.ar-tag-chip b { font-size: 0.7rem; font-weight: 800; color: var(--oa-ink-faint); }
.ar-tag-chip svg { width: 14px; height: 14px; }
.ar-tag-chip.is-active { background: var(--t); border-color: var(--t); color: #fff; }
.ar-tag-chip.is-active i { background: #fff; }
.ar-tag-chip.is-new { border-style: dashed; border-color: var(--oa-line); background: transparent; color: var(--oa-ink-faint); }
.ar-tag-chip.is-new:hover { border-color: var(--oa-brand); color: var(--oa-brand); }
.ar-tag-chip.is-mini { gap: 5px; padding: 0 8px; font-size: 0.66rem; font-weight: 800; line-height: 1.9; cursor: default; }
.ar-tag-chip.is-mini i { width: 7px; height: 7px; }

/* ---- popover menus ---- */
.ar-popover {
    position: fixed;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    min-width: 210px;
    max-width: 280px;
    max-height: 360px;
    overflow-y: auto;
    padding: 6px;
    border-radius: 14px;
    border: 1px solid var(--oa-line);
    background: var(--oa-surface);
    color: var(--oa-ink);
    box-shadow: var(--oa-shadow-modal);
}

.ar-popover button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px; background: none; color: inherit; font-family: inherit; font-size: 0.8rem; font-weight: 700; text-align: start; cursor: pointer; }
.ar-popover button:hover, .ar-popover button:focus-visible { background: var(--oa-surface-muted); outline: 0; }
.ar-popover button svg { width: 16px; height: 16px; color: var(--oa-ink-faint); }
.ar-popover button > span:not([class]) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ar-popover button em { color: var(--oa-success); }
.ar-popover button em svg { color: inherit; }
.ar-popover button.is-on { background: color-mix(in srgb, var(--oa-success) 7%, transparent); }
.ar-popover button.is-danger, .ar-popover button.is-danger svg { color: var(--oa-danger); }
.ar-popover hr { margin: 5px 4px; border: 0; border-top: 1px solid var(--oa-line-subtle); opacity: 1; }
.ar-popover-title { padding: 6px 10px 4px; font-size: 0.7rem; font-weight: 900; color: var(--oa-ink-faint); }
.ar-popover-empty { margin: 0; padding: 6px 10px; font-size: 0.76rem; color: var(--oa-ink-faint); }
.ar-pick-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: color-mix(in srgb, var(--c) 14%, transparent); }
.ar-popover .ar-pick-icon svg { width: 14px; height: 14px; color: var(--c); }
.ar-pick-dot { width: 10px; height: 10px; margin: 0 8px; border-radius: 50%; background: var(--t); flex-shrink: 0; }

/* ---- folder / tag editor ---- */
.ar-editor { width: min(460px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
.ar-editor.is-wide { width: min(760px, 100%); }
.ar-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ar-icon-btn { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--oa-surface-muted); color: var(--oa-ink-soft); cursor: pointer; }
.ar-icon-btn svg { width: 17px; height: 17px; }
.ar-editor .mb-field input[type="text"] { width: 100%; height: 42px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--oa-line); background: var(--oa-surface-soft); color: var(--oa-ink); font-family: inherit; font-size: 0.88rem; }
.ar-editor .mb-field input[type="text"]:focus { outline: 0; border-color: var(--oa-brand); box-shadow: 0 0 0 3px var(--oa-brand-glow); }
.ar-editor .mb-field textarea { min-height: 64px; }
.ar-editor .mb-field b { color: var(--oa-danger); }
.ar-editor-error { min-height: 1.2em; margin: 0; font-size: 0.78rem; font-weight: 700; color: var(--oa-danger); }
.ar-editor-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(220px, 1fr); gap: 18px; align-items: start; }
.ar-editor-fields { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ar-editor-preview { position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 16px; background: var(--oa-surface-muted); }
.ar-preview-label { font-size: 0.7rem; font-weight: 800; color: var(--oa-ink-faint); }
.ar-preview-slot .ar-card { cursor: default; transform: none; }

.ar-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.ar-swatch { position: relative; display: block; width: 30px; height: 30px; margin: 0; cursor: pointer; }
.ar-swatch input[type="radio"] { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.ar-swatch span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25); transition: transform 0.12s ease, box-shadow 0.12s ease; }
.ar-swatch:hover span { transform: scale(1.08); }
.ar-swatch input:checked + span { box-shadow: 0 0 0 2px var(--oa-surface), 0 0 0 4px var(--c); }
.ar-swatch input:focus-visible + span { box-shadow: 0 0 0 2px var(--oa-surface), 0 0 0 4px var(--oa-brand); }
.ar-swatch.is-custom { border-radius: 50%; background: conic-gradient(#ef4444, #f59e0b, #22c55e, #06b6d4, #6366f1, #d946ef, #ef4444); }
.ar-swatch.is-custom input[type="color"] { position: absolute; inset: 4px; width: 22px; height: 22px; padding: 0; border: 2px solid var(--oa-surface); border-radius: 50%; cursor: pointer; }
.ar-swatch.is-custom input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.ar-swatch.is-custom input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.ar-swatch.is-custom:has(input[type="radio"]:checked) { box-shadow: 0 0 0 2px var(--oa-surface), 0 0 0 4px var(--oa-ink-soft); }

.ar-icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.ar-icon-option { position: relative; margin: 0; cursor: pointer; }
.ar-icon-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.ar-icon-option span { display: grid; place-items: center; height: 40px; border-radius: 11px; border: 1px solid var(--oa-line); background: var(--oa-surface-soft); color: var(--oa-ink-soft); transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease; }
.ar-icon-option span svg { width: 18px; height: 18px; }
.ar-icon-option:hover span { border-color: color-mix(in srgb, var(--oa-brand) 40%, var(--oa-line)); }
.ar-icon-option input:checked + span { border-color: var(--oa-brand); background: color-mix(in srgb, var(--oa-brand) 10%, var(--oa-surface)); color: var(--oa-brand); }
.ar-icon-option input:focus-visible + span { box-shadow: 0 0 0 3px var(--oa-brand-glow); }

.ar-tag-preview { display: flex; justify-content: center; padding: 14px; border-radius: 14px; background: var(--oa-surface-muted); }
.ar-tag-preview .ar-tag-chip { cursor: default; font-size: 0.86rem; }
.ar-tag-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.ar-tag-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px; border-radius: 12px; background: var(--oa-surface-soft); }
.ar-tag-list .ar-tag-chip { cursor: default; }
.ar-danger-text, .ar-danger-text:hover:not(:disabled) { color: var(--oa-danger); }
.ar-editor .mb-confirm-actions .ar-danger-text { margin-inline-end: auto; }

/* ---- list view ---- */
.ar-crumbs { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--oa-ink-faint); margin-bottom: -8px; }
.ar-crumbs svg { width: 14px; height: 14px; }
.ar-crumbs button { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 0; border-radius: 8px; background: none; color: var(--oa-brand); font-family: inherit; font-size: 0.8rem; font-weight: 800; cursor: pointer; }
.ar-crumbs button:hover { background: var(--oa-surface-muted); }
.ar-crumbs span { font-weight: 800; color: var(--oa-ink); }

.ar-target {
    --c: var(--oa-brand);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid color-mix(in srgb, var(--c) 25%, var(--oa-line));
    background:
        radial-gradient(90% 140% at 100% 0%, color-mix(in srgb, var(--c) 14%, transparent), transparent 60%),
        var(--oa-surface);
}

.ar-target-text { flex: 1; min-width: 180px; }
.ar-target-text h3 { margin: 0; font-size: 1.08rem; font-weight: 900; color: var(--oa-ink); }
.ar-target-text p { margin: 2px 0 0; font-size: 0.78rem; color: var(--oa-ink-faint); }
.ar-target-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ar-target-count { padding: 3px 10px; border-radius: 99px; background: color-mix(in srgb, var(--c) 12%, transparent); color: var(--c); font-size: 0.76rem; font-weight: 900; }

.ar-tag-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.ar-tag-filter:empty { display: none; }
.ar-tag-filter-label { display: inline-flex; align-items: center; gap: 5px; font-size: 0.74rem; font-weight: 800; color: var(--oa-ink-faint); }
.ar-tag-filter-label svg { width: 14px; height: 14px; }
.ar-tag-filter .ar-tag-chip { padding: 3px 11px; font-size: 0.74rem; }

.ar-row .mb-tags { gap: 5px 6px; }
.ar-star { display: inline-flex; color: #f59e0b; }
.ar-star svg { width: 14px; height: 14px; fill: currentColor; }
.ar-number { font-size: 0.7rem; font-weight: 800; color: var(--oa-ink-soft); direction: ltr; unicode-bidi: isolate; margin-inline-end: 2px; }
.ar-folder-mark { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: 6px; background: color-mix(in srgb, var(--c) 10%, transparent); color: var(--c); font-size: 0.66rem; font-weight: 800; line-height: 1.9; white-space: nowrap; }
.ar-folder-mark svg { width: 12px; height: 12px; }

.ar-row-organize { display: grid; place-items: center; width: 34px; height: 34px; margin-top: 2px; border: 0; border-radius: 10px; background: none; color: var(--oa-ink-faint); cursor: pointer; opacity: 0.5; transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease; }
.ar-row-organize svg { width: 17px; height: 17px; }
.mb-row:hover .ar-row-organize, .mb-row.is-cursor .ar-row-organize, .ar-row-organize:focus-visible { opacity: 1; }
.ar-row-organize:hover { background: var(--oa-surface-muted); color: var(--oa-brand); }

/* ---- dialog: personal organisation ---- */
.ar-organize { border-color: color-mix(in srgb, var(--oa-brand) 22%, var(--oa-line-subtle)); }
.ar-organize-block { display: flex; flex-direction: column; gap: 7px; }
.ar-organize-block + .ar-organize-block { margin-top: 12px; }
.ar-organize-label { font-size: 0.7rem; font-weight: 800; color: var(--oa-ink-faint); }
.ar-organize-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ar-organize .ar-tag-chip { padding: 3px 10px; font-size: 0.74rem; }

.ar-folder-toggle {
    --c: var(--oa-ink-faint);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--c) 30%, var(--oa-line));
    background: var(--oa-surface);
    color: var(--oa-ink);
    font-family: inherit;
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ar-folder-toggle svg { width: 14px; height: 14px; color: var(--c); }
.ar-folder-toggle:hover { border-color: var(--c); }
.ar-folder-toggle.is-on { background: var(--c); border-color: var(--c); color: #fff; }
.ar-folder-toggle.is-on svg { color: #fff; }
.ar-folder-toggle.is-new { border-style: dashed; border-color: var(--oa-line); color: var(--oa-ink-faint); }
.ar-folder-toggle.is-new svg { color: inherit; }

/* ---- responsive ---- */
@media (max-width: 760px) {
    .ar-search-global { flex: 1 1 100%; }
    .ar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .ar-card { min-height: 132px; padding: 13px; }
    .ar-card-desc { display: none; }
    .ar-card-menu { opacity: 1; }
    .ar-editor-grid { grid-template-columns: minmax(0, 1fr); }
    .ar-editor-preview { position: static; order: -1; }
    .ar-target-actions .mb-btn span { display: none; }
    .ar-row-organize { opacity: 1; }
}

@media (max-width: 380px) {
    .ar-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    .ar-card, .ar-card-menu, .ar-tag-chip, .ar-swatch span, .ar-folder-toggle { transition: none; }
}

/* Letters of one outside contact */
.ar-contact-filter { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0; }
.ar-contact-filter .ar-contact-search { max-width: 340px; }
.ar-contact-results { position: absolute; top: 100%; inset-inline-start: 0; z-index: 30; min-width: 280px; max-width: 420px; display: grid; border-radius: 12px; border: 1px solid var(--bs-border-color, rgba(128,128,128,.3)); background: var(--bs-body-bg, #fff); box-shadow: 0 12px 34px rgba(0,0,0,.18); overflow: hidden; }
.ar-contact-results:empty { display: none; }
.ar-contact-results button { display: grid; text-align: right; gap: 2px; padding: 9px 12px; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; }
.ar-contact-results button:hover { background: rgba(80,120,255,.1); }
.ar-contact-results small, .ar-contact-empty { color: var(--bs-secondary-color, #6c757d); font-size: .8rem; padding: 0; }
.ar-contact-empty { padding: 9px 12px; }
