/* Common Components — NeighborHelp */

/* ---- Bottom Navigation (mobile) ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--bottom-nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted); padding: 6px 12px;
  border-radius: var(--radius-sm); transition: color 0.15s;
}
.bottom-nav a.active { color: var(--accent); font-weight: 600; }
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav .publish-btn {
  width: 44px; height: 44px; border-radius: var(--radius-full);
  background: var(--accent); color: #fff; display: flex;
  align-items: center; justify-content: center; margin-top: -18px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: transform 0.15s, box-shadow 0.15s;
}
.bottom-nav .publish-btn:active { transform: scale(0.94); }
.bottom-nav .publish-btn svg { width: 22px; height: 22px; }

/* ---- Top Nav (desktop) ---- */
.top-nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-height);
  background: oklch(97% 0.005 85 / 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; padding: 0 var(--space-xl);
}
.top-nav .logo {
  font-family: var(--font-display); font-size: 20px; font-weight: 700;
  color: var(--fg); letter-spacing: -0.01em;
}
.top-nav .logo span { color: var(--accent); }
.top-nav nav { display: flex; gap: 4px; margin-left: var(--space-3xl); }
.top-nav nav a {
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.top-nav nav a:hover { background: var(--border-light); color: var(--fg); }
.top-nav nav a.active { background: var(--accent-subtle); color: var(--accent); }
.top-nav .nav-right {
  margin-left: auto; display: flex; align-items: center; gap: var(--space-md);
}

/* ---- Page container ---- */
.page {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: var(--space-lg) var(--space-lg) calc(var(--bottom-nav-height) + var(--space-xl));
}
@media (min-width: 1024px) {
  .page { padding-bottom: var(--space-4xl); }
  .bottom-nav { display: none; }
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: var(--space-lg);
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-sm); }
.card.interactive { cursor: pointer; }
.card.interactive:hover { box-shadow: var(--shadow-md); }

/* ---- Avatar ---- */
.avatar {
  width: 40px; height: 40px; border-radius: var(--radius-full);
  background: var(--border); flex-shrink: 0; overflow: hidden;
}
.avatar.sm { width: 32px; height: 32px; }
.avatar.lg { width: 64px; height: 64px; }

/* ---- Badges / Tags ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600; line-height: 1.4;
}
.badge--accent  { background: var(--accent-subtle); color: var(--accent); }
.badge--success { background: var(--success-light); color: var(--success); }
.badge--warning { background: var(--warning-light); color: var(--warning); }
.badge--danger  { background: var(--danger-light); color: var(--danger); }
.badge--reward  { background: oklch(94% 0.05 82); color: var(--reward-gold); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-md);
  font-size: 15px; font-weight: 600; line-height: 1.4;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--secondary { background: var(--border-light); color: var(--fg); }
.btn--secondary:hover { background: var(--border); }
.btn--outline {
  background: transparent; color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn--outline:hover { background: var(--accent-subtle); }
.btn--ghost { color: var(--muted); }
.btn--ghost:hover { background: var(--border-light); color: var(--fg); }
.btn--sm { padding: 6px 14px; font-size: 13px; border-radius: var(--radius-sm); }
.btn--lg { padding: 14px 28px; font-size: 16px; border-radius: var(--radius-lg); }
.btn--full { width: 100%; }
.btn--icon { width: 40px; height: 40px; padding: 0; border-radius: var(--radius-full); }

/* ---- Inputs ---- */
.input {
  width: 100%; padding: 10px 14px; border-radius: var(--radius-md);
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 15px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.input::placeholder { color: var(--muted); }
textarea.input { resize: vertical; min-height: 100px; line-height: 1.6; }

/* ---- Chips / Filter tags ---- */
.chip {
  display: inline-flex; align-items: center; padding: 6px 14px;
  border-radius: var(--radius-full); font-size: 13px; font-weight: 500;
  border: 1.5px solid var(--border); color: var(--muted);
  transition: all 0.15s; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--accent-light); color: var(--fg); }
.chip.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ---- Section headers ---- */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-lg);
}
.section-title {
  font-family: var(--font-display); font-size: 20px; font-weight: 700;
  letter-spacing: -0.01em;
}
.section-action {
  font-size: 14px; font-weight: 500; color: var(--accent);
}

