/* Gaggimate Companion - Design System */

:root {
  --bg: #0a0a0a;
  --surface: #161412;
  --surface-2: #1e1b18;
  --border: #2a2520;
  --text: #e8e0d4;
  --text-muted: #8a8278;
  --text-dim: #5a554e;
  --accent: #c8956c;
  --accent-soft: rgba(200, 149, 108, 0.1);
  --success: #7a9e7a;
  --warning: #c8a84e;
  --danger: #b06060;
  --radius: 8px;
  --radius-sm: 4px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
}

#app {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 80px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}

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

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 24px 0 8px;
}

.section-title:first-child { margin-top: 0; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.card:hover { background: var(--surface-2); }
.card:active { background: var(--surface-2); }

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  font-weight: 500;
  font-size: 0.9375rem;
}

.card-sub {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.card-meta {
  color: var(--text-dim);
  font-size: 0.75rem;
}

/* ─── Metric Grid ────────────────────────────────────────── */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.metric-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

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

.pill {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 100px;
  text-transform: capitalize;
}

.pill-taste {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill-sour { background: rgba(176, 96, 96, 0.12); color: var(--danger); }
.pill-balanced { background: rgba(122, 158, 122, 0.12); color: var(--success); }
.pill-bitter { background: rgba(200, 168, 78, 0.12); color: var(--warning); }

.pill-drink {
  background: rgba(200, 149, 108, 0.08);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.pill-roast {
  background: var(--surface-2);
  color: var(--text-muted);
}

.stars { color: var(--accent); font-size: 0.8125rem; letter-spacing: 1px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { background: var(--accent-soft); }

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

.btn-primary:hover { opacity: 0.9; color: #0a0a0a; }

.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn-block { width: 100%; }

.btn-group {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.btn-group .btn { flex: 1; }

/* ─── Inputs ─────────────────────────────────────────────── */

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-bottom-color: var(--accent);
}

.field select { cursor: pointer; }
.field select option { background: var(--surface); }
.field textarea { resize: vertical; min-height: 60px; }

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

.phase-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  margin: 12px 0;
}

.phase-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.phase-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(42, 37, 32, 0.5);
  color: var(--text-muted);
}

.phase-table td:first-child { color: var(--text); }

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

#nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 0 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.625rem;
  font-weight: 500;
  transition: color 0.15s;
}

.nav-tab svg {
  width: 22px;
  height: 22px;
}

.nav-tab.active { color: var(--accent); }

/* ─── Toast ──────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  z-index: 200;
  transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(10px); pointer-events: none; }

/* ─── Modal / Bottom Sheet ───────────────────────────────── */

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

.modal-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 20px 16px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  overflow-y: auto;
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

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

.chat-messages {
  margin: 12px 0;
}

.chat-msg {
  margin-bottom: 12px;
  font-size: 0.875rem;
  line-height: 1.6;
}

.chat-msg.user {
  color: var(--accent);
}

.chat-msg.assistant {
  color: var(--text-muted);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.chat-input-row input {
  flex: 1;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  outline: none;
}

.chat-input-row input:focus { border-color: var(--accent); }

/* ─── AI Analysis ────────────────────────────────────────── */

.ai-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 12px 0;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--text-muted);
  white-space: pre-wrap;
}

/* ─── Timeline ───────────────────────────────────────────── */

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(42, 37, 32, 0.4);
}

.timeline-date {
  flex-shrink: 0;
  width: 40px;
  text-align: center;
}

.timeline-date .day {
  font-size: 1.125rem;
  font-weight: 600;
}

.timeline-date .month {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.timeline-body { flex: 1; }

.timeline-body .type {
  font-weight: 500;
  font-size: 0.875rem;
}

.timeline-body .detail {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* ─── Status Indicators ──────────────────────────────────── */

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

/* ─── Sparkline ──────────────────────────────────────────── */

.sparkline {
  height: 40px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin: 8px 0;
}

.sparkline-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  opacity: 0.6;
  min-height: 4px;
  transition: opacity 0.15s;
}

.sparkline-bar:last-child { opacity: 1; }

/* ─── Empty State ────────────────────────────────────────── */

.empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.875rem;
  padding: 40px 0;
}

/* ─── Loading ────────────────────────────────────────────── */

.loading {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8125rem;
  padding: 40px 0;
}

/* ─── Back Button ────────────────────────────────────────── */

.back-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.back-row a {
  color: var(--text-muted);
  text-decoration: none;
}

.back-row a:hover { color: var(--accent); }

/* ─── Alert Banner ───────────────────────────────────────── */

.alert {
  background: rgba(176, 96, 96, 0.08);
  border: 1px solid rgba(176, 96, 96, 0.2);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.8125rem;
  color: var(--danger);
  margin-bottom: 8px;
}

.alert-warning {
  background: rgba(200, 168, 78, 0.08);
  border-color: rgba(200, 168, 78, 0.2);
  color: var(--warning);
}

/* ─── Inline Edit ────────────────────────────────────────── */

.inline-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.inline-pills .pill {
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.15s;
}

.inline-pills .pill:hover { border-color: var(--accent); }

.inline-pills .pill.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ─── Counters ───────────────────────────────────────────── */

.counter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.counter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.counter-value {
  font-size: 1.5rem;
  font-weight: 600;
}

.counter-value.warn { color: var(--warning); }
.counter-value.danger { color: var(--danger); }

.counter-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.counter-sub {
  font-size: 0.6875rem;
  color: var(--text-dim);
}
