/* BazaarPK - hand-written stylesheet (no build step needed) */
:root {
  --brand: #0b7a5f;
  --brand-dark: #075a46;
  --brand-soft: #e6f4ef;
  --accent: #f2a516;
  --accent-soft: #fff4dc;
  --ink: #17212b;
  --ink-2: #4a5866;
  --ink-3: #7b8894;
  --line: #e3e8ec;
  --bg: #f4f6f7;
  --card: #ffffff;
  --danger: #c8372d;
  --danger-soft: #fdecea;
  --ok: #18794e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 2px 8px rgba(16, 24, 32, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

/* Header */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.header-bar { display: flex; align-items: center; gap: 16px; height: 64px; }
.logo { font-weight: 800; font-size: 1.35rem; color: var(--ink); letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1rem; }
.logo span.dot { color: var(--brand); }
.header-search { flex: 1; display: flex; max-width: 640px; border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; background: #fff; }
.header-search select, .header-search input { border: 0; padding: 0 12px; font: inherit; height: 40px; background: transparent; min-width: 0; }
.header-search select { border-right: 1px solid var(--line); max-width: 160px; color: var(--ink-2); }
.header-search input { flex: 1; outline: none; }
.header-search button { border: 0; background: var(--ink); color: #fff; width: 48px; cursor: pointer; font-size: 1.1rem; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-link { position: relative; color: var(--ink); padding: 8px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.icon-link:hover { background: var(--bg); text-decoration: none; }
.badge-count { position: absolute; top: 2px; right: 0; background: var(--danger); color: #fff; font-size: .7rem; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.btn-sell { border: 3px solid var(--accent); border-radius: 999px; padding: 6px 18px; font-weight: 800; color: var(--ink); background: #fff; letter-spacing: .02em; }
.btn-sell:hover { text-decoration: none; background: var(--accent-soft); }
.menu-toggle { display: none; background: none; border: 0; font-size: 1.5rem; cursor: pointer; padding: 4px 8px; }
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 200px; padding: 6px; display: none; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 6px; color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg); text-decoration: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.5rem; }

.cat-strip { border-top: 1px solid var(--line); background: var(--card); }
.cat-strip .container { display: flex; gap: 20px; overflow-x: auto; scrollbar-width: none; height: 42px; align-items: center; }
.cat-strip .container::-webkit-scrollbar { display: none; }
.cat-strip a { color: var(--ink-2); white-space: nowrap; font-size: .9rem; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-align: center; line-height: 1.2; background: var(--brand); color: #fff; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--ink); }
.btn.secondary:hover { background: var(--bg); }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #a42b23; }
.btn.accent { background: var(--accent); color: var(--ink); }
.btn.accent:hover { background: #db920c; }
.btn.sm { padding: 6px 12px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
form.inline { display: inline; }

.field { margin-bottom: 16px; }
.field label, .label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .92rem; }
.field .hint { font-size: .82rem; color: var(--ink-3); margin-top: 4px; }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border: 1px solid #cdd5dc; border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
.input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea.input { min-height: 140px; resize: vertical; }
.input.is-invalid { border-color: var(--danger); }
.error-text { color: var(--danger); font-size: .85rem; margin-top: 4px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.seg { display: inline-flex; border: 1px solid #cdd5dc; border-radius: 8px; overflow: hidden; }
.seg label { margin: 0; padding: 9px 18px; cursor: pointer; font-weight: 500; border-right: 1px solid #cdd5dc; }
.seg label:last-child { border-right: 0; }
.seg input { display: none; }
.seg input:checked + span { color: var(--brand-dark); font-weight: 700; }
.seg label:has(input:checked) { background: var(--brand-soft); }

/* Cards & panels */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel.tight { padding: 14px; }
.page { padding: 24px 0 48px; }
.narrow { max-width: 760px; margin: 0 auto; }
.auth-box { max-width: 420px; margin: 40px auto; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert.success { background: var(--brand-soft); border-color: #b5ddd0; color: var(--brand-dark); }
.alert.error { background: var(--danger-soft); border-color: #f3c1bc; color: #8f241c; }
.alert.info { background: var(--accent-soft); border-color: #f3d79a; color: #7a5200; }

/* Hero & categories */
.hero { background: linear-gradient(135deg, var(--brand) 0%, #0e5f73 100%); color: #fff; padding: 36px 0; }
.hero h1 { font-size: 1.9rem; margin-bottom: 6px; }
.hero p { opacity: .9; margin: 0; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.cat-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-align: center; font-size: .85rem; font-weight: 600; }
.cat-tile:hover { border-color: var(--brand); text-decoration: none; }
.cat-icon { width: 54px; height: 54px; border-radius: 50%; background: var(--brand-soft); display: grid; place-items: center; font-size: 1.6rem; }
.section { margin-top: 32px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.section-head h2 { margin: 0; }

/* Ad cards */
.ad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.ad-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; color: var(--ink); position: relative; transition: box-shadow .15s; }
.ad-card:hover { box-shadow: var(--shadow); text-decoration: none; }
.ad-card.is-featured { border-left: 4px solid var(--accent); }
.ad-thumb { aspect-ratio: 4 / 3; background: #eef1f3; overflow: hidden; }
.ad-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ad-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ad-price { font-weight: 800; font-size: 1.1rem; }
.ad-title { color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.ad-meta { margin-top: auto; font-size: .78rem; color: var(--ink-3); display: flex; justify-content: space-between; gap: 6px; text-transform: uppercase; letter-spacing: .02em; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: .04em; }
.tag.featured { background: var(--accent); color: var(--ink); }
.ad-card .tag.featured { position: absolute; top: 8px; left: 8px; }
.tag.pending { background: var(--accent-soft); color: #7a5200; }
.tag.active { background: var(--brand-soft); color: var(--brand-dark); }
.tag.rejected { background: var(--danger-soft); color: #8f241c; }
.tag.verified { background: #e3f0ff; color: #1c4f8f; text-transform: none; letter-spacing: 0; }
.tag.expired { background: #fdf0e1; color: #8a4b00; }
.tag.sold, .tag.approved { background: #e8ebee; color: var(--ink-2); }
.tag.approved { background: var(--brand-soft); color: var(--brand-dark); }

/* Search layout */
.search-layout { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
.filters .panel + .panel { margin-top: 12px; }
.filters h3 { font-size: .95rem; margin-bottom: 10px; }
.filter-list { list-style: none; margin: 0; padding: 0; }
.filter-list li a { display: block; padding: 5px 0; color: var(--ink-2); }
.filter-list li a.on { color: var(--brand-dark); font-weight: 700; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink-2); font-size: .85rem; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.chip:hover { text-decoration: none; border-color: var(--brand); }

/* Ad detail */
.detail { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }
.gallery-main { background: #11181f; border-radius: var(--radius); aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; }
.gallery-main img { max-height: 100%; width: auto; object-fit: contain; }
.thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.thumbs button { border: 2px solid transparent; padding: 0; border-radius: 6px; overflow: hidden; width: 72px; height: 54px; flex-shrink: 0; cursor: pointer; background: #eee; }
.thumbs button.on { border-color: var(--brand); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.price-big { font-size: 1.9rem; font-weight: 800; margin: 0; }
.spec-table { width: 100%; border-collapse: collapse; }
.spec-table td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.spec-table td:first-child { color: var(--ink-3); width: 40%; }
.description { white-space: pre-line; overflow-wrap: anywhere; }
.seller-card { display: flex; gap: 12px; align-items: center; }
.sticky-side { position: sticky; top: 80px; }
.breadcrumb { font-size: .85rem; color: var(--ink-3); margin-bottom: 12px; }
.breadcrumb a { color: var(--ink-3); }

/* Lists & tables */
.list-item { display: flex; gap: 14px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); align-items: center; }
.list-item + .list-item { margin-top: 10px; }
.list-thumb { width: 110px; height: 82px; border-radius: 8px; overflow: hidden; background: #eef1f3; flex-shrink: 0; }
.list-thumb img { width: 100%; height: 100%; object-fit: cover; }
.list-thumb.sm { width: 64px; height: 48px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--ink-2); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a.on { color: var(--brand-dark); border-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { background: #f8fafb; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.table tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Chat */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 460px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat-head { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; background: #f7f9fa; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 75%; padding: 8px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line); align-self: flex-start; white-space: pre-line; overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; background: var(--brand); color: #fff; border-color: var(--brand); }
.bubble time { display: block; font-size: .7rem; opacity: .7; margin-top: 2px; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; min-height: 44px; max-height: 120px; resize: none; }
.quick-replies { display: flex; gap: 6px; padding: 0 12px 10px; overflow-x: auto; }
.conv-item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: var(--card); border-bottom: 1px solid var(--line); color: var(--ink); }
.conv-item:hover { background: #f9fbfb; text-decoration: none; }
.conv-item.unread .conv-title { font-weight: 800; }
.unread-dot { background: var(--brand); color: #fff; border-radius: 999px; font-size: .75rem; padding: 1px 8px; }

/* Pagination */
.pagination { display: flex; gap: 6px; justify-content: center; margin: 24px 0 0; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 38px; height: 38px; padding: 0 10px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.pagination .on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.pagination .off { color: var(--ink-3); }

/* Upload previews */
.upload-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.upload-tile { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #eef1f3; border: 1px solid var(--line); }
.upload-tile img { width: 100%; height: 100%; object-fit: cover; }
.upload-tile label { position: absolute; inset: auto 0 0 0; background: rgba(0,0,0,.6); color: #fff; font-size: .75rem; padding: 4px 6px; display: flex; gap: 4px; align-items: center; margin: 0; cursor: pointer; }
.upload-tile.removing img { opacity: .3; }
.upload-tile label.cover-pick { inset: 0 0 auto 0; background: rgba(0,0,0,.45); }
.upload-drop { display: grid; place-items: center; border: 2px dashed #b9c4cc; border-radius: 8px; aspect-ratio: 1; cursor: pointer; color: var(--ink-3); font-size: .85rem; text-align: center; padding: 8px; background: #fff; }
.upload-drop:hover { border-color: var(--brand); color: var(--brand); }

/* Admin */
.admin-shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.admin-nav { background: #12202b; color: #cfd8df; padding: 18px 12px; }
.admin-nav .logo { color: #fff; margin: 0 8px 20px; font-size: 1.1rem; }
.admin-nav a { display: flex; justify-content: space-between; align-items: center; color: #cfd8df; padding: 9px 12px; border-radius: 6px; margin-bottom: 2px; }
.admin-nav a:hover, .admin-nav a.on { background: #1f3342; color: #fff; text-decoration: none; }
.admin-nav .pill { background: var(--accent); color: var(--ink); font-size: .72rem; border-radius: 999px; padding: 0 7px; font-weight: 700; }
.admin-main { padding: 24px; min-width: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font-size: 1.6rem; }
.stat span { color: var(--ink-3); font-size: .85rem; }
details.edit-row summary { cursor: pointer; color: var(--brand); font-weight: 600; list-style: none; }
details.edit-row summary::-webkit-details-marker { display: none; }
details.edit-row[open] { background: #f8fafb; padding: 10px; border-radius: 8px; margin-top: 6px; }

/* Footer */
.site-footer { background: #12202b; color: #aab6bf; padding: 32px 0; margin-top: 40px; font-size: .9rem; }
.site-footer a { color: #dfe6eb; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
.empty { text-align: center; padding: 48px 16px; color: var(--ink-3); }
.empty .big { font-size: 2.5rem; }

.btn.whatsapp { background: #1fa855; }
.btn.whatsapp:hover { background: #178a45; }

/* Mobile bottom navigation */
.bottom-nav { display: none; }
@media (max-width: 720px) {
  body { padding-bottom: 64px; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--card); border-top: 1px solid var(--line); height: 60px; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .7rem; color: var(--ink-3); gap: 2px; }
  .bottom-nav a span { font-size: 1.2rem; line-height: 1; position: relative; }
  .bottom-nav a.on { color: var(--brand-dark); font-weight: 700; }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a.sell span { background: var(--accent); color: var(--ink); width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; margin-top: -18px; box-shadow: var(--shadow); font-weight: 800; }
  .dot-count { position: absolute; top: -6px; right: -12px; background: var(--danger); color: #fff; font-style: normal; font-size: .6rem; border-radius: 8px; padding: 0 4px; }
  .btn-sell { display: none; }
  .site-footer { margin-bottom: 0; }
}

/* Mobile */
@media (max-width: 900px) {
  .search-layout, .detail { grid-template-columns: 1fr; }
  .sticky-side { position: static; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav { display: flex; overflow-x: auto; gap: 4px; padding: 10px; }
  .admin-nav .logo { display: none; }
  .admin-nav a { white-space: nowrap; margin: 0; }
  .admin-main { padding: 16px; }
}
@media (max-width: 720px) {
  .header-bar { flex-wrap: wrap; height: auto; padding: 10px 0; gap: 10px; }
  .header-search { order: 3; flex-basis: 100%; max-width: none; }
  .header-search select { display: none; }
  .header-actions { margin-left: auto; }
  .header-actions .label-text { display: none; }
  .ad-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .ad-price { font-size: 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .hero { padding: 24px 0; }
  .hero h1 { font-size: 1.4rem; }
  .list-thumb { width: 84px; height: 64px; }
  .bubble { max-width: 88%; }
  .footer-grid { grid-template-columns: 1fr; }
  .chat-wrap { height: calc(100vh - 190px); }
}
