/* fc-renderer.css
   Styles for the FC+UID form renderer.
   Works standalone in browser or inside WebView2.
   Uses CSS custom properties so host apps can theme it.
*/

:root {
  --fc-font:        system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fc-mono:        'Cascadia Code', 'Consolas', monospace;
  --fc-bg:          #f5f5f3;
  --fc-surface:     #ffffff;
  --fc-border:      #e0e0de;
  --fc-text:        #1a1a1a;
  --fc-text-muted:  #666;
  --fc-text-hint:   #999;
  --fc-accent:      #222;
  --fc-danger:      #c0392b;
  --fc-success:     #27ae60;
  --fc-brand:       #0f6d69;
  --fc-radius-sm:   4px;
  --fc-radius:      8px;
  --fc-radius-lg:   10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--fc-font);
  font-size: 14px;
  background: var(--fc-bg);
  color: var(--fc-text);
  min-height: 100vh;
}

/* ── Root ──────────────────────────────────────────────────────── */

#fc-root { padding: 16px; }

/* ── Tabs ──────────────────────────────────────────────────────── */

.fc-tab-bar {
  display: flex;
  border-bottom: 1px solid var(--fc-border);
  background: var(--fc-surface);
  border-radius: var(--fc-radius-lg) var(--fc-radius-lg) 0 0;
  padding: 0 8px;
  margin-bottom: 0;
}

.fc-tab-btn {
  font-family: var(--fc-font);
  font-size: 13px;
  padding: 10px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--fc-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: -1px;
  transition: color 0.15s;
}

.fc-tab-btn:hover { color: var(--fc-text); }
.fc-tab-btn.active { color: var(--fc-text); border-bottom-color: var(--fc-text); font-weight: 500; }
.fc-tab-btn.fc-tab-err { color: var(--fc-danger); }
.fc-tab-btn.fc-tab-err::after { content: " \25CF"; font-size: 9px; vertical-align: middle; }
.fc-validate-btn {
  margin-left: auto;
  align-self: center;
  padding: 4px 12px;
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  background: var(--fc-surface);
  color: var(--fc-text);
  cursor: pointer;
  font-size: 13px;
}
.fc-validate-btn:hover { background: var(--fc-border); }

.fc-panes {
  background: var(--fc-surface);
  border: 1px solid var(--fc-border);
  border-top: none;
  border-radius: 0 0 var(--fc-radius-lg) var(--fc-radius-lg);
  padding: 20px;
}

.fc-tab-pane { display: none; }
.fc-tab-pane.active { display: block; }

/* ── Grid ──────────────────────────────────────────────────────── */

.fc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  align-items: start;
}

/* ── Fields ────────────────────────────────────────────────────── */

.fc-field { display: flex; flex-direction: column; gap: 5px; }
.fc-field--block { grid-column: 1 / -1; }

.fc-label {
  font-size: 12px;
  color: var(--fc-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.fc-req { color: var(--fc-danger); line-height: 1; }

.fc-type {
  font-size: 10px;
  font-family: var(--fc-mono);
  color: var(--fc-text-hint);
}

.fc-hint {
  font-size: 11px;
  color: var(--fc-text-hint);
  margin-top: 2px;
}

/* ── Inputs ────────────────────────────────────────────────────── */

input[type=text]:not(.dx-texteditor-input),
input[type=number]:not(.dx-texteditor-input),
input[type=date]:not(.dx-texteditor-input),
select,
textarea:not(.dx-texteditor-input) {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  font-family: var(--fc-font);
  font-size: 13px;
  background: var(--fc-surface);
  color: var(--fc-text);
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus { border-color: #888; }
textarea { resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--fc-accent); }
input.fc-err, select.fc-err, textarea.fc-err { border-color: var(--fc-danger) !important; }

/* ── Date picker ───────────────────────────────────────────────── */

.fc-date { position: relative; display: block; }
.fc-date input[type=date] { padding-right: 36px; }
.fc-date input[type=date]::-webkit-calendar-picker-indicator { display: none; }
.fc-date-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: var(--fc-radius-sm);
  background: transparent;
  color: var(--fc-text-muted);
  cursor: pointer;
}
.fc-date-btn:hover { background: var(--fc-bg); color: var(--fc-brand); }

.fc-cal {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  width: 260px;
  padding: 10px;
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  background: var(--fc-surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  font-family: var(--fc-font);
  font-size: 13px;
  color: var(--fc-text);
}
.fc-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.fc-cal-title { font-weight: 600; }
.fc-cal-nav {
  width: 28px;
  height: 28px;
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius-sm);
  background: var(--fc-surface);
  color: var(--fc-text);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.fc-cal-nav:hover { border-color: var(--fc-brand); color: var(--fc-brand); }
.fc-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.fc-cal-weekday {
  padding: 4px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--fc-text-muted);
}
.fc-cal-day {
  height: 30px;
  border: 1px solid transparent;
  border-radius: var(--fc-radius-sm);
  background: transparent;
  color: var(--fc-text);
  font: inherit;
  cursor: pointer;
}
.fc-cal-day:hover { background: var(--fc-bg); border-color: var(--fc-border); }
.fc-cal-other { color: var(--fc-text-hint); }
.fc-cal-today { border-color: var(--fc-brand); color: var(--fc-brand); font-weight: 600; }
.fc-cal-selected,
.fc-cal-selected:hover { background: var(--fc-brand); border-color: var(--fc-brand); color: #fff; font-weight: 600; }
.fc-cal-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--fc-border);
}
.fc-cal-link {
  padding: 2px 4px;
  border: none;
  background: none;
  color: var(--fc-brand);
  font: inherit;
  cursor: pointer;
}
.fc-cal-link:hover { text-decoration: underline; }

/* ── Radio / Checkbox groups ───────────────────────────────────── */

.fc-radio-group,
.fc-check-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.fc-radio-group label,
.fc-check-group label,
.fc-inline-check {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--fc-text);
}

