/* Bazar — marketplace TikTok-style.
   Layout fullscreen avec snap scroll vertical entre articles + horizontal entre médias.
*/

html, body.bazar-body {
  margin: 0; padding: 0;
  background: #000;
  color: #fff;
  font-family: Nunito, sans-serif;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body.bazar-body { touch-action: pan-y; }

/* ─── Header overlay ─────────────────────────────────────────────── */
.bazar-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  background: linear-gradient(180deg, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 100%);
  pointer-events: none;
}
.bazar-header > * { pointer-events: auto; }
.bazar-back, .bazar-action {
  appearance: none; border: none;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(0,0,0,.4);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; text-decoration: none; cursor: pointer;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.bazar-title {
  flex: 1;
  font-size: 20px;
  font-weight: 900;
  margin: 0;
  letter-spacing: -.5px;
  text-shadow: 0 2px 8px rgba(0,0,0,.7);
}

/* ─── Feed pager (vertical scroll-snap) ──────────────────────────── */
.bazar-feed {
  height: 100vh; height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.bazar-feed::-webkit-scrollbar { display: none; }

.bazar-loading {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; color: rgba(255,255,255,.7);
  font-size: 14px;
}
.bazar-loading .fa-spinner { margin-right: 8px; }

/* ─── Article (1 page = 1 article) ───────────────────────────────── */
.bazar-article {
  position: relative;
  height: 100vh; height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  background: #111;
}

/* Carousel horizontal des médias d'un article */
.bazar-media-carousel {
  position: absolute; inset: 0;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  background: #000;
}
.bazar-media-carousel::-webkit-scrollbar { display: none; }
.bazar-media-item {
  position: relative;
  flex: 0 0 100vw;
  width: 100vw;
  height: 100%;
  scroll-snap-align: start;
  display: flex; align-items: center; justify-content: center;
  background: #000;
}
.bazar-media-item img,
.bazar-media-item video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.bazar-media-item video { cursor: pointer; }

/* Indicateur position carousel (dots horizontaux en bas) */
.bazar-media-dots {
  position: absolute;
  bottom: 92px;
  left: 50%; transform: translateX(-50%);
  display: flex; gap: 5px;
  z-index: 5;
  pointer-events: none;
}
.bazar-media-dots .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.35);
  transition: width .2s ease, background .2s ease;
}
.bazar-media-dots .dot.active {
  width: 18px;
  background:var(--card-bg);
  border-radius: 3px;
}
.bazar-media-dots .dot.video::before {
  content: ""; display: block; width: 100%; height: 100%; border-radius: inherit;
  background: linear-gradient(135deg, #F5B027 0%, #6750A4 100%);
}
.bazar-media-dots .dot:not(.video)::before { display: none; }

/* Right-rail buttons (style TikTok) */
.bazar-rail {
  position: absolute;
  right: 10px;
  bottom: 92px;
  z-index: 10;
  display: flex; flex-direction: column;
  align-items: center; gap: 18px;
  pointer-events: none;
}
.bazar-rail > * { pointer-events: auto; }
.bazar-rail-btn {
  appearance: none; border: none;
  background: transparent;
  color: #fff;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer;
  text-shadow: 0 2px 6px rgba(0,0,0,.7);
}
.bazar-rail-btn i {
  font-size: 30px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.6));
  transition: transform .15s ease;
}
.bazar-rail-btn:active i { transform: scale(.85); }
.bazar-rail-btn span {
  font-size: 12px;
  font-weight: 800;
}
.bazar-rail-btn.liked i { color: #FF3B30; }
.bazar-rail-btn.liked i::before { content: "\f004"; font-family: 'Font Awesome 6 Free'; font-weight: 900; }

.bazar-rail-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #1C1C2E;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; color: #fff;
  margin-bottom: 4px;
  overflow: hidden;
  cursor: pointer;
}
.bazar-rail-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Bottom info card (titre + prix + desc + boutons paiement) */
.bazar-info {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 80px 14px max(20px, env(safe-area-inset-bottom)) 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.85) 70%);
  z-index: 5;
}
.bazar-info-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px;
  font-size: 13px;
  color: rgba(255,255,255,.85);
  font-weight: 700;
}
.bazar-info-row a { color: #fff; text-decoration: none; }
.bazar-info-row strong { color: #fff; }
.bazar-info-row .bazar-dist {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.18);
  padding: 2px 8px; border-radius: 10px;
  font-size: 11.5px;
}
/* Polish 2 — seller pseudo clickable + reputation badge inline */
.bazar-seller-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.bazar-seller-link:active { opacity: .8; }
.bazar-seller-badge { display: inline-flex; }
.bazar-seller-badge:empty { display: none; }
/* On bazar cards (white text on dark image overlay), tweak badge legibility */
.bazar-info-row .evo-rep-badge {
  background: rgba(255,255,255,.92);
}
.bazar-info-row .evo-rep-badge--high { color: #1B5E20; }
.bazar-info-row .evo-rep-badge--mid  { color: #BF360C; }
.bazar-info-row .evo-rep-badge--low  { color: #B71C1C; }
.bazar-info-row .evo-rep-badge--new  { color: #424242; }
.bazar-title-card {
  font-size: 17px;
  font-weight: 900;
  margin: 0 0 6px;
  line-height: 1.25;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,.85);
}
.bazar-price {
  font-size: 22px;
  font-weight: 900;
  color: #F5B027;
  margin-bottom: 4px;
  display: inline-flex; align-items: center; gap: 8px;
}
.bazar-price .negotiable {
  font-size: 11px;
  font-weight: 700;
  background: rgba(255,255,255,.2);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
}
.bazar-desc {
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255,255,255,.85);
  margin: 0 0 10px;
  max-height: 4.2em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.bazar-payment-modes {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 6px;
}
.bazar-payment-mode {
  font-size: 10.5px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(245,176,39,.25);
  color: #FFE7C7;
  border: 1px solid rgba(245,176,39,.4);
  text-transform: uppercase;
  letter-spacing: .3px;
}

/* ─── Create FAB ─────────────────────────────────────────────────── */
.bazar-create-fab {
  position: fixed;
  right: 16px;
  top: 70px;
  z-index: 40;
  width: 50px; height: 50px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #F5B027 0%, #6750A4 100%);
  color: #fff;
  font-size: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(103, 80, 164,.4);
}

/* ─── Comments drawer ────────────────────────────────────────────── */
.bazar-comments-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,0);
  display: flex; align-items: flex-end; justify-content: center;
  transition: background .28s ease;
}
.bazar-comments-overlay.show { background: rgba(0,0,0,.5); }
.bazar-comments-sheet {
  background: #1C1C2E;
  width: 100%; max-width: 600px;
  border-radius: 20px 20px 0 0;
  padding: 14px 0 0;
  color: #fff;
  height: 70vh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.34,1.2,.64,1);
}
.bazar-comments-overlay.show .bazar-comments-sheet { transform: translateY(0); }
.bazar-comments-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.bazar-comments-head h3 { font-size: 14px; font-weight: 800; margin: 0; }
.bazar-comments-close {
  appearance: none; border: none;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.08); color: #fff;
  cursor: pointer; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
}
.bazar-comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}
.bazar-comment-item {
  display: flex; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.bazar-comment-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F5B027 0%, #6750A4 100%);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 900;
  color: #fff;
  font-size: 12px;
  flex: 0 0 32px;
  overflow: hidden;
}
.bazar-comment-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bazar-comment-body { flex: 1; min-width: 0; }
.bazar-comment-pseudo {
  font-size: 12.5px; font-weight: 800; color: #F5B027;
  margin-bottom: 2px;
}
.bazar-comment-text {
  font-size: 13.5px; line-height: 1.4;
  color: #fff;
  word-wrap: break-word;
}
.bazar-comment-date {
  font-size: 11px; color: rgba(255,255,255,.5);
  margin-top: 2px;
}

