/* ============================================================
   BuyerFinder – styles.css
   Fonts: Syne (headings) + DM Sans (body) + Space Grotesk (prices/numbers) via Google Fonts
   Add this to index.html <head> if not already there:
   <link href="https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:wght@300;400;500;600&family=Space+Grotesk:wght@500;600;700&display=swap" rel="stylesheet"/>
============================================================ */

:root {
  --bg:        #09090f;
  --surf:      #111118;
  --surf2:     #1a1a24;
  --border:    rgba(255,255,255,0.08);
  --accent:    #00dfa2;
  --accent2:   #7b6fff;
  --sell:      #ff5c5c;
  --req:       #4aaeff;
  --text:      #eeeef5;
  --muted:     #64647a;
  --danger:    #ef4444;
  --radius:    16px;
  --radius-sm: 10px;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* subtle grid texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

/* light mode */
body.light-theme {
  --bg:     #f0f0f5;
  --surf:   #ffffff;
  --surf2:  #e8e8f0;
  --border: rgba(0,0,0,0.08);
  --text:   #0a0a14;
  --muted:  #6b6b80;
}
body.light-theme::before { display: none; }

/* ── DEBUG BAR (hidden now) ─────────────────────────────── */
.debug-bar { display: none; }

/* ── HEADER ─────────────────────────────────────────────── */
header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(9,9,15,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 13px 16px;
  display: flex; align-items: center; justify-content: space-between;
}

header h1 {
  margin: 0;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 21px;
  letter-spacing: -0.3px;
}

header .right {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ── SEARCH BAR ─────────────────────────────────────────── */
.search-bar {
  padding: 13px 16px 8px;
  display: flex;
  gap: 0;
  max-width: 900px;
  margin: 0 auto;
}

.search-bar input {
  flex: 1;
  padding: 11px 16px;
  border-radius: 50px 0 0 50px;
  border: 1.5px solid var(--border);
  border-right: none;
  background: var(--surf);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-bar input::placeholder { color: var(--muted); }
.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,223,162,0.1);
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #000;
  padding: 8px 16px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, transform 0.12s;
}
.btn:active { transform: scale(0.96); opacity: 0.85; }

.btn.small {
  padding: 7px 14px;
  font-size: 12px;
}

/* Search button connects to input */
#search-btn, #searchgo {
  border-radius: 0 50px 50px 0;
  padding: 11px 18px;
  font-size: 13px;
  flex-shrink: 0;
}

.btn.outline {
  background: transparent;
  border: 1.5px solid var(--accent);
  color: var(--accent);
}

.btn.danger {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  color: var(--danger);
}
.btn.danger:hover { background: rgba(239,68,68,0.25); }

.btn.full { width: 100%; }

/* ── LAYOUT ─────────────────────────────────────────────── */
.content {
  padding: 10px 16px 90px;
  max-width: 900px;
  margin: 0 auto;
  position: relative; z-index: 1;
}

/* ── USER CARD ───────────────────────────────────────────── */
.user-card {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  background: var(--surf);
  border: 1px solid var(--border);
  gap: 12px;
  position: relative; z-index: 1;
}

.user-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700; font-size: 14px; color: #fff;
}
.user-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.user-avatar.small {
  width: 32px; height: 32px; font-size: 11px;
}

.user-meta { flex: 1; }
.user-meta #user-name {
  font-weight: 700; font-size: 14px;
  font-family: 'DM Sans', sans-serif;
}
.user-meta #user-email {
  font-size: 11px; color: var(--muted);
}

.badge {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.4px;
  padding: 2px 9px; border-radius: 999px;
  background: rgba(100,100,122,0.2);
  color: var(--muted);
}
.badge.premium {
  background: rgba(245,158,11,0.15);
  border: 1px solid rgba(245,158,11,0.4);
  color: #f59e0b;
}

/* ── VIEWS ───────────────────────────────────────────────── */
.view { display: none; position: relative; z-index: 1; }
.view.active { display: block; }

