/* =============================================
   LeadFlow CRM - style.css
   ============================================= */

/* RESET & VARIABLES */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --card: #fafaf7;
  --border: #e8e4dc;
  --text: #1a1814;
  --muted: #8a8478;
  --new: #2563eb;
  --new-bg: #eff6ff;
  --contacted: #d97706;
  --contacted-bg: #fffbeb;
  --converted: #16a34a;
  --converted-bg: #f0fdf4;
  --accent: #e85d2f;
  --accent2: #1a1814;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Instrument Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ─── LOGIN ─────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text);
  position: fixed;
  inset: 0;
  z-index: 1000;
  transition: opacity 0.5s, visibility 0.5s;
}
#login-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.login-box {
  background: var(--bg);
  border-radius: 24px;
  padding: 3rem;
  width: 420px;
  box-shadow: 0 40px 100px rgba(0,0,0,0.4);
}
.login-logo {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.login-logo span { color: var(--accent); }
.login-sub { color: var(--muted); font-size: 0.88rem; margin-bottom: 2rem; }
.login-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 0.4rem;
}
.login-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-family: 'Instrument Sans', sans-serif;
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
}
.login-input:focus { border-color: var(--accent); }
.login-btn {
  width: 100%;
  padding: 0.9rem;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}
.login-btn:hover { background: #333; }
.login-hint { font-size: 0.78rem; color: var(--muted); text-align: center; margin-top: 1rem; }
.login-err { color: #e53e3e; font-size: 0.82rem; margin-bottom: 0.75rem; display: none; }

/* ─── APP SHELL ─────────────────────────────── */
#app { display: none; min-height: 100vh; }
#app.visible { display: block; }

/* ─── LAYOUT ────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ───────────────────────────────── */
.sidebar {
  width: 260px;
  background: var(--text);
  color: var(--bg);
  padding: 1.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
}
.sidebar-logo {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  padding: 0 0.5rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sidebar-logo .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(245,243,238,0.6);
  transition: all 0.2s;
  margin-bottom: 0.25rem;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: 'Instrument Sans', sans-serif;
}
.nav-item:hover { color: var(--bg); background: rgba(255,255,255,0.08); }
.nav-item.active { color: var(--bg); background: rgba(255,255,255,0.13); }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.sidebar-bottom {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.logout-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.88rem;
  color: rgba(245,243,238,0.5);
  border: none;
  background: none;
  width: 100%;
  font-family: 'Instrument Sans', sans-serif;
  transition: color 0.2s;
}
.logout-btn:hover { color: var(--bg); }

/* ─── MAIN ──────────────────────────────────── */
.main { margin-left: 260px; padding: 2rem 2.5rem; flex: 1; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}
.page-title {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 800;
  font-size: 1.75rem;
}
.add-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.add-btn:hover { opacity: 0.88; }

/* ─── STATS ROW ─────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
}
.stat-label-sm {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}
.stat-num {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 800;
  font-size: 2rem;
}
.stat-sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }

/* ─── FILTERS ───────────────────────────────── */
.filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.filter-btn {
  padding: 0.5rem 1rem;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Instrument Sans', sans-serif;
}
.filter-btn.active,
.filter-btn:hover {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}
.search-box {
  padding: 0.5rem 1rem;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
  outline: none;
  font-family: 'Instrument Sans', sans-serif;
  color: var(--text);
  min-width: 220px;
  transition: border-color 0.2s;
  margin-left: auto;
}
.search-box:focus { border-color: var(--text); }

/* ─── TABLE ─────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead { background: var(--card); }
th {
  padding: 0.9rem 1.25rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #faf9f6; }
.lead-name { font-weight: 600; font-size: 0.92rem; }
.lead-email { color: var(--muted); font-size: 0.82rem; }

/* ─── STATUS BADGES ─────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge-new { background: var(--new-bg); color: var(--new); }
.badge-contacted { background: var(--contacted-bg); color: var(--contacted); }
.badge-converted { background: var(--converted-bg); color: var(--converted); }

/* ─── ACTION BUTTONS ────────────────────────── */
.action-btns { display: flex; gap: 0.5rem; }
.action-btn {
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  font-family: 'Instrument Sans', sans-serif;
  transition: all 0.2s;
  color: var(--text);
}
.action-btn:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
.action-btn.danger:hover { background: #e53e3e; color: #fff; border-color: #e53e3e; }

/* ─── EMPTY STATE ───────────────────────────── */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--muted); }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }

/* ─── MODAL ─────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,24,20,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--surface);
  border-radius: 20px;
  padding: 2rem;
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.25s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-title {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}

/* ─── FORM ──────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: 'Instrument Sans', sans-serif;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus { border-color: var(--accent); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}
.btn-cancel {
  padding: 0.7rem 1.5rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: none;
  cursor: pointer;
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--muted);
  transition: all 0.2s;
}
.btn-cancel:hover { border-color: var(--text); color: var(--text); }
.btn-save {
  padding: 0.7rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  transition: opacity 0.2s;
}
.btn-save:hover { opacity: 0.88; }

/* ─── NOTES PANEL ───────────────────────────── */
.notes-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.notes-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}
.note-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.5;
}
.note-date { font-size: 0.72rem; color: var(--muted); margin-top: 0.25rem; }
.note-input-row { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.note-input {
  flex: 1;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Instrument Sans', sans-serif;
  font-size: 0.85rem;
  outline: none;
  background: var(--bg);
  color: var(--text);
}
.note-input:focus { border-color: var(--accent); }
.note-add-btn {
  padding: 0.6rem 1rem;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 500;
}

/* ─── DASHBOARD CARDS ───────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
}
.dash-card-title {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 1.25rem;
}

/* ─── PIPELINE ──────────────────────────────── */
.pipeline-bar {
  display: flex;
  height: 10px;
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.pipeline-seg { transition: flex 0.5s ease; }
.pipeline-legend { display: flex; flex-direction: column; gap: 0.6rem; }
.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}
.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 0.5rem;
  display: inline-block;
}

/* ─── RECENT LEADS ──────────────────────────── */
.recent-lead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.recent-lead:last-child { border-bottom: none; }

/* ─── PAGE VISIBILITY ───────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ─── TOAST ─────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem; right: 2rem;
  background: var(--text);
  color: var(--bg);
  padding: 0.85rem 1.5rem;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 999;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ─── RESPONSIVE ────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; padding: 1.25rem; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
