/* ─── LIVE LEAD ANIMATION ─── */

@keyframes fadeFromYellow {
  from { background-color: rgba(234, 179, 8, 0.18); }
  to   { background-color: transparent; }
}

.lead-card.is-new-arrival,
.lead-row.is-new-arrival {
  animation: fadeFromYellow 2.5s ease-out forwards;
}

/* ─── SF LOGO MARK ─── */

.sf-mark {
  --size:   1.3rem;
  --stroke: calc(var(--size) * 0.16);
  --radius: calc(var(--size) * 0.14);
  --top-color: var(--logo-top-dark);
  --bot-color: var(--logo-bot-dark);
  width: var(--size);
  height: var(--size);
  position: relative;
  flex-shrink: 0;
  display: inline-block;
}

.sf-mark::before, .sf-mark::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 50%;
}

.sf-mark::before {
  top: 0; left: 0;
  border-top:  var(--stroke) solid var(--top-color);
  border-left: var(--stroke) solid var(--top-color);
  border-top-left-radius: var(--radius);
}

.sf-mark::after {
  bottom: 0; right: 0;
  border-bottom: var(--stroke) solid var(--bot-color);
  border-right:  var(--stroke) solid var(--bot-color);
  border-bottom-right-radius: var(--radius);
}

.sf-wordmark {
  font-family: 'Manrope', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.04em;
  color: var(--logo-top-dark);
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
}

.sf-wordmark .sf-period { color: var(--logo-bot-dark); margin-left: 1px; }

/* ─── BADGE ─── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge.green  { background: var(--green-dim);        color: var(--green);  }
.badge.red    { background: rgba(239,68,68,0.10);    color: var(--red);    }
.badge.accent { background: var(--accent-dim);       color: var(--accent); }

/* ─── CARD ─── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  height: 100%;
  box-sizing: border-box;
}

.card-title    { color: var(--text-primary); font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.card-subtitle { color: var(--text-sec); font-size: 12px; margin-bottom: 16px; }

/* ─── SECTION HEAD (overview level) ─── */

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

.section-title { color: var(--text-primary); font-size: 16px; font-weight: 600; }

.view-all { color: var(--accent); font-size: 13px; font-weight: 500; cursor: pointer; }
.view-all:hover { opacity: 0.75; }

/* ─── SECTION HEADER (panel level) ─── */

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

.section-title-sm { font-size: 13px; font-weight: 500; color: var(--text-primary); }

.filter-buttons { display: flex; gap: 6px; }

.filter-btn {
  font-family: 'Inter', 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sec);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filter-btn.active {
  background: rgba(193,122,32,0.15);
  color: var(--accent);
  border-color: transparent;
}

/* ─── TAG ─── */

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.tag.urgent    { color: var(--tag-urgent);    background: var(--tag-urgent-bg);    }
.tag.quote     { color: var(--tag-quote);     background: var(--tag-quote-bg);     }
.tag.complaint { color: var(--tag-complaint); background: var(--tag-complaint-bg); }
.tag.general   { color: var(--tag-general);   background: var(--tag-general-bg);   }
.tag.cold      { color: var(--tag-cold);      background: var(--tag-cold-bg);      }
.tag.callback  { color: var(--tag-callback); background: var(--tag-callback-bg);  }
.tag.quiet     { color: var(--tag-quiet);    background: var(--tag-quiet-bg);     }

/* ─── BUTTONS ─── */

.btn {
  font-family: 'Inter', 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}

