/* ─── AI Agent Builder Admin ─── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:        #f6f7fb;
  --surface:   #ffffff;
  --border:    #e4e7ee;
  --text:      #0f172a;
  --muted:     #64748b;
  --accent:    #2563eb;
  --accent-dk: #1d4ed8;
  --accent-soft: #eff4ff;
  --success:   #10b981;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --radius:    10px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow:    0 4px 14px rgba(15,23,42,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ─── Layout ─── */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}
.brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-dot {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
}
.nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a svg { width: 16px; height: 16px; flex-shrink: 0; }

.logout-link {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 16px;
}
.logout-link:hover { color: var(--danger); text-decoration: none; }

.main { padding: 32px 40px; max-width: 1280px; }

/* ─── Headings ─── */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-head h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ─── Cards ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 18px; }
.card h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.card .h-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }

/* ─── Forms ─── */
.form-grid { display: grid; gap: 18px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .form-grid.cols-2 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: -2px; }

.input, .textarea, .select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 90px; resize: vertical; font-family: inherit; line-height: 1.55; }
.textarea.large { min-height: 200px; }

.color-row { display: flex; align-items: center; gap: 12px; }
.color-row input[type="color"] { width: 46px; height: 38px; border: 1px solid var(--border); border-radius: 6px; padding: 2px; cursor: pointer; background: #fff; }
.color-row .input { flex: 1; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, transform 0.05s, box-shadow 0.12s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent-dk); text-decoration: none; }
.btn-secondary {
  background: var(--surface); border-color: var(--border); color: var(--text);
}
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-danger {
  background: #fff; border-color: #fecaca; color: var(--danger);
}
.btn-danger:hover { background: #fef2f2; text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ─── Tables ─── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.tbl th { background: var(--bg); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg); }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge.active  { background: #dcfce7; color: #15803d; }
.badge.paused  { background: #fef3c7; color: #a16207; }
.badge.muted   { background: var(--bg); color: var(--muted); }

/* ─── FAQ repeater ─── */
.faq-list { display: flex; flex-direction: column; gap: 12px; }
.faq-item {
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}
.faq-item .faq-fields { display: flex; flex-direction: column; gap: 8px; }
.faq-remove {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.faq-remove:hover { color: var(--danger); background: #fef2f2; }

/* ─── Flash ─── */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-weight: 500;
  font-size: 13px;
  border-left: 3px solid;
}
.flash.success { background: #ecfdf5; border-color: var(--success); color: #065f46; }
.flash.error   { background: #fef2f2; border-color: var(--danger);  color: #991b1b; }

/* ─── Embed code box ─── */
.embed-box {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px 18px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  position: relative;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.embed-copy {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}
.embed-copy:hover { background: rgba(255,255,255,0.18); }

/* ─── Stats row ─── */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 900px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }

/* ─── Login ─── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #f6f7fb 0%, #e9edf6 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 14px;
  padding: 36px 32px;
  box-shadow: 0 12px 40px rgba(15,23,42,0.08), 0 0 0 1px var(--border);
}
.login-card h1 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

/* ─── Conversation viewer ─── */
.conv-window {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  max-height: 500px;
  overflow-y: auto;
}
.conv-msg { margin-bottom: 10px; display: flex; }
.conv-msg .conv-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  max-width: 75%;
  font-size: 13.5px;
  line-height: 1.45;
}
.conv-msg.user { justify-content: flex-end; }
.conv-msg.user .conv-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.conv-msg.assistant .conv-bubble { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.conv-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ─── Empty state ─── */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty h3 { color: var(--text); margin-bottom: 6px; font-weight: 600; }
.empty p { font-size: 13.5px; }

/* ─── Mobile ─── */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { padding: 16px; flex-direction: row; overflow-x: auto; }
  .nav { flex-direction: row; }
  .main { padding: 20px; }
  .stat-row { grid-template-columns: 1fr 1fr; }
}
