@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700;800;900&family=DM+Sans:wght@400;500;600&display=swap');

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

/* ── Variables ───────────────────────────────────────────── */
:root {
  --brand:      #2563eb;
  --brand-d:    #1d4ed8;
  --brand-dim:  rgba(37,99,235,0.1);
  --dark:       #1e3a8a;
  --dark-2:     #1e40af;
  --text:       #0f172a;
  --muted:      #64748b;
  --border:     #e2e8f0;
  --bg:         #f0f6ff;
  --white:      #ffffff;
  --radius:     8px;

  --green:  #15803d;
  --red:    #dc2626;
  --amber:  #d97706;
  --blue:   #2563eb;

  --font-display: 'Barlow Condensed', sans-serif;
  --font-body:    'DM Sans', sans-serif;

  --sidebar-w: 220px;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App shell ───────────────────────────────────────────── */
.app-body {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--dark);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  border-right: 1px solid rgba(255,255,255,0.04);
}
.sidebar-brand {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 900;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-decoration: none;
  padding: 0.25rem 0.75rem;
  margin-bottom: 2.5rem;
  display: block;
}
.sidebar-brand span { color: var(--brand); }
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.sidebar-link svg { flex-shrink: 0; opacity: 0.6; }
.sidebar-link:hover { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.8); text-decoration: none; }
.sidebar-link:hover svg { opacity: 1; }
.sidebar-link.active { background: rgba(37,99,235,0.12); color: var(--brand); }
.sidebar-link.active svg { opacity: 1; color: var(--brand); }
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255,255,255,0.3);
  text-decoration: none;
  transition: color 0.15s;
  border-top: 1px solid rgba(255,255,255,0.05);
  padding-top: 1rem;
  margin-top: 0.5rem;
}
.sidebar-logout:hover { color: rgba(255,255,255,0.6); text-decoration: none; }

/* ── Main content ────────────────────────────────────────── */
.app-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  background: var(--bg);
}
.app-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
  font-family: var(--font-body);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--brand);
  color: white;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.btn-primary:hover { background: var(--brand-d); box-shadow: 0 4px 14px rgba(37,99,235,0.35); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm  { padding: 0.35rem 0.85rem; font-size: 0.72rem; }
.btn-lg  { padding: 0.8rem 2rem; font-size: 0.9rem; }
.btn-full { width: 100%; margin-top: 0.75rem; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: 0.875rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
}
.alert a { color: inherit; font-weight: 700; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
}
.card h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
  color: var(--text);
}
.card-header { margin-bottom: 1.25rem; }
.card-header h2 { margin-bottom: 0.25rem; }
.card-desc { font-size: 0.85rem; color: var(--muted); }
.card-action { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-body);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: white;
  box-shadow: 0 0 0 3px rgba(249,115,22,0.08);
}
.form-group textarea { resize: vertical; }
.hint { display: block; margin-top: 0.35rem; font-size: 0.75rem; color: var(--muted); line-height: 1.5; }

.inline-form { display: flex; gap: 0.5rem; align-items: center; }
.inline-form input { flex: 1; }

/* ── Auth pages ──────────────────────────────────────────── */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #dbeafe;
  padding: 2rem;
}
.auth-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(37,99,235,0.12);
}
.auth-logo {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}
.auth-logo span { color: var(--brand); }
.auth-card h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.75rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.auth-footer { margin-top: 1.25rem; text-align: center; font-size: 0.85rem; color: var(--muted); }
.center { display: block; text-align: center; margin-bottom: 1.5rem; }

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--text);
}
.page-header .subtitle { color: var(--muted); font-size: 0.85rem; margin-top: 0.35rem; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
  color: var(--muted);
}
.back-link:hover { color: var(--text); text-decoration: none; }

/* ── Stat grid ───────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.stat-card-highlight {
  border-color: var(--brand);
  background: #eff6ff;
}
.stat-number {
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-weight: 900;
  color: var(--brand);
  line-height: 1;
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.4rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.4;
}

/* ── Section header ──────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.875rem;
}
.section-header h2 {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* ── Lead list ───────────────────────────────────────────── */
.lead-list { display: flex; flex-direction: column; gap: 0.4rem; }
.lead-row {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.lead-row:hover {
  border-color: var(--brand);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  text-decoration: none;
  transform: translateY(-1px);
  color: var(--text);
}
.lead-row-new { border-left: 3px solid var(--brand); }
.lead-left { flex: 1; min-width: 0; }
.lead-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem; flex-shrink: 0; }
.lead-phone { font-weight: 600; font-size: 0.9rem; }
.lead-meta { display: flex; align-items: center; gap: 0.75rem; }
.lead-summary {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.15rem;
}
.lead-time { font-size: 0.7rem; color: var(--muted); }