/* ---- Divider ---- */
.divider {
  height: 1px; background: var(--border-light); margin: var(--space-lg) 0;
}
.divider--dashed {
  height: 0; border-top: 1.5px dashed var(--border);
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center; padding: var(--space-4xl) var(--space-xl); color: var(--muted);
}
.empty-state svg { width: 64px; height: 64px; opacity: 0.3; margin-bottom: var(--space-lg); }
.empty-state p { font-size: 15px; }

/* ---- Tabs ---- */
.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--border-light); border-radius: var(--radius-md);
}
.tabs button {
  flex: 1; padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--muted);
  transition: all 0.15s;
}
.tabs button.active {
  background: var(--surface); color: var(--fg);
  box-shadow: var(--shadow-sm);
}

/* ---- Toast / notification dot ---- */
.dot { width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--danger); }

/* ---- AI FAB (Floating Action Button) ---- */
.ai-fab {
  position: fixed; bottom: 80px; right: var(--space-lg); z-index: 90;
  width: 52px; height: 52px; border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--secondary), oklch(62% 0.12 200));
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px oklch(52% 0.12 175 / 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}
.ai-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 20px oklch(52% 0.12 175 / 0.4);
}
.ai-fab:active { transform: scale(0.95); }
.ai-fab svg { width: 24px; height: 24px; }
.ai-fab .fab-pulse {
  position: absolute; inset: -4px; border-radius: var(--radius-full);
  border: 2px solid oklch(62% 0.12 200 / 0.4);
  animation: fabPulse 2s ease-out infinite;
}
@keyframes fabPulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.4); opacity: 0; }
}
@media (min-width: 1024px) {
  .ai-fab { bottom: var(--space-3xl); right: var(--space-3xl); }
}

/* AI filter button in search bar */
.ai-filter-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 14px; border-radius: var(--radius-full);
  background: linear-gradient(135deg, oklch(94% 0.03 175), oklch(96% 0.02 200));
  border: 1.5px solid var(--secondary-light);
  font-size: 13px; font-weight: 600; color: var(--secondary);
  cursor: pointer; transition: all 0.15s;
  white-space: nowrap; flex-shrink: 0;
}
.ai-filter-btn:hover {
  border-color: var(--secondary);
  box-shadow: 0 2px 8px oklch(52% 0.12 175 / 0.15);
}
.ai-filter-btn svg { width: 16px; height: 16px; }

/* AI assist button in form */
.ai-assist-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--radius-md);
  background: var(--surface); border: 1.5px dashed var(--secondary-light);
  font-size: 14px; font-weight: 500; color: var(--secondary);
  cursor: pointer; transition: all 0.15s;
}
.ai-assist-btn:hover {
  border-color: var(--secondary);
  background: oklch(96% 0.02 200);
}
.ai-assist-btn:active { transform: scale(0.97); }
.ai-assist-btn svg { width: 18px; height: 18px; }

/* ─── AI Modal Overlay ─── */
.ai-modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.35); display: flex; align-items: flex-end;
  justify-content: center; opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
}
.ai-modal-overlay.open { opacity: 1; pointer-events: auto; }

.ai-modal-sheet {
  background: var(--bg); width: 100%; max-width: 520px; max-height: 100dvh;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(24px); transition: transform 0.3s ease;
}
.ai-modal-overlay.open .ai-modal-sheet { transform: translateY(0); }

@media (min-width: 768px) {
  .ai-modal-overlay { align-items: center; }
  .ai-modal-sheet {
    border-radius: var(--radius-xl); max-height: 90dvh;
    height: auto; min-height: 500px; max-width: 560px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  }
}

.ai-modal-header {
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-lg); border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.ai-modal-brand { flex: 1; display: flex; align-items: center; gap: var(--space-sm); }
.ai-modal-avatar {
  width: 32px; height: 32px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.ai-modal-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.ai-modal-subtitle { font-size: 11px; color: var(--muted); }
.ai-modal-header-actions { display: flex; gap: var(--space-sm); }
.ai-modal-icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; flex-shrink: 0;
}
.ai-modal-icon-btn:hover { background: var(--border-light); }

