/**
 * pages/map.css — 한맥 판매처 찾기 (/hanmac/map.php) 전용
 * ------------------------------------------------------------------
 * 페이지에서 $pageCSS = ['map']; 선언 시 layoutHeader 가 자동 로드.
 * 외부 CDN (Bootstrap) 은 $pageCDN 으로 base 이전에 로드.
 *
 * 구조:
 *   1. Tokens (--banner-height / --map-header-banner-height / --safe-bot / --chev-svg)
 *   2. Layout (#body_container, #placePanel, #map)
 *   3. Panel header (#panelHeader, .panel-title, .toggle-btn)
 *   4. Tab / Tag controls (#tabContainer, #tagControls, .tag, .tag-filter, curation)
 *   5. Search controls (#searchControls)
 *   6. Place list (#placeList, .pla-*)
 *   7. Tags & popups (.custom-popup, .report-tag, .autocomplete-items)
 *   8. Map elements (.custom-cluster, #currentLocationBtn, #loading-overlay)
 *   9. Header banner (.header-banner — banner.php 와 별개의 map 전용 배너)
 *  10. Mobile (@media max-width: 768px)
 *  11. Banner responsive (@media max-width: 1800/1600/1400/1024/767/600/500/390)
 */

/* ── 1. Tokens ───────────────────────────────────────────────── */
:root {
  --banner-height: 90px;
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --chev-svg: url("/resources/images/map/function-icon.png");
}
@supports (height: 100dvh) {
  :root { --vb: 100dvh; }
}

/* ── 2. Layout ───────────────────────────────────────────────── */
#body_container:has(#map) { max-height: calc(100vh - 90px); overflow: hidden; }
#map { width: 100%; height: calc(100vh - 90px); }

#placePanel { position: absolute; top: 20px; left: 20px; width: 350px; height: auto; max-height: calc(100vh - 180px); background: #fff; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); z-index: 100; display: flex; flex-direction: column; transition: all 0.3s ease; }
#placePanel.collapsed { height: 122px; overflow: hidden; }

/* ── 3. Panel header ─────────────────────────────────────────── */
#panelHeader { display: flex; align-items: center; justify-content: space-around; height: 48px; padding: 30px 0; background-color: #004c39; }
.panel-title { width: 250px; }
#panelHeader .toggle-btn { position: static; background: transparent; border: none; padding: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.toggle-btn { position: static !important; box-shadow: none !important; left: auto !important; top: auto !important; bottom: auto !important; }
.toggle-btn img { width: 20px; height: 20px; filter: invert(1); }
.toggle-btn .chev { position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; transition: opacity .25s ease, transform .25s ease; }
.toggle-btn .chev-up { opacity: 0; transform: translateY(4px); }
.toggle-btn .chev-down { opacity: 1; transform: translateY(0); }

