/* AgentTool Dashboard — style.css
   Matches agenttool-landing aesthetic exactly.
   Variables, typography, and components shared across all pages. */

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

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #1a1a26;
  --surface3: #1e1e2e;
  --border: #1e1e2e;
  --accent: #7c3aed;
  --accent-soft: #a78bfa;
  --text: #e2e8f0;
  --muted: #64748b;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #f87171;
  --blue: #60a5fa;
  --sidebar-w: 240px;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
}

html { scroll-behavior: smooth; }

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

/* ─── Shared Components ─── */

.logo { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; text-decoration: none; color: var(--text); }
.logo span { color: var(--accent-soft); }

.btn {
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent-soft); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--accent-soft); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; border-radius: 6px; }
.btn-danger { background: rgba(248,113,113,0.12); color: var(--red); border: 1px solid rgba(248,113,113,0.25); }
.btn-danger:hover { background: rgba(248,113,113,0.2); }

/* ─── Onboarding Page (index.html) ─── */

.onboarding {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}
.onboarding::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(124,58,237,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.onboard-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 480px;
  z-index: 1;
}
.onboard-card h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}
.onboard-card h1 em { font-style: normal; color: var(--accent-soft); }
.onboard-sub { color: var(--muted); font-size: 0.95rem; margin-bottom: 2rem; }

.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--accent-soft); }
.form-input::placeholder { color: var(--muted); }
.form-hint { font-size: 0.78rem; color: var(--muted); margin-top: 0.35rem; }

.form-submit {
  width: 100%;
  padding: 0.875rem;
  margin-top: 0.5rem;
}

/* Success state */
.success-panel {
  display: none;
  text-align: center;
}
.success-panel.visible { display: block; }
.success-icon { font-size: 3rem; margin-bottom: 1rem; }
.success-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.5rem; }
.success-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

/* API key display */
.key-display {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
  position: relative;
}
.key-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.key-value {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent-soft);
  word-break: break-all;
  line-height: 1.5;
  padding-right: 3rem;
  user-select: all;
}
.key-copy {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.key-copy:hover { color: var(--text); border-color: var(--accent-soft); }
.key-copy.copied { color: var(--green); border-color: var(--green); }

.key-warning {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.82rem;
  color: #fbbf24;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

/* Error state */
.error-msg {
  display: none;
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.25);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--red);
}
.error-msg.visible { display: block; }
.error-hint { color: var(--muted); font-size: 0.78rem; margin-top: 0.35rem; }

/* Footer link */
.onboard-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}
.onboard-footer a { color: var(--accent-soft); text-decoration: none; }
.onboard-footer a:hover { text-decoration: underline; }

/* ─── Dashboard Layout ─── */

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.sidebar-top { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }

.project-pill {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}
.project-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.project-name { flex: 1; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-section {
  padding: 1.25rem 1.5rem 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.15s;
}
.sidebar nav a:hover { color: var(--text); background: rgba(124,58,237,0.06); }
.sidebar nav a.active { color: var(--accent-soft); background: rgba(124,58,237,0.12); border-right: 2px solid var(--accent); }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-bottom {
  margin-top: auto;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
}

.main { margin-left: var(--sidebar-w); flex: 1; }

/* Top bar */
.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: rgba(18,18,26,0.9);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 1rem; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; gap: 0.75rem; align-items: center; }

/* Content */
.content { padding: 2rem; }

/* ─── Stat Cards ─── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.stat.green::after { background: var(--green); }
.stat.purple::after { background: var(--accent); }
.stat.blue::after { background: var(--blue); }
.stat.yellow::after { background: var(--yellow); }

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.stat-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.stat-value .unit {
  font-size: 1rem;
  font-weight: 400;
  color: var(--muted);
}
.stat-sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }
.stat-loading { color: var(--muted); font-size: 1.25rem; }

/* ─── Cards ─── */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 2rem; }
.grid-1 { margin-bottom: 2rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.card-title { font-size: 0.9rem; font-weight: 700; }
.card-sub { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }

/* ─── Code Snippets ─── */

.snippet-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.snippet-tab {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  font-family: inherit;
}
.snippet-tab:hover { color: var(--text); }
.snippet-tab.active { color: var(--accent-soft); border-bottom-color: var(--accent); }

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

.code-block {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.code-header {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.r { background: #ff5f57; }
.dot.y { background: #febc2e; }
.dot.g { background: #28c840; }
.code-lang { margin-left: auto; font-size: 0.7rem; color: var(--muted); }

pre {
  padding: 1.25rem;
  font-size: 0.82rem;
  line-height: 1.7;
  font-family: var(--mono);
  overflow-x: auto;
  margin: 0;
}
.kw { color: #c084fc; }
.str { color: #86efac; }
.fn { color: #67e8f9; }
.cm { color: #475569; }
.num { color: #fb923c; }

.code-copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  z-index: 2;
}
.code-copy:hover { color: var(--text); border-color: var(--accent-soft); }
.code-copy.copied { color: var(--green); border-color: var(--green); }

/* ─── Usage Bars ─── */

.usage-rows { display: flex; flex-direction: column; gap: 0.85rem; }
.usage-row { display: flex; align-items: center; gap: 0.75rem; }
.usage-name { font-size: 0.85rem; width: 100px; flex-shrink: 0; }
.usage-bar-wrap { flex: 1; height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.usage-bar { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.usage-count { font-size: 0.8rem; color: var(--muted); width: 64px; text-align: right; font-family: var(--mono); }

/* ─── Empty / Loading States ─── */

.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-text { font-size: 0.9rem; margin-bottom: 0.5rem; }
.empty-hint { font-size: 0.8rem; color: var(--muted); }

.loading-pulse {
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Toast ─── */

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1.25rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 999;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.toast.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast.success { border-color: rgba(16,185,129,0.4); }
.toast.error { border-color: rgba(248,113,113,0.4); }

/* ─── Logout ─── */

.logout-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
  margin-top: 0.75rem;
}
.logout-link:hover { color: var(--red); }

/* ─── Responsive ─── */

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .onboard-card { padding: 1.75rem; }
  .stats { grid-template-columns: 1fr; }
  .content { padding: 1.25rem; }
  .topbar { padding: 0 1.25rem; }
}
