/* StreetFlow Client Portal — Lead Inbox Dashboard */

/* ---------- Layout ---------- */
.portal-wrap {
  min-height: 100vh;
  background: var(--bg-primary);
  color: var(--fg-primary);
  font-family: var(--font-body);
}

/* ---------- Portal Topbar ---------- */
.portal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 100;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.portal-brand-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.portal-nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(0, 230, 118, 0.2);
  padding: 3px 10px;
  border-radius: 100px;
}

/* ---------- Stats Bar ---------- */
.portal-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}

.portal-stat {
  background: var(--bg-secondary);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.portal-stat-num {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--fg-primary);
  line-height: 1;
}

.portal-stat-num.accent { color: var(--accent); }

.portal-stat-label {
  font-size: 12px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* ---------- Main Content ---------- */
.portal-body {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ---------- Inbox Header ---------- */
.inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.inbox-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.inbox-filters {
  display: flex;
  gap: 8px;
}

.filter-btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-btn:hover {
  border-color: var(--fg-muted);
  color: var(--fg-primary);
}

.filter-btn.active {
  background: var(--accent-dim);
  border-color: rgba(0, 230, 118, 0.3);
  color: var(--accent);
}

/* ---------- Lead List ---------- */
#lead-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ---------- Lead Card ---------- */
.lead-card {
  background: var(--bg-secondary);
  padding: 20px 24px;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 16px;
  align-items: start;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}

.lead-card:hover { background: var(--bg-card); }

.lead-card.selected {
  background: var(--bg-card);
  border-left: 2px solid var(--accent);
}

.lead-card.status-new::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

/* Source icon */
.lead-source-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.lead-source-icon.instagram { background: rgba(225, 48, 108, 0.1); border-color: rgba(225, 48, 108, 0.2); }
.lead-source-icon.facebook  { background: rgba(24, 119, 242, 0.1); border-color: rgba(24, 119, 242, 0.2); }
.lead-source-icon.website   { background: rgba(0, 230, 118, 0.08); border-color: rgba(0, 230, 118, 0.15); }

.lead-main { min-width: 0; }

.lead-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.lead-name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-handle {
  font-size: 13px;
  color: var(--fg-muted);
  white-space: nowrap;
}

.lead-message {
  font-size: 14px;
  color: var(--fg-secondary);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.lead-time {
  font-size: 12px;
  color: var(--fg-muted);
  white-space: nowrap;
}

.lead-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lead-status.new     { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(0,230,118,0.2); }
.lead-status.replied { background: rgba(59, 130, 246, 0.1); color: #60a5fa; border: 1px solid rgba(59,130,246,0.2); }
.lead-status.closed  { background: rgba(255,255,255,0.04); color: var(--fg-muted); border: 1px solid var(--border); }

/* ---------- Lead Detail Drawer ---------- */
#lead-detail {
  display: none;
  margin-top: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

#lead-detail.visible { display: block; }

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.detail-sender {
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-source-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.detail-sender-info h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.detail-sender-info p {
  font-size: 13px;
  color: var(--fg-muted);
}

.detail-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-secondary);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.detail-close:hover { background: var(--bg-card); color: var(--fg-primary); }

.detail-body { padding: 24px; }

.detail-section {
  margin-bottom: 20px;
}

.detail-section:last-child { margin-bottom: 0; }

.detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-bottom: 8px;
}

.detail-message {
  font-size: 15px;
  color: var(--fg-primary);
  line-height: 1.7;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

/* AI reply section */
.ai-reply-wrap {
  position: relative;
}

.ai-reply-textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  color: var(--fg-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.7;
  resize: vertical;
  min-height: 120px;
  outline: none;
  transition: border-color 0.15s ease;
}

.ai-reply-textarea:focus {
  border-color: rgba(0, 230, 118, 0.4);
}

.ai-reply-textarea::placeholder { color: var(--fg-muted); }

.ai-reply-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-primary:hover { background: #00ff88; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-secondary);
}

.btn-ghost:hover { border-color: var(--fg-muted); color: var(--fg-primary); }

.ai-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(0,230,118,0.2);
  padding: 2px 8px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, #222 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
  height: 14px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Empty state ---------- */
.inbox-empty {
  padding: 60px 24px;
  text-align: center;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.inbox-empty-icon { font-size: 40px; margin-bottom: 16px; }

.inbox-empty h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.inbox-empty p {
  font-size: 14px;
  color: var(--fg-secondary);
  margin-bottom: 20px;
}

/* ---------- Toast notifications ---------- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  font-size: 13px;
  font-weight: 500;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg-primary);
  animation: slideIn 0.2s ease;
  max-width: 280px;
}

.toast.success { border-color: rgba(0,230,118,0.3); color: var(--accent); }
.toast.error   { border-color: rgba(239,68,68,0.3); color: #f87171; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Demo controls ---------- */
.demo-bar {
  background: rgba(0, 230, 118, 0.04);
  border: 1px solid rgba(0, 230, 118, 0.12);
  border-radius: 10px;
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.demo-bar p {
  font-size: 13px;
  color: var(--fg-secondary);
}

.demo-bar strong { color: var(--accent); }

/* ---------- Mobile responsive ---------- */
@media (max-width: 640px) {
  .portal-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .portal-body { padding: 20px 16px; }

  .inbox-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .lead-card {
    grid-template-columns: 36px 1fr;
    grid-template-rows: auto auto;
  }

  .lead-meta {
    grid-column: 2;
    grid-row: 2;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
  }

  .detail-header {
    flex-wrap: wrap;
    gap: 12px;
  }

  .ai-reply-actions { flex-wrap: wrap; }
}
