/**
 * AI Studio — Design System
 *
 * Driven by CSS custom properties set from studio.config.js at runtime.
 * Dark mode is default. Light mode swaps the property values.
 */

/* ---------------------------------------------------------------------------
   CSS Custom Properties (defaults — overridden by JS from studio.config.js)
   --------------------------------------------------------------------------- */

:root {
  --bg: #0c0c0d;
  --surface: #141416;
  --surface2: #1a1a1e;
  --border: #2a2a2e;
  --text: #f0ede8;
  --subtext: #888;
  --muted: #444;
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --font: 'Manrope', sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --input-bg: #0f0f11;
  --transition: 0.2s ease;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

[data-theme="light"] {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface2: #f0f0f0;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --subtext: #666;
  --muted: #999;
  --input-bg: #f7f7f7;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

/* ---------------------------------------------------------------------------
   Reset & Base
   --------------------------------------------------------------------------- */

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

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

input, textarea, button, select {
  font-family: inherit;
  font-size: inherit;
}

/* ---------------------------------------------------------------------------
   Layout
   --------------------------------------------------------------------------- */

#app {
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo {
  height: 32px;
  width: auto;
}

.sidebar-title {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 0 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--subtext);
  transition: background var(--transition), color var(--transition);
  font-size: 13px;
  font-weight: 500;
}
.sidebar-nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}
.sidebar-nav-item.active {
  background: var(--primary-tint, rgba(214, 88, 40, 0.1));
  color: var(--primary);
  font-weight: 700;
}
.sidebar-nav-item .nav-emoji {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-section-label {
  padding: 16px 20px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ---------------------------------------------------------------------------
   Auth Screens
   --------------------------------------------------------------------------- */

.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 100vh;
  background: var(--bg);
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}

.auth-logo img {
  height: 36px;
}

.auth-logo h1 {
  font-size: 20px;
  font-weight: 800;
}

.auth-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.auth-card p.subtitle {
  color: var(--subtext);
  font-size: 14px;
  margin-bottom: 24px;
}

/* ---------------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------------- */

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--subtext);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus {
  border-color: var(--primary);
}
.form-input::placeholder {
  color: var(--muted);
}

.form-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--subtext);
  margin-bottom: 16px;
}
.form-checkbox input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--primary);
}

.form-error {
  color: #ef4444;
  font-size: 13px;
  margin-top: 6px;
}

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  letter-spacing: -0.2px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--subtext);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--surface2);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ---------------------------------------------------------------------------
   Dashboard
   --------------------------------------------------------------------------- */

.dashboard {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.dashboard-header {
  margin-bottom: 32px;
}

.dashboard-greeting {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}

.dashboard-subtitle {
  color: var(--subtext);
  font-size: 15px;
}

.dashboard-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  flex: 1;
  min-width: 140px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
}

.stat-label {
  color: var(--subtext);
  font-size: 13px;
  margin-top: 4px;
}

.tools-section h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
}

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

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tool-card:hover {
  background: var(--surface2);
  box-shadow: var(--shadow);
}

.tool-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.tool-card-emoji {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.tool-card-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.tool-card-role {
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
}

.tool-card-desc {
  color: var(--subtext);
  font-size: 13px;
  line-height: 1.55;
}

.tool-card-tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.tool-card-action {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  transition: color var(--transition);
}
.tool-card:hover .tool-card-action {
  color: var(--primary);
}

/* ---------------------------------------------------------------------------
   Chat View
   --------------------------------------------------------------------------- */

#chat-root {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.chat-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.chat-sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.chat-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.chat-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chat-sidebar-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--subtext);
  font-size: 13px;
  transition: background var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-sidebar-item:hover {
  background: var(--surface2);
  color: var(--text);
}
.chat-sidebar-item.active {
  background: var(--surface2);
  color: var(--text);
}

.chat-sidebar-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}

.chat-header-emoji {
  font-size: 24px;
}

.chat-header-name {
  font-weight: 700;
  font-size: 16px;
}

.chat-header-role {
  color: var(--subtext);
  font-size: 13px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-message {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  gap: 12px;
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: var(--surface2);
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.6;
  position: relative;
  max-width: 85%;
}

.chat-message.assistant .chat-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
}

