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

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────── */
#app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
}

.logo-icon {
  font-size: 22px;
}

.header-nav {
  display: flex;
  gap: 4px;
}

.nav-btn {
  background: none;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.nav-btn:hover { background: var(--bg); color: var(--text); }
.nav-btn.active { background: var(--primary); color: #fff; }

/* ── Main Content ────────────────────────────────────────────────── */
#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.card-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ── Form Elements ───────────────────────────────────────────────── */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { opacity: 0.9; }

.btn-danger {
  background: var(--error);
  color: #fff;
}
.btn-danger:hover { opacity: 0.9; }

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Input Section ───────────────────────────────────────────────── */
.url-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.url-input-row input {
  flex: 1;
}

.input-sources {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #eef2ff;
  color: var(--primary);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

/* ── Loading ─────────────────────────────────────────────────────── */
.loading-screen {
  text-align: center;
  padding: 80px 20px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 24px;
}

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

.loading-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.loading-subtext {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── Review Screen ───────────────────────────────────────────────── */
.review-section {
  margin-bottom: 24px;
}

.review-section h3 {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.services-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.service-item {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.service-item input,
.service-item textarea {
  background: var(--surface);
}

.trust-signals-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trust-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
}

.trust-tag button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
}

/* ── Preview Screen ──────────────────────────────────────────────── */
.preview-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.viewport-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.viewport-btn {
  padding: 6px 14px;
  border: none;
  background: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.viewport-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.preview-frame-wrapper {
  background: #e2e8f0;
  border-radius: var(--radius);
  padding: 4px;
  display: flex;
  justify-content: center;
  min-height: 600px;
  transition: all 0.3s;
}

.preview-frame-wrapper iframe {
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: #fff;
  width: 100%;
  height: 800px;
  transition: width 0.3s;
}

.preview-frame-wrapper.mobile iframe {
  width: 375px;
  box-shadow: var(--shadow-lg);
}

.share-link-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  margin-top: 16px;
}

.share-link-box input {
  flex: 1;
  border-color: #a7f3d0;
}

/* ── Client Log ──────────────────────────────────────────────────── */
.client-table {
  width: 100%;
  border-collapse: collapse;
}

.client-table th,
.client-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.client-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.sent { background: #dbeafe; color: #1d4ed8; }
.status-badge.viewed { background: #fef3c7; color: #92400e; }
.status-badge.sold { background: #d1fae5; color: #065f46; }

/* ── Settings ────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  gap: 20px;
}

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ── Empty State ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner { padding: 0 16px; }
  #app { padding: 20px 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .service-item { grid-template-columns: 1fr; }
  .preview-controls { flex-direction: column; align-items: stretch; }
  .url-input-row { flex-direction: column; }
}

/* ── Step Indicator ──────────────────────────────────────────────── */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 28px;
  padding: 0 20px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
}

.step.active .step-num { background: var(--primary); color: #fff; }
.step.completed .step-num { background: var(--success); color: #fff; }

.step.active { color: var(--text); font-weight: 600; }
.step.completed { color: var(--success); }

.step-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  flex-shrink: 0;
}

.step-line.completed { background: var(--success); }

/* ── Toast Notifications ─────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 72px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease-out, toastOut 0.25s ease-in forwards;
  animation-delay: 0s, 3s;
  max-width: 380px;
}

.toast-success { background: #065f46; color: #fff; }
.toast-error { background: #991b1b; color: #fff; }
.toast-info { background: #1e40af; color: #fff; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); }
}

/* ── Loading Enhancements ────────────────────────────────────────── */
.loading-elapsed {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 16px;
  font-variant-numeric: tabular-nums;
}

.loading-tips {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  font-style: italic;
}

/* ── Preview Enhancements ────────────────────────────────────────── */
.preview-frame-wrapper.tablet iframe {
  width: 768px;
  box-shadow: var(--shadow-lg);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.preview-title {
  font-size: 18px;
  font-weight: 700;
}

.preview-business-name {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 8px;
}

/* ── Character Count ─────────────────────────────────────────────── */
.char-count {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  margin-top: 4px;
}

.char-count.warn { color: var(--warning); }
.char-count.good { color: var(--success); }

/* ── Example Data Button ─────────────────────────────────────────── */
.example-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.example-chip {
  padding: 5px 12px;
  background: #eef2ff;
  color: var(--primary);
  border: 1px solid #c7d2fe;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.example-chip:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── Client Actions ──────────────────────────────────────────────── */
.client-actions {
  display: flex;
  gap: 6px;
}

.status-select {
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ── Dashboard stats ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 4px;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.1;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pipeline-tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: capitalize;
}

.pipeline-tag strong { color: var(--text); }
.pipeline-new { border-color: #bfdbfe; background: #eff6ff; color: #1e40af; }
.pipeline-contacted { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.pipeline-qualified { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.pipeline-closed { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.pipeline-lost { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.pipeline-open { border-color: #bfdbfe; background: #eff6ff; color: #1e40af; }
.pipeline-in_progress { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.pipeline-done { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }

/* Activity list */
.activity-list {
  list-style: none;
  padding: 0;
}

.activity-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.activity-list li:last-child { border-bottom: none; }

.activity-kind {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.activity-kind.lead { background: #dbeafe; color: #1d4ed8; }
.activity-kind.edit { background: #fef3c7; color: #92400e; }

.activity-ts {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Fade transition ─────────────────────────────────────────────── */
.fade-in {
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
