@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --purple-50: #f5f3ff;
  --purple-100: #ede9fe;
  --purple-200: #ddd6fe;
  --purple-300: #c4b5fd;
  --purple-400: #a78bfa;
  --purple-500: #8b5cf6;
  --purple-600: #7c3aed;
  --purple-700: #6d28d9;
  --purple-800: #5b21b6;

  --green-500: #22c55e;
  --green-100: #dcfce7;
  --red-500: #ef4444;
  --red-100: #fee2e2;
  --amber-500: #f59e0b;
  --amber-100: #fef3c7;

  --bg: #f7f6fb;
  --surface: #ffffff;
  --surface-2: #fbfaff;
  --border: #e6e1f5;
  --text: #1f1b2e;
  --text-muted: #6b6480;
  --text-faint: #9c95b3;
  --shadow: 0 1px 2px rgba(31, 20, 60, 0.04), 0 8px 24px rgba(31, 20, 60, 0.06);
  --shadow-lg: 0 4px 12px rgba(31, 20, 60, 0.08), 0 16px 40px rgba(31, 20, 60, 0.10);
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme='dark'] {
  --bg: #14101f;
  --surface: #1c1730;
  --surface-2: #211b39;
  --border: #322a4d;
  --text: #f1eefb;
  --text-muted: #b6adcf;
  --text-faint: #8880a3;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4), 0 20px 44px rgba(0, 0, 0, 0.45);
  --green-100: #113822;
  --red-100: #3a1414;
  --amber-100: #3a2c0c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: inherit; text-decoration: none; }

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.navbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand-emoji {
  font-size: 1.6rem;
  filter: drop-shadow(0 2px 4px rgba(124, 58, 237, 0.35));
}

.brand-name span { color: var(--purple-600); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover { background: var(--purple-50); color: var(--purple-700); }
.nav-link.active { background: var(--purple-100); color: var(--purple-700); }

[data-theme='dark'] .nav-link:hover,
[data-theme='dark'] .nav-link.active {
  background: rgba(139, 92, 246, 0.18);
  color: var(--purple-300);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text);
}

/* ---------- Layout ---------- */
.page {
  flex: 1;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0;
  max-width: 640px;
}

/* ---------- Connector grid ---------- */
.connector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.connector-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.connector-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.connector-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.connector-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: white;
  flex-shrink: 0;
}

.connector-name {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0 0 2px;
}

.connector-desc {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.4;
  margin: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.status-badge.connected { background: var(--green-100); color: #15803d; }
.status-badge.disconnected { background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--border); }
.status-badge.error { background: var(--red-100); color: #b91c1c; }
.status-badge.coming-soon { background: var(--amber-100); color: #92700a; }

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.connector-meta {
  font-size: 0.82rem;
  color: var(--text-faint);
}

.connector-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 650;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--purple-600); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--purple-700); }

.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--purple-50); border-color: var(--purple-200); }

.btn-danger { background: transparent; color: #dc2626; border: 1px solid #fca5a5; }
.btn-danger:hover:not(:disabled) { background: var(--red-100); }

.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 0.8rem; }

/* ---------- Forms ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.card + .card { margin-top: 20px; }

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-weight: 650;
  font-size: 0.88rem;
  margin-bottom: 6px;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-top: 6px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 26px 0;
}

.section-title {
  font-weight: 750;
  font-size: 1.05rem;
  margin: 0 0 4px;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0 0 18px;
}

.tag-oauth-todo {
  display: inline-block;
  background: var(--amber-100);
  color: #92700a;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---------- Alerts / test result banners ---------- */
.alert {
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 0.88rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-success { background: var(--green-100); color: #15803d; }
.alert-error { background: var(--red-100); color: #b91c1c; }
.alert-info { background: var(--purple-50); color: var(--purple-700); }

[data-theme='dark'] .alert-info { background: rgba(139, 92, 246, 0.14); color: var(--purple-300); }

/* ---------- Breadcrumb / back link ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 18px;
}
.back-link:hover { color: var(--purple-600); }

/* ---------- FAQ / Help ---------- */
.faq-step {
  display: flex;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.faq-step:last-child { border-bottom: none; }

.faq-step-number {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--purple-100);
  color: var(--purple-700);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

[data-theme='dark'] .faq-step-number { background: rgba(139, 92, 246, 0.2); color: var(--purple-300); }

.faq-step-body h4 { margin: 2px 0 6px; font-size: 0.98rem; }
.faq-step-body p { margin: 0 0 8px; color: var(--text-muted); font-size: 0.9rem; line-height: 1.55; }

.callout {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.faq-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.faq-tab {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 650;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text-muted);
}

.faq-tab.active { background: var(--purple-600); color: white; border-color: var(--purple-600); }

.faq-panel { display: none; }
.faq-panel.active { display: block; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 22px 24px;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
}
.footer .brand-emoji { font-size: 1rem; }

/* ---------- Utility ---------- */
.mt-0 { margin-top: 0; }
.text-center { text-align: center; }
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}

@media (max-width: 640px) {
  .navbar-inner { flex-wrap: wrap; }
  .nav-links { order: 3; width: 100%; justify-content: space-between; }
  .connector-actions { flex-direction: column; }
}