/* ── 4. Tab / Tag controls ───────────────────────────────────── */
#tabContainer { background: #014d39; display: flex; align-items: center; padding: 5px 0 20px; }
.tab-group { display: flex; width: 330px; margin: auto; border-radius: 30px; background: #c0cdc9; padding: 4px; }
.tab-button { flex: 1; padding: 4px 6px; font-size: 14px; background-color: #c0cdc9; color: #014d39; border: none; cursor: pointer; transition: background-color 0.3s, color 0.3s; text-align: center; border-radius: 30px; }
.tab-button.active { background-color: #014d39; color: #fff; border-radius: 30px; }
.tab-button:not(.active):hover { background-color: #e0f0e9; }

#tagControls { padding: 4px 15px; background-color: #ffffff; box-shadow: 0px 2px 8px -3px #00000030; }
#tagControls .search-row.tag-row { margin: 0; }

#tagContainer { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0; white-space: nowrap; scrollbar-width: none; flex-wrap: wrap; }
#tagContainer::-webkit-scrollbar { display: none; }

.tag-filter { display: flex; align-items: center; justify-content: center; padding: 4px 10px; font-size: 12px; background-color: #F0F0F0; border-radius: 30px; color: #4C4C4C; cursor: pointer; transition: all 0.2s ease; font-weight: 500; }
.tag-filter.active { background-color: #003d28; color: #fff; border-color: #003d28; }

/* 태그 스크롤러 화살표 (PC hover 시만 표시) */
.tag-scroller { position: relative; overflow: visible; }
.tag-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border: none; border-radius: 50%; background: #b6f8e8; color: #fff; font-size: 14px; display: none; justify-content: center; align-items: center; cursor: pointer; user-select: none; z-index: 5; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); line-height: 1; padding: 0; }
.nav-prev { left: -6px; }
.nav-next { right: -6px; }
.tag-nav:disabled { opacity: .35; cursor: default; box-shadow: none; }
.tag-scroller:hover .tag-nav { display: flex; }

/* 큐레이션 드롭다운 (Bootstrap dropdown override) */
#curationSelect,
#curationSelect:hover,
#curationSelect:focus,
#curationSelect:active,
#curationSelect:focus-visible,
.dropdown.show #curationSelect { background-color: #fff !important; color: #333 !important; }
#curationSelect.dropdown-toggle::after { display: none; }
#curationSelect { -webkit-appearance: none; -moz-appearance: none; appearance: none; height: 48px; padding: 0 calc(10px + var(--chev-size) + 8px) 0 12px; border: 0; border-bottom: 1px solid #E7E7E7; font-size: 12px; line-height: 34px; text-align: left; background-image: var(--chev-svg) !important; background-repeat: no-repeat; background-position: right 10px center; background-size: 20px; }
#curationSelect:hover,
#curationSelect:focus { background-color: #003d2810; }
#curationSelect .label { font-size: 12px; font-weight: 300; color: #000; }

#curationDropdownMenu[data-bs-popper] { margin-top: 0 !important; }
#curationDropdownMenu { --bs-dropdown-spacer: 0; display: flex; transform: translate(0, 65%) !important; opacity: 0; pointer-events: none; transition: transform .32s cubic-bezier(.2,.8,.2,1), opacity .32s cubic-bezier(.2,.8,.2,1); will-change: transform, opacity; padding: 20px 10px !important; border-radius: 0 !important; overflow: auto; box-shadow: 0px 0px 10px 2px #0000004f; border: 0; flex-wrap: wrap; justify-content: flex-start; align-items: center; gap: 8px; }
#curationDropdownMenu.show { transform: translateY(0); opacity: 1; pointer-events: auto; transition-delay: .15s; }
#curationDropdownMenu.animating-out { transform: translateY(-8px); opacity: 0; pointer-events: none; transition-delay: .15s; }
#curationDropdownMenu .cur-tag { font-size: 12px !important; line-height: 1 !important; display: inline-flex; padding: 4px 8px !important; background: #F0F0F0 !important; color: #4c4c4c !important; border-radius: 30px !important; border-color: #F0F0F0 !important; }
#curationDropdownMenu .cur-tag.btn-success { background: #003d28 !important; border-color: #003d28 !important; color: #fff !important; border-radius: 30px !important; }

/* ── 5. Search controls ──────────────────────────────────────── */
#searchControls { display: none; padding: 0 11px; background-color: #ffffff; box-shadow: 0px 2px 8px -3px #00000030; }
#searchControls .search-row { display: flex; margin-bottom: 8px; }
#searchControls .search-row { margin-bottom: 3px; }
#searchControls .common-row { margin-bottom: 4px; }

#searchControls input[type="text"]::placeholder { color: #000; opacity: 1; }
.search-row input[type="text"] { height: 34px; line-height: 34px; padding: 0 10px; color: #333; background-color: #ffffff; border: 1.5px solid #ccc; border-radius: 4px; font-size: 12px; width: 100%; box-sizing: border-box; margin-bottom: 0; display: flex; align-items: center; }
#searchControls select { -webkit-appearance: none; -moz-appearance: none; appearance: none; height: 48px; width: 100%; padding: 0 calc(10px + var(--chev-size) + 8px) 0 0; font-size: 12px; border: 0; border-bottom: 1px solid #E7E7E7; border-radius: 0; box-sizing: border-box; line-height: normal; display: flex; align-items: center; background-color: #fff; color: #333; background-image: var(--chev-svg); background-repeat: no-repeat; background-position: right 10px center; background-size: 20px; }
#searchControls select:hover,
#searchControls select:focus { background-image: var(--chev-svg); }
#searchControls select:focus,
#searchControls input:focus { outline: none; border-color: #014d39; }

#searchControls .input-with-icon { position: relative; width: 100%; }
#searchControls .input-with-icon input { padding-right: 38px; font-size: 12px !important; font-weight: 400 !important; color: #333 !important; line-height: 34px !important; border-radius: 99px; border-color: #003d28; text-indent: 10px; }
#searchControls .input-with-icon input::placeholder { font-size: 12px !important; font-weight: 400 !important; color: #333 !important; border-radius: 99px; }
#searchControls .input-with-icon #searchMapBtn.search-icon-btn { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); width: 28px; height: 28px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; opacity: .8; }
#searchControls .input-with-icon #searchMapBtn.search-icon-btn svg { width: 18px; height: 18px; fill: #444; }
#searchControls .input-with-icon #searchMapBtn.search-icon-btn:hover { opacity: 1; }
#searchControls .input-with-icon #searchMapBtn.search-icon-btn:focus { outline: none; }
#searchControls #searchMapBtn { background: transparent; color: inherit; padding: 0; border: 0; }
#searchControls .search-icon { width: 16px; height: 16px; display: block; fill: currentColor; }

/* ── 6. Place list ───────────────────────────────────────────── */
#placeList { padding: 0; overflow-y: auto; max-height: calc(100vh - 180px); }
#placeList div { cursor: pointer; color: #244634; }
#placeList::-webkit-scrollbar { width: 6px; }
#placeList::-webkit-scrollbar-track { background: transparent; border-radius: 3px; }
#placeList::-webkit-scrollbar-thumb { background: #d0a255; border-radius: 3px; }
#placeListCount { background-color: #ffffff !important; color: #014d39 !important; padding: 75px 0; }

#placeListDetail { color: #fff; padding: 20px 15px; margin: 0; border-bottom: 1px solid #DFDFDF; }
.pla-tit { display: flex; justify-content: space-between; align-items: center; padding: 0; margin: 0; }
.pla-shop-nm { font-size: 16px; font-weight: bold; margin: 0; padding: 0; overflow-wrap: break-word; width: 220px; word-break: keep-all; }
.pla-gomap { display: flex; align-items: center; margin: 0; padding: 0; height: 15px; }
.pla-gomap img { width: 18px; vertical-align: middle; }
.pla-tags { font-size: 11px; color: #fff; margin: 8px 0; padding: 0; display: flex; justify-content: flex-start; align-items: center; flex-wrap: wrap; gap: 4px; }
.pla-dis { font-size: 12px; margin-bottom: 4px; padding: 0; }
.pla-dis span { margin-right: 12px; font-weight: 500; }
.pla-cate { font-weight: 500; color: #016f35; letter-spacing: -.8px; }
.pla-adr { font-size: 12px; margin: 0; padding: 0; font-weight: 500; letter-spacing: -.8px; width: 260px; word-break: keep-all; word-wrap: break-word; }

/* ── 7. Tags & popups ────────────────────────────────────────── */
.tag { display: flex; align-items: center; justify-content: space-between; padding: 4px 14px; background-color: #003d28; color: #fff; border-radius: 30px; font-size: 11px; font-weight: 400; white-space: nowrap; line-height: 1.1; }
.tag span { display: inline-block; transform: translateY(1px); }
.curation-tag { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; background-color: #c2a471; color: #ffffff; border-radius: 99px; font-size: 11px; line-height: 1.2; }
.tag,
.curation-tag { font-size: 11px; display: flex; justify-content: center; align-items: center; border-radius: 30px; font-weight: 400; padding: 5px 15px; max-height: 22px; }

#placeList .tag,
#placeList .curation-tag,
.custom-popup .tag,
.custom-popup .curation-tag { margin: 0; }

.custom-popup { padding: 15px; font-size: 16px; line-height: 1.5; width: 336px; background: #fff; z-index: 1000; box-shadow: 0 0 8px 8px #00000030; border-radius: 10px; }
.custom-popup b { font-size: 18px; color: #244634; font-weight: bold; }
.custom-popup .address,
.custom-popup .distance,
.custom-popup .category { color: #000; font-size: 13px; display: block; }

.report-tag { display: inline-flex; align-items: center; justify-content: center; padding: 3px; font-size: 9px; line-height: 1; font-weight: 400; color: #595959; background-color: #f5f5f5; border: 1.1px solid #d9d9d9; border-radius: 4px; }

.autocomplete-items { position: absolute; top: 100%; left: 0; right: 0; z-index: 999; max-height: 180px; overflow-y: auto; background-color: white; border-top: none; font-size: 13px; color: black; }
.autocomplete-items div { padding: 8px; cursor: pointer; border-bottom: 1px solid #eee; font-size: 13px; }
.autocomplete-items div:hover { background-color: #f0f0f0; }
#autocompleteList { z-index: 1001; }

/* ── 8. Map elements ─────────────────────────────────────────── */
.custom-cluster { width: 42px; height: 42px; border-radius: 50%; background-color: #03d39c; color: white; font-size: 14px; font-weight: bold; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 6px rgba(0, 0, 0, 0.3); transition: transform 0.2s ease; }
.custom-cluster:hover { transform: scale(1.1); }

#currentLocationBtn { position: absolute; bottom: 10px; right: 10px; z-index: 1000; background-color: #fff; border: 1px solid #ccc; border-radius: 8px; padding: 8px 12px; font-size: 14px; cursor: pointer; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); display: flex; align-items: center; }

#loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); display: none; justify-content: center; align-items: center; z-index: 2000; }
#loading-icon { width: 40px; height: 40px; border: 4px solid #5ae782; border-top: 4px solid transparent; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

select:focus { outline: none !important; }
.form-select:focus { box-shadow: unset !important; }

.mobile-only-footer { display: none; }

/* ── 9. Header banner (map 전용) ─────────────────────────────── */
.header-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 100; line-height: 0; background: #014634; }
.header-banner .banner-wrap { margin: 0 auto; display: block; width: 100%; position: relative; line-height: 0; }
.header-banner picture { display: block; width: 100%; height: auto; }
.header-banner img { display: block; width: 70%; max-width: 100%; margin: 0 auto; height: auto; object-fit: contain; object-position: center center; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; backface-visibility: hidden; transform: translateZ(0); }
.header-banner .banner-close-btn { position: absolute; top: 30px; right: 20px; transform: translateY(-50%); width: 24px; height: 24px; border: 0; background: rgba(0, 0, 0, 0.5); border-radius: 50%; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 101; }

@media (max-width: 1024px) {
  #body_container:has(#map) { max-height: calc(100vh - 53px); }
  #map { height: calc(100vh - 53px); }
}

/* ── 10. Mobile (max-width: 768px) ───────────────────────────── */
@media (max-width: 768px) {
  #body_container { height: 100vh; overflow: hidden; box-sizing: border-box; position: relative; padding-top: 0; }

  /* 지도 — 헤더 아래 배치 */
  #map { width: 100%; position: absolute; left: 0; z-index: 1; }

  /* 상단 헤더 */
  #panelHeader { position: fixed; top: 0; left: 0; width: 100%; background-color: #014d39; display: flex; align-items: center; justify-content: space-between; padding: 35px 10px; box-sizing: border-box; z-index: 2000; }
  .panel-title { color: #ffffff; font-size: 18px; font-weight: bold; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #panelHeader .toggle-btn { width: 32px; height: 32px; background: transparent; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; }
  .toggle-btn img { width: 20px; height: 20px; }

  /* 패널 — 화면 하단 고정 */
  #placePanel { position: fixed !important; left: 0; top: auto !important; bottom: 0 !important; width: 100%; height: clamp(96px, 50vh, calc(100vh - var(--map-header-banner-height, 53px) - var(--safe-bot))); background: #fff; box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3); z-index: 1000; display: flex; flex-direction: column; justify-content: flex-end; transition: all 0.3s ease; border-radius: 10px; }
  #placePanel.expanded { height: calc(var(--vb) - var(--map-header-banner-height, 53px) - var(--safe-bot)); max-height: calc(var(--vb) - var(--map-header-banner-height, 53px) - var(--safe-bot)); }
  #placePanel.collapsed { top: auto !important; height: 110px !important; min-height: 135px !important; bottom: 0 !important; overflow: hidden; background: #004c39; }
  #placePanel.collapsed #tagControls,
  #placePanel.collapsed #searchControls,
  #placePanel.collapsed #placeList,
  #placePanel.collapsed #placeListCount { display: none !important; }

  /* 패널 내부 순서: 리스트 > 탭 > 헤더 */
  #tagControls,
  #searchControls { order: 0; flex-shrink: 0; padding: 15px; background-color: #ffffff; border-top-left-radius: 10px; border-top-right-radius: 10px; }
  #placeList { order: 1; flex: 1 1 auto; overflow-y: auto; padding: 0 12px; }
  #placeListCount { order: 1; flex: 0 0 70px; display: none; text-align: center; padding: 50px 10px; }
  #tabContainer { order: 2; position: relative; display: flex; align-items: center; width: 100%; box-sizing: border-box; z-index: 1001; padding: 15px 10px; border-top-left-radius: 10px; border-top-right-radius: 10px; }
  #placePanel #panelHeader { order: 3; position: relative; display: flex; align-items: center; justify-content: center; border-bottom: none; z-index: 1002; }
  #placePanel .panel-title { width: 100%; padding: 0 20px; }
  #placePanel #panelHeader .toggle-btn { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; background: transparent; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 1003; }

  /* 탭 버튼 */
  .tab-group { display: flex; width: 100%; height: 100%; }
  .tab-button { flex: 1; padding: 6px 0; font-size: 12px; background-color: #c0cdc9; color: #014d39; border: none; cursor: pointer; transition: background-color 0.3s, color 0.3s; text-align: center; line-height: 24px; }
  .tab-button.active { background-color: #014d39; color: #fff; font-weight: bold; }
  .tab-button:not(.active):hover { background-color: #e0f0e9; }

  /* 현재 위치 버튼 */
  #currentLocationBtn { position: fixed; top: 20%; right: 8px; padding: 5px; width: 35px; height: 35px; z-index: 900; display: flex; align-items: center; justify-content: center; background-color: #fff; border: 1px solid #ccc; border-radius: 8px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); cursor: pointer; transform: translateY(40%); }
  #currentLocationBtn img { width: 24px; height: 24px; }

  /* 푸터 */
  .mobile-only-footer { display: block; position: fixed; bottom: 0; left: 0; width: 100%; height: 60px; padding-bottom: var(--safe-bot); background-color: white; box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.1); z-index: 999; }

  /* 팝업 */
  .custom-popup { padding: 6px 10px; font-size: 16px; line-height: 1.5; min-width: 300px; max-width: 400px; background: white; z-index: 1010; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45); }

  /* 태그 내비 숨김 */
  .tag-nav { display: none !important; }

  /* 마지막 줄 여백 제거 */
  #searchControls .common-row { margin-bottom: 0; }
}

/* ── 11. Header banner responsive ────────────────────────────── */
@media (max-width: 1800px) { .header-banner img { width: 80%; } }
@media (max-width: 1600px) { .header-banner img { width: 90%; } }
@media (max-width: 1400px) { .header-banner img { width: 100%; } }
@media (max-width: 1024px) {
  .header-banner .banner-wrap { margin: 0 auto; display: block; width: 100%; position: relative; }
  .header-banner picture { display: block; width: 100%; height: auto; line-height: 0; }
  .header-banner .banner-close-btn { right: 10px; }
}
@media (max-width: 768px) { .header-banner img { width: 80%; } }
@media (max-width: 767px) {
  .header-banner .banner-wrap { max-width: 100%; padding: 0 10px; }
  .header-banner picture { width: 100%; margin: 0; }
  .header-banner .banner-close-btn { right: 8px; top: 18px; width: 18px; height: 18px; }
  .header-banner .banner-close-btn svg { width: 8px; height: 8px; }
}
@media (max-width: 600px) { .header-banner img { width: 90%; } }
@media (max-width: 500px) { .header-banner img { width: 100%; } }
@media (max-width: 390px) { .header-banner .banner-wrap { padding: 0 5px; } }