/* ── Toggle ────────────────────────────────────────────────────── */

.fc-toggle-wrap { display: flex; align-items: center; gap: 10px; margin-top: 4px; }

.fc-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  display: inline-block;
  flex-shrink: 0;
}

.fc-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.fc-toggle-track {
  position: absolute;
  inset: 0;
  background: #ddd;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s;
}

.fc-toggle input:checked + .fc-toggle-track { background: var(--fc-accent); }

.fc-toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.fc-toggle input:checked ~ .fc-toggle-thumb { transform: translateX(18px); }
.fc-toggle-label { font-size: 13px; color: var(--fc-text-muted); }

/* ── Nested object ─────────────────────────────────────────────── */

.fc-nested-obj {
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  padding: 14px;
}

/* ── Array fact ────────────────────────────────────────────────── */

.fc-nested-arr {
  border: 1px dashed var(--fc-border);
  border-radius: var(--fc-radius);
  padding: 14px;
}

.fc-nested-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fc-text-muted);
}

.fc-array-rows { margin-bottom: 4px; }

.fc-array-row {
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius-sm);
  padding: 12px;
  margin-bottom: 8px;
}

.fc-row-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.fc-row-label { font-size: 11px; font-family: var(--fc-mono); color: var(--fc-text-hint); }

/* ── Badges ────────────────────────────────────────────────────── */

.fc-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: var(--fc-radius-sm);
  background: #f0f0f0;
  color: var(--fc-text-muted);
}

.fc-badge--obj   { background: #fef3e2; color: #7d4e00; }
.fc-badge--array { background: #e8f4fd; color: #1565c0; }

/* ── Buttons ───────────────────────────────────────────────────── */

button { cursor: pointer; font-family: var(--fc-font); }

.fc-btn-add {
  font-size: 12px;
  padding: 5px 12px;
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  background: #fafafa;
  color: var(--fc-text);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  transition: background 0.15s;
}

.fc-btn-add:hover { background: #f0f0f0; }

.fc-btn-remove {
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid #f5c6cb;
  border-radius: var(--fc-radius-sm);
  background: #fff;
  color: var(--fc-danger);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
}

.fc-btn-remove:hover { background: #fdf0f0; }

/* ── Action bar ────────────────────────────────────────────────── */

.fc-action-bar {
  position: sticky;
  bottom: 0;
  background: var(--fc-surface);
  border-top: 1px solid var(--fc-border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
}

.fc-btn-primary {
  padding: 8px 20px;
  border: none;
  border-radius: var(--fc-radius);
  background: var(--fc-accent);
  color: #fff;
  font-size: 13px;
  transition: opacity 0.15s;
}

.fc-btn-primary:hover { opacity: 0.85; }

.fc-btn-secondary {
  padding: 8px 16px;
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-radius);
  background: var(--fc-surface);
  color: var(--fc-text);
  font-size: 13px;
}

.fc-btn-secondary:hover { background: #f5f5f5; }

.fc-status {
  font-size: 12px;
  color: var(--fc-success);
}

.fc-status--error { color: var(--fc-danger); }
