/* ══════════════════════════════════════════════════════════════
   ReachBot — Modern Dark Theme
   ══════════════════════════════════════════════════════════════ */

:root {
  --bg: #0a0a0f;
  --bg-card: #111118;
  --bg-card-hover: #16161f;
  --bg-input: #1a1a24;
  --border: #222233;
  --border-focus: #a855f7;
  --text: #e4e4eb;
  --text-muted: #8888a0;
  --text-dim: #55556a;
  --accent: #a855f7;
  --accent-hover: #9333ea;
  --accent-glow: rgba(168, 85, 247, 0.15);
  --pink: #ec4899;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Navbar ──────────────────────────────────────────── */

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ─── Container ───────────────────────────────────────── */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ─── Hero ────────────────────────────────────────────── */

.hero {
  text-align: center;
  padding: 48px 0 40px;
}

.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(168, 85, 247, 0.2);
  margin-bottom: 20px;
}

.hero h1 {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 16px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  color: var(--text-muted);
  font-size: 16px;
  max-width: 580px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ─── Card ────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  transition: border-color var(--transition);
}

.card:hover {
  border-color: #2a2a40;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent-glow);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-icon.purple {
  background: rgba(168, 85, 247, 0.12);
  color: var(--accent);
}

.card-header h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Form ────────────────────────────────────────────── */

.search-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  width: 100%;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.required {
  color: var(--pink);
}

.form-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

input[type="text"],
input[type="number"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-dim);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ─── Buttons ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--pink));
  color: white;
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(168, 85, 247, 0.45);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
  border-radius: var(--radius);
  width: 100%;
  justify-content: center;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.btn-dm-all {
  border-color: rgba(168, 85, 247, 0.3);
  color: var(--accent);
}

.btn-dm-all:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

/* ─── Status Card ─────────────────────────────────────── */

.status-card {
  border-color: rgba(168, 85, 247, 0.25);
}

.status-content {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.status-content h3 {
  font-size: 15px;
  font-weight: 600;
}

.status-content p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 100px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--pink));
  border-radius: 100px;
  transition: width 0.5s ease;
}

/* ─── DM Card ─────────────────────────────────────────── */

.dm-card {
  border-color: rgba(168, 85, 247, 0.15);
}

.clickable {
  cursor: pointer;
  user-select: none;
}

.clickable:hover {
  opacity: 0.9;
}

.chevron {
  margin-left: auto;
  color: var(--text-dim);
  transition: transform var(--transition);
}

.dm-card.open .chevron {
  transform: rotate(180deg);
}

.dm-body {
  display: none;
  margin-top: 4px;
}

.dm-card.open .dm-body {
  display: block;
}

.dm-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(168, 85, 247, 0.06);
  border: 1px solid rgba(168, 85, 247, 0.12);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.dm-info svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--accent);
}

.dm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dm-grid label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

textarea#dmTemplate {
  resize: vertical;
  min-height: 140px;
}

.dm-tags {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.dm-tag {
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.dm-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.dm-preview-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 140px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ─── Results Card ────────────────────────────────────── */

.results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.results-title h2 {
  font-size: 18px;
  font-weight: 700;
}

.results-title h2 span {
  color: var(--accent);
}

.dm-counter-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
}

.results-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.results-table thead {
  background: var(--bg-input);
}

.results-table th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.results-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  max-width: 200px;
}

.results-table tbody tr {
  transition: background var(--transition);
}

.results-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.results-table tbody tr:last-child td {
  border-bottom: none;
}

/* Profile cell */
.profile-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--pink));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.profile-cell a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
}

.profile-cell a:hover {
  text-decoration: underline;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-good {
  background: rgba(34, 197, 94, 0.12);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-poor {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-unknown {
  background: rgba(136, 136, 160, 0.1);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Bio cell */
.bio-cell {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
}

/* DM button */
.btn-dm {
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  background: var(--accent-glow);
  border: 1px solid rgba(168, 85, 247, 0.25);
  color: var(--accent);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-dm:hover {
  background: rgba(168, 85, 247, 0.2);
  border-color: var(--accent);
}

.btn-dm.dm-sent {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.25);
  color: var(--green);
  cursor: default;
}

/* ─── Error Card ──────────────────────────────────────── */

.error-card {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  max-width: 560px;
  width: calc(100% - 48px);
}

.error-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 14px;
  backdrop-filter: blur(12px);
}

.error-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--red);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.7;
}

.error-dismiss:hover {
  opacity: 1;
}

/* ─── Toast ───────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transition: bottom 0.3s ease;
  z-index: 300;
  white-space: nowrap;
}

.toast.show {
  bottom: 32px;
}

/* ─── Footer ──────────────────────────────────────────── */

.footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
}

/* ─── Responsive ──────────────────────────────────────── */

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .dm-grid {
    grid-template-columns: 1fr;
  }

  .results-header {
    flex-direction: column;
  }

  .results-actions {
    width: 100%;
  }

  .results-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .hero h1 {
    font-size: 28px;
  }

  .card {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .nav-inner {
    padding: 0 16px;
  }

  .container {
    padding: 20px 16px 60px;
  }

  .hero {
    padding: 32px 0 28px;
  }
}
