/* ============================================================
   Clau Dashboard — Stylesheet
   Design: Dark sidebar, warm off-white content, orange accent
   Fonts: Space Mono (headings), DM Sans (body)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=DM+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #faf8f5;
  --bg-sidebar: #1a1a2e;
  --bg-card: #ffffff;
  --bg-hover: rgba(232,115,74,0.08);
  --accent: #e8734a;
  --accent-dark: #d45a33;
  --accent-light: #f4a261;
  --text: #1a1a2e;
  --text-muted: rgba(26,26,46,0.5);
  --text-light: rgba(26,26,46,0.35);
  --border: rgba(26,26,46,0.08);
  --danger: #ef4444;
  --warning: #fbbf24;
  --success: #4ade80;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Space Mono', 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --sidebar-width: 220px;
  --radius: 16px;
  --radius-sm: 10px;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────── */
.app { display: flex; width: 100%; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: none;
  position: relative;
  z-index: 10;
}

.sidebar-brand {
  padding: 0 20px 32px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: #faf8f5;
  letter-spacing: -0.02em;
}

.sidebar-brand svg { width: 28px; height: 28px; image-rendering: pixelated; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(250,248,245,0.5);
  font-size: 0.87rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0;
}
.sidebar-nav a:hover {
  color: rgba(250,248,245,0.8);
  background: transparent;
  text-decoration: none;
}
.sidebar-nav a.active {
  background: rgba(232,115,74,0.15);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar-nav a svg { width: 18px; height: 18px; opacity: 0.7; flex-shrink: 0; }
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: rgba(250,248,245,0.25);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── Main Content ───────────────────────────────────────── */
.main {
  flex: 1;
  padding: 36px 48px;
  overflow-y: auto;
  max-width: 860px;
}

/* ── Page Header ────────────────────────────────────────── */
.page-header {
  text-align: left;
  margin-bottom: 32px;
  position: relative;
  background: linear-gradient(135deg, #e8f0fe 0%, #fce4d6 50%, #faf8f5 100%);
  border-radius: var(--radius);
  padding: 32px 36px;
  overflow: hidden;
}
.page-header h1 {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.page-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: rgba(26,26,46,0.02);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}
.card:hover {
  box-shadow: 0 4px 16px rgba(26,26,46,0.04);
}
.card-header {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.7rem;
  margin-bottom: 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.card-text {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
  line-height: 1.6;
}

/* ── Dark CTA Card (Get Started) ───────────────────────── */
.card-dark {
  background: var(--bg-sidebar);
  border: none;
  position: relative;
  overflow: hidden;
}
.card-dark::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(232,115,74,0.15) 0%, transparent 70%);
  pointer-events: none;
}
.card-dark .card-header { color: var(--accent); }
.card-dark .card-text { color: rgba(250,248,245,0.5); }

/* ── Price Display ──────────────────────────────────────── */
.price-display {
  text-align: center;
  padding: 40px 36px;
  background: linear-gradient(135deg, #1a1a2e 0%, #2a2a4e 100%);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
}
.price-display::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(232,115,74,0.2) 0%, transparent 70%);
  pointer-events: none;
}
.price-amount {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 700;
  color: #faf8f5;
}
.price-period {
  font-size: 1rem;
  color: rgba(250,248,245,0.4);
  font-weight: 400;
}
.price-desc {
  color: rgba(250,248,245,0.5);
  font-size: 0.9rem;
  margin-top: 12px;
  line-height: 1.6;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}