/* Scene bar */
.ai-modal-scene-bar {
  display: flex; gap: 6px; padding: var(--space-md) var(--space-lg);
  overflow-x: auto; scrollbar-width: none; flex-shrink: 0;
}
.ai-modal-scene-bar::-webkit-scrollbar { display: none; }
.ai-modal-scene-chip {
  padding: 7px 14px; border-radius: var(--radius-full);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  border: 1.5px solid var(--border); color: var(--muted);
  cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 5px;
}
.ai-modal-scene-chip:hover { border-color: var(--accent-light); color: var(--fg); }
.ai-modal-scene-chip.active {
  background: var(--secondary); border-color: var(--secondary); color: #fff;
}
.ai-modal-scene-chip svg { width: 15px; height: 15px; }

/* Chat area */
.ai-modal-chat {
  flex: 1; overflow-y: auto; padding: var(--space-lg);
  display: flex; flex-direction: column; gap: var(--space-lg);
  scroll-behavior: smooth;
}

/* Welcome */
.ai-modal-welcome { text-align: center; padding: var(--space-xl) 0; }
.ai-modal-welcome .welcome-icon {
  width: 64px; height: 64px; border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto var(--space-xl); color: #fff;
  box-shadow: 0 4px 16px oklch(52% 0.12 175 / 0.25);
}
.ai-modal-welcome .welcome-icon svg { width: 32px; height: 32px; }
.ai-modal-welcome h2 {
  font-family: var(--font-display); font-size: 20px; font-weight: 700; margin-bottom: var(--space-sm);
}
.ai-modal-welcome p {
  font-size: 14px; color: var(--muted); line-height: 1.6; max-width: 340px; margin: 0 auto;
}
.suggested-qs { margin-top: var(--space-xl); }
.sq-label {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-md); text-align: left;
}
.sq-grid { display: grid; gap: 8px; }
.sq-btn {
  width: 100%; text-align: left; padding: 12px 16px; border-radius: var(--radius-md);
  border: 1px solid var(--border-light); background: var(--surface);
  font-size: 14px; line-height: 1.5; color: var(--fg); cursor: pointer;
  transition: all 0.15s; display: flex; align-items: center; gap: var(--space-sm);
}
.sq-btn:hover { border-color: var(--secondary); box-shadow: 0 2px 8px oklch(52% 0.12 175 / 0.1); }
.sq-icon {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sq-text { flex: 1; min-width: 0; }

/* Chat messages */
.ai-modal-msg {
  display: flex; gap: var(--space-md); max-width: 90%;
  animation: aiModalMsgIn 0.25s ease;
}
@keyframes aiModalMsgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.ai-modal-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.ai-modal-msg.assistant { align-self: flex-start; }
.ai-modal-msg-avatar {
  width: 30px; height: 30px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 13px; font-weight: 700; color: #fff;
}
.ai-modal-msg.user .ai-modal-msg-avatar { background: oklch(60% 0.12 28); }
.ai-modal-msg.assistant .ai-modal-msg-avatar {
  background: linear-gradient(135deg, var(--secondary), oklch(62% 0.12 200));
}
.ai-modal-msg-bubble {
  padding: 10px 16px; border-radius: var(--radius-lg); font-size: 14px;
  line-height: 1.6; word-break: break-word;
}
.ai-modal-msg.user .ai-modal-msg-bubble {
  background: var(--accent); color: #fff; border-bottom-right-radius: 4px;
}
.ai-modal-msg.assistant .ai-modal-msg-bubble {
  background: var(--surface); border: 1px solid var(--border-light);
  border-bottom-left-radius: 4px;
}
.ai-modal-msg-actions { display: flex; gap: var(--space-sm); margin-top: 6px; }
.ai-modal-msg.assistant .ai-modal-msg-actions { justify-content: flex-start; }
.ai-modal-msg-action-btn {
  font-size: 11px; padding: 4px 10px; border-radius: var(--radius-full);
  border: 1px solid var(--border-light); color: var(--muted);
  background: var(--surface); cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; gap: 3px;
}
.ai-modal-msg-action-btn:hover { border-color: var(--accent-light); color: var(--accent); }
.ai-modal-msg-action-btn.active { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent); }
.ai-modal-msg-action-btn svg { width: 12px; height: 12px; }

