/* ═══════════════════════════════════════════════
   Marketplace 2.0 UI overlay v1 — 2026-05-13
   Кнопка-вход + полноэкранный wizard/feed/profile
   ═══════════════════════════════════════════════ */

/* === Floating launch button === */
.mp-launch {
  position: fixed;
  right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  z-index: 80; /* НИЖЕ bottom-nav (z=100), чтобы при необходимости nav был сверху */
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 18px 12px 16px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 6px 20px rgba(99,102,241,.4), 0 1px 0 rgba(255,255,255,.2) inset;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.mp-launch:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(99,102,241,.5); }
.mp-launch:active { transform: scale(.96); }
.mp-launch-icon { font-size: 18px; line-height: 1; }

@media (max-width: 768px) {
  .mp-launch {
    /* bottom-nav высота ~62px + safe-area; +14 для отступа */
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    right: 14px;
    padding: 10px 14px 10px 12px;
    font-size: 13px;
  }
  /* Когда чат открыт — bottom-nav прячется, кнопка должна быть рядом с composer но НЕ на нём */
  body:has(.app.has-active) .mp-launch,
  body:has(.chat-view.active) .mp-launch {
    /* На открытом чате прячем кнопку — composer уже занимает низ */
    display: none !important;
  }
}

/* На очень узких экранах (≤360px) — иконка-only, без текста */
@media (max-width: 360px) {
  .mp-launch {
    padding: 12px !important;
    border-radius: 50%;
    width: 52px; height: 52px;
    justify-content: center;
  }
  .mp-launch > *:not(.mp-launch-icon) { display: none; }
}

/* === Fullscreen overlay === */
.mp-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: #f8fafc;
  color: #0f172a;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: none;
  flex-direction: column;
}
[data-theme="dark"] .mp-overlay { background: #0e0e0e; color: #e5e7eb; }
.mp-overlay.open { display: flex; }

.mp-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0,0,0,.06);
  padding: max(12px, env(safe-area-inset-top, 0px)) 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