.price-features {
  display: flex;
  gap: 8px;
  margin-top: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.price-feature {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: rgba(250,248,245,0.6);
  background: rgba(250,248,245,0.08);
  padding: 6px 12px;
  border-radius: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  position: relative;
}
.btn-primary {
  background: var(--accent);
  color: #faf8f5;
  width: 100%;
}
.btn-primary:hover {
  background: var(--accent-dark);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(232,115,74,0.3);
}
.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-secondary:hover {
  background: var(--accent);
  color: #faf8f5;
  transform: translateY(-1px);
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 8px 18px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* Dark variant for dark backgrounds */
.btn-dark {
  background: var(--accent);
  color: #faf8f5;
}

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 400;
  margin-bottom: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.93rem;
  font-family: var(--font-body);
  background: rgba(26,26,46,0.02);
  color: var(--text);
  transition: border-color 0.2s ease;
  outline: none;
}
.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,115,74,0.1);
}
.form-group textarea {
  min-height: 200px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  resize: vertical;
}
.form-hint {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 6px;
}

/* ── Status Badges ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-running { background: rgba(74,222,128,0.1); color: #22c55e; }
.badge-stopped { background: rgba(251,191,36,0.1); color: #f59e0b; }
.badge-error { background: rgba(239,68,68,0.1); color: var(--danger); }
.badge-pending { background: rgba(232,115,74,0.1); color: var(--accent); }
.badge-active { background: rgba(74,222,128,0.1); color: #22c55e; }
.badge-inactive { background: rgba(26,26,46,0.05); color: var(--text-muted); }

.badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.badge-running::before { box-shadow: 0 0 8px rgba(74,222,128,0.4); }

/* ── Status Grid ────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.stat-card {
  background: rgba(26,26,46,0.03);
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
  cursor: default;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(26,26,46,0.08);
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
  letter-spacing: 0.04em;
}

/* ── Credential row ─────────────────────────────────────── */
.cred-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.cred-row:last-child { border-bottom: none; }
.cred-info { flex: 1; }
.cred-type {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
}
.cred-meta {
  font-size: 0.78rem;
  color: var(--text-light);
}
.cred-actions { display: flex; gap: 8px; }

/* ── Tabs (workspace editor) ───────────────────────────── */
.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-bar button {
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}
.tab-bar button:hover {
  color: var(--text);
}
.tab-bar button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content textarea {
  min-height: 300px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* ── Key-Value Input Row ───────────────────────────────── */
.kv-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 8px;
  align-items: start;
  margin-bottom: 12px;
}
.kv-row input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: var(--font-mono);
  background: rgba(26,26,46,0.02);
  color: var(--text);
}
.kv-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,115,74,0.1);
}

