/* FlowBot dashboard and builder styles. Chat widget styles live in chat.css. */
@import url("chat.css");

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1d2433;
  --muted: #6b7385;
  --border: #e1e5ee;
  --accent: #3b5bdb;
  --accent-dark: #2f49b5;
  --danger: #c92a2a;
  --ok: #2b8a3e;
  --warn: #b7791f;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 26px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
h4 { font-size: 14px; margin: 0 0 8px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; font-size: 18px; text-decoration: none; color: var(--text); }
.topnav { display: flex; gap: 16px; align-items: center; }

.container { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
.container.wide { max-width: 1400px; }
.container.narrow { max-width: 440px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.empty { padding: 32px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.warn { color: var(--warn); font-size: 13px; margin: 4px 0 8px; }

/* Buttons */
.button, button.button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  line-height: 1.3;
}
.button:hover { background: var(--accent-dark); }
.button.secondary { background: var(--surface); color: var(--accent); }
.button.secondary:hover { background: #eef2ff; }
.button.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.button.danger:hover { background: #fff0f0; }
.button.small { padding: 5px 10px; font-size: 13px; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
button.icon {
  font: inherit;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: default; }
form.inline { display: inline; }

/* Forms */
.form label, .field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  font: inherit;
  font-weight: 400;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.help { font-weight: 400; color: var(--muted); font-size: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 8px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; flex: 1; min-width: 180px; }
.form-row.tight { gap: 8px; align-items: center; }
.title-input { font-size: 22px !important; font-weight: 700 !important; border-color: transparent !important; padding-left: 0 !important; min-width: 280px; }
.title-input:hover, .title-input:focus { border-color: var(--border) !important; padding-left: 8px !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* Flash messages */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.flash-success { background: #ebfbee; border-color: #b2f2bb; color: var(--ok); }
.flash-error { background: #fff5f5; border-color: #ffc9c9; color: var(--danger); }

/* Page header */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumbs { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.public-link { margin: -4px 0 16px; font-size: 14px; overflow-wrap: anywhere; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f5; color: var(--muted); }
.badge-live, .status-completed { background: #ebfbee; color: var(--ok); }
.badge-warn { background: #fff4e6; color: var(--warn); }
.status-active { background: #e7f5ff; color: #1c7ed6; }
.status-abandoned { background: #f1f3f5; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); background: #fafbfd; }
.table tr:last-child td { border-bottom: 0; }
.actions { white-space: nowrap; }
.actions .button, .actions form { margin-right: 4px; }
.pager { display: flex; gap: 16px; justify-content: center; margin: 16px 0; }
.template-help { margin: 12px 0 0; padding-left: 18px; font-size: 13px; }

/* Landing */
.hero { text-align: center; padding: 64px 16px; }
.hero h1 { font-size: 40px; }
.lead { font-size: 18px; color: var(--muted); max-width: 620px; margin: 0 auto 24px; }

/* Builder */
.builder-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.preview { position: sticky; top: 16px; }
.preview-head { display: flex; justify-content: space-between; align-items: center; }
.preview-head h2 { margin: 0; }
.add-node { display: flex; gap: 12px; align-items: flex-end; }
.add-node label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.builder-status { min-height: 22px; font-size: 13px; margin: -6px 0 8px; color: var(--muted); }
.builder-status.ok { color: var(--ok); }
.builder-status.error { color: var(--danger); }
.node-card { padding: 0; }
.node-card.is-start { border-color: var(--accent); }
.node-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: #fafbfd; border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
.node-index { font-weight: 700; color: var(--muted); min-width: 20px; }
.spacer { flex: 1; }
.node-body { padding: 16px; }
.node-save { display: flex; justify-content: flex-end; }
.options-section { padding: 0 16px 16px; border-top: 1px dashed var(--border); padding-top: 12px; }
.option-row { display: grid; grid-template-columns: minmax(0, 2fr) 90px minmax(0, 2fr) auto; gap: 8px; align-items: end; padding: 8px 0; border-bottom: 1px solid #f0f2f6; }
.option-row .field { margin-bottom: 0; }
.option-row.new { border-bottom: 0; }
.row-actions { display: flex; gap: 4px; align-items: center; padding-bottom: 2px; }
.score-input { width: 90px; }
.type-message { background: #e7f5ff; color: #1c7ed6; }
.type-options { background: #f3f0ff; color: #6741d9; }
.type-question { background: #fff9db; color: #a67c00; }
.type-handoff { background: #fff4e6; color: var(--warn); }
.type-end { background: #ebfbee; color: var(--ok); }

/* Transcript */
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
.transcript { display: flex; flex-direction: column; gap: 8px; background: var(--chat-bg); padding: 16px; border-radius: 8px; }
.bubble-time { font-size: 11px; opacity: 0.7; margin-top: 4px; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; }
.details dt { color: var(--muted); font-size: 13px; }
.details dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 960px) {
  .builder-layout, .split { grid-template-columns: 1fr; }
  .preview { position: static; }
  .option-row { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
