/* popup.css — Skoop dark theme */

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #232636;
  --border: #2d3148;
  --purple: #7c3aed;
  --purple-light: #8b5cf6;
  --purple-dim: rgba(124, 58, 237, 0.15);
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --text-dim: #5a647a;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 8px;
  --radius-sm: 5px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  width: 380px;
  min-height: 120px;
  max-height: 640px;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── HEADER ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 7px;
}

.logo-text {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
  color: var(--text);
}

.badge-beta {
  font-size: 9px;
  font-weight: 600;
  background: var(--purple-dim);
  color: var(--purple-light);
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  gap: 4px;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}
.btn-icon:hover {
  background: var(--surface);
  color: var(--text);
}

/* ── STATES ── */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  gap: 8px;
  text-align: center;
  min-height: 200px;
}

.state-icon { font-size: 32px; }

.state-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.state-sub {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.6;
}

.tip-box {
  background: var(--purple-dim);
  border: 1px solid var(--purple);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: left;
  max-width: 300px;
  line-height: 1.6;
}
.tip-box strong { color: var(--purple-light); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary {
  background: var(--purple);
  color: #fff;
}
.btn-primary:hover { background: var(--purple-light); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text); border-color: var(--text-dim); }

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

/* ── COMMUNITY SELECTOR ── */
.community-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}

