/* ======== GENERIC COMPONENTS ======== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }

.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: .875rem;
  border: none;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
  text-decoration: none;
}
.btn-primary { background: var(--accent, #EA580C); color: #fff; }
.btn-primary:hover { background: var(--accent-hover, #C2410C); }
.btn-outline { background: var(--card); color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger-soft { background: #fef2f2; color: var(--red); border: 1.5px solid #fecaca; }
.btn-danger-soft:hover { background: #fee2e2; border-color: var(--red); }
.btn-sm { padding: 7px 14px; font-size: .8rem; }
.btn-block { width: 100%; text-align: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .875rem; }
input[type="text"], input[type="email"], input[type="url"], input[type="password"], input[type="search"], input[type="tel"], input[type="number"], select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  transition: border .15s;
  background: var(--card);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input[readonly] { background: var(--bg); cursor: default; }

.alert { padding: 11px 15px; border-radius: var(--radius); margin-bottom: 14px; font-size: .875rem; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.hidden { display: none !important; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Stats row */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 20px 20px; text-align: center; position: relative; overflow: hidden; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -12px rgba(15,23,42,.18); }
.stat-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; opacity: 0; transition: opacity 0.2s; }
.stat-card:hover::before { opacity: 1; }
.stat-icon { font-size: 1.4rem; margin-bottom: 6px; line-height: 1; }
.stat-card-blue::before { background: linear-gradient(90deg,#2563eb,#60a5fa); }
.stat-card-blue { background: linear-gradient(180deg,#fff 0%,#f0f7ff 100%); }
.stat-card-violet::before { background: linear-gradient(90deg,#7c3aed,#a78bfa); }
.stat-card-violet { background: linear-gradient(180deg,#fff 0%,#faf5ff 100%); }
.stat-card-green::before { background: linear-gradient(90deg,#059669,#34d399); }
.stat-card-green { background: linear-gradient(180deg,#fff 0%,#ecfdf5 100%); }
.stat-val { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-lbl { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* Bot card */
.bot-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  gap: 12px;
}
.bot-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); margin-right: 9px; display: inline-block; flex-shrink: 0; }
.bot-name { font-weight: 600; font-size: .9rem; }
.bot-meta { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.bot-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* Mobile: stack bot info above actions, full-width tap targets */
@media (max-width: 480px) {
  .bot-card { flex-direction: column; align-items: stretch; gap: 12px; }
  .bot-actions { width: 100%; justify-content: stretch; }
  .bot-actions .btn { flex: 1; min-height: 44px; }
}

/* Code snippet */
.snippet {
  background: #1e293b;
  color: #86efac;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-family: 'Courier New', monospace;
  font-size: .82rem;
  overflow-x: auto;
  position: relative;
  word-break: break-all;
  line-height: 1.6;
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .75rem;
  font-family: inherit;
}
.copy-btn:hover { background: rgba(255,255,255,.25); }

/* Plan badge */
.plan-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.plan-free { background: #f1f5f9; color: #475569; }
.plan-starter { background: #ecfdf5; color: #047857; }
.plan-pro { background: #eff6ff; color: var(--primary); }
.plan-business { background: #faf5ff; color: #7c3aed; }
.plan-enterprise { background: #1e293b; color: #fff; }
.plan-trial { background: #F8F5F1; color: #0F172A; border: 1px solid #E8DFD4; }
.plan-expired_trial { background: #fef2f2; color: #991b1b; }

/* Analytics chart */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding: 0 4px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.chart-bar { width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 4px; transition: height 0.3s ease; opacity: 0.85; }
.chart-bar:hover { opacity: 1; }
.chart-label { font-size: .7rem; color: var(--muted); white-space: nowrap; }
.chart-val { font-size: .72rem; color: var(--text); font-weight: 600; }

/* Top questions */
.q-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .875rem; }
.q-item:last-child { border-bottom: none; }
.q-rank { width: 24px; height: 24px; background: var(--bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; color: var(--muted); flex-shrink: 0; }

/* Onboarding step indicator */
/* Crawl progress (onboarding step 1) */
.crawl-progress { margin-top: 20px; }
.crawl-bar { height: 6px; background: #f1f5f9; border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.crawl-bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), #60a5fa); border-radius: 3px; transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); position: relative; overflow: hidden; }
.crawl-bar-fill::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.4) 50%, transparent 100%); animation: crawl-shimmer 1.4s infinite; }
@keyframes crawl-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.crawl-status { font-size: 0.875rem; color: var(--muted); text-align: center; }
.crawl-progress.hidden { display: none; }

.step-indicator { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 28px; }
.step-dot { width: 32px; height: 32px; border-radius: 50%; background: #f1f5f9; color: #94a3b8; font-size: .85rem; font-weight: 700; display: flex; align-items: center; justify-content: center; transition: background 0.3s ease, color 0.3s ease, transform 0.3s ease; position: relative; }
.step-dot::before { counter-increment: step; content: counter(step); }
.step-indicator { counter-reset: step; }
.step-dot.active { background: var(--primary); color: #fff; transform: scale(1.1); box-shadow: 0 4px 12px -2px rgba(37,99,235,.4); }
.step-dot.done { background: var(--green); color: #fff; }
.step-dot.done::before { content: '✓'; font-size: .95rem; }
.step-indicator > .step-dot + .step-dot { position: relative; }
.step-indicator > .step-dot + .step-dot::after { content: ''; position: absolute; right: 100%; top: 50%; width: 24px; height: 2px; background: #e2e8f0; transform: translateY(-50%); }

.success-box { background: #f0fdf4; border: 1.5px solid #bbf7d0; border-radius: var(--radius); padding: 20px; text-align: center; margin: 16px 0; }
.success-box h3 { color: var(--green); margin-bottom: 4px; }

/* Form helpers */
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 8px; }
.form-row > * { flex: 1; }

/* Danger zone */
.danger-zone { border: 1px solid #fecaca; border-radius: var(--radius); padding: 20px; margin-top: 20px; }
.danger-zone h3 { color: var(--red); font-size: .95rem; margin-bottom: 8px; }
.danger-zone p { font-size: .85rem; color: var(--muted); margin-bottom: 14px; }

/* API key field */
.api-key-row { display: flex; gap: 8px; }
.api-key-row input { font-family: 'Courier New', monospace; font-size: .82rem; }

/* Empty state */
.empty-state { text-align: center; padding: 32px 20px; color: var(--muted); }
.empty-state p { margin-bottom: 14px; }
.empty-state-premium { padding: 48px 24px; background: linear-gradient(180deg, #fff 0%, #f8fafc 100%); border-radius: var(--radius); text-align: center; }
.empty-state-premium .illust { font-size: 3.2rem; margin-bottom: 14px; line-height: 1; }
.empty-state-premium h3 { font-size: 1.15rem; font-weight: 700; color: var(--text); margin: 0 0 8px; }
.empty-state-premium p { color: var(--muted); font-size: .92rem; max-width: 420px; margin: 0 auto 18px; line-height: 1.55; }
.empty-state-premium .preview-mock { margin-top: 18px; max-width: 460px; margin-left: auto; margin-right: auto; padding: 14px; background: #fff; border: 1.5px dashed #cbd5e1; border-radius: 12px; text-align: left; font-size: .82rem; color: var(--muted); }
.empty-state-premium .preview-mock strong { color: var(--text); display: block; margin-bottom: 6px; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

/* Next-steps onboarding card (Overview) */
.next-steps-card { background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%); border: 1.5px solid #bfdbfe; border-radius: 14px; padding: 28px; margin-bottom: 20px; box-shadow: 0 8px 24px -12px rgba(37,99,235,.18); }
.next-steps-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.next-steps-emoji { font-size: 2rem; line-height: 1; }
.next-steps-header h3 { font-size: 1.1rem; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.next-steps-header p { font-size: .88rem; color: var(--muted); margin: 0; }
.next-steps-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.next-steps-list .step { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: #fff; border: 1.5px solid var(--border); border-radius: 10px; transition: border-color .15s, box-shadow .15s; }
.next-steps-list .step:hover { border-color: var(--primary); box-shadow: 0 4px 16px -8px rgba(37,99,235,.18); }
.next-steps-list .step.done { background: #f0fdf4; border-color: #bbf7d0; }
.next-steps-list .step .step-num { flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; background: #eff6ff; color: var(--primary); font-weight: 700; font-size: .9rem; display: flex; align-items: center; justify-content: center; }
.next-steps-list .step.done .step-num { background: var(--green); color: #fff; }
.next-steps-list .step > div { flex: 1; min-width: 0; }
.next-steps-list .step strong { display: block; font-size: .92rem; color: var(--text); margin-bottom: 2px; }
.next-steps-list .step span { display: block; font-size: .8rem; color: var(--muted); }
.next-steps-list .step .step-cta { flex-shrink: 0; font-size: .82rem; font-weight: 600; color: var(--primary); text-decoration: none; padding: 6px 12px; border-radius: 8px; transition: background .15s; white-space: nowrap; }
.next-steps-list .step .step-cta:hover { background: #eff6ff; }

/* Install platform tabs */
.install-tabs-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0; margin-bottom: 20px; overflow: hidden; }
.install-tabs { display: flex; gap: 4px; padding: 12px 12px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; background: #f8fafc; }
.install-tab { background: transparent; border: none; padding: 10px 16px; font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer; border-radius: 8px 8px 0 0; transition: color .15s, background .15s; font-family: inherit; position: relative; bottom: -1px; border: 1px solid transparent; border-bottom: none; }
.install-tab:hover { color: var(--text); background: rgba(255,255,255,.6); }
.install-tab.active { background: var(--card); color: var(--primary); border-color: var(--border); }
.install-tab-content { padding: 24px; }
.install-tab-content.hidden { display: none !important; }
.install-tab-content > p { font-size: .9rem; color: var(--muted); margin-bottom: 14px; }
.install-steps { list-style: none; counter-reset: istep; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 10px; }
.install-steps li { counter-increment: istep; padding: 10px 12px 10px 44px; background: #f8fafc; border-radius: 8px; font-size: .88rem; color: var(--text); position: relative; line-height: 1.5; }
.install-steps li::before { content: counter(istep); position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: .75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.install-alt { margin-top: 14px; padding: 12px 14px; background: #f0f7ff; border-left: 3px solid var(--primary); border-radius: 6px; font-size: .85rem; color: #475569; }
.install-alt strong { color: var(--primary); }

/* Snippet — fix copy-button overlap */
.snippet { padding-right: 88px !important; }
.snippet code { display: block; word-break: break-all; }

/* Sparkline + trend */
.stat-card .stat-extra { margin-top: 8px; min-height: 22px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.stat-trend { font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; display: inline-flex; align-items: center; gap: 3px; }
.stat-trend.up { color: #047857; background: #ecfdf5; }
.stat-trend.down { color: #b91c1c; background: #fef2f2; }
.stat-trend.flat { color: var(--muted); background: #f1f5f9; }
.stat-spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; }
.stat-spark span { width: 3px; background: var(--primary); border-radius: 1px; opacity: .6; transition: opacity .15s; min-height: 2px; }
.stat-card:hover .stat-spark span { opacity: 1; }

/* Conversations — premium empty state addition */
.convo-empty-illust { font-size: 3rem; margin-bottom: 14px; line-height: 1; }

/* Mobile responsive — stat row stacks, install tabs scroll */
@media (max-width: 720px) {
  .stats-row { grid-template-columns: 1fr; gap: 12px; }
  .install-tabs { flex-wrap: nowrap; overflow-x: auto; padding: 10px 10px 0; }
  .install-tab { white-space: nowrap; flex-shrink: 0; }
  .install-tab-content { padding: 18px; }
  .next-steps-list .step { flex-wrap: wrap; }
  .next-steps-list .step .step-cta { width: 100%; text-align: center; padding: 10px; background: #eff6ff; }
}

/* Focus visible */
:focus-visible { outline: 2px solid var(--primary, #2563eb); outline-offset: 2px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary, #2563eb); outline-offset: 2px; }