/* Apply filter card */
.apply-filter-card {
  margin-top: var(--space-sm); background: var(--bg);
  border: 1.5px solid var(--secondary-light); border-radius: var(--radius-md);
  padding: var(--space-md);
}
.filter-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--space-sm); }
.filter-tag {
  font-size: 12px; padding: 4px 10px; border-radius: var(--radius-full);
  background: var(--secondary-light); color: var(--secondary); font-weight: 500;
}
.apply-filter-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-md);
  background: var(--secondary); color: #fff; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: background 0.15s, transform 0.1s;
}
.apply-filter-btn:hover { background: oklch(48% 0.12 175); }
.apply-filter-btn:active { transform: scale(0.97); }

/* Rules list */
.ai-rules-list {
  list-style: none; font-size: 13px; line-height: 1.8; margin-top: var(--space-md);
}
.ai-rules-list li { padding-left: var(--space-md); position: relative; }
.ai-rules-list li::before {
  content: '·'; position: absolute; left: 0; color: var(--secondary); font-weight: 700;
}
.ai-rules-footer { margin-top: var(--space-md); font-size: 12px; color: var(--muted); }

/* Draft card */
.draft-card {
  margin-top: var(--space-sm); background: var(--bg);
  border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: var(--space-md);
}
.draft-card .draft-title { font-size: 15px; font-weight: 600; margin-bottom: var(--space-sm); }
.draft-card .draft-body {
  font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: var(--space-md);
}
.draft-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--space-md); }
.draft-actions { display: flex; gap: var(--space-sm); }

/* Typing */
.ai-modal-typing {
  display: flex; align-items: center; gap: 4px; padding: 12px 18px;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); border-bottom-left-radius: 4px;
  align-self: flex-start; max-width: 90%;
}
.tdot {
  width: 7px; height: 7px; border-radius: var(--radius-full);
  background: var(--muted); animation: tdotPulse 1.4s ease infinite;
}
.tdot:nth-child(2) { animation-delay: 0.2s; }
.tdot:nth-child(3) { animation-delay: 0.4s; }
@keyframes tdotPulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
  30% { opacity: 1; transform: scale(1); }
}

/* Disclaimer */
.ai-modal-disclaimer {
  text-align: center; font-size: 11px; color: var(--muted);
  padding: var(--space-md) var(--space-lg); line-height: 1.5; flex-shrink: 0;
  border-top: 1px solid var(--border-light);
}

/* Input bar */
.ai-modal-input-bar {
  display: flex; align-items: flex-end; gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg) calc(var(--space-md) + env(safe-area-inset-bottom, 0));
  background: var(--surface); border-top: 1px solid var(--border-light); flex-shrink: 0;
}
.ai-modal-input-bar textarea {
  flex: 1; border: 1.5px solid var(--border); border-radius: var(--radius-xl);
  padding: 10px 16px; font-size: 14px; line-height: 1.45;
  outline: none; resize: none; max-height: 100px; background: var(--bg);
  transition: border-color 0.15s;
}
.ai-modal-input-bar textarea:focus { border-color: var(--secondary); }
.ai-modal-send-btn {
  width: 42px; height: 42px; border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--secondary), oklch(62% 0.12 200));
  color: #fff; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px oklch(52% 0.12 175 / 0.2);
}
.ai-modal-send-btn:hover { background: var(--secondary); }
.ai-modal-send-btn:active { transform: scale(0.94); }
.ai-modal-send-btn:disabled { opacity: 0.4; pointer-events: none; }
.ai-modal-send-btn svg { width: 18px; height: 18px; }

/* ---- Skeleton loading ---- */
.skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 37%, var(--border-light) 63%);
  background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* Legacy admin pages: prevent desktop tables/layout from widening mobile viewports. */
@media (max-width: 860px) {
  .admin-page {
    display: block !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .admin-main {
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
  }

  .au-search-row,
  .al-search-row,
  .filter-row,
  .search-row {
    min-width: 0 !important;
  }

  .au-search,
  .al-search {
    min-width: 0 !important;
  }

  .au-filter-group,
  .ai-subnav {
    max-width: 100% !important;
    overflow-x: auto !important;
    scrollbar-width: none;
  }

  .au-filter-group::-webkit-scrollbar,
  .ai-subnav::-webkit-scrollbar {
    display: none;
  }

  .au-table-wrap,
  .al-table-wrap,
  .audit-list,
  .cat-grid,
  .stats-grid {
    max-width: 100% !important;
  }
}
