/* OlxBG — single-file stylesheet. Mobile-first. No build step. */
html { -webkit-text-size-adjust: 100%; }
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-ink: #ffffff;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.06);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.page { max-width: 1200px; margin: 0 auto; padding: 16px; min-height: calc(100vh - 200px); }
@media (max-width: 600px) {
  .page { padding: 10px; }
}

/* ---------- Header (top bar, always compact) ---------- */
.site-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 8px; color: inherit; flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 32px; height: 32px; border-radius: 7px; object-fit: cover; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.2px; }

.search-form {
  display: flex; gap: 4px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 6px 3px 12px;
  flex: 1; min-width: 0; max-width: 540px;
}
.search-form input { border: 0; background: transparent; outline: none; padding: 6px 0; flex: 1; min-width: 0; font-size: 14px; }
.search-form button { border: 0; background: transparent; cursor: pointer; font-size: 18px; color: var(--muted); padding: 4px 8px; }

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

/* Generic icon-only button used in header */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid transparent;
  color: var(--ink); cursor: pointer; font-size: 18px; line-height: 1;
  text-decoration: none;
}
.icon-btn:hover { background: #e2e8f0; text-decoration: none; }
.icon-btn.is-on { background: #dcfce7; color: #166534; }

.nav-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink);
  font-size: 14px; font-weight: 600; border: 1px solid transparent;
  white-space: nowrap;
}
.nav-pill:hover { text-decoration: none; background: #e2e8f0; }
.nav-pill.nav-primary { background: var(--primary); color: var(--primary-ink); }
.nav-pill.nav-primary:hover { background: #4338ca; }
.nav-pill.nav-muted   { color: var(--muted); }

/* Hamburger button — visible at every viewport. */
.nav-burger { font-size: 20px; }

@media (max-width: 600px) {
  .site-header { padding: 8px 10px; gap: 6px; }
  .brand-name  { display: none; }      /* logo-only on phones */
  .search-form { padding: 2px 4px 2px 10px; }
  .nav-pill    { padding: 7px 12px; font-size: 13px; }
  /* Hide the "Post" word on tiny phones — leave the + */
}
@media (max-width: 380px) {
  .header-right .nav-primary { font-size: 0; padding: 0; width: 38px; height: 38px; justify-content: center; border-radius: 999px; }
  .header-right .nav-primary::before { content: "＋"; font-size: 22px; font-weight: 600; }
}

/* ---------- Drawer (slide-in side menu) ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
  z-index: 60;
}
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: 88%; max-width: 320px;
  background: var(--surface); border-right: 1px solid var(--border);
  transform: translateX(-105%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  z-index: 70; display: flex; flex-direction: column;
  box-shadow: 0 10px 40px rgba(15,23,42,.18);
  overscroll-behavior: contain;
}
.drawer.is-open                  { transform: translateX(0); }
.drawer-backdrop.is-open         { opacity: 1; pointer-events: auto; }

.drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px; border-bottom: 1px solid var(--border);
}
.drawer-close { margin-left: auto; }

.drawer-nav { padding: 8px 0; overflow-y: auto; }
.drawer-nav a {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; color: var(--ink); font-size: 15px;
  border-left: 3px solid transparent;
}
.drawer-nav a:hover { background: var(--surface-2); text-decoration: none; border-left-color: var(--primary); }
.drawer-nav .drawer-admin { color: #92400e; background: #fef3c7; }
.drawer-nav .drawer-admin:hover { background: #fde68a; }

.drawer-section {
  padding: 14px 16px 6px; color: var(--muted);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}

.demo-banner {
  background: #fde68a; color: #92400e; text-align: center; padding: 6px 8px; font-size: 12px;
  border-bottom: 1px solid #f59e0b;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px;
}
.row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.row-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 800px) { .row-2 { grid-template-columns: 1fr; } }

.product-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.product-card .pc-img {
  aspect-ratio: 1 / 1; background: #e2e8f0 center/cover no-repeat;
  position: relative;
}
.product-card .pc-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.product-card .pc-title { font-weight: 600; color: var(--ink); }
.product-card .pc-price { color: var(--primary); font-weight: 700; }
.product-card .pc-meta  { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2);
}
.badge-sell { background: #dcfce7; color: #166534; }
.badge-buy  { background: #dbeafe; color: #1e40af; }
.badge-sold { background: #fee2e2; color: #991b1b; }
.badge-aud-boys  { background: #dbeafe; color: #1e3a8a; }
.badge-aud-girls { background: #fce7f3; color: #9d174d; }
.badge-aud-common { background: #e2e8f0; color: #334155; }
.badge-anon { background: #fef3c7; color: #92400e; }
.pc-overlay { position: absolute; top: 8px; left: 8px; display: flex; gap: 6px; }
.pc-views { position: absolute; bottom: 8px; right: 8px; background: rgba(15,23,42,.7); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 999px; }

/* Sold scrim */
.product-card.is-sold .pc-img::after {
  content: "SOLD"; position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(15,23,42,.55); color: #fff;
  font-size: 28px; font-weight: 800; letter-spacing: 4px;
}

/* ---------- Hero strip (scrolling top-15) ---------- */
.scroll-strip {
  display: grid; grid-auto-flow: column; grid-auto-columns: 220px;
  gap: 12px; overflow-x: auto; padding: 6px 2px 14px;
  scroll-snap-type: x mandatory;
}
.scroll-strip > * { scroll-snap-align: start; }

/* ---------- Buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  background: var(--primary); color: var(--primary-ink); border: 0;
  border-radius: 8px; cursor: pointer; font-weight: 600;
}
.btn:hover { background: #4338ca; }
.btn.secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); }
.btn.secondary:hover { background: #e2e8f0; }
.btn.danger { background: var(--danger); }
.btn.warn   { background: var(--warn); }
.btn.ok     { background: var(--ok); }
.btn.ghost  { background: transparent; color: var(--primary); }
.btn.full   { width: 100%; justify-content: center; }
.btn.sm     { padding: 4px 10px; font-size: 13px; }

label { display: block; margin: 8px 0 4px; font-weight: 600; font-size: 13px; }
input[type="text"], input[type="email"], input[type="number"], input[type="search"], input[type="tel"], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); font: inherit;
}
textarea { min-height: 100px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.help { color: var(--muted); font-size: 12px; }

/* ---------- Flash messages ---------- */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.flash { padding: 10px 14px; border-radius: 8px; border: 1px solid; }
.flash-success { background: #dcfce7; color: #166534; border-color: #86efac; }
.flash-error   { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.flash-info    { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.flash-warn    { background: #fef3c7; color: #92400e; border-color: #fcd34d; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center; padding: 24px 16px 60px; color: var(--muted);
  border-top: 1px solid var(--border); background: var(--surface);
}

/* ---------- Tables (admin) ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { background: var(--surface-2); font-weight: 600; color: var(--ink-2); }
.table tr:hover { background: #f8fafc; }

/* ---------- Comments / chat ---------- */
.comment {
  padding: 10px 12px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border); margin-bottom: 8px;
}
.comment.private { background: #fef3c7; border-color: #fcd34d; }
.comment .who { font-weight: 600; font-size: 13px; }
.comment .when { color: var(--muted); font-size: 12px; }
.comment .body { margin-top: 4px; white-space: pre-wrap; }

/* ---------- Filters bar ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px;
  background: var(--surface); padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 14px;
}
.filters select, .filters input { width: auto; }

/* ---------- Section header ---------- */
.section-h { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 10px; }
.section-h h2 { margin: 0; font-size: 18px; }
.section-h .more { font-size: 13px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--primary); border-color: var(--primary); }

/* ---------- Login screen ---------- */
.center-card { max-width: 420px; margin: 60px auto; }

/* ---------- Admin layout ---------- */
.admin-shell { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.admin-side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; height: fit-content; position: sticky; top: 80px; }
.admin-side a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--ink); }
.admin-side a:hover { background: var(--surface-2); text-decoration: none; }
.admin-side a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
@media (max-width: 800px) { .admin-shell { grid-template-columns: 1fr; } .admin-side { position: static; } }

/* ---------- Stat cards ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat .v { font-size: 22px; font-weight: 700; }
.stat .k { color: var(--muted); font-size: 12px; }

/* ---------- Modal ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 18px; max-width: 480px; width: 92%; box-shadow: 0 10px 40px rgba(15,23,42,.25); }
dialog::backdrop { background: rgba(15,23,42,.4); }

/* =====================================================================
   Mobile-specific overrides — keep all the rules small and consolidated
   here so the rest of the stylesheet stays readable.
   ===================================================================== */
@media (max-width: 700px) {
  .card { padding: 12px; border-radius: 10px; }
  .row { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .row-2 { gap: 12px; }
  .scroll-strip { grid-auto-columns: 160px; gap: 10px; }
  .product-card .pc-body { padding: 8px 10px 10px; }
  .product-card .pc-title { font-size: 14px; }
  .product-card .pc-price { font-size: 14px; }
  .product-card .pc-meta { font-size: 11px; }
  .product-card.is-sold .pc-img::after { font-size: 18px; letter-spacing: 2px; }

  .filters { padding: 8px; gap: 6px; }
  .filters select { font-size: 13px; padding: 8px 8px; }
  .filters input  { font-size: 13px; padding: 8px 8px; }
  .filters > * { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .filters .btn { flex: 1 1 100%; }

  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .stat .v { font-size: 18px; }

  .section-h { margin: 12px 0 8px; }
  .section-h h2 { font-size: 16px; }

  /* Admin tables — let them scroll horizontally instead of crushing columns */
  .admin-main .table { display: block; overflow-x: auto; white-space: nowrap; }
  .table th, .table td { padding: 8px 10px; font-size: 13px; }

  .center-card { margin: 30px auto; }
  .demo-banner { font-size: 11px; padding: 5px 8px; }

  /* Make every fixed-width image inside a card behave */
  .card img { max-width: 100%; height: auto; }

  /* Forms on phones — bigger tap targets, less padding */
  input, select, textarea { font-size: 16px; /* prevents iOS zoom-on-focus */ }
  textarea { min-height: 80px; }
  .btn { padding: 10px 14px; }
  .btn.sm { padding: 6px 12px; }
}

@media (max-width: 480px) {
  .row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .product-card .pc-img { aspect-ratio: 4 / 3; }
  .scroll-strip { grid-auto-columns: 140px; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  h3 { font-size: 16px; }
  .badge { font-size: 10px; padding: 2px 6px; }
}

/* Safe-area inset support for iOS */
@supports (padding: env(safe-area-inset-bottom)) {
  body  { padding-bottom: env(safe-area-inset-bottom); }
  .site-header { padding-top: max(8px, env(safe-area-inset-top)); }
}
