/* CUSTOMER-FORMS-00A
 *   1. The shared form renderer (.cf-*): hosted public page, embed, and the workspace Preview.
 *   2. The management workspace (.cfm-*): list, editor, submissions.
 * Both light and dark themes are tokenized; the hosted page picks one with ?theme=. */

/* ── 1. renderer ─────────────────────────────────────────────────────────── */

.cf-page, .cf-preview-surface {
    --cf-bg: #0f172a;
    --cf-surface: #1e293b;
    --cf-surface-2: #263347;
    --cf-border: rgba(148, 163, 184, 0.3);
    --cf-text: #e2e8f0;
    --cf-muted: #a8b3c7;
    --cf-accent: #6366f1;
    --cf-accent-text: #ffffff;
    --cf-danger: #fca5a5;
    --cf-danger-border: #f87171;
    --cf-success: #86efac;
}
body.cf-page[data-theme="light"], .cf-preview-surface[data-theme="light"] {
    --cf-bg: #f1f5f9;
    --cf-surface: #ffffff;
    --cf-surface-2: #f8fafc;
    --cf-border: #cbd5e1;
    --cf-text: #0f172a;
    --cf-muted: #475569;
    --cf-accent: #4f46e5;
    --cf-danger: #b91c1c;
    --cf-danger-border: #dc2626;
    --cf-success: #15803d;
}

