/* The ask / new-post editor (Views/Shared/_Composer.cshtml): one calm column, big title,
   a body without chrome, settings in a drawer. Uses the site's theme variables (site.css),
   so light and dark follow [data-theme]. */

.composer-page {
    --c-bg: var(--bg-secondary, #fff);
    --c-soft: var(--bg-tertiary, #f1f5f9);
    --c-text: var(--text-primary, #1e293b);
    --c-text-2: var(--text-secondary, #64748b);
    --c-muted: var(--text-muted, #94a3b8);
    --c-accent: var(--accent-primary, #2563eb);
    --c-border: var(--border-color, #e2e8f0);
    --c-bad: #dc2626;
    --c-ok: #059669;
    max-width: 760px;
    margin: 0 auto;
    padding: 24px 16px 96px;
    color: var(--c-text);
}

.composer-intro h1 { font-size: 15px; font-weight: 700; color: var(--c-text-2); margin: 0 0 2px; }
.composer-intro p { font-size: 13px; color: var(--c-muted); margin: 0 0 12px; }

/* Bar: autosave state + the three actions. On phones it sticks to the bottom. */
.composer-bar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    padding: 10px 0; background: var(--bg-primary, #fafbfc);
    border-bottom: 1px solid var(--c-border); margin-bottom: 18px;
}
.composer-saved { font-size: 12.5px; color: var(--c-muted); min-height: 1em; }
.composer-saved.ok::before { content: "✓ "; color: var(--c-ok); }
.composer-actions { display: flex; gap: 8px; align-items: center; margin-inline-start: auto; }

.c-btn {
    display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; border: 1px solid transparent;
    padding: 8px 16px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; line-height: 1.4;
    min-height: 40px; transition: background-color .15s, border-color .15s, opacity .15s;
}
.c-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.c-btn.primary { background: var(--c-accent); color: #fff; }
.c-btn.primary:hover { filter: brightness(1.08); }
.c-btn.ghost { background: transparent; color: var(--c-text-2); border-color: var(--c-border); }
.c-btn.ghost:hover { background: var(--c-soft); color: var(--c-text); }
.c-btn.small { padding: 4px 12px; min-height: 32px; font-size: 13px; }
.c-btn:disabled, .c-btn.busy { opacity: .6; cursor: progress; }
.c-btn:focus-visible, .composer-title:focus-visible, .c-input:focus-visible, .tag-input:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.c-count:not(:empty) { background: var(--c-accent); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; min-width: 18px; text-align: center; }

.composer-alert { background: color-mix(in srgb, var(--c-bad) 10%, var(--c-bg)); border: 1px solid color-mix(in srgb, var(--c-bad) 35%, var(--c-border)); color: var(--c-text); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.composer-restore { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--c-soft); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.composer-restore span { flex: 1; min-width: 160px; }
.composer-restore small { color: var(--c-muted); }

/* Title: big, borderless, grows with the text */
.composer-title {
    width: 100%; border: 0; background: transparent; color: var(--c-text); resize: none; overflow: hidden;
    font: inherit; font-size: 30px; font-weight: 800; line-height: 1.5; padding: 4px 0;
}
/* site.css forces form fields to 16px up to 768px wide (iOS zoom); the title stays big. */
.composer-page .composer-title { font-size: 30px !important; }
.composer-title::placeholder { color: var(--c-muted); opacity: .8; }
.composer-meta { display: flex; justify-content: space-between; gap: 10px; min-height: 20px; }
.composer-count { font-size: 12px; color: var(--c-muted); }
.composer-count.near { color: #b45309; font-weight: 700; }
.field-error { font-size: 13px; color: var(--c-bad); }
.field-error:empty { display: none; }
[aria-invalid="true"] { box-shadow: inset 0 -2px 0 var(--c-bad); }

/* «پرسش‌های مشابه» */
.composer-similar { border: 1px solid var(--c-border); border-radius: 12px; padding: 10px 14px; margin: 6px 0 16px; background: var(--c-bg); }
.similar-head { font-size: 13px; font-weight: 700; color: var(--c-text-2); margin-bottom: 4px; }
.composer-similar ul { list-style: none; margin: 0; padding: 0; }
.composer-similar li a { display: block; padding: 6px 0; font-size: 14px; color: var(--c-accent); text-decoration: none; border-top: 1px solid var(--c-border); }
.composer-similar li:first-child a { border-top: 0; }
.composer-similar li a:hover { text-decoration: underline; }

/* Body: no frame, the editor grows with the text */
.composer-body { margin-top: 8px; }
.composer-body .tox-tinymce { border: 0 !important; border-radius: 0 !important; }
.composer-body .tox .tox-edit-area::before { display: none; }
/* site.css shrinks every iframe on phones (embedded videos); the editor is an iframe too. */
.composer-body .tox .tox-edit-area__iframe { height: 100% !important; max-height: none !important; aspect-ratio: auto !important; }
.composer-body textarea { width: 100%; min-height: 320px; border: 0; background: transparent; font: inherit; font-size: 17px; line-height: 2; color: var(--c-text); }
.composer-body.invalid .tox-tinymce { box-shadow: inset -3px 0 0 var(--c-bad); }

/* Drawer «تنظیمات انتشار»: side panel on desktop, bottom sheet on phones */
.composer-drawer, .composer-preview { position: fixed; inset: 0; z-index: 1050; }
.composer-drawer[hidden], .composer-preview[hidden] { display: none; }
.drawer-backdrop { position: absolute; inset: 0; background: rgb(15 23 42 / .45); }
.drawer-panel {
    position: absolute; top: 0; bottom: 0; inset-inline-end: 0; width: min(400px, 100%);
    background: var(--c-bg); color: var(--c-text); display: flex; flex-direction: column; gap: 18px;
    padding: 18px; overflow-y: auto; box-shadow: 0 0 40px rgb(0 0 0 / .2);
}
.drawer-head, .preview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.drawer-head h2, .preview-head h2 { font-size: 17px; font-weight: 800; margin: 0; }
.drawer-close { border: 0; background: var(--c-soft); color: var(--c-text); width: 36px; height: 36px; border-radius: 50%; font-size: 22px; line-height: 1; cursor: pointer; }
.drawer-group label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.drawer-group label small { font-weight: 400; color: var(--c-muted); }
.drawer-foot { margin-top: auto; display: flex; justify-content: flex-end; }
.c-input, .tag-box { width: 100%; border: 1px solid var(--c-border); border-radius: 10px; background: var(--c-bg); color: var(--c-text); font: inherit; font-size: 14px; padding: 8px 10px; }
.cat-picked { font-size: 13px; color: var(--c-text-2); margin-bottom: 6px; }
.cat-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 220px; overflow-y: auto; border: 1px solid var(--c-border); border-radius: 10px; }
.cat-list button { width: 100%; text-align: right; border: 0; background: none; color: var(--c-text); font: inherit; font-size: 14px; padding: 9px 12px; cursor: pointer; }
.cat-list button:hover, .cat-list button:focus-visible { background: var(--c-soft); }
.cat-list button[aria-selected="true"] { background: color-mix(in srgb, var(--c-accent) 12%, var(--c-bg)); color: var(--c-accent); font-weight: 700; }
.cat-list li[hidden] { display: none; }
.tag-box { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 8px; }
.tag-chips { display: contents; }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--c-soft); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 13px; }
.tag-chip button { border: 0; background: none; color: var(--c-text-2); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 4px; }
.tag-input { flex: 1; min-width: 120px; border: 0; background: transparent; color: var(--c-text); font: inherit; font-size: 14px; padding: 4px; }
.tag-suggest { list-style: none; margin: 4px 0 0; padding: 4px; border: 1px solid var(--c-border); border-radius: 10px; background: var(--c-bg); }
.tag-suggest li { padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.tag-suggest li[aria-selected="true"], .tag-suggest li:hover { background: var(--c-soft); }
.image-pick img { width: 100%; max-height: 200px; object-fit: cover; border-radius: 10px; margin-bottom: 8px; }
.image-actions { display: flex; gap: 8px; }
.upload-progress { height: 6px; background: var(--c-soft); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.upload-progress i { display: block; height: 100%; width: 0; background: var(--c-accent); transition: width .2s; }

/* Preview */
.composer-preview { background: rgb(15 23 42 / .55); display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; }
.preview-panel { width: min(860px, 100%); background: var(--c-bg); color: var(--c-text); border-radius: 16px; padding: 16px 18px; box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
.preview-ready { background: color-mix(in srgb, var(--c-ok) 12%, var(--c-bg)); color: var(--c-text); border: 1px solid color-mix(in srgb, var(--c-ok) 40%, var(--c-border)); border-radius: 12px; padding: 10px 14px; margin: 12px 0 4px; font-weight: 700; }
.preview-body { margin: 14px 0; min-height: 120px; }
.preview-body .card { border: 0; }
.preview-body .post-detail-page { padding: 0; background: none; }
.preview-body img { max-width: 100%; height: auto; }
.preview-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--c-border); padding-top: 12px; }
.preview-loading { color: var(--c-muted); text-align: center; padding: 40px 0; }

@media (max-width: 640px) {
    .composer-page { padding: 12px 16px 120px; }
    .composer-page .composer-title { font-size: 26px !important; }
    /* The main button stays at hand at the bottom, also with the keyboard open. */
    .composer-bar {
        position: fixed; top: auto; bottom: 0; inset-inline: 0; margin: 0; z-index: 1040;
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--c-border); border-bottom: 0;
        box-shadow: 0 -6px 20px rgb(0 0 0 / .08);
    }
    .composer-saved { width: 100%; text-align: center; font-size: 11.5px; }
    .composer-actions { width: 100%; margin: 0; }
    .composer-actions .c-btn.ghost span { display: none; }
    .composer-actions .c-btn.primary { flex: 1; justify-content: center; }
    .drawer-panel { top: auto; inset-inline: 0; width: 100%; max-height: 85vh; border-radius: 18px 18px 0 0; }
    .composer-preview { padding: 0; }
    .preview-panel { border-radius: 0; min-height: 100%; }
    .preview-foot { position: sticky; bottom: 0; background: var(--c-bg); padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
    .preview-foot .c-btn.primary { flex: 1; justify-content: center; }
}

/* «بهبود پرسش با هوش مصنوعی» */
.composer-ai { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.c-btn.ai { background: color-mix(in srgb, #7c3aed 10%, var(--c-bg)); color: #6d28d9; border-color: color-mix(in srgb, #7c3aed 35%, var(--c-border)); }
.c-btn.ai:hover:not(:disabled) { background: color-mix(in srgb, #7c3aed 16%, var(--c-bg)); }
.c-btn.ai:disabled { opacity: .55; cursor: not-allowed; }
.composer-ai-status { font-size: 12.5px; color: var(--c-muted); }
.composer-ai-status.bad { color: var(--c-bad); }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.ai-note { font-size: 13px; color: var(--c-text-2); margin: 8px 0 4px; }
.ai-section { border: 1px solid var(--c-border); border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
.ai-section h3 { font-size: 14px; font-weight: 800; margin: 0 0 8px; }
.ai-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ai-compare > div { min-width: 0; }
.ai-compare small { display: block; font-size: 11.5px; color: var(--c-muted); margin-bottom: 4px; }
.ai-old { color: var(--c-text-2); }
.ai-new { background: color-mix(in srgb, var(--c-ok) 8%, var(--c-bg)); border-radius: 8px; padding: 6px 8px; }
.ai-body { max-height: 300px; overflow-y: auto; font-size: 14px; line-height: 1.9; }
.ai-body h3 { font-size: 14px; margin: 8px 0 2px; }
.ai-actions { display: flex; gap: 8px; margin-top: 10px; }
.ai-section.done { opacity: .6; }
.ai-section ul.ai-missing { margin: 0; padding-inline-start: 18px; font-size: 14px; }
@media (max-width: 640px) { .ai-compare { grid-template-columns: 1fr; } }