.chat-message.user .chat-bubble {
  background: var(--primary);
  color: #fff;
}

.chat-bubble-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0;
  transition: opacity var(--transition);
}
.chat-bubble:hover .chat-bubble-actions {
  opacity: 1;
}

.copy-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 4px 8px;
  cursor: pointer;
  color: var(--subtext);
  font-size: 12px;
  transition: all var(--transition);
}
.copy-btn:hover {
  color: var(--text);
  background: var(--border);
}

.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.chat-input-wrapper {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 200px;
  min-height: 44px;
  line-height: 1.5;
  transition: border-color var(--transition);
}
.chat-input:focus {
  border-color: var(--primary);
}
.chat-input::placeholder {
  color: var(--muted);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}
.chat-send-btn:hover {
  background: var(--primary-hover);
}
.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--subtext);
  font-size: 13px;
  padding: 8px 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Compaction notices */
.compaction-typing {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--primary);
}

.compaction-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 10px 16px;
  margin: 12px auto;
  max-width: 480px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: 20px;
  opacity: 0.8;
}

/* ---------------------------------------------------------------------------
   Markdown rendering in chat
   --------------------------------------------------------------------------- */

.chat-bubble h1, .chat-bubble h2, .chat-bubble h3 {
  font-weight: 700;
  margin: 16px 0 8px;
}
.chat-bubble h1 { font-size: 18px; }
.chat-bubble h2 { font-size: 16px; }
.chat-bubble h3 { font-size: 15px; }
.chat-bubble h1:first-child,
.chat-bubble h2:first-child,
.chat-bubble h3:first-child {
  margin-top: 0;
}

.chat-bubble p {
  margin: 8px 0;
}
.chat-bubble p:first-child { margin-top: 0; }
.chat-bubble p:last-child { margin-bottom: 0; }

.chat-bubble ul, .chat-bubble ol {
  padding-left: 20px;
  margin: 8px 0;
}

.chat-bubble li {
  margin: 4px 0;
}

.chat-bubble strong {
  font-weight: 700;
}

.chat-bubble code {
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.chat-bubble pre {
  background: var(--bg);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid var(--border);
}
.chat-bubble pre code {
  background: none;
  padding: 0;
  font-size: 13px;
}

.chat-bubble blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 12px;
  margin: 12px 0;
  color: var(--subtext);
}

.chat-bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ---------------------------------------------------------------------------
   Settings Page
   --------------------------------------------------------------------------- */

.settings {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.settings h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
}

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}

.settings-section h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child {
  border-bottom: none;
}

.settings-label {
  font-size: 14px;
  font-weight: 500;
}

.settings-value {
  color: var(--subtext);
  font-size: 14px;
}

/* ---------------------------------------------------------------------------
   Skeleton Loading
   --------------------------------------------------------------------------- */

.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  height: 160px;
  border-radius: var(--radius);
}

.skeleton-line {
  height: 14px;
  margin-bottom: 8px;
}
.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }

.skeleton-chat-msg {
  height: 60px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

/* ---------------------------------------------------------------------------
   Welcome Overlay
   --------------------------------------------------------------------------- */

.welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
}

.welcome-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

@media (max-width: 480px) {
  .welcome-card {
    padding: 24px 20px;
  }
}

.welcome-card h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 12px;
}

.welcome-card p {
  color: var(--subtext);
  font-size: 15px;
  margin-bottom: 24px;
}

/* ---------------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 440px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal p {
  color: var(--subtext);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ---------------------------------------------------------------------------
   Toast Notifications
   --------------------------------------------------------------------------- */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
}

