/* ============================================
   NICHFLOW APP STYLES
   Complete styling for all screens
   ============================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple: #534AB7;
  --purple-dark: #26215C;
  --purple-light: #EEEDFE;
  --purple-mid: #AFA9EC;
  --teal: #0F6E56;
  --teal-light: #E1F5EE;
  --coral: #D85A30;
  --coral-light: #FAECE7;
  --amber: #854F0B;
  --amber-light: #FAEEDA;
  --text: #1a1a18;
  --muted: #5f5e5a;
  --border: #e8e6df;
  --bg: #f9f8f5;
  --white: #ffffff;
  --sidebar-width: 240px;
  --nav-height: 62px;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}

/* ── TYPOGRAPHY ─────────────────────────────── */
h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.2; }
h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
h3 { font-size: 17px; font-weight: 700; }
h4 { font-size: 14px; font-weight: 600; }
p { line-height: 1.65; }

/* ── AUTH PAGES (login/signup) ───────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--purple-dark);
  padding: 24px;
}

.auth-card {
  background: var(--white);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.15);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-logo img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.auth-logo-text {
  font-size: 22px;
  font-weight: 800;
  color: var(--purple-dark);
  letter-spacing: -0.5px;
}

.auth-logo-text span { color: var(--purple); }

.auth-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 28px;
}

.auth-link-text {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--muted);
}

.auth-link-text a {
  color: var(--purple);
  text-decoration: none;
  font-weight: 600;
}

.auth-note {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  color: #aaa;
}

.auth-note strong { color: var(--teal); }

/* ── FORMS ───────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-input:focus { border-color: var(--purple); }
.form-input::placeholder { color: #bbb; }

.form-select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  background: var(--white);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235f5e5a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  font-family: inherit;
}

.form-select:focus { border-color: var(--purple); outline: none; }

.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  outline: none;
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
  line-height: 1.6;
}

.form-textarea:focus { border-color: var(--purple); }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ── BUTTONS ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--purple); color: #fff; width: 100%; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost { background: transparent; color: var(--purple); border: 1.5px solid var(--purple); }
.btn-danger { background: #E24B4A; color: #fff; }
.btn-success { background: var(--teal); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 16px 32px; font-size: 16px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; border-radius: 8px; }

/* ── APP LAYOUT ──────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--purple-dark);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 50;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  margin-bottom: 32px;
}

.sidebar-logo img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.sidebar-logo-text {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.sidebar-logo-text span { color: var(--purple-mid); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #AFA9EC;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; }
.nav-item-icon { font-size: 18px; flex-shrink: 0; }

.sidebar-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 16px;
  margin-top: 16px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: 11px; color: #AFA9EC; }

/* ── MAIN CONTENT ────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  padding: 32px;
}

.page-header {
  margin-bottom: 28px;
}

.page-greeting {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

.page-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── CARDS ───────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.card-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ── DASHBOARD GRID ──────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dashboard-grid .card-full { grid-column: 1 / -1; }

/* ── ACTION PLAN CARD ────────────────────────── */
.action-plan-card {
  background: var(--purple-dark);
  border-radius: 14px;
  padding: 24px;
  color: #fff;
  grid-column: 1 / -1;
}

.action-plan-card .card-label { color: #AFA9EC; }
.action-plan-card .card-title { color: #fff; font-size: 18px; }

.action-block {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 16px;
  margin-top: 12px;
}

.action-block-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #AFA9EC;
  margin-bottom: 6px;
}

.action-block-content {
  font-size: 14px;
  color: #fff;
  line-height: 1.65;
}

.action-blocks-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

/* ── POST CARD ───────────────────────────────── */
.post-hook {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.4;
}

.post-body {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.post-cta {
  background: var(--purple-light);
  border: 1px solid var(--purple-mid);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--purple-dark);
  margin-top: 12px;
  font-weight: 600;
}

.post-cta::before {
  content: "CTA: ";
  color: var(--purple);
}

.post-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ── DM SCRIPT CARD ──────────────────────────── */
.dm-trigger {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--purple);
  background: var(--purple-light);
  border-radius: 6px;
  padding: 3px 8px;
  display: inline-block;
  margin-bottom: 8px;
}

.dm-script-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
  font-style: italic;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid var(--purple);
}

.dm-scripts-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── LEADS LIST ──────────────────────────────── */
.leads-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lead-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.2s;
}

