/* ============================================================
   Phase 9 — Map Radius Search
   Mobile-first · Pixel parity với theme Đức Sơn Nhà Đất
   ============================================================ */

/* ── Form tìm kiếm theo bán kính ────────────────────── */

/* Wrapper toàn bộ form + results */
.dsnd-radius-form-wrap {
  width: 100%;
}

/* Form hàng ngang */
.dsnd-radius-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  padding: 16px;
}

/* Mỗi field */
.dsnd-rf-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dsnd-rf-label {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,.7);
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Context = archive: label tối hơn */
.dsnd-radius-panel .dsnd-rf-label {
  color: var(--text-muted);
}

.dsnd-rf-input,
.dsnd-rf-select {
  width: 100%;
  padding: 10px 13px;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.92);
  color: var(--navy);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
  box-sizing: border-box;
  -webkit-appearance: none;
}

.dsnd-rf-input:focus,
.dsnd-rf-select:focus {
  border-color: var(--gold);
  background: #fff;
}

/* Context archive — border tối */
.dsnd-radius-panel .dsnd-rf-input,
.dsnd-radius-panel .dsnd-rf-select {
  border-color: var(--border);
}

/* Gợi ý nhanh (chips) bên dưới input */
.dsnd-rf-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.dsnd-rf-chip {
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.85);
  border: 1px solid rgba(255,255,255,.22);
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.dsnd-rf-chip:hover {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
}

/* Context archive: chips tối */
.dsnd-radius-panel .dsnd-rf-chip {
  background: rgba(10,22,40,.06);
  color: var(--navy);
  border-color: var(--border);
}
.dsnd-radius-panel .dsnd-rf-chip:hover {
  background: var(--navy);
  color: var(--white);
}

/* Nút tìm */
.dsnd-rf-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s;
}
.dsnd-rf-btn:hover   { background: #b8904f; }
.dsnd-rf-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Thông báo trạng thái */
.dsnd-radius-status {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dsnd-radius-status--loading {
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.8);
}
.dsnd-radius-status--error {
  background: #fce7e7;
  color: #d63638;
  border: 1px solid #f5c6c6;
}
.dsnd-radius-panel .dsnd-radius-status--loading {
  background: #f0f7ff;
  color: var(--navy);
}

/* Spinner */
@keyframes dsnd-spin { to { transform: rotate(360deg); } }
.dsnd-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  animation: dsnd-spin .7s linear infinite;
}
.dsnd-radius-panel .dsnd-spinner {
  border-color: rgba(0,0,0,.15);
  border-top-color: var(--navy);
}

/* ── Panel archive ───────────────────────────────────── */

.dsnd-radius-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-card, 10px);
  margin-bottom: 20px;
  overflow: hidden;
}

.dsnd-radius-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  gap: 10px;
  background: var(--navy);
  color: var(--white);
  user-select: none;
}

.dsnd-radius-panel__title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dsnd-radius-panel__toggle {
  font-size: 12px;
  opacity: .7;
  transition: transform .2s;
}
.dsnd-radius-panel.open .dsnd-radius-panel__toggle {
  transform: rotate(180deg);
}

.dsnd-radius-panel__body {
  padding: 16px 18px;
  display: none;
}
.dsnd-radius-panel.open .dsnd-radius-panel__body {
  display: block;
}

/* Trong archive: form nằm ngang */
.dsnd-radius-panel .dsnd-radius-form {
  background: transparent;
  border: none;
  padding: 0;
  gap: 12px;
}

/* ── RESULTS — tóm tắt ───────────────────────────────── */

.dsnd-radius-results {
  margin-top: 16px;
}

.dsnd-radius-summary {
  background: var(--navy);
  color: var(--white);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.dsnd-radius-summary strong { color: var(--gold); }
.dsnd-radius-clear {
  margin-left: auto;
  color: rgba(255,255,255,.6);
  font-size: 12px;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  padding: 2px 8px;
  border-radius: 4px;
  transition: background .15s;
}
.dsnd-radius-clear:hover { background: rgba(255,255,255,.1); }

/* Layout: map trên, cards dưới (mobile) */
.dsnd-radius-layout {
  display: grid;
  gap: 16px;
}

/* ── BẢN ĐỒ Leaflet ─────────────────────────────────── */

.dsnd-map-outer {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--sh-card);
  position: relative;
}