.select-community {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.select-community:focus { outline: 1px solid var(--purple); }

.sync-label {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
}

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

.stat-card {
  background: var(--bg);
  padding: 12px 6px;
  text-align: center;
}

.stat-number {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.stat-active .stat-number { color: var(--green); }
.stat-silent .stat-number { color: var(--yellow); }
.stat-risk .stat-number { color: var(--red); }

.stat-label {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ── ACTIONS ── */
.actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.actions .btn { flex: 1; justify-content: center; }

/* ── TABS ── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 40px;
  z-index: 5;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex-shrink: 0;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.tab.active, .tab:hover {
  color: var(--text);
}
.tab.active {
  border-bottom-color: var(--purple);
  color: var(--purple-light);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── FILTER ROW ── */
.filter-row {
  display: flex;
  gap: 4px;
  padding: 8px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.filter-row::-webkit-scrollbar { display: none; }

.filter-btn {
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--text-dim); color: var(--text); }
.filter-btn.active {
  background: var(--purple-dim);
  border-color: var(--purple);
  color: var(--purple-light);
}

/* ── LIST ITEMS ── */
.list {
  max-height: 320px;
  overflow-y: auto;
}

.member-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.member-item:hover { background: var(--surface); }

.member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
}

.avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.member-info { flex: 1; min-width: 0; }

.member-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

.member-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}

.badge-active { background: rgba(16,185,129,0.12); color: var(--green); }
.badge-silent { background: rgba(245,158,11,0.12); color: var(--yellow); }
.badge-atRisk { background: rgba(239,68,68,0.12); color: var(--red); }
.badge-churned { background: rgba(90,100,122,0.2); color: var(--text-dim); }
.badge-unknown { background: var(--surface2); color: var(--text-dim); }
.badge-cancel { background: rgba(239,68,68,0.18); color: var(--red); border: 1px solid rgba(239,68,68,0.4); font-weight: 700; }
.filter-btn-cancel.active { background: var(--red); color: #fff; border-color: var(--red); }
.filter-btn-rescue.active { background: #f59e0b; color: #1a1a1a; border-color: #f59e0b; }

/* POST ITEMS */
.post-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.post-item:hover { background: var(--surface); }

.post-author {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
}

.post-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.post-content {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-stats {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ENDPOINT ITEMS */
.endpoint-item {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.endpoint-url {
  font-size: 11px;
  color: var(--purple-light);
  word-break: break-all;
}

.endpoint-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

.tab-desc {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  line-height: 1.6;
}

/* ── EMPTY STATE IN LIST ── */
.list-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

/* ── SETTINGS PANEL ── */
.settings-panel {
  padding: 14px;
}

.settings-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.setting-group {
  margin-bottom: 16px;
}

.setting-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.input:focus { outline: 1px solid var(--purple); }

/* ── SPINNER ── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  z-index: 100;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: opacity 0.2s;
}

/* ── PROGRESS BAR ── */
.progress-bar-wrap {
  width: 100%;
  max-width: 260px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.progress-bar-fill {
  height: 100%;
  width: 40%;
  background: var(--purple);
  border-radius: 2px;
  animation: progress-slide 1.4s ease-in-out infinite;
}

@keyframes progress-slide {
  0%   { transform: translateX(-100%); }
  50%  { transform: translateX(160%); }
  100% { transform: translateX(160%); }
}

/* ── TOGGLE SWITCH ── */
.toggle {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 18px;
  cursor: pointer;
  transition: .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  left: 3px;
  top: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: .2s;
}
.toggle input:checked + .toggle-slider { background: var(--purple-dim); border: 1px solid var(--purple); }
.toggle input:checked + .toggle-slider::before { transform: translateX(14px); background: var(--purple-light); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }

/* ── ACTIVE ICON BUTTON ── */
.btn-icon.active {
  background: var(--purple-dim);
  border-color: var(--purple);
  color: var(--purple-light);
}

/* ── TAB SECTIONS ── */
.tab-section {
  padding: 10px 14px;
}

.tab-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 8px;
}

.tab-hint {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 10px;
}
.tab-hint code {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10px;
  color: var(--purple-light);
  margin: 0 2px;
}

/* ── MINI BUTTONS ── */
.btn-mini {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all .15s;
}
.btn-mini:hover { color: var(--text); }
.btn-mini-primary {
  background: var(--purple-dim);
  border-color: var(--purple);
  color: var(--purple-light);
}
.btn-mini-primary:hover { background: var(--purple); color: #fff; }

/* ── FORM ELEMENTS ── */
.form-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 4px;
}
.form-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.select-sm {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  width: 100%;
}
.select-sm:focus { outline: 1px solid var(--purple); }

/* ── LABEL CHIP ── */
.label-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
}
.label-chip.removable:hover { opacity: .7; }
.label-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
}

/* ── LABEL TYPE ITEM ── */
.label-type-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
}
.label-type-item .label-chip { pointer-events: none; }
.label-type-item-actions { margin-left: auto; display: flex; gap: 4px; }

/* ── COLOR PICKER ── */
.color-picker-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0;
}
.color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .15s;
}
.color-dot:hover { transform: scale(1.2); }
.color-dot.selected { border-color: #fff; transform: scale(1.15); }

/* ── LABEL ASSIGN AREA ── */
.label-assign-area {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 6px;
}

/* ── PIPELINE ── */
.pipeline-summary {
  display: flex;
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.pipeline-stat {
  flex: 1;
  background: var(--bg);
  padding: 8px 4px;
  text-align: center;
}
.pipeline-stat-num {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.pipeline-stat-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 1px;
}

.pipeline-member-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.pipeline-member-item:hover { background: var(--surface); }
.pipeline-stage-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
  flex-shrink: 0;
}
.stage-lead { background: rgba(59,130,246,.15); color: #60a5fa; }
.stage-prospect { background: rgba(245,158,11,.15); color: var(--yellow); }
.stage-hot { background: rgba(239,68,68,.15); color: var(--red); }
.stage-client { background: rgba(16,185,129,.15); color: var(--green); }
.pipeline-notes {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── TEMPLATE ITEMS ── */
.template-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.template-item:hover { background: var(--surface); }
.template-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.template-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
}
.template-body-preview {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.template-actions { display: flex; gap: 4px; }

/* ── DM MASIVO ── */
.dm-preview-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
  background: var(--purple-dim);
  border: 1px solid var(--purple);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}
.dm-preview-item {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.dm-preview-name {
  font-weight: 600;
  font-size: 11px;
  color: var(--purple-light);
  margin-bottom: 3px;
}
.dm-preview-body {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dm-copy-btn {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  cursor: pointer;
  margin-top: 3px;
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
}
.dm-copy-btn:hover { color: var(--purple-light); }

/* ── PENDING WELCOME ── */
.welcome-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.welcome-item-name { flex: 1; font-weight: 600; color: var(--text); }
.welcome-item-btn {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--purple-dim);
  border: 1px solid var(--purple);
  color: var(--purple-light);
  cursor: pointer;
  transition: all .15s;
}
.welcome-item-btn:hover { background: var(--purple); color: #fff; }

/* ── SCAN BANNER ── */
.scan-banner {
  margin: 0 10px 8px;
  padding: 8px 10px;
  background: var(--purple-dim);
  border: 1px solid var(--purple);
  border-radius: 6px;
}
.scan-banner-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
#scan-banner-label {
  font-size: 11px;
  color: var(--purple-light);
  font-weight: 500;
}
.scan-progress-wrap { margin-top: 6px; }
.scan-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}
.scan-progress-fill {
  height: 100%;
  background: var(--purple);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.scan-progress-text { font-size: 10px; color: var(--text-muted); }

/* ── UTILS ── */
.hidden { display: none !important; }