/* ── POSTS GRID ──────────────────────────────────────────── */
.posts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (min-width: 600px) {
  .posts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.post {
  position: relative;
  border-radius: var(--radius);
  background: var(--surf);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
  animation: fadeUp 0.3s ease both;
}
.post:active { transform: scale(0.97); }
.post:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(0,0,0,0.45);
  border-color: rgba(255,255,255,0.13);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.post:nth-child(1) { animation-delay: 0.04s; }
.post:nth-child(2) { animation-delay: 0.08s; }
.post:nth-child(3) { animation-delay: 0.12s; }
.post:nth-child(4) { animation-delay: 0.16s; }
.post:nth-child(5) { animation-delay: 0.20s; }
.post:nth-child(6) { animation-delay: 0.24s; }

.post img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

/* card body area */
.post h3 {
  margin: 0 0 3px;
  padding: 9px 10px 0;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post p {
  margin: 0;
  padding: 0 10px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* price — styled as green accent */
.post p:last-of-type {
  padding: 5px 10px 10px;
  font-family: 'Space Grotesk', 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 0;
  -webkit-line-clamp: unset;
  display: block;
}

/* edit pencil button */
.post .edit-btn {
  position: absolute;
  top: 7px; right: 7px;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s, color 0.15s;
}
.post .edit-btn:hover {
  background: rgba(0,223,162,0.2);
  color: var(--accent);
}


/* ── POST CARD FOOTER (avatar + username + price) ───────────── */
.post-footer {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px 10px;
}
.post-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #fff;
  flex-shrink: 0; overflow: hidden;
  border: 1px solid var(--border);
}
.post-username {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; flex: 1;
}
.post-price {
  font-family: 'Space Grotesk', 'DM Sans', sans-serif;
  font-weight: 700; font-size: 13px;
  color: var(--accent); flex-shrink: 0;
  letter-spacing: 0;
}

/* remove old standalone price paragraph */
.post p:last-of-type {
  display: none;
}

/* ── FAB ─────────────────────────────────────────────────── */
.fab {
  position: fixed;
  right: 18px; bottom: 68px;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 28px; font-weight: 300; line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,223,162,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 30;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,223,162,0.55);
}
.fab:active { transform: scale(0.94); }

/* ── SEGMENTED CONTROL (Selling / Requests) ──────────────── */
.segment-wrap {
  padding: 8px 16px 4px;
  position: relative; z-index: 1;
}
.segment-track {
  position: relative;
  display: flex;
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px;
  gap: 0;
}
.segment-slider {
  position: absolute;
  top: 4px; left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(255,92,92,0.18), rgba(255,92,92,0.08));
  border: 1px solid rgba(255,92,92,0.35);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
.segment-slider.right {
  transform: translateX(calc(100% + 0px));
  background: linear-gradient(135deg, rgba(74,174,255,0.18), rgba(74,174,255,0.08));
  border-color: rgba(74,174,255,0.35);
}
.segment-option {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: color 0.2s;
  position: relative; z-index: 1;
  user-select: none;
}
.segment-option.active { color: var(--text); }
.seg-dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0; transition: background 0.2s, box-shadow 0.2s;
}
.sell-dot { background: var(--sell); }
.req-dot  { background: var(--req); }
.segment-option.active .sell-dot { box-shadow: 0 0 6px var(--sell); }
.segment-option.active .req-dot  { box-shadow: 0 0 6px var(--req); }

/* ── BOTTOM NAV (5 items now) ────────────────────────────── */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(9,9,15,0.94);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  padding: 8px 4px 16px;
  z-index: 30;
}

.nav-item {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; cursor: pointer;
  padding: 4px 2px;
  border-radius: 12px;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item:active { background: rgba(255,255,255,0.05); }

.nav-item span:first-child {
  font-size: 18px;
  line-height: 1;
  transition: transform 0.15s;
}
.nav-item:hover span:first-child { transform: translateY(-1px); }

.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: color 0.15s;
}

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

/* active indicator bar */
.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  width: 20px; height: 3px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* notification badge on alerts */
.nav-item .nav-badge {
  position: absolute;
  top: 1px; right: 10%;
  min-width: 16px; height: 16px;
  border-radius: 10px;
  background: #ef4444;
  border: 2px solid var(--bg);
  font-size: 9px; font-weight: 800; color: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

/* ── MAP ─────────────────────────────────────────────────── */
.map-wrapper {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surf);
  border: 1px solid var(--border);
}
#map-canvas {
  margin-top: 10px;
  min-height: 240px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: radial-gradient(circle at top, rgba(0,223,162,0.06), var(--bg));
}

/* ── SETTINGS / SECTIONS ─────────────────────────────────── */
.section {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surf);
  border: 1px solid var(--border);
}
.section h3 {
  margin: 0 0 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px; font-weight: 700;
}

