/* ── Reset & Variables ───────────────────────────────────────────────────── */

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

:root {
  --bg: #faf7f2;
  --bg-card: #ffffff;
  --bg-input: #f5f0e8;
  --fg: #1a1208;
  --fg-muted: #7a6a52;
  --border: #e8dece;
  --primary: #6b3f1f;
  --primary-hover: #52300f;
  --primary-fg: #ffffff;
  --accent: #c8873a;
  --accent-light: #fef3e2;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}

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

h1, h2, h3 { font-weight: 700; line-height: 1.2; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

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

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: #b5762e; }

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-input); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-icon {
  padding: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--bg-input); color: var(--fg); }

/* ── Form elements ──────────────────────────────────────────────────────────── */

.input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--fg);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: border-color 0.15s;
  outline: none;
}
.input:focus { border-color: var(--primary); }
.input::placeholder { color: var(--fg-muted); }

textarea.input { resize: vertical; min-height: 80px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.9rem; font-weight: 600; color: var(--fg-muted); }

/* ── Badges & pills ─────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-cozy     { background: #fef3c7; color: #92400e; }
.badge-work     { background: #dbeafe; color: #1e40af; }
.badge-hipster  { background: #f3e8ff; color: #6b21a8; }
.badge-romantic { background: #fce7f3; color: #9d174d; }
.badge-festif   { background: #dcfce7; color: #166534; }
.badge-arr      { background: var(--bg-input); color: var(--fg-muted); font-size: 0.75rem; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */

.page { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Navbar ─────────────────────────────────────────────────────────────────── */

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
  text-decoration: none;
}
.navbar-brand:hover { text-decoration: none; }

.navbar-brand span { color: var(--accent); }

.navbar-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.navbar-search .input {
  padding-left: 36px;
  background: var(--bg);
}

.navbar-search .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-muted);
  pointer-events: none;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg-muted);
}

.animal-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-light);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ── Filters bar ────────────────────────────────────────────────────────────── */

.filters-bar {
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--fg-muted);
  transition: all 0.15s;
}

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

select.filter-select {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--fg-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
select.filter-select:focus { border-color: var(--primary); }

/* ── Main content ───────────────────────────────────────────────────────────── */

.main-content { flex: 1; padding: 24px; }

/* ── Café grid ──────────────────────────────────────────────────────────────── */

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

.cafe-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
}

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

.cafe-card-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.cafe-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cafe-card-body { padding: 14px; }

.cafe-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.cafe-card-name { font-size: 1rem; font-weight: 700; }
.cafe-card-arr { color: var(--fg-muted); font-size: 0.85rem; margin-bottom: 8px; }

