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

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #1a1a1a;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Admin layout ──────────────────────────────────────────────────────── */
.admin-page { background: #f3f4f6; min-height: 100vh; }

.admin-nav {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-brand { font-weight: 700; font-size: 1.1rem; }
.nav-brand a { color: inherit; }

.admin-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.page-header h1 { font-size: 1.6rem; font-weight: 700; }
.back-link { font-size: .85rem; color: #6b7280; display: block; margin-bottom: .25rem; }

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid #f3f4f6;
}

.empty-state { text-align: center; padding: 3rem; color: #6b7280; }

/* ─── Login ─────────────────────────────────────────────────────────────── */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-container .card {
  width: 100%;
  max-width: 380px;
}

.login-container h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.login-container .subtitle { color: #6b7280; margin-bottom: 1.5rem; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .5rem 1rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity .15s;
  white-space: nowrap;
}

.btn:hover { opacity: .85; text-decoration: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary { background: #2563eb; color: #fff; }
.btn-success { background: #22c55e; color: #fff; }
.btn-danger  { background: #ef4444; color: #fff; }
.btn-outline { background: transparent; color: #374151; border: 1px solid #d1d5db; }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; }

.btn-row { display: flex; gap: .75rem; flex-wrap: wrap; }

/* ─── Forms ─────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: .87rem; font-weight: 500; color: #374151; margin-bottom: .35rem; }

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: .9rem;
  font-family: inherit;
  background: #fff;
  transition: border-color .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

textarea { resize: vertical; }
.textarea-code { font-family: 'Courier New', monospace; font-size: .85rem; }

/* ─── Table ─────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; padding: .6rem .75rem; border-bottom: 2px solid #f3f4f6; }
.table td { padding: .75rem; border-bottom: 1px solid #f9fafb; }
.table tbody tr:hover { background: #fafafa; }
.table code { font-size: .82rem; background: #f3f4f6; padding: .15rem .4rem; border-radius: 4px; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .65rem;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-lg { font-size: .88rem; padding: .3rem .9rem; }
.badge-pending  { background: #f3f4f6; color: #6b7280; }
.badge-active   { background: #dcfce7; color: #16a34a; }
.badge-inactive { background: #fee2e2; color: #dc2626; }
.badge-error    { background: #ffedd5; color: #ea580c; }

/* ─── Info grid ─────────────────────────────────────────────────────────── */
.info-grid { display: grid; grid-template-columns: 140px 1fr; gap: .4rem .75rem; }
.info-grid dt { font-size: .85rem; color: #6b7280; font-weight: 500; }
.info-grid dd { font-size: .9rem; }

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: 6px; font-size: .9rem; margin-bottom: 1rem; }
.alert-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }

/* ─── Copy row ───────────────────────────────────────────────────────────── */
.copy-row { display: flex; gap: .5rem; }
.input-copy { flex: 1; font-size: .85rem; color: #374151; background: #f9fafb; }

/* ─── Conversations ─────────────────────────────────────────────────────── */
.conv-group { margin-bottom: 1.25rem; }
.conv-phone { font-size: .82rem; font-weight: 600; color: #374151; background: #f3f4f6; padding: .35rem .75rem; border-radius: 6px; margin-bottom: .5rem; }
.conv-msg { display: flex; gap: .5rem; align-items: baseline; padding: .3rem 0; font-size: .87rem; border-bottom: 1px solid #f9fafb; }
.conv-role { font-weight: 600; min-width: 50px; font-size: .78rem; text-transform: uppercase; color: #6b7280; }
.conv-user .conv-role { color: #2563eb; }
.conv-assistant .conv-role { color: #16a34a; }
.conv-text { flex: 1; color: #1a1a1a; }
.conv-time { font-size: .75rem; color: #9ca3af; white-space: nowrap; }

/* ─── Modal ─────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.modal-box { position: relative; z-index: 1; max-width: 460px; width: 100%; }
.modal-box h2 { margin-bottom: 1.25rem; }

/* ─── Onboarding layout ─────────────────────────────────────────────────── */
.onboarding-page {
  background: #f9fafb;
  min-height: 100vh;
  padding: 1rem;
}

.onboarding-container {
  max-width: 640px;
  margin: 0 auto;
  padding-bottom: 3rem;
}

.onboarding-header {
  text-align: center;
  padding: 2rem 0 1.5rem;
}

.logo-mark { font-size: 2.5rem; margin-bottom: .5rem; }
.onboarding-header h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.5rem; }

/* ─── Progress ───────────────────────────────────────────────────────────── */
.progress-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: .75rem;
}

.progress-step {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700;
  background: #e5e7eb; color: #9ca3af;
  border: 2px solid #e5e7eb;
  flex-shrink: 0;
}

.progress-step.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.progress-step.done   { background: #22c55e; color: #fff; border-color: #22c55e; }

.progress-line {
  width: 60px; height: 2px;
  background: #e5e7eb;
  flex-shrink: 0;
}
.progress-line.active { background: #22c55e; }
.progress-label { font-size: .85rem; color: #6b7280; }

/* ─── Tabs ───────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: .5rem; margin-bottom: 1.5rem; border-bottom: 2px solid #e5e7eb; }
.tab-btn {
  padding: .6rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: .9rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tab-btn.active { color: #2563eb; border-bottom-color: #2563eb; }
.tab-btn:hover { color: #2563eb; }

/* ─── Radio groups ───────────────────────────────────────────────────────── */
.radio-group { display: flex; flex-direction: column; gap: .6rem; }
.radio-label {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .75rem 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s;
}
.radio-label:has(input:checked) { border-color: #2563eb; background: #eff6ff; }
.radio-label input { margin-top: .2rem; flex-shrink: 0; }
.radio-text strong { display: block; font-size: .9rem; }
.radio-text small { color: #6b7280; font-size: .8rem; }

/* ─── FAQ items ─────────────────────────────────────────────────────────── */
.faq-item { border: 1px solid #e5e7eb; border-radius: 8px; padding: .75rem; margin-bottom: .75rem; }
.faq-item input { margin-bottom: .4rem; }

/* ─── Upload area ───────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed #d1d5db;
  border-radius: 10px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-area:hover { border-color: #2563eb; background: #eff6ff; }
.upload-icon { font-size: 2.5rem; margin-bottom: .75rem; }

.file-name-display {
  margin-top: .75rem;
  padding: .5rem .75rem;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  font-size: .88rem;
  color: #15803d;
}

/* ─── QR placeholder ────────────────────────────────────────────────────── */
.qr-placeholder {
  padding: 2rem;
  text-align: center;
  color: #6b7280;
}

/* ─── Instructions box ──────────────────────────────────────────────────── */
.instructions-box {
  background: #f3f4f6;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  text-align: left;
  margin: 1.5rem 0;
}
.instructions-box h3 { font-size: .95rem; margin-bottom: .75rem; }
.instructions-list { padding-left: 1.25rem; }
.instructions-list li { margin-bottom: .5rem; font-size: .9rem; }

/* ─── Success tips ──────────────────────────────────────────────────────── */
.success-tips { background: #f0fdf4; border-radius: 10px; padding: 1.25rem; }
.success-tips h3 { font-size: .95rem; margin-bottom: .75rem; color: #15803d; }
.success-tips ul { padding-left: 1.25rem; }
.success-tips li { margin-bottom: .4rem; font-size: .88rem; color: #374151; }

/* ─── Spinner ───────────────────────────────────────────────────────────── */
.spinner {
  width: 40px; height: 40px;
  border: 3px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Utils ─────────────────────────────────────────────────────────────── */
.text-muted { color: #6b7280; font-size: .88rem; }

/* ─── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .admin-container { padding: 1rem; }
  .info-grid { grid-template-columns: 1fr; }
  .info-grid dt { margin-top: .5rem; }
  .table { font-size: .85rem; }
  .btn-row { flex-direction: column; }
  .copy-row { flex-direction: column; }
}