.cf-page { margin: 0; min-height: 100vh; background: var(--cf-bg); color: var(--cf-text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 16px; line-height: 1.5; }
.cf-page *, .cf-page *::before, .cf-page *::after, .cf-preview-surface *, .cf-preview-surface *::before, .cf-preview-surface *::after { box-sizing: border-box; }
.cf-shell { max-width: 560px; margin: 0 auto; padding: 24px 16px 32px; width: 100%; }
.cf-embedded .cf-shell { padding: 12px; max-width: none; }
.cf-embedded .cf-powered { display: none; }
.cf-card, .cf-preview-surface { background: var(--cf-surface); border: 1px solid var(--cf-border); border-radius: 14px; padding: 24px; color: var(--cf-text); }
.cf-embedded .cf-card { border: 0; border-radius: 0; background: transparent; padding: 4px; }
.cf-powered { text-align: center; margin: 14px 0 0; font-size: 0.8rem; color: var(--cf-muted); }
.cf-loading, .cf-unavailable, .cf-noscript { margin: 0; color: var(--cf-muted); text-align: center; }

.cf-form { display: flex; flex-direction: column; gap: 16px; position: relative; }
.cf-title { margin: 0; font-size: 1.5rem; line-height: 1.25; overflow-wrap: anywhere; }
.cf-description { margin: -6px 0 0; color: var(--cf-muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.cf-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cf-label { font-weight: 600; font-size: 0.95rem; overflow-wrap: anywhere; }
.cf-req { color: var(--cf-danger); }
.cf-input { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--cf-border); background: var(--cf-surface-2); color: var(--cf-text); font: inherit; }
textarea.cf-input { min-height: 96px; resize: vertical; }
.cf-input:focus-visible, .cf-check input:focus-visible, .cf-submit:focus-visible { outline: 3px solid var(--cf-accent); outline-offset: 2px; }
.cf-input[aria-invalid="true"] { border-color: var(--cf-danger-border); }
.cf-check { display: flex; gap: 10px; align-items: flex-start; }
.cf-check input { width: 22px; height: 22px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--cf-accent); }
.cf-check-label { font-size: 0.95rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.cf-help { font-size: 0.85rem; color: var(--cf-muted); overflow-wrap: anywhere; }
.cf-error { font-size: 0.88rem; color: var(--cf-danger); font-weight: 600; }
.cf-error[hidden] { display: none; }
.cf-status { min-height: 1.2em; font-size: 0.92rem; }
.cf-status--error { color: var(--cf-danger); font-weight: 600; }
.cf-status--info { color: var(--cf-muted); }
.cf-submit { min-height: 48px; padding: 12px 20px; border: 0; border-radius: 10px; background: var(--cf-accent); color: var(--cf-accent-text); font: inherit; font-weight: 700; cursor: pointer; }
.cf-submit:disabled { opacity: 0.6; cursor: progress; }
.cf-preview-note { margin: 0; font-size: 0.85rem; color: var(--cf-muted); text-align: center; }
.cf-success { text-align: center; padding: 12px 0; outline: none; }
.cf-success-title { margin: 0 0 8px; color: var(--cf-success); }
.cf-success-message { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.cf-sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 480px) {
    .cf-card, .cf-preview-surface { padding: 16px; }
    .cf-title { font-size: 1.3rem; }
}
@media (prefers-reduced-motion: reduce) { .cf-page * { transition: none !important; animation: none !important; } }

/* ── 2. management workspace ─────────────────────────────────────────────── */

.cfm-root { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cfm-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.cfm-toolbar .cfm-grow { flex: 1 1 auto; }
.cfm-card { border: 1px solid var(--border-soft, rgba(143, 164, 255, 0.28)); border-radius: var(--radius-md, 12px); background: rgba(38, 42, 53, 0.94); padding: 16px; color: var(--text-primary, #f3f6fb); min-width: 0; }
.cfm-card h3 { margin: 0 0 10px; font-size: 1rem; }
.cfm-muted { color: rgba(244, 247, 255, 0.65); font-size: 0.88rem; }
.cfm-table-wrap { overflow-x: auto; }
.cfm-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.cfm-table th, .cfm-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); vertical-align: middle; font-size: 0.92rem; overflow-wrap: anywhere; }
.cfm-table th { color: rgba(244, 247, 255, 0.6); font-size: 0.74rem; letter-spacing: 0.04em; text-transform: uppercase; }
.cfm-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; text-transform: capitalize; background: rgba(255, 255, 255, 0.12); }
.cfm-badge--active { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.cfm-badge--archived { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }
.cfm-badge--draft { background: rgba(245, 183, 66, 0.2); color: #fcd34d; }
.cfm-tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.cfm-tab { min-height: 40px; padding: 8px 14px; background: transparent; border: 0; border-bottom: 3px solid transparent; color: inherit; font: inherit; cursor: pointer; }
.cfm-tab[aria-selected="true"] { border-bottom-color: #818cf8; font-weight: 700; }
.cfm-tab:focus-visible, .cfm-root button:focus-visible, .cfm-root input:focus-visible, .cfm-root select:focus-visible, .cfm-root textarea:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 2px; }
.cfm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cfm-fieldwrap { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cfm-fieldwrap label { font-size: 0.82rem; font-weight: 700; color: rgba(244, 247, 255, 0.75); }
.cfm-input { width: 100%; min-height: 40px; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(15, 23, 42, 0.6); color: inherit; font: inherit; }
textarea.cfm-input { min-height: 84px; resize: vertical; }
.cfm-fieldlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cfm-fieldrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 10px; background: rgba(15, 23, 42, 0.45); }
.cfm-fieldrow .cfm-fieldmain { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.cfm-fieldrow .cfm-fieldmeta { font-size: 0.78rem; color: rgba(244, 247, 255, 0.6); }
.cfm-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.cfm-btn { min-height: 36px; padding: 6px 12px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.08); color: inherit; font: inherit; font-size: 0.88rem; cursor: pointer; }
.cfm-btn--primary { background: #6366f1; border-color: #6366f1; color: #fff; font-weight: 700; }
.cfm-btn--danger { border-color: rgba(248, 113, 113, 0.6); color: #fca5a5; }
.cfm-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cfm-notice { padding: 10px 12px; border-radius: 8px; font-size: 0.9rem; }
.cfm-notice--error { background: rgba(248, 113, 113, 0.15); color: #fecaca; }
.cfm-notice--info { background: rgba(99, 102, 241, 0.16); }
.cfm-code { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; }
.cfm-detail dt { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; color: rgba(244, 247, 255, 0.6); margin-top: 10px; }
.cfm-detail dd { margin: 2px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.cfm-preview-wrap { max-width: 560px; }

@media (max-width: 768px) {
    .cfm-grid { grid-template-columns: minmax(0, 1fr); }
    .cfm-card { padding: 12px; }
}

.cfm-fieldrow--column { flex-direction: column; align-items: stretch; }
.cfm-fieldinner { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
