/* ─────────────────────────────────────────
   leads-crm / css / style.css
   ───────────────────────────────────────── */

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

/* Variables */
:root {
  --bg:           #f5f4f0;
  --surface:      #ffffff;
  --border:       #e2e0d8;
  --text:         #1a1a18;
  --muted:        #6b6b67;
  --accent:       #1a1a18;

  --green-bg:     #eaf3de;  --green-txt:  #3b6d11;
  --amber-bg:     #faeeda;  --amber-txt:  #854f0b;
  --blue-bg:      #e6f1fb;  --blue-txt:   #185fa5;
  --red-bg:       #faece7;  --red-txt:    #993c1d;
  --gray-bg:      #f1efe8;  --gray-txt:   #5f5e5a;
  --purple-bg:    #eeedfe;  --purple-txt: #534ab7;

  --radius:       10px;
  --radius-sm:    6px;
}

/* Base */
body {
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* Layout */
.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.muted { color: var(--muted); }

/* ── Header ── */
.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}
.app-header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.app-header p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}
.ai-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--purple-bg);
  color: var(--purple-txt);
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  margin-top: 2px;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

/* ── API Key ── */
.api-key-section { margin-bottom: 1.5rem; }
.field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}
.api-key-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.api-key-row input {
  flex: 1;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 13px;
  font-family: 'DM Mono', 'Courier New', monospace;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.api-key-row input:focus { border-color: var(--accent); }
.field-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}
.field-note a { color: var(--blue-txt); text-decoration: none; }
.field-note a:hover { text-decoration: underline; }

/* ── Alert ── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 1rem;
}
.alert-error { background: var(--red-bg);  color: var(--red-txt);  border: 1px solid #f0997b; }
.alert-info  { background: var(--blue-bg); color: var(--blue-txt); border: 1px solid #85b7eb; }
.alert-success { background: var(--green-bg); color: var(--green-txt); border: 1px solid #97c459; }

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface);
  margin-bottom: 1.5rem;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: #fafaf8;
}
.upload-zone input[type="file"] { display: none; }
.upload-icon { font-size: 32px; margin-bottom: 10px; }
.upload-zone h3 { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.upload-zone p  { font-size: 13px; color: var(--muted); }
.hint {
  display: inline-block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 12px;
}

/* ── Progress ── */
.progress-section { margin-bottom: 1.5rem; }
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 500;
}
.progress-bar-track {
  background: var(--bg);
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
}
.progress-bar-fill {
  background: var(--accent);
  height: 100%;
  border-radius: 20px;
  transition: width 0.3s ease;
  width: 0%;
}
.progress-log {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  max-height: 100px;
  overflow-y: auto;
}
.progress-log div {
  padding: 3px 0;
  border-bottom: 0.5px solid var(--border);
}
.progress-log div:last-child { border-bottom: none; }
.log-keep   { color: var(--green-txt) !important; }
.log-remove { color: var(--red-txt)   !important; }

/* ── Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.s-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.s-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
}
.s-active  .s-value { color: var(--green-txt); }
.s-removed .s-value { color: var(--red-txt); }

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.filter-bar input,
.filter-bar select {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.filter-bar input { flex: 1; min-width: 180px; }
.filter-bar input:focus,
.filter-bar select:focus { border-color: var(--accent); }

/* ── Info Banner ── */
.info-banner {
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red-txt);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 1rem;
}

/* ── Table ── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table { min-width: 700px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafaf8; }

.td-num   { color: var(--muted); font-size: 12px; width: 40px; }
.td-name  { font-weight: 500; }
.td-phone { font-family: 'DM Mono', 'Courier New', monospace; font-size: 13px; }
.td-email { font-size: 13px; }
.td-email a { color: var(--blue-txt); text-decoration: none; }
.td-email a:hover { text-decoration: underline; }
.td-desc,
.td-reason {
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.td-reason { font-style: italic; }

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.badge-callback   { background: var(--blue-bg);  color: var(--blue-txt);  }
.badge-nopick     { background: var(--amber-bg); color: var(--amber-txt); }
.badge-interested { background: var(--green-bg); color: var(--green-txt); }
.badge-followup   { background: var(--amber-bg); color: var(--amber-txt); }
.badge-other      { background: var(--gray-bg);  color: var(--gray-txt);  }

/* ── Buttons ── */
.btn {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { opacity: 0.85; background: var(--accent); }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  font-size: 14px;
}
.empty-icon { font-size: 32px; margin-bottom: 10px; }

/* ── Tab Navigation ── */
.tab-nav {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab-btn {
  padding: 9px 20px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
  position: relative;
  bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-btn:hover { color: var(--text); background: #f0efe8; }
.tab-btn.tab-active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  border-bottom-color: var(--surface);
}
.tab-pane { display: none; }
.tab-pane.tab-visible { display: block; }
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--green-bg);
  color: var(--green-txt);
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 20px;
  padding: 0 4px;
}

/* ── Follow Up Tab ── */
.fu-email-card { margin-bottom: 1.5rem; }
.fu-email-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.fu-email-row input[type="email"] {
  flex: 1;
  min-width: 220px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.fu-email-row input[type="email"]:focus { border-color: var(--accent); }
.field-note code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: 'DM Mono', 'Courier New', monospace;
}

/* datetime-local picker in follow-up table */
.dt-picker {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  padding: 0 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  width: 180px;
  transition: border-color 0.15s;
}
.dt-picker:focus { border-color: var(--accent); }

/* Action buttons in follow-up table */
.td-actions { white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.btn-schedule {
  font-size: 11px;
  height: 28px;
  padding: 0 8px;
}
.btn-wa {
  font-size: 15px;
  height: 28px;
  width: 28px;
  padding: 0;
  background: #e8faf0;
  color: #1a7a4a;
  border: 1px solid #b2dfc5;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-wa:hover { background: #cdf0df; }
.btn-scheduled {
  background: var(--green-bg) !important;
  color: var(--green-txt) !important;
  border-color: #97c459 !important;
  cursor: default;
}
.btn-del {
  font-size: 13px;
  height: 28px;
  width: 28px;
  padding: 0;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
}
.btn-del:hover { color: var(--red-txt); background: var(--red-bg); border-color: #f0997b; }

/* ISO datetime display */
.dt-wrap { display: flex; flex-direction: column; gap: 2px; }
.dt-iso  { font-size: 10px; color: var(--muted); font-family: 'DM Mono','Courier New',monospace; letter-spacing: 0.02em; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .stats-row .stat-card:nth-child(3) { grid-column: 1 / -1; }
  .app-header { flex-direction: column; align-items: flex-start; }
  .td-desc, .td-reason { display: none; }
  .dt-picker { width: 150px; }
}
