:root {
  --primary: #0f2744;
  --bank: #c2410c;
  --restaurant: #0f766e;
  --hotel: #a16207;
  --bg: #eef3f8;
  --card: #ffffff;
  --muted: #5b6b7c;
  --border: #d7e0ea;
  --accent: #1d4ed8;
  --shadow: 0 10px 28px rgba(15, 39, 68, 0.08);
  --map-h: min(42vh, 360px);
  --list-h: min(58vh, 520px);
  --pad: 12px;
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: #0f172a;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(29, 78, 216, 0.14), transparent 60%),
    radial-gradient(900px 420px at 90% 0%, rgba(15, 118, 110, 0.12), transparent 55%),
    linear-gradient(180deg, #f7fafc 0%, #eef3f8 45%, #e8eef5 100%);
}

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.site-header {
  text-align: center;
  padding: 4px 0 8px;
}

.header-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
}

.lang-switcher {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  box-shadow: 0 4px 14px rgba(15, 39, 68, 0.06);
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 9px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 32px;
}

.lang-btn.active {
  background: var(--primary);
  color: #fff;
}

header h1, .site-header h1 {
  color: var(--primary);
  font-size: clamp(1.35rem, 4.8vw, 2.15rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  word-break: break-word;
}

header p, .site-header p {
  color: var(--muted);
  font-size: clamp(0.84rem, 2.5vw, 0.98rem);
  margin-top: 6px;
  padding: 0 4px;
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
}

.search-section {
  background: var(--card);
  padding: 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 12px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-box {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 100%;
}

.search-box input {
  width: 100%;
  padding: 12px 40px 12px 42px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 16px; /* tránh zoom tự động trên iOS */
  outline: none;
  background: #fff;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.search-box input:focus { border-color: var(--accent); }

.search-box .fa-magnifying-glass {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.search-box .clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  padding: 8px;
  display: none;
  border-radius: 6px;
  min-width: 36px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
}

.search-box .clear-btn:hover { color: var(--primary); background: #f1f5f9; }
.search-box.has-value .clear-btn { display: inline-flex; }

.filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.filter-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 9px 14px;
  border: none;
  border-radius: 9px;
  background: #e2e8f0;
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
  color: #475569;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  flex: 0 0 auto;
  min-height: 40px;
}

.tab-btn.active[data-cat="all"] { background: var(--primary); color: #fff; }
.tab-btn.active[data-cat="nganhang"] { background: var(--bank); color: #fff; }
.tab-btn.active[data-cat="nhahang"] { background: var(--restaurant); color: #fff; }
.tab-btn.active[data-cat="khachsan"] { background: var(--hotel); color: #111; }

.locate-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn-locate {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 9px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 40px;
}

.btn-locate.active {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.locate-status {
  font-size: 0.82rem;
  color: var(--muted);
}

.distance-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  font-size: 0.78rem;
  font-weight: 750;
  vertical-align: middle;
}

.track-code {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 4px 0 6px;
}

.track-code code,
.comment-item code {
  font-size: 0.78rem;
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
}

.google-auth-host {
  margin: 8px 0 10px;
}

.google-auth-status.ok {
  color: #059669;
  font-weight: 650;
  margin-top: 6px;
}

.promo-banner {
  background: linear-gradient(135deg, #0f2744 0%, #1e4d8c 100%);
  color: #fff;
  padding: 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  flex-direction: column;
  box-shadow: 0 6px 20px rgba(15, 39, 68, 0.18);
}

.promo-banner h4 {
  font-size: clamp(0.95rem, 3vw, 1.05rem);
  color: #fde047;
  margin-bottom: 4px;
}

.promo-banner p {
  font-size: 0.85rem;
  opacity: 0.92;
  max-width: 640px;
}

.btn-promo {
  background: #fff;
  color: #0f2744;
  padding: 10px 16px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  align-self: stretch;
  text-align: center;
}

.adsense-wrapper {
  background: #fff;
  text-align: center;
  padding: 10px;
  margin-bottom: 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  display: none;
}

.adsense-wrapper.visible { display: block; }

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.78rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.main-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

/* Mobile: bản đồ trước, danh sách sau — dễ xem vị trí */
.map-wrapper {
  order: -1;
  position: relative;
  top: 0;
  height: var(--map-h);
  min-height: 220px;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 8px;
  box-shadow: var(--shadow);
}

#map {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: #e2e8f0;
  touch-action: pan-x pan-y;
}

.list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.place-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
  border-left: 5px solid #94a3b8;
  transition: box-shadow 0.2s;
  cursor: pointer;
  gap: 10px;
}

.place-media {
  width: 100%;
  max-height: 160px;
  overflow: hidden;
  border-radius: 8px;
  background: #e2e8f0;
}

.place-media img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

.place-body { display: flex; flex-direction: column; min-width: 0; }
.muted-text { color: #94a3b8; font-size: 0.88rem; }
.info-row a { color: #2563eb; word-break: break-word; }

.place-card.nganhang { border-left-color: var(--bank); }
.place-card.nhahang { border-left-color: var(--restaurant); }
.place-card.khachsan { border-left-color: var(--hotel); }
.place-card.active-card { outline: 2px solid var(--accent); outline-offset: 1px; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 0.7rem;
  font-weight: 750;
  border-radius: 5px;
  margin-bottom: 8px;
  width: fit-content;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.nganhang .badge { background: #fee2e2; color: var(--bank); }
.nhahang .badge { background: #d1fae5; color: var(--restaurant); }
.khachsan .badge { background: #fef08a; color: #854d0e; }

.place-title {
  font-size: clamp(1rem, 3.2vw, 1.08rem);
  color: var(--primary);
  font-weight: 750;
  margin-bottom: 4px;
  word-break: break-word;
}

.seo-tagline {
  font-size: 0.75rem;
  color: #2563eb;
  font-weight: 600;
  margin-bottom: 8px;
  word-break: break-word;
}

.info-row {
  display: flex;
  gap: 10px;
  font-size: 0.86rem;
  color: #475569;
  margin-top: 5px;
  align-items: flex-start;
}

.info-row i {
  margin-top: 3px;
  width: 14px;
  color: #94a3b8;
  text-align: center;
  flex-shrink: 0;
}

.rating { color: #ca8a04; font-weight: 700; }

.action-area {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: stretch;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}

.card-meta { margin-top: 2px; }
.meta-info { font-size: 0.72rem; color: #94a3b8; }

.btn-directions,
.btn-action,
.btn-review-submit,
.btn-promo {
  min-height: 42px;
}

.btn-directions {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #2563eb;
  color: #fff;
  border: 1px solid #2563eb;
  flex: 1 1 140px;
}

.btn-action {
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 140px;
  text-align: center;
}

.leaflet-popup-content .popup-directions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 8px 10px;
  background: #2563eb;
  color: #fff !important;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
}

.review-box {
  margin-top: 12px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.review-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}

.star-input {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
}

.star-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.4rem;
  color: #cbd5e1;
  padding: 6px;
  line-height: 1;
  min-width: 40px;
  min-height: 40px;
}

.star-btn.active,
.star-btn:hover { color: #f59e0b; }

.review-comment {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  font-size: 16px;
  resize: vertical;
  min-height: 56px;
  margin-bottom: 8px;
  outline: none;
}

.review-comment:focus { border-color: #2563eb; }

.btn-review-submit {
  border: none;
  background: #0f172a;
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.btn-review-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.review-msg { margin-top: 6px; font-size: 0.78rem; }
.review-msg.error { color: #b91c1c; }

.review-comments-wrap {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.comments-list { display: flex; flex-direction: column; gap: 8px; }

.comment-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
}

.comment-stars { color: #f59e0b; font-size: 0.85rem; font-weight: 700; }
.comment-time { color: #94a3b8; font-weight: 500; font-size: 0.72rem; margin-left: 6px; }
.comment-text { margin-top: 4px; font-size: 0.86rem; color: #334155; white-space: pre-wrap; word-break: break-word; }
.comment-empty { font-size: 0.8rem; }

.about-section {
  margin-top: 28px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
}

.submit-section {
  margin-top: 28px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
}

.submit-head h2 {
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  color: var(--primary);
  margin-bottom: 6px;
}

.submit-head p {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 14px;
}

.submit-form .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #334155;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  background: #fff;
}

.form-field textarea {
  resize: vertical;
  min-height: 84px;
}

.form-field-full {
  grid-column: 1 / -1;
}

.submit-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn-submit {
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 11px 16px;
  cursor: pointer;
  min-height: 44px;
}

.btn-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.submit-msg {
  font-size: 0.9rem;
  color: var(--muted);
}

.submit-msg.ok { color: #059669; font-weight: 650; }
.submit-msg.error { color: #dc2626; font-weight: 650; }

@media (max-width: 700px) {
  .submit-form .form-grid {
    grid-template-columns: 1fr;
  }
}

.about-section h2 {
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  color: var(--primary);
  margin-bottom: 10px;
}

.about-body {
  color: #334155;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.site-footer {
  margin-top: 18px;
  padding: 14px 4px 8px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.site-footer a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 700;
}

.nganhang .btn-action { background: #fef2f2; color: var(--bank); border: 1px solid var(--bank); }
.nhahang .btn-action { background: #ecfdf5; color: #047857; border: 1px solid #34d399; }
.khachsan .btn-action { background: #fefce8; color: #854d0e; border: 1px solid #facc15; }

.empty-state {
  text-align: center;
  padding: 36px 18px;
  background: var(--card);
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 500;
  box-shadow: var(--shadow);
  font-size: 0.95rem;
}

.empty-state.error { color: #b91c1c; }
.empty-state i { margin-bottom: 12px; display: block; }
.leaflet-popup-content { font-size: 0.9rem; max-width: min(260px, 70vw); }

/* ===== Tablet ===== */
@media (min-width: 640px) {
  .container { padding: 16px 18px 32px; }
  .search-section { padding: 14px 16px; }
  .search-box { max-width: 520px; }
  .filter-tabs { flex-wrap: wrap; overflow: visible; }
  .promo-banner {
    flex-direction: row;
    align-items: center;
  }
  .btn-promo { align-self: center; }
  .map-wrapper { --map-h: min(46vh, 420px); }
  .btn-review-submit { width: auto; }
  .action-area { justify-content: flex-start; }
  .btn-directions,
  .btn-action { flex: 0 1 auto; }
}

@media (min-width: 768px) {
  .search-section {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .place-media,
  .place-media img { max-height: 180px; height: 180px; }
}

/* ===== Desktop ===== */
@media (min-width: 992px) {
  :root {
    --map-h: 680px;
    --list-h: 680px;
  }

  .container { padding: 20px 16px 40px; }

  .main-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
  }

  .map-wrapper {
    order: 0;
    position: sticky;
    top: 16px;
    height: var(--map-h);
    padding: 10px;
  }

  .list-container {
    max-height: var(--list-h);
    overflow-y: auto;
    padding-right: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .place-card { padding: 16px 18px; }
  .place-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  }
  .nganhang .btn-action:hover { background: var(--bank); color: #fff; }
  .nhahang .btn-action:hover { background: #059669; color: #fff; }
  .khachsan .btn-action:hover { background: #facc15; color: #111; }
  .btn-directions:hover { background: #1d4ed8; transform: translateY(-1px); }
  .btn-promo:hover { transform: scale(1.04); }
  .tab-btn:hover { transform: translateY(-1px); }
}

/* Màn rất hẹp */
@media (max-width: 380px) {
  .tab-btn { padding: 8px 10px; font-size: 0.78rem; }
  .promo-banner p { font-size: 0.8rem; }
  .star-btn { min-width: 34px; font-size: 1.25rem; }
}

/* Landscape điện thoại: bản đồ thấp hơn một chút */
@media (max-width: 991px) and (orientation: landscape) {
  .map-wrapper {
    height: min(52vh, 280px);
    min-height: 180px;
  }
}

/* Giảm chuyển động nếu người dùng yêu cầu */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