[data-theme="dark"] .mp-header { background: rgba(14,14,14,.85); border-bottom-color: rgba(255,255,255,.06); }
.mp-back {
  width: 36px; height: 36px;
  border-radius: 999px;
  background: rgba(0,0,0,.05);
  border: none;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
[data-theme="dark"] .mp-back { background: rgba(255,255,255,.08); color: #fff; }
.mp-title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; flex: 1; }
.mp-step { font-size: 12px; color: #64748b; }

.mp-content {
  flex: 1;
  padding: 16px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}

/* === Category picker === */
.mp-cat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.mp-cat-section {
  margin-bottom: 20px;
}
.mp-cat-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
  padding: 0 4px;
}
.mp-cat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 14px;
  cursor: pointer;
  transition: all .12s;
  min-height: 56px;
}
[data-theme="dark"] .mp-cat-item { background: #1a1a1a; border-color: rgba(255,255,255,.06); }
.mp-cat-item:hover { border-color: #6366f1; background: rgba(99,102,241,.05); }
.mp-cat-item:active { transform: scale(.98); }
.mp-cat-item.selected { border-color: #6366f1; background: linear-gradient(90deg, rgba(99,102,241,.08), rgba(139,92,246,.04)); }
.mp-cat-icon { font-size: 22px; line-height: 1; width: 32px; text-align: center; }
.mp-cat-name { font-size: 15px; font-weight: 500; flex: 1; }
.mp-cat-arrow { color: #94a3b8; font-size: 18px; }

/* === Form fields === */
.mp-field { margin-bottom: 16px; }
.mp-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
}
[data-theme="dark"] .mp-label { color: #cbd5e1; }
.mp-input, .mp-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(0,0,0,.1);
  border-radius: 12px;
  font-size: 16px;
  background: #fff;
  color: #0f172a;
  box-sizing: border-box;
  font-family: inherit;
}
[data-theme="dark"] .mp-input, [data-theme="dark"] .mp-textarea {
  background: #1a1a1a; color: #e5e7eb; border-color: rgba(255,255,255,.1);
}
.mp-input:focus, .mp-textarea:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.mp-textarea { min-height: 120px; resize: vertical; }

.mp-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mp-hint { font-size: 12px; color: #94a3b8; margin-top: 4px; }

/* === Urgency chips === */
.mp-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.mp-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.1);
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all .12s;
}
[data-theme="dark"] .mp-chip { background: #1a1a1a; border-color: rgba(255,255,255,.1); color: #e5e7eb; }
.mp-chip:hover { border-color: #6366f1; }
.mp-chip.active { background: #6366f1; color: #fff; border-color: #6366f1; }

/* === Photo upload === */
.mp-photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.mp-photo, .mp-photo-add {
  aspect-ratio: 1;
  border-radius: 12px;
  background: #f1f5f9;
  border: 2px dashed rgba(0,0,0,.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  color: #94a3b8;
  cursor: pointer;
  overflow: hidden;
}
[data-theme="dark"] .mp-photo, [data-theme="dark"] .mp-photo-add {
  background: #1a1a1a; border-color: rgba(255,255,255,.1);
}
.mp-photo img { width: 100%; height: 100%; object-fit: cover; }

/* === AI suggestions box === */
.mp-ai-box {
  background: linear-gradient(135deg, rgba(99,102,241,.08), rgba(139,92,246,.04));
  border: 1px solid rgba(99,102,241,.2);
  border-radius: 14px;
  padding: 14px;
  margin-top: 12px;
}
.mp-ai-title { font-size: 12px; font-weight: 700; color: #6366f1; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.mp-ai-item { font-size: 14px; line-height: 1.45; padding: 6px 0; color: #1e293b; }
[data-theme="dark"] .mp-ai-item { color: #cbd5e1; }
.mp-ai-warn { color: #b45309; font-weight: 500; }

/* === Bottom bar === */
.mp-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 901;
  background: rgba(255,255,255,.95);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgba(0,0,0,.06);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  display: none;
  gap: 10px;
}
[data-theme="dark"] .mp-bottom-bar { background: rgba(14,14,14,.95); border-top-color: rgba(255,255,255,.06); }
.mp-overlay.open ~ .mp-bottom-bar,
.mp-bottom-bar.show { display: flex; }

.mp-btn {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid rgba(0,0,0,.08);
  background: #fff;
  cursor: pointer;
  min-height: 48px;
}
[data-theme="dark"] .mp-btn { background: #1a1a1a; color: #e5e7eb; border-color: rgba(255,255,255,.08); }
.mp-btn-primary {
  flex: 2;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(99,102,241,.3);
}
.mp-btn-primary:hover { box-shadow: 0 6px 18px rgba(99,102,241,.45); }
.mp-btn:disabled { opacity: .5; cursor: not-allowed; }

/* === Feed list === */
.mp-feed-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all .12s;
}
[data-theme="dark"] .mp-feed-card { background: #1a1a1a; border-color: rgba(255,255,255,.06); }
.mp-feed-card:hover { border-color: #6366f1; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.04); }

.mp-feed-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; color: #64748b; flex-wrap: wrap; }
.mp-feed-cat { font-weight: 700; color: #6366f1; }
.mp-feed-city::before { content: "📍"; margin-right: 2px; }
.mp-feed-urgency-today { color: #dc2626; font-weight: 600; }
.mp-feed-urgency-this_week { color: #d97706; font-weight: 600; }

.mp-feed-title { font-size: 16px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.mp-feed-desc { font-size: 14px; color: #475569; line-height: 1.4; }
[data-theme="dark"] .mp-feed-desc { color: #94a3b8; }
.mp-feed-actions { margin-top: 10px; display: flex; gap: 8px; }

/* === Empty state === */
.mp-empty {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
}
.mp-empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.mp-empty-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; color: #475569; }
[data-theme="dark"] .mp-empty-title { color: #cbd5e1; }
.mp-empty-sub { font-size: 14px; }

/* === Filters bar === */
.mp-filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
  margin-bottom: 8px;
  scrollbar-width: none;
}
.mp-filters::-webkit-scrollbar { display: none; }
.mp-filter-chip {
  flex-shrink: 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
[data-theme="dark"] .mp-filter-chip { background: #1a1a1a; border-color: rgba(255,255,255,.08); color: #e5e7eb; }
.mp-filter-chip.active { background: #6366f1; color: #fff; border-color: #6366f1; }

/* === Toast === */
.mp-toast {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: #0f172a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: mp-toast-in .25s ease-out;
}
.mp-toast.success { background: #10b981; }
.mp-toast.error { background: #ef4444; }
@keyframes mp-toast-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* === Listing detail modal === */
.mp-modal-bg {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: mp-modal-in 0.2s ease-out;
  overflow-y: auto;
}
@keyframes mp-modal-in { from { opacity: 0; } to { opacity: 1; } }

.mp-modal {
  background: #fff;
  color: #0f172a;
  border-radius: 20px;
  max-width: 560px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  padding: 22px 22px calc(22px + env(safe-area-inset-bottom, 0px));
  animation: mp-modal-slide .25s cubic-bezier(.2,.8,.2,1);
}
[data-theme="dark"] .mp-modal { background: #1a1a1a; color: #e5e7eb; }
@keyframes mp-modal-slide { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.mp-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
[data-theme="dark"] .mp-modal-close { background: rgba(255, 255, 255, 0.08); color: #fff; }

.mp-modal-head { margin-bottom: 18px; }
.mp-modal-cat {
  font-size: 13px;
  font-weight: 700;
  color: #6366f1;
  margin-bottom: 4px;
}
.mp-modal-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
  padding-right: 40px;
}
.mp-modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: #64748b;
}
.mp-modal-meta .mp-feed-urgency-today { color: #dc2626; font-weight: 600; }
.mp-modal-meta .mp-feed-urgency-this_week { color: #d97706; font-weight: 600; }

.mp-modal-photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 0 0 16px;
}
.mp-modal-photos img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  cursor: pointer;
}

.mp-modal-section { margin-bottom: 16px; }
.mp-modal-section-title {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.mp-modal-desc {
  font-size: 15px;
  line-height: 1.5;
  color: #1e293b;
  white-space: pre-wrap;
  word-wrap: break-word;
}
[data-theme="dark"] .mp-modal-desc { color: #e5e7eb; }

.mp-modal-budget {
  font-size: 16px;
  font-weight: 600;
  color: #0f172a;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  padding: 10px 14px;
  border-radius: 10px;
}
[data-theme="dark"] .mp-modal-budget { color: #fbbf24; }

.mp-modal-privacy {
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  color: #475569;
  line-height: 1.4;
}
[data-theme="dark"] .mp-modal-privacy { color: #cbd5e1; }

.mp-resp-card {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 10px;
  margin-bottom: 6px;
  font-size: 13px;
}
[data-theme="dark"] .mp-resp-card { background: rgba(255, 255, 255, 0.04); }
.mp-resp-name { font-weight: 600; flex: 1; }
.mp-resp-rating { color: #f59e0b; }
.mp-resp-verified { color: #10b981; font-weight: 500; }
.mp-btn-mini {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  background: #6366f1;
  color: #fff;
  border: none;
  cursor: pointer;
}

.mp-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, rgba(255,255,255,1) 70%, rgba(255,255,255,0));
  padding-top: 14px;
  margin-left: -22px;
  margin-right: -22px;
  padding-left: 22px;
  padding-right: 22px;
  padding-bottom: 4px;
}
[data-theme="dark"] .mp-modal-actions {
  background: linear-gradient(to top, rgba(26,26,26,1) 70%, rgba(26,26,26,0));
}

@media (max-width: 480px) {
  .mp-modal-bg { padding: 0; align-items: flex-end; }
  .mp-modal {
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    width: 100%;
  }
  .mp-modal-photos { grid-template-columns: repeat(2, 1fr); }
}

/* Hide launch button on tablet/desktop and inside the mp-overlay */
@media (min-width: 1100px) {
  .mp-launch { right: 24px; bottom: 24px; }
}
.mp-overlay.open ~ .mp-launch { display: none; }


/* === Supplier profile === */
.mp-profile-bar {
  margin-bottom: 10px;
  display: flex;
  justify-content: flex-end;
}
.mp-btn-small {
  padding: 7px 12px !important;
  font-size: 13px !important;
  min-height: auto !important;
  flex: 0 0 auto !important;
}
.mp-cats-grid-small {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.mp-cat-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.1);
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all .12s;
  user-select: none;
}
[data-theme="dark"] .mp-cat-pill {
  background: #1a1a1a;
  border-color: rgba(255,255,255,.1);
  color: #e5e7eb;
}
.mp-cat-pill:hover { border-color: #6366f1; }
.mp-cat-pill.selected {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}
