/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-light: #eff6ff;
  --surface: #ffffff;
  --bg: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
}

html, body { height: 100%; font-family: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; }

h1, h2, h3, h4, h5, h6 { font-family: 'Ubuntu', sans-serif; font-weight: 300; color: #00ADBF; }

/* ─── Nav ─── */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 56px;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.nav-brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--brand);
  text-decoration: none;
  margin-right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-brand svg { width: 20px; height: 20px; }
.nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.nav a:hover, .nav a.active { background: var(--brand-light); color: var(--brand); }
.nav-spacer { flex: 1; }
.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.nav-user img { width: 28px; height: 28px; border-radius: 50%; }
.nav-badge {
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ─── Layout ─── */
.page { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.page-sm { max-width: 720px; margin: 0 auto; padding: 32px 24px; }

/* ─── Page header ─── */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 22px; }
.page-header p { color: var(--text-muted); margin-top: 4px; font-size: 14px; }

/* ─── Card ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: #BF1E5E; color: #fff; }
.btn-primary:hover { background: #A0194F; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ─── Forms ─── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-group label span.req { color: var(--danger); margin-left: 2px; }
.form-group small { color: var(--text-muted); font-size: 12px; margin-top: 4px; display: block; }
input[type=text], input[type=url], input[type=email], textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 90px; }
.radio-group, .checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.radio-group label, .checkbox-group label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-weight: 400;
  font-size: 14px;
  cursor: pointer;
}
.radio-group input, .checkbox-group input { margin-top: 2px; accent-color: var(--brand); }
.custom-input-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.custom-input-row input { flex: 1; }

/* ─── Alerts ─── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-info { background: var(--brand-light); color: var(--brand); border: 1px solid #bfdbfe; }

/* ─── Table ─── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); background: var(--bg); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ─── Stepper ─── */
.stepper { display: flex; gap: 0; margin-bottom: 28px; }
.step-item { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; }
.step-item:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.step-item.completed:not(:last-child)::after { background: var(--brand); }
.step-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
  position: relative;
}
.step-item.active .step-num { background: var(--brand); color: #fff; }
.step-item.completed .step-num { background: var(--success); color: #fff; }
.step-label { font-size: 12px; color: var(--text-muted); margin-top: 6px; text-align: center; }
.step-item.active .step-label { color: var(--brand); font-weight: 600; }

/* ─── Persona list ─── */
.persona-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.persona-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  position: relative;
  background: var(--bg);
}
.persona-item .remove-persona {
  position: absolute; top: 10px; right: 10px;
  background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 18px; line-height: 1;
}
.persona-item .remove-persona:hover { color: var(--danger); }

/* ─── Mode tabs ─── */
.mode-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.mode-tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s;
}
.mode-tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ─── Output panel ─── */
.output-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 200px;
  padding: 20px;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  font-family: inherit;
  position: relative;
}
.output-panel .placeholder {
  color: var(--text-muted);
  font-style: italic;
}
.output-actions { display: flex; gap: 8px; margin-top: 12px; }
.cursor-blink {
  display: inline-block;
  width: 2px; height: 16px;
  background: var(--brand);
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* ─── Loading spinner ─── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Login page ─── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 48px;
  text-align: center;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background .15s, box-shadow .15s;
}
.btn-google:hover { background: var(--bg); box-shadow: var(--shadow); }

/* ─── Client cards ─── */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.client-card h3 { font-size: 16px; }
.client-card .meta { font-size: 12px; color: var(--text-muted); }
.client-card .actions { margin-top: auto; padding-top: 12px; display: flex; gap: 8px; }

/* ─── Select ─── */
select { cursor: pointer; }

/* ─── Divider ─── */
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

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

/* ─── Floating copy button ─── */
.copy-btn {
  position: absolute; top: 12px; right: 12px;
  padding: 4px 10px; font-size: 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; color: var(--text-muted);
}
.copy-btn:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }

/* ─── AI prefill loading ─── */
#prefill-status { display: none; align-items: center; gap: 8px; font-size: 13px; color: var(--brand); margin-top: 8px; }

/* ─── Admin badge ─── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-user { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