.lead-item:hover { border-color: var(--purple-mid); }
.lead-name { font-size: 14px; font-weight: 700; color: var(--text); }
.lead-handle { font-size: 12px; color: var(--muted); }
.lead-platform { font-size: 11px; color: var(--muted); }

.stage-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: capitalize;
}

.stage-new { background: var(--purple-light); color: var(--purple); }
.stage-replied { background: #E6F1FB; color: #185FA5; }
.stage-interested { background: var(--teal-light); color: var(--teal); }
.stage-qualified { background: var(--amber-light); color: var(--amber); }
.stage-call_booked { background: #EAF3DE; color: #3B6D11; }
.stage-proposal_sent { background: #FAEEDA; color: #854F0B; }
.stage-won { background: var(--teal-light); color: var(--teal); }
.stage-lost { background: #FCEBEB; color: #A32D2D; }

/* ── ADD LEAD FORM ───────────────────────────── */
.add-lead-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── ONBOARDING ──────────────────────────────── */
.onboarding-page {
  min-height: 100vh;
  background: var(--bg);
  padding: 40px 24px;
}

.onboarding-inner {
  max-width: 620px;
  margin: 0 auto;
}

.onboarding-header {
  text-align: center;
  margin-bottom: 40px;
}

.onboarding-logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--purple-dark);
  margin-bottom: 24px;
}

.onboarding-logo span { color: var(--purple); }

.progress-bar {
  background: var(--border);
  border-radius: 20px;
  height: 6px;
  margin-bottom: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--purple);
  border-radius: 20px;
  transition: width 0.4s ease;
}

.progress-label {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.onboarding-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px;
}

.onboarding-step-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.onboarding-step-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 28px;
  line-height: 1.6;
}

.onboarding-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── ALERTS ──────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-error { background: #FCEBEB; color: #A32D2D; border: 1px solid #F7C1C1; }
.alert-success { background: var(--teal-light); color: var(--teal); border: 1px solid #5DCAA5; }
.alert-info { background: var(--purple-light); color: var(--purple-dark); border: 1px solid var(--purple-mid); }

/* ── LOADING STATES ──────────────────────────── */
.loading-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-spinner.dark {
  border-color: rgba(83,74,183,0.2);
  border-top-color: var(--purple);
}

@keyframes spin { to { transform: rotate(360deg); } }

.generating-state {
  text-align: center;
  padding: 40px 20px;
}

.generating-state .spinner-large {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.generating-state p {
  font-size: 14px;
  color: var(--muted);
}

/* ── EMPTY STATE ─────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--muted); max-width: 360px; margin: 0 auto 24px; line-height: 1.65; }

/* ── TABS ────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
  text-align: center;
}

.tab.active { background: var(--white); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.tab:hover:not(.active) { color: var(--text); }

/* ── MODAL ───────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal {
  background: var(--white);
  border-radius: 20px;
  padding: 32px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.modal-sub { font-size: 14px; color: var(--muted); margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; justify-content: flex-end; }

/* ── ANGLE CARDS ─────────────────────────────── */
.angles-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.angle-card {
  padding: 16px 18px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.angle-card:hover { border-color: var(--purple-mid); background: var(--purple-light); }
.angle-card.selected { border-color: var(--purple); background: var(--purple-light); }
.angle-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.angle-pain { font-size: 13px; color: var(--muted); }
.angle-goal { font-size: 12px; color: var(--purple); margin-top: 6px; font-weight: 600; }

/* ── PIPELINE STAGES (simple) ────────────────── */
.stage-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.stage-option {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--muted);
  transition: all 0.15s;
  font-family: inherit;
}

.stage-option:hover { border-color: var(--purple-mid); color: var(--purple); }
.stage-option.active { border-color: var(--purple); background: var(--purple-light); color: var(--purple); }

/* ── UTILITIES ───────────────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--muted); font-size: 13px; }
.text-sm { font-size: 13px; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── RESPONSIVE ──────────────────────────────── */
@media(max-width: 900px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 20px 16px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .action-blocks-row { grid-template-columns: 1fr; }
  .add-lead-form { grid-template-columns: 1fr; }
}

@media(max-width: 600px) {
  .auth-card { padding: 28px 20px; }
  .onboarding-card { padding: 24px 20px; }
}