/* ─── ZooGent Design System ─────────────────────────────────────────────────── */
/* Fonts: Plus Jakarta Sans (display) + Manrope (body)                         */
/* Themes: light (default) + dark (toggle)                                     */

/* ─── Theme Variables ────────────────────────────────────────────────────────── */

:root[data-theme="light"] {
  --bg-page: #f8f9fb;
  --bg-card: #ffffff;
  --bg-card-hover: #fdfdfe;
  --bg-inset: #f1f3f7;
  --bg-secondary: #f1f3f7;
  --bg-header: rgba(255,255,255,0.85);
  --text-primary: #0f1729;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --accent: #0EA5E9;
  --accent-soft: rgba(14,165,233,0.08);
  --accent-hover: #0284C7;
  --success: #10B981;
  --success-soft: rgba(16,185,129,0.08);
  --warning: #F59E0B;
  --warning-soft: rgba(245,158,11,0.08);
  --error: #EF4444;
  --error-soft: rgba(239,68,68,0.08);
  --shadow-sm: 0 1px 2px rgba(15,23,41,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,41,0.06);
  --shadow-lg: 0 8px 24px rgba(15,23,41,0.08);
  --focus-ring: rgba(14,165,233,0.15);
}

:root[data-theme="dark"] {
  --bg-page: #0c0f1a;
  --bg-card: #151927;
  --bg-card-hover: #1a1f33;
  --bg-inset: #111525;
  --bg-secondary: #111525;
  --bg-header: rgba(12,15,26,0.9);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #1e293b;
  --border-hover: #334155;
  --accent: #38bdf8;
  --accent-soft: rgba(56,189,248,0.1);
  --accent-hover: #0ea5e9;
  --success: #34d399;
  --success-soft: rgba(52,211,153,0.1);
  --warning: #fbbf24;
  --warning-soft: rgba(251,191,36,0.1);
  --error: #fb7185;
  --error-soft: rgba(251,113,133,0.1);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  --focus-ring: rgba(56,189,248,0.15);
}

/* ─── Base ───────────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

body {
  font-family: 'Manrope', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg-page);
  color: var(--text-primary);
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  line-height: 1.2;
}

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

.font-display { font-family: 'Plus Jakarta Sans', sans-serif; }
.font-body { font-family: 'Manrope', sans-serif; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

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

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

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

/* ─── Badges ─────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Plus Jakarta Sans', sans-serif;
  letter-spacing: 0.01em;
}

.badge-running { background: var(--success-soft); color: var(--success); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-error { background: var(--error-soft); color: var(--error); }
.badge-idle { background: var(--bg-inset); color: var(--text-muted); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* ─── Status Dot ─────────────────────────────────────────────────────────────── */

@keyframes pulse-glow {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--success); }
  50% { opacity: 0.7; box-shadow: 0 0 0 4px transparent; }
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-glow 2s ease-in-out infinite;
  flex-shrink: 0;
}

/* ─── Navigation ─────────────────────────────────────────────────────────────── */

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-inset);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-soft);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  height: 46px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Plus Jakarta Sans', sans-serif;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  box-shadow: var(--shadow-md);
}

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

input, select, textarea {
  background: var(--bg-inset);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  height: 46px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: 'Manrope', sans-serif;
  width: 100%;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

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

input::placeholder { color: var(--text-muted); }

/* ─── Tables ─────────────────────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Plus Jakarta Sans', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  color: var(--text-secondary);
}

tr { transition: background 0.15s ease; }
tr:hover td { background: var(--accent-soft); }
tr:last-child td { border-bottom: none; }

/* ─── Scrollbar ──────────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
html { overflow-y: auto; scrollbar-gutter: stable; }

/* ─── Animations ─────────────────────────────────────────────────────────────── */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in { animation: fadeInUp 0.4s ease-out both; }
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }

/* ─── Utility Classes ────────────────────────────────────────────────────────── */

.stat-label {
  font-size: 12px;
  font-weight: 700;
  font-family: 'Plus Jakarta Sans', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.stat-value {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  margin-top: 6px;
}

.hidden { display: none; }

/* ─── Chat ──────────────────────────────────────────────────────────────────── */

.chat-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; text-align: center; padding: 60px 20px;
}

.chat-empty-icon {
  width: 64px; height: 64px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; font-family: 'Plus Jakarta Sans', sans-serif;
  margin-bottom: 20px;
}

.chat-bubble-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  animation: fadeInUp 0.25s ease-out both;
  padding: 4px 0;
}

.chat-bubble-row-user { justify-content: flex-end; }
.chat-bubble-row-assistant { justify-content: flex-start; }

/* Avatar circles */
.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  font-family: 'Plus Jakarta Sans', sans-serif;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  margin-top: 4px;
}

.chat-avatar-assistant {
  background: var(--accent-soft);
  color: var(--accent);
}

.chat-avatar-user {
  background: var(--bg-inset);
  color: var(--text-muted);
  order: 1;
}

.chat-bubble {
  max-width: min(72%, 720px);
  padding: 18px 24px;
  font-size: 17px;
  line-height: 1.7;
  border-radius: 20px;
}

.chat-bubble-user {
  background: var(--text-primary);
  color: var(--bg-page);
  border-bottom-right-radius: 6px;
}