.btn:hover      { opacity: 0.78; }
.btn-ghost      { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.btn-primary    { background: var(--accent); color: #000; }
.btn-danger     { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-disabled   { opacity: 0.35; cursor: not-allowed; }

/* ─── CONFIRM MODAL (iOS-style) ─── */

.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  animation: fadeIn 0.15s ease;
}
.confirm-sheet {
  background: #1C1C1E;
  border-radius: 14px;
  width: 270px;
  overflow: hidden;
  text-align: center;
}
.confirm-body { padding: 20px 16px 12px; }
.confirm-title {
  font-size: 17px; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.confirm-msg {
  font-size: 13px; color: var(--text-sec); line-height: 1.4;
}
.confirm-actions {
  border-top: 1px solid #3A3A3C;
  display: flex;
}
.confirm-btn {
  flex: 1; padding: 14px 0;
  font-family: 'Inter', 'DM Sans', sans-serif;
  font-size: 17px; background: transparent; border: none;
  cursor: pointer; transition: opacity 0.1s;
}
.confirm-btn:hover { opacity: 0.7; }
.confirm-btn + .confirm-btn { border-left: 1px solid #3A3A3C; }
.confirm-btn.cancel  { color: var(--accent); font-weight: 400; }
.confirm-btn.confirm { color: var(--red);    font-weight: 600; }

/* ─── EMPTY STATE ─── */

.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 20px;
  gap: 10px;
  color: var(--text-tert);
  font-size: 14px;
}

/* ─── CONVERSATION LIST ─── */

.conv-list { display: flex; flex-direction: column; gap: 8px; }

.conv-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background 0.15s;
}
.conv-row:hover { background: var(--surface-hi); }
.conv-row-info { flex: 1; min-width: 0; }
.conv-row-name { font-size: 14px; font-weight: 500; color: var(--text-primary); margin-bottom: 2px; }
.conv-row-note { font-size: 12px; color: var(--text-sec); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.conv-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.conv-row-meta { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text-tert); }

/* ─── CHAT VIEW ─── */

.chat-view { display: flex; flex-direction: column; gap: 0; }

.chat-back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.chat-back-btn:hover { opacity: 0.75; }

.chat-topbar-name {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-bubbles { display: flex; flex-direction: column; gap: 10px; padding-bottom: 72px; }

.bubble-wrap           { max-width: 75%; display: flex; flex-direction: column; }
.bubble-wrap.outbound  { align-self: flex-end;   align-items: flex-end;   }
.bubble-wrap.inbound   { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
}
.bubble.outbound {
  background: #F5A623;
  color: #111;
  border-bottom-right-radius: 4px;
}
.bubble.outbound::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: -7px;
  width: 7px;
  height: 12px;
  background: linear-gradient(to bottom-right, #F5A623 50%, transparent 50%);
}
.bubble.inbound {
  background: #0B8EF0;
  color: #fff;
  border-bottom-left-radius: 4px;
}
.bubble.inbound::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -7px;
  width: 7px;
  height: 12px;
  background: linear-gradient(to bottom-left, #0B8EF0 50%, transparent 50%);
}
.bubble.outbound-auto {
  background: rgba(245, 158, 11, 0.15);
  color: var(--text-primary);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.bubble.outbound-auto::after {
  background: linear-gradient(to bottom-right, rgba(245,158,11,0.4) 50%, transparent 50%);
}

.bubble.outbound-manual {
  background: rgba(34, 197, 94, 0.15);
  color: var(--text-primary);
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.bubble.outbound-manual::after {
  background: linear-gradient(to bottom-right, rgba(34,197,94,0.4) 50%, transparent 50%);
}

.bubble-time {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text-tert);
  margin-top: 4px;
  text-align: right;
}
.bubble-wrap.inbound .bubble-time { text-align: left; }

/* ─── CHAT INPUT BAR ─── */

#chat-input-bar {
  display: none;
  position: fixed;
  left: 220px;
  right: 0;
  bottom: 0;
  z-index: 90;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  align-items: center;
  gap: 10px;
}

.chat-input-text {
  flex: 1;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: 'Inter', 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 8px 12px;
  resize: none;
  line-height: 1.4;
  outline: none;
}
.chat-input-text::placeholder { color: var(--text-tert); }
.chat-input-text:focus        { border-color: var(--accent); }

.chat-send-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.chat-send-btn:hover { opacity: 0.78; }

@media (max-width: 900px) {
  #chat-input-bar { left: 64px; }
}

@media (max-width: 768px) {
  #chat-input-bar {
    left: 0;
    bottom: calc(60px + env(safe-area-inset-bottom));
  }
}

/* ─── TOGGLE ─── */

.toggle { position: relative; display: inline-block; width: 44px; height: 24px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background 0.2s;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-track::after { transform: translateX(20px); }