/* ── Secret Vault Card ─────────────────────────────────── */
.vault-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(26,26,46,0.02);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.vault-item-key {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.vault-item-meta {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 2px;
}
.vault-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Integrations Page ─────────────────────────────────── */
.int-category-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.int-cat-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.int-cat-btn:hover { background: var(--bg-hover); color: var(--text); }
.int-cat-btn.active {
  background: var(--accent);
  color: #faf8f5;
  border-color: var(--accent);
}

.int-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.int-card {
  background: rgba(26,26,46,0.02);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  transition: box-shadow 0.2s, transform 0.2s;
}
.int-card:hover {
  box-shadow: 0 8px 24px rgba(26,26,46,0.06);
  transform: translateY(-2px);
}
.int-card-connected {
  background: rgba(232,115,74,0.04);
  border-color: rgba(232,115,74,0.2);
}

.int-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
  margin-bottom: 8px;
}
.int-icon { font-size: 1.5rem; flex-shrink: 0; }
.int-card-title {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
}
.int-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.4;
}
.int-card-caps { flex: 1; margin-bottom: 12px; }
.int-cap { font-size: 0.78rem; color: var(--text); line-height: 1.6; }
.int-card-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.int-connected-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.int-connected-card {
  background: rgba(26,26,46,0.02);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  border: 1px solid var(--border);
}
.int-connected-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.int-connected-name { font-family: var(--font-mono); font-weight: 600; font-size: 0.88rem; }
.int-connected-account { font-size: 0.78rem; color: var(--text-muted); }
.int-connected-status { margin-left: auto; flex-shrink: 0; }
.int-connected-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.int-connected-actions { display: flex; gap: 6px; }
.int-error {
  font-size: 0.78rem;
  color: var(--danger);
  background: rgba(239,68,68,0.06);
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
}

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.88rem;
}
.alert-info { background: rgba(232,115,74,0.06); color: var(--accent-dark); border: 1px solid rgba(232,115,74,0.15); }
.alert-success { background: rgba(74,222,128,0.08); color: #16a34a; }
.alert-error { background: rgba(239,68,68,0.06); color: var(--danger); }
.alert-warning { background: rgba(251,191,36,0.08); color: #d97706; }

/* ── Login Page ─────────────────────────────────────────── */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  padding: 20px;
  background: var(--bg);
  position: relative;
}
.login-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(26,26,46,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}
.login-card {
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(26,26,46,0.08);
  position: relative;
  z-index: 2;
}
.login-card h1 {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.login-card .subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 0.87rem;
  letter-spacing: 0.02em;
}

.login-toggle {
  margin-top: 20px;
  font-size: 0.87rem;
  color: var(--text-muted);
}
.login-toggle a { color: var(--accent); font-weight: 500; }

/* ── Misc ───────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 16px; }
.mt-4 { margin-top: 32px; }
.mb-2 { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none !important; }

/* ── Alebrije ──────────────────────────────────────────── */
.alebrije-hero {
  display: flex;
  gap: 32px;
  align-items: center;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.alebrije-creature-container {
  flex-shrink: 0;
}
.alebrije-orb {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, var(--orb-color), rgba(0,0,0,0.3));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 40px color-mix(in srgb, var(--orb-color) 30%, transparent),
              0 0 80px color-mix(in srgb, var(--orb-color) 15%, transparent);
  animation: alebrije-pulse 4s ease-in-out infinite;
  overflow: hidden;
}
.alebrije-orb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}
@keyframes alebrije-pulse {
  0%, 100% { box-shadow: 0 0 40px color-mix(in srgb, var(--orb-color) 30%, transparent); }
  50% { box-shadow: 0 0 60px color-mix(in srgb, var(--orb-color) 50%, transparent), 0 0 100px color-mix(in srgb, var(--orb-color) 20%, transparent); }
}
.alebrije-hero-info {
  flex: 1;
}
.alebrije-stage-badge {
  display: inline-block;
  padding: 4px 16px;
  border-radius: 20px;
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.alebrije-stage-desc {
  color: var(--text-muted);
  margin: 0 0 20px;
  font-size: 0.95rem;
  line-height: 1.5;
}
.alebrije-progress {
  max-width: 400px;
}
.alebrije-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.alebrije-progress-bar-bg {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.alebrije-progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}
.alebrije-progress-stages {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.alebrije-progress-stages span.active {
  font-weight: 600;
  color: var(--text);
}
.alebrije-affinities {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 16px;
}
.alebrije-affinity-group {
  background: var(--bg);
  padding: 16px;
  border-radius: 8px;
}
.alebrije-affinity-title {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: capitalize;
  margin-bottom: 10px;
  color: var(--text);
}
.alebrije-affinity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.alebrije-affinity-label {
  width: 80px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: capitalize;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.alebrije-affinity-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.alebrije-affinity-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.alebrije-affinity-val {
  width: 24px;
  text-align: right;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar-brand span { display: none; }
  .sidebar-nav a span { display: none; }
  .sidebar-nav a { justify-content: center; padding: 10px 0; }
  .sidebar-footer { display: none; }
  .main { padding: 24px; }
  .login-card { padding: 32px 24px; }
  .alebrije-hero { flex-direction: column; text-align: center; }
  .alebrije-orb { width: 140px; height: 140px; }
  .alebrije-progress { max-width: 100%; }
}
@media (max-width: 480px) {
  .sidebar { display: none; }
  .main { padding: 16px; }
}