.cafe-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.like-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--fg-muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.like-btn:hover { background: #fef2f2; color: #ef4444; }
.like-btn.liked { color: #ef4444; }
.like-btn svg { transition: transform 0.15s; }
.like-btn.liked svg { transform: scale(1.2); }

/* ── Noise bar ──────────────────────────────────────────────────────────────── */

.noise-bar {
  display: flex;
  gap: 3px;
  align-items: center;
}

.noise-segment {
  width: 16px;
  height: 8px;
  border-radius: 3px;
  background: var(--border);
  transition: background 0.15s;
}

.noise-segment.filled { background: var(--accent); }

.noise-bar-interactive .noise-segment {
  cursor: pointer;
  width: 20px;
  height: 10px;
}

.noise-bar-interactive .noise-segment:hover ~ .noise-segment,
.noise-bar-interactive:hover .noise-segment { background: var(--accent-light); }

.noise-bar-interactive:hover .noise-segment.hovered { background: var(--accent); }

/* ── Detail view ────────────────────────────────────────────────────────────── */

.view { display: none; }
.view.active { display: block; }

.detail-header {
  position: relative;
  height: 240px;
  background: var(--bg-input);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
}

.detail-header img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-back {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(255,255,255,0.9);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-back:hover { background: #fff; }

.detail-body { max-width: 800px; margin: 0 auto; }

.detail-name {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--fg-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.detail-meta a { color: var(--primary); }

.detail-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.detail-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  margin-bottom: 12px;
}

/* ── Mood section ───────────────────────────────────────────────────────────── */

.mood-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mood-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg);
  min-width: 80px;
}

.mood-option:hover { border-color: var(--primary); }
.mood-option.selected { border-color: var(--primary); background: var(--accent-light); }
.mood-option .mood-emoji { font-size: 1.4rem; }
.mood-option .mood-label { font-size: 0.78rem; font-weight: 600; color: var(--fg-muted); }
.mood-option .mood-count { font-size: 0.75rem; color: var(--fg-muted); }
.mood-option.selected .mood-label { color: var(--primary); }

/* ── Noise section ──────────────────────────────────────────────────────────── */

.noise-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.noise-label { font-size: 0.85rem; color: var(--fg-muted); min-width: 70px; }

/* ── Crowd heatmap ──────────────────────────────────────────────────────────── */

.heatmap-container { overflow-x: auto; }

.heatmap-grid {
  display: grid;
  grid-template-columns: 40px repeat(24, 1fr);
  gap: 2px;
  min-width: 600px;
}

.heatmap-cell {
  height: 20px;
  border-radius: 3px;
  background: var(--bg-input);
}

.heatmap-cell.l0 { background: var(--bg-input); }
.heatmap-cell.l1 { background: #fde68a; }
.heatmap-cell.l2 { background: #fbbf24; }
.heatmap-cell.l3 { background: #f59e0b; }
.heatmap-cell.l4 { background: #d97706; }

.heatmap-label {
  font-size: 0.7rem;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 4px;
}

.heatmap-hour-label {
  font-size: 0.65rem;
  color: var(--fg-muted);
  text-align: center;
}

/* ── Comments ───────────────────────────────────────────────────────────────── */

.comment-form {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.comment-form .input { flex: 1; }

.comments-list { display: flex; flex-direction: column; gap: 12px; }

.comment-item {
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

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

.comment-author { font-weight: 700; font-size: 0.9rem; }
.comment-date { font-size: 0.78rem; color: var(--fg-muted); }
.comment-content { font-size: 0.92rem; }

.comment-delete-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--fg-muted);
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 4px;
}
.comment-delete-btn:hover { color: var(--danger); background: #fef2f2; }

/* ── Crowd report button ────────────────────────────────────────────────────── */

.crowd-report {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.busyness-selector {
  display: flex;
  gap: 6px;
}

.busyness-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.busyness-btn:hover { border-color: var(--accent); }
.busyness-btn.selected { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Modal ──────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 20px; }

/* ── Auth tabs ──────────────────────────────────────────────────────────────── */

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Quiz ───────────────────────────────────────────────────────────────────── */

.quiz-question { margin-bottom: 20px; }
.quiz-question h3 { font-size: 1rem; margin-bottom: 10px; }

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg);
}

.quiz-option:hover { border-color: var(--primary); background: var(--accent-light); }
.quiz-option input[type="radio"] { accent-color: var(--primary); }
.quiz-option label { cursor: pointer; font-size: 0.9rem; flex: 1; }

/* ── Animal result ──────────────────────────────────────────────────────────── */

.animal-result {
  text-align: center;
  padding: 24px 0;
}
.animal-result .animal-emoji { font-size: 4rem; display: block; margin-bottom: 12px; }
.animal-result h2 { margin-bottom: 8px; }
.animal-result p { color: var(--fg-muted); }

/* ── Landing page ───────────────────────────────────────────────────────────── */

.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  background: linear-gradient(135deg, #faf7f2 0%, #fef3e2 100%);
}

.landing-logo { font-size: 3rem; margin-bottom: 8px; }

.landing h1 {
  font-size: 2.8rem;
  color: var(--primary);
  margin-bottom: 8px;
}

.landing h1 span { color: var(--accent); }

.landing-tagline {
  font-size: 1.15rem;
  color: var(--fg-muted);
  margin-bottom: 32px;
  max-width: 500px;
}

.landing-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Submit form ────────────────────────────────────────────────────────────── */

.submit-form {
  max-width: 600px;
  margin: 0 auto;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px;
}

.submit-form h2 { margin-bottom: 20px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Admin panel ────────────────────────────────────────────────────────────── */

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.pending-cafe {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.pending-cafe-info { flex: 1; }
.pending-cafe-name { font-weight: 700; margin-bottom: 4px; }
.pending-cafe-meta { font-size: 0.85rem; color: var(--fg-muted); }
.pending-cafe-actions { display: flex; gap: 8px; }

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

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
  max-width: 320px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }

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

/* ── Empty state ────────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--fg-muted);
}
.empty-state .empty-icon { font-size: 3rem; display: block; margin-bottom: 12px; }
.empty-state h3 { margin-bottom: 8px; color: var(--fg); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .navbar { padding: 0 12px; gap: 8px; }
  .navbar-search { display: none; }
  .main-content { padding: 16px; }
  .cafe-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .landing h1 { font-size: 2rem; }
}
