/* Marketplace page */
.market-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
  background: var(--bg);
  overflow: hidden;
}

.market-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 8, 18, .94);
}

.market-heading {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.market-heading h1 {
  margin: 0;
  color: #fff;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.market-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.market-summary strong {
  color: #fff;
  font-size: 18px;
}

.market-toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.market-view-switch {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line);
  border-radius: var(--pub-radius-sm);
  padding: 4px;
}

.market-view-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
}

.market-view-switch button.active {
  background: var(--identity-primary);
  color: #041a12;
}

.market-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(390px, 440px) minmax(0, 1fr);
  overflow: hidden;
}

.market-layout.view-list {
  grid-template-columns: 1fr;
}

.market-layout.view-list .market-map-pane,
.market-layout.view-map .market-side {
  display: none;
}

.market-layout.view-map {
  grid-template-columns: 1fr;
}

.market-side {
  min-height: 0;
  border-left: 1px solid var(--line);
  background: rgba(7, 12, 22, .96);
  display: grid;
  grid-template-rows: auto 1fr;
}

.market-filters {
  border-bottom: 1px solid var(--line);
  padding: 14px;
  background: rgba(255, 255, 255, .025);
  max-height: 42vh;
  overflow: auto;
}

.market-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.market-filter-head h2 {
  font-size: 16px;
  margin: 0;
  color: #fff;
}

.market-form {
  display: grid;
  gap: 10px;
}

.market-form-grid,
.market-checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.market-checks label {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line);
  border-radius: var(--pub-radius-sm);
  padding: 9px 10px;
  color: rgba(255, 255, 255, .78);
  font-size: 12px;
  font-weight: 800;
}

.market-checks input {
  accent-color: var(--identity-primary);
}

.market-list {
  min-height: 0;
  overflow: auto;
  padding: 14px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.listing-card {
  border: 1px solid var(--line);
  border-radius: var(--pub-radius-sm);
  background: rgba(255, 255, 255, .035);
  overflow: hidden;
  display: grid;
  transition: border-color .2s, transform .2s, background .2s;
}

.listing-card:hover,
.listing-card.active {
  border-color: var(--identity-map-highlight, #facc15);
  background: rgba(250, 204, 21, .06);
}

.listing-card.active {
  box-shadow: 0 0 0 2px rgba(250, 204, 21, .16);
}

.listing-thumb {
  position: relative;
  background: rgba(255, 255, 255, .04);
}

.listing-thumb img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.listing-no-image {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  background:
    linear-gradient(135deg, rgba(16, 185, 129, .08), rgba(59, 130, 246, .08)),
    rgba(255, 255, 255, .025);
}

.listing-badges {
  position: absolute;
  top: 10px;
  right: 10px;
  left: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  z-index: 2;
}

.market-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(4, 8, 18, .82);
  border: 1px solid rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.market-badge.featured {
  background: var(--identity-accent);
  color: #241500;
  border-color: transparent;
}

.market-badge.verified {
  background: rgba(16, 185, 129, .88);
  color: #041a12;
  border-color: transparent;
}

.listing-body {
  padding: 13px;
  display: grid;
  gap: 9px;
}

.listing-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.listing-title-row h3 {
  margin: 0;
  color: #fff;
  font-size: 17px;
  line-height: 1.45;
}

.listing-price {
  color: var(--identity-primary);
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
}

.listing-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.listing-meta span {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .035);
  border-radius: 999px;
  padding: 5px 8px;
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
  font-weight: 700;
}

.listing-publisher {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.listing-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.listing-actions .btn {
  padding: 9px 8px;
  font-size: 12px;
  min-height: 40px;
}

.whatsapp-btn {
  background: #22c55e;
  color: #03210f;
}

.market-map-pane {
  position: relative;
  min-height: 0;
}

#listingsMap {
  width: 100%;
  height: 100%;
}

.map-note {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  max-width: calc(100% - 28px);
  background: rgba(4, 8, 18, .86);
  border: 1px solid var(--line);
  border-radius: var(--pub-radius-sm);
  padding: 9px 12px;
  color: rgba(255, 255, 255, .78);
  font-size: 12px;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

.market-map-label {
  position: absolute;
  color: #fff;
  font-family: Tajawal, Arial, sans-serif;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  text-shadow: 0 1px 4px rgba(4, 8, 18, .84);
  white-space: nowrap;
  pointer-events: none;
}

.listing-pulse-pin {
  position: absolute;
  width: 34px;
  height: 42px;
  transform: translate(-50%, -100%);
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .5));
}