.chat-bubble-assistant {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.chat-bubble-error {
  background: var(--error-soft);
  border: 1px solid rgba(239,68,68,0.2);
  color: var(--error);
  border-bottom-left-radius: 6px;
}

.chat-bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble-text code {
  background: rgba(0,0,0,0.08);
  padding: 2px 7px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
}

[data-theme="dark"] .chat-bubble-user {
  background: var(--accent);
  color: #fff;
}

[data-theme="dark"] .chat-bubble-text code {
  background: rgba(255,255,255,0.1);
}

/* Chat input */

.chat-input-wrap {
  position: sticky;
  bottom: 0;
  padding: 20px 0 0;
  background: var(--bg-page);
  z-index: 10;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 10px 14px 10px 24px;
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring), var(--shadow-md);
}

.chat-input-bar textarea {
  flex: 1;
  border: none !important;
  background: transparent !important;
  padding: 10px 0 4px !important;
  font-size: 17px !important;
  font-family: 'Manrope', sans-serif !important;
  color: var(--text-primary) !important;
  resize: none;
  outline: none !important;
  line-height: 1.5 !important;
  min-height: 44px !important;
  max-height: 130px;
  height: 44px !important;
  box-shadow: none !important;
  width: auto !important;
  overflow-y: auto;
}

.chat-input-bar textarea::placeholder {
  color: var(--text-muted);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  border: none;
  background: var(--text-primary);
  color: var(--bg-page);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.chat-send-btn:hover { transform: scale(1.05); }
.chat-send-btn:active { transform: scale(0.95); }
.chat-send-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

[data-theme="dark"] .chat-send-btn {
  background: var(--accent);
  color: #fff;
}

/* Tool call blocks */

.chat-tool {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  font-size: 14px;
}

.chat-tool-header {
  background: var(--bg-inset);
  padding: 10px 16px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-tool-icon { font-size: 14px; }

.chat-tool-input {
  padding: 12px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
  max-height: 140px;
  overflow-y: auto;
  background: transparent;
  border-bottom: 1px solid var(--border);
}

.chat-tool-result {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-primary);
  white-space: pre-wrap;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.5;
}

/* Thinking indicator */
.chat-thinking {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  animation: fadeInUp 0.2s ease-out both;
}

.chat-thinking.active { display: flex; }

.chat-thinking-dots {
  display: flex;
  gap: 6px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.chat-thinking-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: dotPulse 1.4s ease-in-out infinite;
}

.chat-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

@keyframes spin { to { transform: rotate(360deg); } }
.chat-tool-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* ─── Login Page ─────────────────────────────────────────────────────────────── */

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 52px 48px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.06);
  animation: cardIn 0.5s ease-out;
}

.login-logo {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-align: center;
  color: var(--text-primary);
}

.login-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
  font-weight: 500;
}

.login-tabs {
  display: flex;
  margin: 36px 0 32px;
  background: var(--bg-inset);
  border-radius: 12px;
  padding: 4px;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 9px;
  transition: all 0.25s ease;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  color: var(--text-primary);
  background: var(--bg-card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0 18px;
  height: 50px;
  border-radius: 12px;
  font-size: 16px;
  color: var(--text-secondary);
}

.form-group select {
  padding-right: 44px;
}

.submit-btn {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: 'Plus Jakarta Sans', sans-serif;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
  margin-top: 6px;
}

.submit-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(14,165,233,0.3);
  transform: translateY(-1px);
}

.submit-btn:active { transform: translateY(0); }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.error-msg {
  color: var(--error);
  font-size: 14px;
  font-weight: 600;
  margin-top: 18px;
  text-align: center;
  min-height: 22px;
}

.page-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  margin: 0;
}

/* ─── Typography ───────────────────────────────────────────────────────────── */

.page-subtitle { color: var(--text-secondary); font-size: 16px; font-weight: 500; margin: 6px 0 0; }
.section-title { font-size: 18px; font-weight: 700; color: var(--text-primary); margin: 0; }
.label { font-size: 13px; font-weight: 600; color: var(--text-secondary); display: block; margin-bottom: 6px; }
.text-muted { color: var(--text-muted); font-size: 14px; }
.text-mono { font-family: 'JetBrains Mono', monospace; font-size: 14px; }

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

.card-body { padding: 24px; }
.card-body-lg { padding: 32px; }

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

.input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-inset);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}
.input-mono { font-family: 'JetBrains Mono', monospace; }

/* ─── Responsive Grid Classes ──────────────────────────────────────────────── */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-sidebar { display: grid; grid-template-columns: 280px 1fr; gap: 24px; }

/* ─── Mobile Breakpoints ───────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-sidebar { grid-template-columns: 1fr; }

  main { padding: 12px 16px !important; }

  /* Header: hamburger instead of inline nav, solid background */
  header { background: var(--bg-page) !important; backdrop-filter: none !important; }
  .desktop-nav { display: none !important; }
  .mobile-burger { display: block !important; }

  /* Team nav: show header row with toggle, wrap links */
  .team-nav-header { display: flex !important; }
  .desktop-team-name { display: none !important; }
  #team-nav-items {
    flex-wrap: wrap !important;
    height: auto !important;
    padding-bottom: 8px;
  }

  /* Chat: let content determine height on mobile */
  #chat-container { min-height: 0 !important; }
}
