/**
 * KangCamp — Map page styles
 * Extracted from map.html for browser caching
 */

/* ── Reset for full-screen map ───────────────── */
body { overflow: hidden; background: #f0f4f0; }
.map-page { display: flex; flex-direction: column; height: 100vh; }

/* ── Navbar stays at top ─────────────────────── */
.navbar { flex-shrink: 0; }

/* ── Main layout ─────────────────────────────── */
.map-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - 60px);
  overflow: hidden;
  position: relative;
}

/* ── Sidebar ─────────────────────────────────── */
.map-sidebar {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  box-shadow: 2px 0 12px rgba(0,0,0,.06);
  z-index: 20;
  position: relative;
}

/* Sidebar top header */
.sidebar-header {
  padding: .85rem 1rem .6rem;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}
.sidebar-brand {
  font-weight: 800;
  font-size: 1rem;
  color: var(--green-dark, #1b4332);
  margin-bottom: .55rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.sidebar-brand span { color: var(--green, #2d6a4f); }

/* Search input */
.sidebar-search {
  position: relative;
  margin-bottom: .55rem;
}
.sidebar-search input {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: .45rem .75rem .45rem 2rem;
  font-family: inherit;
  font-size: .88rem;
  background: #f8fafc;
  color: #334155;
  outline: none;
  transition: border-color .15s;
}
.sidebar-search input:focus { border-color: var(--green, #2d6a4f); background: #fff; }
.sidebar-search .search-icon {
  position: absolute; left: .6rem; top: 50%; transform: translateY(-50%);
  font-size: .85rem; color: #94a3b8; pointer-events: none;
}

/* Category chips */
.sidebar-chips {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  padding-bottom: .15rem;
  scrollbar-width: none;
}
.sidebar-chips::-webkit-scrollbar { display: none; }
.scat-chip {
  flex-shrink: 0;
  padding: .28rem .65rem;
  border-radius: 999px;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc;
  font-size: .78rem;
  font-weight: 700;
  color: #64748b;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  font-family: inherit;
}
.scat-chip:hover { border-color: var(--green, #2d6a4f); color: var(--green, #2d6a4f); }
.scat-chip.active {
  background: var(--green, #2d6a4f);
  border-color: var(--green, #2d6a4f);
  color: #fff;
}

/* Result count */
.sidebar-meta {
  padding: .45rem 1rem .35rem;
  font-size: .78rem;
  color: #94a3b8;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sidebar-meta strong { color: #334155; }

/* Filters row */
.sidebar-filters {
  padding: .45rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}
.sidebar-filters select {
  flex: 1 1 calc(50% - .25rem);
  min-width: 120px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: .32rem .55rem;
  font-family: inherit;
  font-size: .8rem;
  color: #475569;
  background: #f8fafc;
  outline: none;
  cursor: pointer;
}
.sidebar-filters select:focus { border-color: var(--green, #2d6a4f); }

/* Place list */
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar-list::-webkit-scrollbar { width: 4px; }
.sidebar-list::-webkit-scrollbar-track { background: #f8fafc; }
.sidebar-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.place-list-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #f8fafc;
  transition: background .12s;
}
.place-list-item:hover { background: #f0fdf4; }
.place-list-item.active { background: #ecfdf5; border-left: 3px solid var(--green, #2d6a4f); }
.place-list-img {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: #e2e8f0;
}
.place-list-info { flex: 1; min-width: 0; }
.place-list-name {
  font-weight: 700;
  font-size: .88rem;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .12rem;
}
.place-list-sub {
  font-size: .76rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.place-list-rating {
  font-size: .75rem;
  font-weight: 700;
  color: #f59e0b;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .1rem;
}
.place-list-visited {
  font-size: .72rem;
  color: var(--green, #2d6a4f);
  font-weight: 800;
  background: #dcfce7;
  padding: .1rem .4rem;
  border-radius: 999px;
  margin-top: .15rem;
}

/* Map area */
.map-area {
  flex: 1;
  position: relative;
}
#map {
  height: 100%;
  width: 100%;
  z-index: 0;
}

/* ── Popup custom ────────────────────────────── */
.kc-popup { min-width: 220px; max-width: 260px; font-family: 'Sarabun', sans-serif; }
.kc-popup-img {
  width: calc(100% + 24px);
  margin: -12px -12px 10px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px 8px 0 0;
  display: block;
  background: #e2e8f0;
}
.kc-popup-badges { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .5rem; }
.kc-badge {
  font-size: .7rem; font-weight: 700;
  padding: .15rem .5rem; border-radius: 999px;
  border: 1.5px solid;
}
.kc-badge-cat  { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.kc-badge-diff-easy     { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.kc-badge-diff-moderate { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.kc-badge-diff-hard     { background: #fff0f0; color: #991b1b; border-color: #fecaca; }
.kc-badge-diff-extreme  { background: #fdf2f8; color: #7c3aed; border-color: #e9d5ff; }
.kc-popup-title { font-weight: 800; font-size: .95rem; color: #1e293b; margin-bottom: .2rem; line-height: 1.3; }
.kc-popup-province { font-size: .8rem; color: #64748b; margin-bottom: .45rem; }
.kc-popup-rating {
  display: flex; align-items: center; gap: .3rem;
  font-size: .82rem; color: #f59e0b; font-weight: 700;
  margin-bottom: .6rem;
}
.kc-popup-rating .review-ct { color: #94a3b8; font-weight: 400; }
.kc-popup-footer { display: flex; gap: .5rem; }
.kc-popup-btn {
  flex: 1; text-align: center;
  padding: .38rem 0;
  border-radius: 8px;
  font-size: .82rem; font-weight: 700;
  text-decoration: none;
  transition: opacity .15s;
}
.kc-popup-btn:hover { opacity: .85; }
.kc-popup-btn-primary { background: var(--green, #2d6a4f); color: #fff !important; text-decoration: none !important; }
.kc-popup-btn-outline {
  background: #f8fafc; color: #475569;
  border: 1.5px solid #e2e8f0;
}

/* Leaflet popup tweak */
.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  padding: 0 !important;
  box-shadow: 0 8px 30px rgba(0,0,0,.14) !important;
  overflow: hidden;
}
.leaflet-popup-content { margin: 12px !important; }
.leaflet-popup-tip-container { margin-top: -1px; }

/* ── Custom marker pin ───────────────────────── */
.map-pin {
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer;
}
.map-pin-bubble {
  width: 36px; height: 36px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(0,0,0,.25);
  border: 2px solid rgba(255,255,255,.9);
  transition: transform .15s;
}
.map-pin-bubble span {
  transform: rotate(45deg);
  font-size: 1rem;
  display: block;
  line-height: 1;
}
.map-pin-visited .map-pin-bubble {
  background: linear-gradient(135deg, #2d6a4f, #52b788) !important;
}
.map-pin-visited .map-pin-bubble::after {
  content: '';
  position: absolute;
  bottom: -1px; right: -1px;
  width: 13px; height: 13px;
  background: #22c55e;
  border: 2px solid #fff;
  border-radius: 50%;
}
.map-pin-shadow {
  width: 8px; height: 4px;
  background: rgba(0,0,0,.2);
  border-radius: 50%;
  margin-top: 1px;
  filter: blur(2px);
}

/* Cluster marker style override */
.marker-cluster-small  { background-color: rgba(45,106,79,.2) !important; }
.marker-cluster-medium { background-color: rgba(45,106,79,.3) !important; }
.marker-cluster-large  { background-color: rgba(45,106,79,.4) !important; }
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: rgba(45,106,79,.75) !important;
  color: #fff !important;
  font-weight: 800 !important;
  font-family: 'Sarabun', sans-serif !important;
}

/* ── Visited toggle bar ──────────────────────── */
.visited-toggle-bar {
  position: absolute;
  bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 10;
  background: #fff;
  border-radius: 50px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  display: none; gap: 0; overflow: hidden;
  border: 1.5px solid #e2e8f0;
}
.visited-toggle-bar.visible { display: flex; }
.vtb-btn {
  padding: .5rem 1.2rem;
  font-size: .82rem; font-weight: 700;
  cursor: pointer; background: none; border: none;
  color: #64748b; font-family: inherit;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.vtb-btn + .vtb-btn { border-left: 1px solid #e2e8f0; }
.vtb-btn:hover { background: #f0fdf4; color: var(--green, #2d6a4f); }
.vtb-btn.active { background: var(--green, #2d6a4f); color: #fff; }

/* ── Map controls (tile switcher) ────────────── */
.map-controls {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.tile-switcher {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.12);
  overflow: hidden;
  border: 1.5px solid #e2e8f0;
  display: flex;
}
.tile-btn {
  padding: .4rem .65rem;
  font-size: .76rem; font-weight: 700;
  border: none; background: none;
  cursor: pointer; font-family: inherit;
  color: #64748b;
  transition: background .12s;
}
.tile-btn + .tile-btn { border-left: 1px solid #e2e8f0; }
.tile-btn:hover { background: #f0fdf4; }
.tile-btn.active { background: var(--green, #2d6a4f); color: #fff; }

/* ── Sidebar toggle (mobile) ─────────────────── */
.sidebar-toggle-btn {
  display: none;
  position: absolute;
  top: 10px; left: 10px;
  z-index: 30;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: .45rem .65rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  font-size: .82rem; font-weight: 700;
  color: var(--green, #2d6a4f);
  font-family: inherit;
}

/* ── Loading overlay ─────────────────────────── */
.map-loading {
  position: absolute; inset: 0;
  background: rgba(240,244,240,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  backdrop-filter: blur(2px);
  border-radius: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.map-loading.visible { opacity: 1; pointer-events: all; }
.map-loading-inner {
  background: #fff;
  border-radius: 12px;
  padding: 1rem 1.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  font-size: .9rem; font-weight: 700;
  color: var(--green, #2d6a4f);
  display: flex; align-items: center; gap: .6rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.map-spinner {
  width: 18px; height: 18px;
  border: 2px solid #e2e8f0;
  border-top-color: var(--green, #2d6a4f);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Mobile responsive ───────────────────────── */
@media (max-width: 768px) {
  .map-sidebar {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 25;
    width: 280px;
  }
  .map-sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.15); }
  .sidebar-toggle-btn { display: flex; align-items: center; gap: .35rem; }
  .map-area { flex: 1; }
}