.dsnd-map-wrap {
  height: 320px;
  width: 100%;
  background: #e8e0d8; /* fallback màu trước khi tiles load */
}

/* Leaflet popup tùy chỉnh */
.dsnd-map-popup {
  font-family: var(--sans, sans-serif);
  font-size: 13px;
  max-width: 200px;
}
.dsnd-map-popup__title {
  font-weight: 600;
  color: var(--navy, #0A1628);
  margin-bottom: 3px;
  line-height: 1.3;
}
.dsnd-map-popup__price {
  color: var(--gold, #8B5E2B);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}
.dsnd-map-popup__dist {
  font-size: 11px;
  color: #888;
  margin-bottom: 6px;
}
.dsnd-map-popup__link {
  display: inline-block;
  background: var(--navy, #0A1628);
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  text-decoration: none;
}

/* Leaflet attribution nhỏ hơn trên mobile */
.leaflet-control-attribution {
  font-size: 9px !important;
}

/* ── RESULT CARDS ────────────────────────────────────── */

.dsnd-radius-cards {
  display: grid;
  gap: 14px;
}

.dsnd-rc {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-card, 10px);
  overflow: hidden;
  display: flex;
  box-shadow: var(--sh-card);
  transition: box-shadow .2s;
  text-decoration: none;
  color: inherit;
}
.dsnd-rc:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
}

.dsnd-rc__img {
  width: 100px;
  min-height: 90px;
  flex-shrink: 0;
  overflow: hidden;
}
.dsnd-rc__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.dsnd-rc__img-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--navy) 0%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.dsnd-rc__body {
  padding: 10px 12px;
  flex: 1;
  min-width: 0;
}

.dsnd-rc__dist {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(139,94,43,.15);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  margin-bottom: 6px;
}

.dsnd-rc__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.35;
  margin-bottom: 4px;
  /* 2 dòng giới hạn */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dsnd-rc__price {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 2px;
}

.dsnd-rc__meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.dsnd-rc__meta span::before { margin-right: 3px; }

/* Nút xem trên card (hover) */
.dsnd-rc__cta {
  display: none;
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
  margin-top: 6px;
  text-decoration: none;
}
.dsnd-rc:hover .dsnd-rc__cta { display: block; }

/* Empty state */
.dsnd-radius-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.dsnd-radius-empty__icon { font-size: 40px; margin-bottom: 10px; }

/* ── RESPONSIVE ──────────────────────────────────────── */

@media (min-width: 600px) {
  .dsnd-radius-form {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
  }
  .dsnd-rf-field--location { flex: 1 1 240px; }
  .dsnd-rf-field--radius   { flex: 0 0 120px; }
  .dsnd-rf-field--type     { flex: 0 0 130px; }
  .dsnd-rf-field--submit   { flex: 0 0 auto; }
  .dsnd-rf-btn             { white-space: nowrap; }
  .dsnd-radius-cards       { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
  .dsnd-map-wrap { height: 420px; }
  .dsnd-radius-layout {
    grid-template-columns: 1.2fr 1fr;
    align-items: start;
  }
  .dsnd-radius-cards {
    grid-template-columns: 1fr;
    max-height: 420px;
    overflow-y: auto;
    overscroll-behavior: contain;
    /* Scroll mượt iOS Safari */
    -webkit-overflow-scrolling: touch;
  }
  .dsnd-rc__img { width: 120px; }
}

@media (min-width: 1025px) {
  .dsnd-map-wrap { height: 480px; }
  .dsnd-rf-field--location { flex-basis: 280px; }
}

/* Leaflet fix iOS Safari — tránh ghost click */
.leaflet-container {
  -webkit-tap-highlight-color: transparent;
}
/* Leaflet marker icon điều chỉnh khi retina */
.leaflet-retina .leaflet-marker-icon { image-rendering: auto; }