.bazar-comments-composer {
  display: flex; gap: 8px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,.08);
}
.bazar-comments-composer input {
  flex: 1;
  appearance: none; border: none; outline: none;
  background: rgba(255,255,255,.08);
  color: #fff;
  font-family: Nunito; font-size: 14px;
  padding: 10px 14px;
  border-radius: 22px;
}
.bazar-comments-send {
  appearance: none; border: none;
  background: linear-gradient(135deg, #F5B027 0%, #6750A4 100%);
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ─── Create modal (full screen multi-step) ─────────────────────── */
.bazar-create-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: var(--bg);
  color: var(--text);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.34,1.2,.64,1);
}
.bazar-create-overlay.show { transform: translateX(0); }
.bazar-create-head {
  display: flex; align-items: center; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid rgba(0,0,0,.08);
  background:var(--card-bg);
}
.bazar-create-head h2 { flex: 1; font-size: 17px; font-weight: 900; margin: 0; }
.bazar-create-back, .bazar-create-submit {
  appearance: none; border: none;
  font-family: Nunito; font-weight: 800; font-size: 14px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}
.bazar-create-submit {
  background: linear-gradient(135deg, #F5B027 0%, #6750A4 100%);
  color: #fff;
}
.bazar-create-submit:disabled { opacity: .45; cursor: not-allowed; }
.bazar-create-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.bazar-create-field { margin-bottom: 16px; }
.bazar-create-field label {
  display: block;
  font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .5px;
  color: #6B6B7A;
  margin-bottom: 6px;
}
.bazar-create-field input,
.bazar-create-field textarea,
.bazar-create-field select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid rgba(0,0,0,.1);
  border-radius: 12px;
  font-family: Nunito;
  font-size: 14px;
  color: var(--text);
  background:var(--card-bg);
  box-sizing: border-box;
  outline: none;
}
.bazar-create-field textarea { resize: vertical; min-height: 80px; }
.bazar-create-field input:focus,
.bazar-create-field textarea:focus,
.bazar-create-field select:focus { border-color: #F5B027; }

.bazar-create-payment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.bazar-create-payment-grid label {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border: 1.5px solid rgba(0,0,0,.1);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px; font-weight: 700;
  text-transform: none; letter-spacing: 0;
  color: var(--text); margin: 0;
}
.bazar-create-payment-grid label.checked {
  border-color: #F5B027;
  background: #FFF4E0;
}
.bazar-create-payment-grid input[type="checkbox"] {
  appearance: none;
  width: 18px; height: 18px;
  border: 1.5px solid rgba(0,0,0,.2);
  border-radius: 4px;
  position: relative;
  cursor: pointer;
}
.bazar-create-payment-grid input[type="checkbox"]:checked {
  background: #F5B027;
  border-color: #F5B027;
}
.bazar-create-payment-grid input[type="checkbox"]:checked::after {
  content: "✓"; color: #fff; font-weight: 900; font-size: 12px;
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}

.bazar-create-media-zone {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.bazar-create-media-slot {
  aspect-ratio: 1;
  border: 2px dashed rgba(0,0,0,.18);
  border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 22px;
  color: #8B8B9A;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: #F7F7FA;
}
.bazar-create-media-slot.has-media {
  border-style: solid;
  border-color: #F5B027;
}
.bazar-create-media-slot img,
.bazar-create-media-slot video {
  width: 100%; height: 100%;
  object-fit: cover;
}
.bazar-create-media-slot .media-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,.7);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  z-index: 2;
}
.bazar-create-media-slot .media-kind-badge {
  position: absolute;
  bottom: 4px; left: 4px;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}