.listing-pulse-pin::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50% 50% 50% 0;
  background: var(--identity-map-highlight, #facc15);
  border: 3px solid #fff;
  transform: rotate(-45deg);
  box-shadow: 0 0 0 2px rgba(4, 8, 18, .55), 0 0 18px rgba(250, 204, 21, .95);
  animation: listingPinGlow 1.05s ease-in-out infinite;
}

.listing-pulse-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 23px;
  width: 18px;
  height: 18px;
  border: 2px solid var(--identity-map-highlight, #facc15);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: listingPinPulse 1.05s ease-out infinite;
  background: rgba(250, 204, 21, .18);
}

.listing-pulse-pin .pin-count {
  position: absolute;
  top: -7px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  border: 2px solid #fff;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

@keyframes listingPinGlow {
  0%, 100% { transform: rotate(-45deg) scale(1); opacity: 1; }
  50% { transform: rotate(-45deg) scale(1.16); opacity: .82; }
}

@keyframes listingPinPulse {
  0% { opacity: .9; transform: translate(-50%, -50%) scale(.55); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2.25); }
}

.mobile-filter-btn {
  display: none;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--pub-radius-sm);
  padding: 28px;
  text-align: center;
  color: var(--muted);
  line-height: 1.8;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  padding: 4px 0 12px;
}

.gm-style .gm-style-iw-c {
  color: #111827;
}

.market-info {
  direction: rtl;
  text-align: right;
  font-family: Tajawal, system-ui, sans-serif;
  color: #111827;
  max-width: 310px;
}

.market-info h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.market-info-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.market-info-offer {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.market-info-offer strong {
  display: block;
  font-size: 13px;
  color: #111827;
  margin-bottom: 3px;
}

.market-info-offer span {
  display: block;
  font-size: 12px;
  color: #047857;
  font-weight: 800;
  margin-bottom: 3px;
}

.market-info-offer small {
  display: block;
  color: #6b7280;
  font-size: 11px;
}

.market-info-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.market-info-actions a {
  flex: 1;
  text-align: center;
  border-radius: 7px;
  background: #10b981;
  color: #041a12;
  padding: 6px;
  text-decoration: none;
  font-weight: 800;
  font-size: 11px;
}

.market-info-actions a.secondary {
  background: #e5e7eb;
  color: #111827;
}

@media (max-width: 900px) {
  .market-shell {
    grid-template-rows: auto auto 1fr;
  }

  .market-toolbar {
    align-items: stretch;
    display: grid;
    padding: 12px 14px;
  }

  .market-heading h1 {
    font-size: 16px;
  }

  .market-toolbar-actions {
    justify-content: stretch;
  }

  .market-toolbar-actions .btn,
  .market-view-switch,
  .market-view-switch button {
    min-width: 0;
  }

  .market-view-switch {
    flex: 1;
  }

  .market-view-switch button {
    flex: 1;
    padding-inline: 10px;
    min-height: 44px;
  }

  .mobile-filter-btn {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  .listing-actions .btn,
  .listing-actions a {
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  .market-layout,
  .market-layout.view-list,
  .market-layout.view-map {
    display: block;
    position: relative;
  }

  .market-side,
  .market-map-pane {
    height: 100%;
    border-left: 0;
  }

  .market-layout:not(.view-map) .market-map-pane,
  .market-layout.view-map .market-side {
    display: none;
  }

  .market-filters {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    max-height: 82vh;
    border-radius: 16px 16px 0 0;
    border-top: 1px solid var(--line);
    transform: translateY(110%);
    transition: transform .25s;
    background: rgba(7, 12, 22, .98);
    box-shadow: 0 -18px 50px rgba(0, 0, 0, .5);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .market-filters.open {
    transform: translateY(0);
  }

  .market-form-grid,
  .market-checks,
  .listing-actions {
    grid-template-columns: 1fr;
  }

  .market-view-switch button[data-view="split"] {
    display: none;
  }

  .market-summary {
    font-size: 12px;
  }
}

@media (max-width: 520px) {
  .listing-title-row,
  .listing-publisher {
    display: grid;
  }

  .listing-price {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce), (max-width: 900px) {
  .listing-pulse-pin::before,
  .listing-pulse-pin::after {
    animation: none;
  }
}
