/* Bob PWA — Mobile-first dark theme */

:root {
  --bg: #0a0a0f;
  --bg-card: #14141f;
  --bg-input: #1a1a2e;
  --border: #2a2a3e;
  --text: #e0e0e8;
  --text-dim: #8888a0;
  --accent: #6c5ce7;
  --accent-glow: #7c6cf7;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --info: #3498db;
  --radius: 12px;
  --radius-sm: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* Auth gate */
.auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.5rem;
}
.auth-card {
  text-align: center;
  width: 100%;
  max-width: 320px;
}
.auth-logo { font-size: 2.5rem; font-weight: 800; margin-bottom: 0.25rem; }
.auth-sub { color: var(--text-dim); margin-bottom: 1.5rem; font-size: 0.9rem; }
.auth-error { color: var(--danger); font-size: 0.85rem; margin-top: 0.75rem; }

/* Inputs */
input, textarea, select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 100px; font-family: inherit; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  width: 100%;
  margin-top: 0.75rem;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-glow); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.topbar-title { font-weight: 800; font-size: 1.15rem; }
.topbar-status { font-size: 0.7rem; }
.topbar-status.connected { color: var(--success); }
.topbar-status.disconnected { color: var(--danger); }

/* Page content */
.page-content {
  padding: 1rem 1rem calc(4.5rem + var(--safe-bottom));
  max-width: 600px;
  margin: 0 auto;
}

/* Bottom nav */
.bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  padding: 0.5rem 0 calc(0.5rem + var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 100;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 0.7rem;
  padding: 0.25rem 0.75rem;
  transition: color 0.15s;
}
.nav-item.active { color: var(--accent); }
.nav-icon { font-size: 1.25rem; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.card-title { font-weight: 700; font-size: 1rem; margin-bottom: 0.5rem; }
.card-sub { color: var(--text-dim); font-size: 0.85rem; }

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  text-align: center;
}
.stat-value { font-size: 1.5rem; font-weight: 800; }
.stat-label { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.15rem; }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-success { background: rgba(46,204,113,0.15); color: var(--success); }
.badge-danger { background: rgba(231,76,60,0.15); color: var(--danger); }
.badge-warning { background: rgba(243,156,18,0.15); color: var(--warning); }
.badge-info { background: rgba(52,152,219,0.15); color: var(--info); }
.badge-dim { background: rgba(136,136,160,0.15); color: var(--text-dim); }

/* Phase pipeline */
.pipeline {
  display: flex;
  gap: 0.25rem;
  margin: 0.75rem 0;
  flex-wrap: wrap;
}
.pipeline-step {
  flex: 1;
  min-width: 40px;
  text-align: center;
  padding: 0.35rem 0.15rem;
  border-radius: 6px;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--bg-input);
  color: var(--text-dim);
  transition: all 0.3s;
}
.pipeline-step.done { background: rgba(46,204,113,0.2); color: var(--success); }
.pipeline-step.active { background: rgba(108,92,231,0.3); color: var(--accent-glow); animation: pulse 1.5s infinite; }
.pipeline-step.failed { background: rgba(231,76,60,0.2); color: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  margin: 0.5rem 0;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Task list */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-num {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--bg-input);
  color: var(--text-dim);
}
.task-num.completed { background: rgba(46,204,113,0.2); color: var(--success); }
.task-num.in_progress { background: rgba(108,92,231,0.3); color: var(--accent); }
.task-num.failed { background: rgba(231,76,60,0.2); color: var(--danger); }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 0.9rem; }
.task-meta { color: var(--text-dim); font-size: 0.75rem; margin-top: 0.15rem; }

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
}
.data-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* Filter chips */
.chips {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.chip {
  padding: 0.35rem 0.85rem;
  border-radius: 99px;
  font-size: 0.8rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  transition: all 0.15s;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Section heading */
.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  margin: 1.25rem 0 0.5rem;
}

/* Slider */
input[type="range"] {
  -webkit-appearance: none;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  border: none;
  padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

/* Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
}
.toggle-label { font-size: 0.9rem; }
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-input);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::after { transform: translateX(20px); background: #fff; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

/* Truncate text */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Clickable row */
.clickable { cursor: pointer; }
.clickable:active { opacity: 0.7; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollable code block for spec */
.spec-preview {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-dim);
  margin-top: 0.5rem;
}