.field-row {
  display: flex; flex-wrap: wrap;
  align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.field-row label {
  min-width: 70px;
  font-size: 12px; color: var(--muted);
}
.field-row input,
.field-row textarea,
.field-row select {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surf2);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.field-row input:focus,
.field-row textarea:focus {
  border-color: var(--accent);
}
.field-row textarea { min-height: 64px; resize: vertical; }
.field-row input[type="file"] { flex: 1 1 100%; }

.hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── LIST (matches / notifications) ─────────────────────── */
.list {
  display: flex; flex-direction: column; gap: 8px;
}
.list-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surf);
  font-size: 13px;
}
.list-item small {
  display: block; font-size: 11px; color: var(--muted);
}

/* pill badges (used in matches) */
.pill {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(100,100,122,0.2);
  color: var(--muted);
}
.pill.premium {
  background: rgba(245,158,11,0.15);
  border: 1px solid rgba(245,158,11,0.35);
  color: #f59e0b;
}

/* ── MODAL ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 40;
}
.modal-backdrop.active { display: flex; }

.modal {
  width: 92%; max-width: 420px;
  border-radius: var(--radius);
  background: var(--surf);
  border: 1px solid var(--border);
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.modal h3 {
  margin: 0 0 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 17px; font-weight: 700;
}
.modal-actions {
  display: flex; justify-content: flex-end;
  gap: 8px; margin-top: 12px;
}

/* ── DETAIL PANEL ────────────────────────────────────────── */
.detail-overlay,
#detail-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  display: none; z-index: 49;
}
.detail-overlay.active,
#detail-overlay.active { display: block; }

.detail-panel,
#detail-panel {
  position: fixed;
  left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: 100%; max-width: 520px;
  max-height: 82vh;
  background: var(--surf);
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 16px;
  box-shadow: 0 -12px 40px rgba(0,0,0,0.6);
  display: none; z-index: 50;
  overflow-y: auto;
}
.detail-panel.active,
#detail-panel.active { display: block; }

.close-btn {
  position: absolute; right: 12px; top: 12px;
  border: none; background: var(--surf2);
  color: var(--muted); cursor: pointer;
  font-size: 16px; font-weight: 700;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.close-btn:hover { background: var(--border); color: var(--text); }

.detail-images {
  display: flex; gap: 8px;
  overflow-x: auto; margin-bottom: 12px;
  scrollbar-width: none;
}
.detail-images::-webkit-scrollbar { display: none; }
.detail-images img {
  border-radius: var(--radius-sm);
  max-height: 200px; flex-shrink: 0;
}

.big-price {
  font-family: 'Space Grotesk', 'DM Sans', sans-serif;
  font-size: 22px; font-weight: 700;
  color: var(--accent);
  margin: 0 0 6px;
  letter-spacing: 0;
}

.seller-row {
  display: flex; align-items: center;
  gap: 10px; margin: 10px 0;
  padding: 10px;
  background: var(--surf2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

#detail-minimap-container { margin: 10px 0; }
#detail-minimap {
  height: 160px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.delete-post-btn {
  margin-top: 14px; width: 100%;
  padding: 11px; border-radius: var(--radius-sm);
  border: none; background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger); font-weight: 700;
  cursor: pointer; transition: background 0.15s;
}
.delete-post-btn:hover { background: rgba(239,68,68,0.25); }

/* ── CHAT / MESSAGES ─────────────────────────────────────── */
.chat-modal { max-width: 420px; width: 92%; }

.chat-messages {
  max-height: 300px; overflow-y: auto;
  margin: 12px 0;
  display: flex; flex-direction: column; gap: 6px;
  scrollbar-width: none;
}
.chat-messages::-webkit-scrollbar { display: none; }

.chat-bubble {
  padding: 8px 12px;
  border-radius: 14px;
  max-width: 80%;
  font-size: 14px; line-height: 1.4;
}
.chat-bubble.me {
  align-self: flex-end;
  background: var(--accent);
  color: #000; font-weight: 500;
  border-bottom-right-radius: 4px;
}
.chat-bubble.them {
  align-self: flex-start;
  background: var(--surf2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

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

/* ── LIGHT MODE ──────────────────────────────────────────── */
body.light-theme header {
  background: rgba(240,240,245,0.9);
}
body.light-theme .detail-panel,
body.light-theme #detail-panel {
  background: #ffffff;
  border-color: rgba(0,0,0,0.08);
}
body.light-theme .modal {
  background: #ffffff;
}
body.light-theme .bottom-nav {
  background: rgba(240,240,245,0.95);
  }