.bazar-create-media-slot .media-progress {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 8px;
  gap: 6px;
}
.media-progress-label {
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.media-progress-bar {
  width: 90%;
  height: 4px;
  background: rgba(255,255,255,.2);
  border-radius: 2px;
  overflow: hidden;
}
.media-progress-fill {
  height: 100%;
  background: #6750A4;
  transition: width .25s ease-out;
}
.bazar-create-media-add-label {
  font-size: 11px; color: #8B8B9A;
  margin-top: 4px;
  font-weight: 700;
}

.bazar-create-err {
  color: #EF5350;
  font-size: 13px;
  font-weight: 700;
  margin: 10px 0;
}

/* Filters modal */
.bazar-filter-overlay {
  position: fixed; inset: 0; z-index: 65;
  background: rgba(0,0,0,0);
  display: flex; align-items: flex-end;
  transition: background .28s ease;
}
.bazar-filter-overlay.show { background: rgba(0,0,0,.55); }
.bazar-filter-sheet {
  width: 100%;
  background: #1C1C2E;
  color: #fff;
  border-radius: 20px 20px 0 0;
  padding: 14px 16px max(20px, env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .3s ease;
  font-family: Nunito;
}
.bazar-filter-overlay.show .bazar-filter-sheet { transform: translateY(0); }
.bazar-filter-sheet h3 { font-size: 14px; font-weight: 800; margin: 4px 0 14px; }
.bazar-filter-cats {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 16px;
}
.bazar-filter-cat {
  appearance: none; border: 1px solid rgba(255,255,255,.18);
  background: transparent; color: #fff;
  font-family: Nunito; font-weight: 700; font-size: 12.5px;
  padding: 8px 12px; border-radius: 99px;
  cursor: pointer;
}
.bazar-filter-cat.active {
  background: #F5B027;
  border-color: #F5B027;
  color: var(--text);
}
.bazar-filter-apply {
  appearance: none; border: none;
  background: linear-gradient(135deg, #F5B027 0%, #6750A4 100%);
  color: #fff;
  font-family: Nunito; font-weight: 800; font-size: 14px;
  padding: 12px; border-radius: 12px;
  width: 100%; cursor: pointer;
}

/* ─── Media picker bottom-sheet (Photo / Vidéo choice) ─────────── */
.bz-pick-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,0);
  display: flex; align-items: flex-end; justify-content: center;
  transition: background .28s ease;
}
.bz-pick-overlay.show { background: rgba(0,0,0,.55); }
.bz-pick-sheet {
  width: 100%; max-width: 480px;
  background: var(--card-bg);
  color: var(--text);
  border-radius: 22px 22px 0 0;
  padding: 14px 20px max(20px, env(safe-area-inset-bottom));
  font-family: Nunito, sans-serif;
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.34,1.2,.64,1);
  box-shadow: 0 -8px 30px rgba(0,0,0,.18);
}
.bz-pick-overlay.show .bz-pick-sheet { transform: translateY(0); }
.bz-pick-handle {
  width: 42px; height: 4px; border-radius: 2px;
  background: rgba(0,0,0,.18);
  margin: 0 auto 14px;
}
.bz-pick-title {
  font-size: 17px; font-weight: 900;
  text-align: center; margin: 0 0 4px;
  color: var(--text);
}
.bz-pick-sub {
  font-size: 12.5px; color: var(--text-muted); font-weight: 600;
  text-align: center; margin: 0 0 18px;
}
.bz-pick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.bz-pick-card {
  appearance: none; border: 2px solid var(--border);
  background: var(--bg-soft);
  padding: 20px 12px;
  border-radius: 16px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: all .18s ease;
  font-family: Nunito, sans-serif;
}
.bz-pick-card:active {
  transform: scale(.97);
  border-color: var(--primary, #F5B027);
  background: var(--primary-bg-soft, #FFF4E0);
}
.bz-pick-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #F5B027 0%, #6750A4 100%);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(245,176,39,.35);
}
.bz-pick-card-title {
  font-size: 15px; font-weight: 900; color: var(--text);
}
.bz-pick-card-sub {
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
}
.bz-pick-cancel {
  appearance: none; border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: Nunito, sans-serif; font-weight: 700; font-size: 14px;
  padding: 12px;
  cursor: pointer;
  width: 100%;
}
.bz-pick-cancel:active { color: var(--text); }

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .bz-pick-sheet { background: #1C1C2E; color: #fff; }
  .bz-pick-title { color: #fff; }
  .bz-pick-sub, .bz-pick-card-sub { color: rgba(255,255,255,.6); }
  .bz-pick-card { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); }
  .bz-pick-card:active { background: rgba(245,176,39,.18); }
  .bz-pick-card-title { color: #fff; }
  .bz-pick-cancel { color: rgba(255,255,255,.6); }
  .bz-pick-cancel:active { color: #fff; }
}

/* ─── Toast (replaces alert()) ─────────────────────────────────── */
.bz-toast {
  position: fixed;
  bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1C1C2E;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-family: Nunito, sans-serif;
  font-weight: 700; font-size: 13.5px;
  box-shadow: 0 6px 24px rgba(0,0,0,.3);
  z-index: 99999;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.bz-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Empty state */
.bazar-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
  text-align: center;
  color: #fff;
}
.bazar-empty > i { font-size: 48px; color: #F5B027; margin-bottom: 12px; }
.bazar-empty button i { color: inherit; font-size: inherit; }
.bazar-empty h3 { font-size: 18px; font-weight: 900; margin: 0 0 6px; }
.bazar-empty p { font-size: 13px; opacity: .8; max-width: 320px; line-height: 1.4; }
.bazar-empty button {
  margin-top: 16px;
  appearance: none; border: none;
  background: linear-gradient(135deg, #F5B027 0%, #6750A4 100%);
  color: #fff;
  font-family: Nunito; font-weight: 800; font-size: 14px;
  padding: 12px 22px;
  border-radius: 12px;
  cursor: pointer;
}
