/* ── AI Enrichment Upload Dialog ────────────────────────────────── */

.fm-ai-enrich-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 100100;
    display: flex; align-items: center; justify-content: center;
}
.fm-ai-enrich-dialog {
    background: #fff;
    border-radius: 8px;
    width: 520px; max-width: 95vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    overflow: hidden;
}
.fm-ai-enrich-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
}
.fm-ai-enrich-header h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.fm-ai-enrich-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #666; line-height: 1; }
.fm-ai-enrich-body { padding: 20px; }
.fm-ai-enrich-desc { margin: 0 0 12px; color: #555; font-style: italic; }

.fm-ai-enrich-dropzone {
    border: 2px dashed #bbb;
    border-radius: 8px;
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.fm-ai-enrich-dropzone:hover,
.fm-ai-enrich-dropzone.fm-ai-dragover {
    border-color: #0073aa;
    background: #f0f7fc;
}
.fm-ai-enrich-dropzone .dashicons { font-size: 36px; width: 36px; height: 36px; color: #999; }
.fm-ai-enrich-dropzone p { margin: 8px 0 4px; color: #555; }
.fm-ai-enrich-dropzone small { color: #999; }

.fm-ai-enrich-file-list { margin-top: 12px; }
.fm-ai-file-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px;
    background: #f5f5f5;
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 13px;
}
.fm-ai-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-ai-file-size { color: #888; font-size: 12px; }
.fm-ai-file-remove { background: none; border: none; color: #c00; cursor: pointer; font-size: 16px; }

.fm-ai-enrich-prompt-wrap { margin-top: 16px; }
.fm-ai-enrich-prompt-wrap label { display: block; margin-bottom: 4px; font-size: 13px; color: #555; }
.fm-ai-enrich-prompt { width: 100%; box-sizing: border-box; }

.fm-ai-enrich-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
}

/* Progress UI */
.fm-ai-enrich-progress { text-align: center; padding: 20px 0; }
.fm-ai-enrich-spinner .spinner { float: none; margin: 0 auto; }
.fm-ai-enrich-status-text { font-size: 15px; margin: 12px 0 4px; }
.fm-ai-enrich-elapsed { color: #666; }
.fm-ai-enrich-status-detail { color: #888; font-size: 13px; }
.fm-ai-enrich-hint { margin-top: 16px; padding: 10px; background: #f5f5f5; border-radius: 4px; }
.fm-ai-enrich-hint small { color: #666; }

/* Error UI */
.fm-ai-enrich-error { text-align: center; padding: 20px; color: #c00; }
.fm-ai-enrich-error .dashicons { font-size: 32px; width: 32px; height: 32px; }
.fm-ai-enrich-error p { margin-top: 8px; }


/* ── Proposal Reviewer Modal ──────────────────────────────────── */

.fm-proposal-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100200;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 20px;
    overflow-y: auto;
}
.fm-proposal-container {
    background: #fff;
    border-radius: 8px;
    width: 900px; max-width: 98vw;
    max-height: calc(100vh - 40px);
    display: flex; flex-direction: column;
    box-shadow: 0 12px 48px rgba(0,0,0,0.3);
}

/* Header */
.fm-proposal-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
}
.fm-proposal-header-top {
    display: flex; justify-content: space-between; align-items: center;
}
.fm-proposal-header h3 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 6px; }
.fm-proposal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #666; }
.fm-proposal-summary { margin-top: 8px; color: #555; font-size: 13px; }
.fm-proposal-stats { margin-top: 6px; display: flex; gap: 12px; }
.fm-proposal-stat { font-size: 13px; color: #444; font-weight: 500; }
.fm-proposal-stat-unmatched { color: #e65100; }

/* Stale banner */
.fm-proposal-stale-banner {
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff3e0;
    border: 1px solid #ffb74d;
    border-radius: 4px;
    color: #e65100;
    font-size: 13px;
    display: flex; align-items: center; gap: 6px;
}

/* Page tabs */
.fm-proposal-tabs {
    display: flex; gap: 0;
    border-bottom: 2px solid #e0e0e0;
    padding: 0 20px;
    background: #fafafa;
    flex-shrink: 0;
    overflow-x: auto;
}
.fm-proposal-tab {
    padding: 10px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.fm-proposal-tab:hover { color: #333; }
.fm-proposal-tab.active { color: #0073aa; border-bottom-color: #0073aa; font-weight: 500; }
.fm-proposal-tab-count { font-size: 11px; color: #999; }
.fm-proposal-tab.active .fm-proposal-tab-count { color: #0073aa; }

/* Body (scrollable) */
.fm-proposal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}
.fm-proposal-page { display: none; }
.fm-proposal-no-changes { color: #999; text-align: center; padding: 40px 0; }

/* ── Change Card ──────────────────────────────────────────────── */

.fm-proposal-card {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: border-color .2s, box-shadow .2s;
}
.fm-proposal-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

.fm-proposal-decided.fm-proposal-accepted { border-color: #4caf50; background: #f1f8e9; }
.fm-proposal-decided.fm-proposal-rejected { border-color: #e0e0e0; background: #fafafa; opacity: 0.7; }
.fm-proposal-decided.fm-proposal-userEdit { border-color: #2196f3; background: #e3f2fd; }

.fm-proposal-card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px;
    background: #f5f5f5;
    border-bottom: 1px solid #eee;
}
.fm-proposal-field-label { font-weight: 600; font-size: 14px; }
.fm-proposal-action-type {
    font-size: 11px; padding: 2px 8px;
    background: #e0e0e0; border-radius: 3px; color: #555;
    text-transform: uppercase; font-weight: 500;
}

.fm-proposal-card-body { padding: 12px 14px; }

.fm-proposal-row {
    display: flex; gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    line-height: 1.5;
}
.fm-proposal-label { font-weight: 500; color: #666; min-width: 100px; flex-shrink: 0; }
.fm-proposal-value { flex: 1; word-break: break-word; }
.fm-proposal-current { color: #555; }
.fm-proposal-proposed { color: #1565c0; font-weight: 500; }
.fm-proposal-edited-val { color: #2e7d32; font-weight: 500; }
.fm-proposal-empty { color: #bbb; }
.fm-proposal-expand-link,
.fm-proposal-collapse-link {
    font-size: 11px;
    color: #0073aa;
    text-decoration: none;
    cursor: pointer;
}
.fm-proposal-expand-link:hover,
.fm-proposal-collapse-link:hover { text-decoration: underline; }
.fm-proposal-number { color: #5d4037; }
.fm-proposal-array, .fm-proposal-object { color: #7b1fa2; cursor: pointer; }

.fm-proposal-json-preview {
    display: none;
    margin: 4px 0 0;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 11px;
    max-height: 150px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.fm-proposal-array:hover + .fm-proposal-json-preview,
.fm-proposal-object:hover + .fm-proposal-json-preview,
.fm-proposal-json-preview:hover { display: block; }

/* Metadata */
.fm-proposal-meta { font-size: 12px; color: #777; margin-top: 4px; }
.fm-proposal-meta-label { font-weight: 500; color: #555; }
.fm-proposal-evidence { font-style: italic; }
.fm-proposal-reasoning { margin-top: 4px; color: #666; }

/* Confidence bar */
.fm-proposal-confidence {
    display: flex; align-items: center; gap: 8px;
    margin-top: 8px;
    font-size: 12px;
}
.fm-proposal-conf-bar {
    flex: 0 0 100px;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}
.fm-proposal-conf-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .3s;
}
.fm-proposal-conf-high { background: #4caf50; }
.fm-proposal-conf-medium { background: #ffc107; }
.fm-proposal-conf-low { background: #bdbdbd; }
.fm-proposal-conf-value { font-weight: 500; color: #444; }

/* Array conflict */
.fm-proposal-array-conflict {
    margin-top: 8px;
    padding: 8px 10px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 4px;
    font-size: 12px;
    color: #f57f17;
}
.fm-proposal-array-options { margin-top: 6px; }
.fm-proposal-array-options label { display: block; margin: 4px 0; color: #333; font-size: 12px; cursor: pointer; }

/* Inline editor */
.fm-proposal-editor {
    margin-top: 8px;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
}
.fm-proposal-edit-input {
    width: 100%; box-sizing: border-box;
    font-family: monospace; font-size: 12px;
    margin-bottom: 4px;
}
.fm-proposal-edit-save,
.fm-proposal-edit-cancel {
    padding: 2px 10px;
    font-size: 11px;
    line-height: 1.5;
    min-height: 0;
    height: auto;
}

/* Decision buttons */
.fm-proposal-card-actions {
    display: flex; gap: 4px;
    padding: 6px 14px;
    border-top: 1px solid #eee;
    background: #fafafa;
}
.fm-proposal-btn {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 3px 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    font-size: 11px;
    line-height: 1.4;
    transition: background .15s, border-color .15s;
}
.fm-proposal-btn:hover { background: #f0f0f0; }
.fm-proposal-btn .dashicons { font-size: 14px; width: 14px; height: 14px; }

.fm-proposal-btn-accept.active { background: #e8f5e9; border-color: #4caf50; color: #2e7d32; }
.fm-proposal-btn-reject.active { background: #fce4ec; border-color: #e57373; color: #c62828; }
.fm-proposal-btn-edit.active { background: #e3f2fd; border-color: #42a5f5; color: #1565c0; }


/* ── Unmatched Section ────────────────────────────────────────── */

.fm-proposal-unmatched-section {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 2px solid #e0e0e0;
}
.fm-proposal-unmatched-section h4 {
    margin: 0 0 12px;
    font-size: 14px;
    display: flex; align-items: center; gap: 6px;
    color: #e65100;
}
.fm-proposal-unmatched-item {
    padding: 10px 12px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 13px;
}
.fm-proposal-unmatched-desc { margin: 0 0 2px; }
.fm-proposal-unmatched-loc { color: #888; display: block; margin-bottom: 4px; }
.fm-proposal-copy-btn {
    padding: 2px 8px;
    font-size: 11px;
    line-height: 1.4;
    min-height: 0;
    height: auto;
    vertical-align: middle;
}
.fm-proposal-copy-btn .dashicons {
    font-size: 13px;
    width: 13px;
    height: 13px;
    vertical-align: middle;
    margin-right: 2px;
}


/* ── Footer (sticky) ─────────────────────────────────────────── */

.fm-proposal-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
    border-radius: 0 0 8px 8px;
    flex-shrink: 0;
}
.fm-proposal-footer-counts { font-size: 12px; color: #555; }
.fm-proposal-footer-counts span { font-weight: 600; }
.fm-proposal-footer-actions { display: flex; gap: 6px; }
.fm-proposal-footer-actions .button {
    padding: 3px 12px;
    font-size: 12px;
    line-height: 1.5;
    min-height: 0;
    height: auto;
}


/* ── Notification Toast ──────────────────────────────────────── */

.fm-proposal-notification {
    position: fixed;
    bottom: 20px; right: 20px;
    padding: 12px 20px;
    color: #fff;
    border-radius: 6px;
    font-size: 14px;
    z-index: 100300;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: none;
}


/* ── Orphan Discovery Badge ──────────────────────────────────── */

.fm-ai-proposal-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    margin: 6px 0 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}
.fm-ai-badge-ready {
    background: #e8f5e9;
    border: 1px solid #4caf50;
    color: #2e7d32;
}
.fm-ai-badge-running {
    background: #e3f2fd;
    border: 1px solid #42a5f5;
    color: #1565c0;
}
.fm-ai-badge-failed {
    background: #fce4ec;
    border: 1px solid #e57373;
    color: #c62828;
}
.fm-ai-proposal-badge .dashicons { font-size: 16px; width: 16px; height: 16px; }


/* ── AI Analyse Result Overlay ───────────────────────────────── */

.fm-ai-analyse-result-overlay {
    position: fixed; inset: 0;
    background: #fff;
    z-index: 100400;
    display: flex; flex-direction: column;
}
.fm-ai-analyse-result-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 20px;
    background: #1565c0;
    color: #fff;
    flex-shrink: 0;
}
.fm-ai-analyse-result-title {
    font-size: 15px; font-weight: 600;
    display: flex; align-items: center; gap: 6px;
}
.fm-ai-analyse-result-title .dashicons { font-size: 18px; width: 18px; height: 18px; }
.fm-ai-analyse-result-actions { display: flex; gap: 8px; }
.fm-ai-analyse-result-actions .button { font-size: 12px; }
.fm-ai-analyse-result-actions .button-primary {
    background: #fff; color: #1565c0; border-color: #fff;
}
.fm-ai-analyse-result-actions .button-primary:hover { background: #e3f2fd; }
.fm-ai-analyse-result-actions .button.active {
    background: #e8f5e9; border-color: #4caf50; color: #2e7d32;
}
.fm-ai-analyse-edit-hint {
    background: #e3f2fd;
    border-bottom: 1px solid #90caf9;
    padding: 6px 20px;
    font-size: 12px;
    color: #1565c0;
    display: flex; align-items: center; gap: 6px;
    flex-shrink: 0;
}
.fm-ai-analyse-result-body { flex: 1; overflow: hidden; }

/* ── Analyse Sticky Background Badge ────────────────────────── */

.fm-ai-analyse-sticky {
    position: fixed;
    bottom: 24px; right: 24px;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    z-index: 100500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    display: flex; align-items: center;
    animation: fm-sticky-slide-in .25s ease;
}
@keyframes fm-sticky-slide-in {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.fm-ai-analyse-sticky--running {
    background: #1565c0; color: #fff;
}
.fm-ai-analyse-sticky--done {
    background: #2e7d32; color: #fff;
    cursor: pointer;
}
.fm-ai-analyse-sticky--done:hover { background: #1b5e20; }
.fm-ai-analyse-sticky--error {
    background: #c62828; color: #fff;
}

/* Warning in analyse prompt modal */
.fm-ai-enrich-warn {
    padding: 8px 12px;
    background: #fff3e0;
    border: 1px solid #ffb74d;
    border-radius: 4px;
    color: #e65100;
    font-size: 13px;
    margin-bottom: 10px;
    display: flex; align-items: center; gap: 6px;
}