.toast.success { border-left: 3px solid #22c55e; }
.toast.error { border-left: 3px solid #ef4444; }
.toast.info { border-left: 3px solid var(--primary); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---------------------------------------------------------------------------
   Email Verification Banner
   --------------------------------------------------------------------------- */

.verify-banner {
  background: var(--primary);
  color: #fff;
  text-align: center;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
}

.verify-banner a {
  color: #fff;
  text-decoration: underline;
  font-weight: 700;
}

/* ---------------------------------------------------------------------------
   Theme Toggle
   --------------------------------------------------------------------------- */

.theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--subtext);
  font-size: 14px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* ---------------------------------------------------------------------------
   Usage Bar
   --------------------------------------------------------------------------- */

.usage-bar-container {
  padding: 12px 20px;
}

.usage-bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.usage-bar-fill.warning {
  background: #f59e0b;
}

.usage-bar-fill.critical {
  background: #ef4444;
}

.usage-text {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    z-index: 50;
    transition: left 0.3s ease;
  }
  .sidebar.open {
    left: 0;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 49;
  }
  .sidebar-backdrop.open {
    display: block;
  }

  .chat-sidebar {
    display: none;
  }
  .chat-sidebar.open {
    display: flex;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    width: 280px;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }
  .chat-sidebar-toggle {
    display: flex;
  }

  .dashboard {
    padding: 20px;
  }

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

  .dashboard-stats {
    flex-direction: column;
  }

}

/* ---------------------------------------------------------------------------
   Admin Panel
   --------------------------------------------------------------------------- */

.admin {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  width: 100%;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.admin-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.admin-tab {
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--subtext);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  margin-bottom: -1px;
}
.admin-tab:hover {
  color: var(--text);
}
.admin-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-search .form-input {
  min-width: 280px;
}

.admin-loading {
  padding: 48px;
  text-align: center;
  color: var(--subtext);
  font-size: 14px;
}

/* Admin tables */
.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

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

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

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.admin-table tr:hover td {
  background: var(--surface2);
}

.admin-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-transform: capitalize;
}

.admin-action-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}

.admin-actions {
  display: flex;
  gap: 4px;
}

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  padding: 12px 0;
}

/* Admin stats grid */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.admin-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.admin-stat-value {
  font-size: 28px;
  font-weight: 800;
}

.admin-stat-label {
  font-size: 12px;
  color: var(--subtext);
  margin-top: 4px;
}

.admin-section {
  margin-bottom: 24px;
}

.admin-section h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* Admin plugin grid */
.admin-plugin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.admin-plugin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.admin-plugin-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Admin chart (CSS bar chart) */
.admin-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 160px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  min-width: 0;
}

.admin-chart-bar {
  width: 100%;
  max-width: 32px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
  transition: height 0.3s ease;
}

.admin-chart-label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
  white-space: nowrap;
}

/* Admin prompt editor */
.admin-prompt-editor {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.5;
  min-height: 200px;
  resize: vertical;
}

/* Admin temp password display */
.admin-temp-password {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  margin: 12px 0;
  user-select: all;
}

.text-success {
  color: #22c55e;
}

/* Admin responsive */
@media (max-width: 768px) {
  .admin {
    padding: 20px;
  }
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .admin-search .form-input {
    min-width: 0;
    width: 100%;
  }
  .admin-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-plugin-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------------------------------
   Image Upload (Chat)
   --------------------------------------------------------------------------- */

.chat-msg-row img {
  display: block;
}

.chat-msg-row .chat-image-placeholder {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* ---------------------------------------------------------------------------
   Utility Classes
   --------------------------------------------------------------------------- */

.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--subtext); }

/* ---------------------------------------------------------------------------
   Training / Content View
   --------------------------------------------------------------------------- */

.content-view {
  line-height: 1.75;
  font-size: 14px;
}
.content-view h1 { font-size: 24px; font-weight: 800; margin: 24px 0 10px; letter-spacing: -0.03em; }
.content-view h2 { font-size: 19px; font-weight: 700; margin: 20px 0 8px; letter-spacing: -0.02em; }
.content-view h3 { font-size: 15px; font-weight: 700; margin: 16px 0 6px; }
.content-view p { margin: 12px 0; line-height: 1.75; color: var(--subtext); }
.content-view ul, .content-view ol { padding-left: 24px; margin: 12px 0; }
.content-view li { margin: 6px 0; line-height: 1.65; color: var(--subtext); }
.content-view strong { color: var(--text); font-weight: 700; }
.content-view a { color: var(--primary); font-weight: 600; }
.content-view blockquote {
  border-left: 3px solid var(--primary);
  padding: 4px 16px;
  margin: 16px 0;
  color: var(--subtext);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

/* Video embed — responsive 16:9 */
.video-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  margin: 20px auto;
  box-shadow: var(--shadow);
  width: 75%;
  box-sizing: border-box;
}
.video-embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: none;
}
