/* app.css — shared design system + workbench shell for jsoncsvtools.com P1
 * (Ada, p1/schema-streaming). Extracted from the per-page inline <style> blocks
 * (previously duplicated across every tool page) + new components: workbench grid,
 * CodeMirror container, preview table, options bar. Static, no build step — pages
 * reference this via <link rel="stylesheet" href="/assets/app.css">.
 * Light + dark via prefers-color-scheme. */

:root {
  --bg: #ffffff; --bg-card: #f8f9fa; --bg-input: #ffffff; --text: #1a1a2e;
  --text-secondary: #555; --border: #dee2e6; --accent: #2563eb; --accent-hover: #1d4ed8;
  --btn-text: #ffffff; --tag-bg: #eff6ff; --tag-text: #1e40af; --footer-bg: #f1f3f5;
  --shadow: 0 2px 8px rgba(0,0,0,0.06); --radius: 8px; --success: #16a34a; --error: #dc2626;
  --warn: #b45309; --warn-bg: #fffbeb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a; --bg-card: #1e293b; --bg-input: #1e293b; --text: #e2e8f0;
    --text-secondary: #94a3b8; --border: #334155; --accent: #3b82f6; --accent-hover: #60a5fa;
    --btn-text: #ffffff; --tag-bg: #1e3a5f; --tag-text: #93c5fd; --footer-bg: #1a2332;
    --shadow: 0 2px 8px rgba(0,0,0,0.2); --warn: #fbbf24; --warn-bg: #2a2410;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; }

/* header / nav */
header { background: var(--bg-card); border-bottom: 1px solid var(--border); padding: 1rem 1.5rem; }
.header-inner { max-width: 960px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }
.logo { font-size: 1.3rem; font-weight: 700; color: var(--accent); text-decoration: none; }
.logo span { color: var(--text); }
nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
nav a { color: var(--text-secondary); text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: color 0.15s; }
nav a:hover, nav a.active { color: var(--accent); }
nav a.active { font-weight: 600; }

main { flex: 1; max-width: 960px; margin: 0 auto; padding: 1.5rem; width: 100%; }

/* tool section */
.tool-section { margin-bottom: 2rem; }
.tool-section h1 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.tool-section .subtitle { color: var(--text-secondary); margin-bottom: 1.25rem; font-size: 1rem; }

/* workbench: input editor | output, side by side */
.editor-pane { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 640px) { .editor-pane { grid-template-columns: 1fr; } }
.pane-label { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.4rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }

/* CodeMirror container (vendored CM6/CM5 mounts here); falls back to textarea if JS off */
.editor-host { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-input); min-height: 260px; overflow: hidden; }
.editor-host .cm-editor { height: 260px; font-size: 0.88rem; }
.editor-host textarea, textarea.editor-fallback { width: 100%; min-height: 260px; padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-family: "SF Mono", "Fira Code", "Consolas", monospace; font-size: 0.88rem; line-height: 1.5; background: var(--bg-input); color: var(--text); resize: vertical; }
textarea:focus, .editor-host:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea[readonly] { background: var(--bg-card); }

/* options + buttons */
.options-bar { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.options-bar label { font-size: 0.88rem; color: var(--text-secondary); display: flex; align-items: center; gap: 0.35rem; }
.options-bar select { padding: 0.3em 0.5em; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-input); color: var(--text); font-size: 0.88rem; }
.btn-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.btn { padding: 0.6rem 1.5rem; border: none; border-radius: var(--radius); font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: background 0.15s, transform 0.1s; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--btn-text); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }

/* status + privacy */
.msg { font-size: 0.88rem; margin-top: 0.5rem; min-height: 1.4em; }
.msg.ok { color: var(--success); } .msg.err { color: var(--error); } .msg.warn { color: var(--warn); }
.privacy-notice { font-size: 0.88rem; color: var(--text-secondary); background: var(--tag-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.5rem 0.75rem; margin-bottom: 1rem; }
.privacy-notice a { color: var(--accent); }
.progress { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin: 0.5rem 0; display: none; }
.progress.active { display: block; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

/* preview table (preview-table.js renders into .preview-host) */
.preview-host { margin: 1rem 0 1.5rem; }
.preview-wrap { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.preview-table { border-collapse: collapse; width: 100%; font-size: 0.85rem; }
.preview-table th, .preview-table td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.preview-table thead th { position: sticky; top: 0; background: var(--bg-card); font-weight: 600; z-index: 1; }
.preview-table tbody tr:nth-child(even) { background: var(--bg-card); }
.preview-note { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.4rem; }
.preview-empty { font-size: 0.88rem; color: var(--text-secondary); padding: 1rem; text-align: center; }

/* content / FAQ */
.tool-links { display: flex; gap: 1rem; flex-wrap: wrap; padding: 1rem 0; border-top: 1px solid var(--border); margin-bottom: 1.5rem; }
.tool-links a { color: var(--accent); text-decoration: none; font-size: 0.9rem; font-weight: 500; }
.tool-links a:hover { text-decoration: underline; }
.content-section { margin-bottom: 2.5rem; }
.content-section h2 { font-size: 1.3rem; margin-bottom: 0.75rem; }
.content-section h3 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
.content-section p, .content-section li { color: var(--text-secondary); margin-bottom: 0.6rem; }
.content-section ul, .content-section ol { padding-left: 1.25rem; margin-bottom: 1rem; }
.content-section code { background: var(--bg-card); padding: 0.15em 0.4em; border-radius: 3px; font-size: 0.88em; border: 1px solid var(--border); }
.content-section pre { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; overflow-x: auto; font-size: 0.85rem; margin-bottom: 1rem; }

/* breadcrumb (scenario pages) */
.breadcrumb { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 1rem; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

footer { background: var(--footer-bg); border-top: 1px solid var(--border); padding: 1.5rem; text-align: center; font-size: 0.85rem; color: var(--text-secondary); }
footer a { color: var(--accent); text-decoration: none; margin: 0 0.5rem; }
footer a:hover { text-decoration: underline; }