.empty-state { text-align: center; padding: 3.5rem 2rem; color: var(--muted); }
.empty-icon { font-size: 2rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state p { font-size: 0.9rem; font-weight: 500; }
.empty-sub { font-size: 0.82rem; margin-top: 0.35rem; }
.empty-state-sm {
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  background: var(--bg);
  border-radius: 6px;
}

/* ── Filter bar ──────────────────────────────────────────── */
.filter-bar { display: flex; gap: 0.4rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.filter-tab {
  padding: 0.35rem 0.85rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid var(--border);
  background: white;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: all 0.15s;
}
.filter-tab:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); }
.filter-tab.active { background: var(--brand); color: white; border-color: var(--brand); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.badge-lg { font-size: 0.78rem; padding: 0.3rem 0.8rem; }
.badge-new       { background: #dbeafe; color: #1e40af; }
.badge-engaged   { background: #fef3c7; color: #92400e; }
.badge-contacted { background: #ede9fe; color: #5b21b6; }
.badge-won       { background: #dcfce7; color: #15803d; }
.badge-lost      { background: #fee2e2; color: #b91c1c; }

/* ── Lead detail ─────────────────────────────────────────── */
.lead-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.summary-text { font-size: 0.975rem; font-weight: 500; margin-bottom: 1.25rem; line-height: 1.6; }
.summary-fields { display: flex; flex-direction: column; }
.field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.field-row:last-child { border-bottom: none; }
.field-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.field-value { font-weight: 600; font-size: 0.875rem; }
.urgency-urgent   { color: var(--red); }
.urgency-soon     { color: var(--amber); }
.urgency-flexible { color: var(--green); }
.detail-fields { display: flex; flex-direction: column; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* ── Status options ──────────────────────────────────────── */
.status-options { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.status-option { cursor: pointer; }
.status-option input { display: none; }
.status-option .badge { cursor: pointer; opacity: 0.4; transition: opacity 0.15s; }
.status-option:hover .badge { opacity: 0.7; }
.status-option-active .badge { opacity: 1; box-shadow: 0 0 0 2px currentColor; }

/* ── Conversation ────────────────────────────────────────── */
.conversation { display: flex; flex-direction: column; gap: 0.75rem; }
.message { max-width: 72%; padding: 0.75rem 1rem; border-radius: 12px; }
.message-outbound {
  background: #f0f6ff;
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}
.message-inbound {
  background: var(--brand);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.message-body { font-size: 0.875rem; line-height: 1.55; }
.message-meta { font-size: 0.68rem; margin-top: 0.3rem; opacity: 0.55; }

/* ── Settings ────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
}
.toggle-label { font-weight: 600; font-size: 0.875rem; }
.toggle-desc { font-size: 0.8rem; color: var(--muted); margin-top: 0.1rem; }
.call-mode-options { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.5rem; }
.call-mode-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.15s;
}
.call-mode-option:hover { border-color: #93c5fd; }
.call-mode-option input[type="radio"] { margin-top: 0.2rem; flex-shrink: 0; }
.call-mode-option strong { font-size: 0.875rem; }
.call-mode-desc { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }
.call-mode-active { border-color: var(--brand) !important; background: #eff6ff; }

.toggle { position: relative; display: inline-block; width: 46px; height: 25px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5e1; border-radius: 999px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: ""; position: absolute;
  height: 19px; width: 19px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-slider { background: var(--brand); }
.toggle input:checked + .toggle-slider::before { transform: translateX(21px); }

.phone-list { display: flex; flex-direction: column; gap: 0.4rem; }
.phone-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.phone-number { font-weight: 700; font-size: 0.9rem; }
.phone-provider { font-size: 0.72rem; color: var(--muted); margin-top: 0.1rem; }

.webhook-list { display: flex; flex-direction: column; gap: 0.5rem; }
.webhook-row {
  background: #1e3a8a;
  border-radius: 6px;
  padding: 0.85rem 1rem;
}
.webhook-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255,255,255,0.45);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.webhook-url { font-size: 0.78rem; color: rgba(255,255,255,0.65); word-break: break-all; font-family: monospace; }

/* ── Call forwarding guide ───────────────────────────────── */
.how-number-works { display: flex; flex-direction: column; gap: 1.25rem; }
.forward-step { display: flex; gap: 1rem; align-items: flex-start; }
.forward-step-num {
  width: 26px; height: 26px; flex-shrink: 0;
  background: var(--brand); color: white;
  border-radius: 4px;
  font-size: 0.75rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin-top: 0.1rem;
  font-family: var(--font-display);
}
.forward-step strong { display: block; font-size: 0.875rem; margin-bottom: 0.25rem; }
.forward-step p { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.3rem; }
.forward-step em { color: var(--text); font-style: normal; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .app-main { margin-left: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .lead-detail-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; gap: 1rem; }
}
@media (max-width: 480px) {
  .app-container { padding: 1.5rem 1rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .lead-summary { display: none; }
}
