/* ============================================
   시설 지도 페이지 공통 스타일
   (장례식장 / 화장시설 / 봉안시설 등 공유)
   ============================================ */

html,
body {
  height: 100%;
}

/* ── 페이지 레이아웃 ── */
.fh-page {
  padding: 24px 0 40px;
}
.fh-workspace {
  display: grid;
  gap: 14px;
}
.fh-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(520px, 1fr);
  gap: 16px;
  height: calc(100vh - 244px);
  min-height: 640px;
}

/* ── 지도 & 리스트 컨테이너 ── */
.fh-map-wrap,
.fh-list-wrap {
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}
.fh-map-wrap {
  position: relative;
  border: 1px solid #d8dde6;
}
#fh-map {
  width: 100%;
  height: 100%;
}
.fh-list-wrap {
  display: flex;
  flex-direction: column;
}

/* ── 초기 로딩 모달 ── */
.fh-loading {
  position: fixed;
  inset: 0;
  z-index: 2400;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, 0.9);
  backdrop-filter: blur(2px);
}
.fh-loading[hidden] {
  display: none;
}
.fh-loading-panel {
  min-width: 220px;
  max-width: 90vw;
  padding: 16px 18px;
  border: 1px solid #d7dee8;
  border-radius: 12px;
  background: #fff;
  display: grid;
  justify-items: center;
  gap: 10px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16);
}
.fh-loading-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #d1d5db;
  border-top-color: #0f766e;
  animation: fh-spin 0.85s linear infinite;
}
.fh-loading-text {
  margin: 0;
  color: #374151;
  font-size: 14px;
  font-weight: 600;
}

@keyframes fh-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── 검색/필터 툴바 ── */
.fh-toolbar {
  padding: 16px;
  border-radius: 16px;
  display: block;
  background: #f8fafc;
}
.fh-control-row {
  display: grid;
  grid-template-columns: 88px 88px 94px 108px minmax(300px, 1fr);
  gap: 10px;
  align-items: center;
}
.fh-autocomplete-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
}
.fh-autocomplete-wrap input,
.fh-control-row select {
  width: 100%;
  height: 42px;
  border: 1px solid #d4dbe6;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  color: #111827;
  background: #fff;
}
.fh-search-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 280px;
  overflow: auto;
  border: 1px solid #d4dbe6;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.14);
}
.fh-search-suggest[hidden] {
  display: none;
}
.fh-search-suggest-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #eef2f7;
  background: #fff;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
}
.fh-search-suggest-item:last-child {
  border-bottom: 0;
}
.fh-search-suggest-item:hover,
.fh-search-suggest-item.is-active {
  background: #ffffff;
}
.fh-search-suggest-name {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #111827;
}
.fh-search-suggest-meta {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #6b7280;
}

@media (max-width: 1280px) and (min-width: 961px) {
  .fh-control-row {
    grid-template-columns: 82px 82px 90px 102px minmax(240px, 1fr);
    gap: 8px;
  }
  .fh-autocomplete-wrap input,
  .fh-control-row select {
    padding: 0 10px;
    font-size: 13px;
  }
}

/* ── 결과 메타 ── */
.fh-list-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px 10px;
  color: #6b7280;
  font-size: 13px;
}
.fh-list-meta[hidden] {
  display: none;
}

/* ── 리스트 ── */
.fh-list {
  flex: 1;
  overflow: auto;
  padding: 4px 14px 16px;
  display: grid;
  gap: 12px;
  align-content: start;
  grid-auto-rows: max-content;
}
.fh-list[hidden] {
  display: none;
}

/* ── 카드 ── */
.fh-card {
  border: 1px solid #d8dde6;
  border-radius: 14px;
  padding: 16px 18px;
  cursor: pointer;
  align-self: start;
}
.fh-card.is-active {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.18);
}
.fh-card h3 {
  margin: 0;
  font-size: clamp(1.06rem, 1.05vw, 1.24rem);
  line-height: 1.35;
  color: #111827;
}
.fh-card p {
  margin: 8px 0 0;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.45;
}

/* ── 뱃지 ── */
.fh-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.fh-badge {
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}
.fh-badge.type-01 { background: #8b5cf6; }
.fh-badge.type-02 { background: #3b82f6; }

/* ── 조건 태그 ── */
.fh-condition-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.fh-condition-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  background: #64748b;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.fh-condition-tag.seonkol  { background: #ec4899; }
.fh-condition-tag.hukol   { background: #f59e0b; }
.fh-condition-tag.altar   { background: #6366f1; }
.fh-condition-tag.supplies { background: #0ea5e9; }
.fh-condition-tag.parking  { background: #10b981; }

/* ── 빈 상태 ── */
.fh-empty {
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  color: #64748b;
}

/* ── 지도 오버레이 라벨 ── */
.fh-overlay-label {
  padding: 6px 10px;
  border: 2px solid #23b0a2;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.14);
  cursor: pointer;
}
.fh-overlay-label:hover {
  background: #f0fdfa;
}

/* ── Bottom Sheet (모바일 상세 패널) / PC 우측 오버레이 ── */
.fh-sheet-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  z-index: 1000;
}
.fh-sheet-backdrop.is-open {
  display: block;
}
/* 모바일 기본: 화면 하단 바텀시트 */
.fh-sheet {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 0;
  width: 100%;
  max-width: 560px;
  transform: translate(-50%, 100%);
  z-index: 1001;
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.18);
  padding: 0 0 env(safe-area-inset-bottom, 12px);
  max-height: 80vh;
  overflow-y: auto;
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
.fh-sheet.is-open {
  transform: translate(-50%, 0);
}
/* PC: 우측 리스트 영역을 덮는 오버레이 패널
   (left/top/width/height는 JS에서 인라인 스타일로 주입) */
.fh-sheet.is-pc {
  position: fixed;
  bottom: auto;
  transform: translateY(100%);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
  padding: 0;
  max-height: none;
}
.fh-sheet.is-pc.is-open {
  transform: translateY(0);
}
/* ── Backdrop: 패널 열릴 때 배경 어둡게 ── */
.fh-sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #d1d5db;
  margin: 12px auto 0;
}
.fh-sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 18px 4px;
}
.fh-sheet-close {
  background: none;
  border: none;
  font-size: 14px;
  color: #6b7280;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  flex-shrink: 0;
  border: 1px solid #d1d5db;
  border-radius: 4px;
}
.fh-sheet-body {
  padding: 4px 20px 8px;
}
.fh-sheet-body h2 {
  margin: 0 0 6px;
  font-size: 1.22rem;
  color: #111827;
  line-height: 1.35;
}
.fh-sheet-body p {
  margin: 0 0 4px;
  color: #6b7280;
  font-size: 13.5px;
  line-height: 1.5;
}
.fh-sheet-body #fh-sheet-conditions {
  margin-top: 12px;
}

.fh-sheet-section {
  margin-bottom: 16px;
}

.fh-sheet-photo-wrap {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 5 / 3;
  height: auto;
  padding-top: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #dbe3ef;
  background: #f8fafc;
  margin-bottom: 12px;
}

.fh-sheet-photo {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fh-sheet-photo-empty {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 12px;
}

/* 다중 사진 그리드 레이아웃 */
.fh-photo-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.fh-photo-main-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 3;
  height: auto;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #dbe3ef;
  background: #f8fafc;
}

.fh-photo-main {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fh-photo-subs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fh-photo-sub {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #dbe3ef;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.fh-photo-sub:hover {
  border-color: #a3e4d7;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.fh-sheet-title-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.fh-sheet-sub {
  margin: 4px 0 8px;
  color: #64748b;
  font-size: 13px;
}

.fh-info-line {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.fh-info-text {
  color: #1f2937;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

.fh-inline-action {
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #0f766e;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.fh-amenities {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.fh-amenity {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  background: #ccfbf1;
  color: #0f766e;
}

.fh-amenity.is-off {
  background: #f1f5f9;
  color: #94a3b8;
}

.fh-section-title {
  margin: 0 0 8px;
  font-size: 15px;
  color: #0f172a;
}

.fh-condition-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 10px;
  overflow: hidden;
}

.fh-condition-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
}

.fh-condition-list li:last-child {
  border-bottom: none;
}

.fh-condition-list strong {
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.fh-condition-list span {
  color: #0f172a;
  text-align: right;
  word-break: break-word;
}

.fh-condition-table-wrap {
  overflow-x: auto;
}

.fh-info-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}

.fh-info-table th,
.fh-info-table td {
  border-bottom: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  padding: 8px 10px;
  font-size: 12.5px;
  text-align: left;
}

.fh-info-table th:last-child,
.fh-info-table td:last-child {
  border-right: none;
}

.fh-info-table tbody tr:last-child td {
  border-bottom: none;
}

.fh-info-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
}

.fh-table-empty {
  text-align: center;
  color: #94a3b8;
}

.fh-toggle {
  border: none;
  border-radius: 14px;
  margin-bottom: 12px;
  background: #fff;
  overflow: hidden;
}

.fh-toggle > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  position: relative;
  border-radius: 14px;
  user-select: none;
}

.fh-toggle[open] > summary {
  border-radius: 14px 14px 0 0;
}

.fh-toggle > summary::-webkit-details-marker {
  display: none;
}

.fh-toggle > summary::after {
  content: "▾";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  opacity: 0.85;
}

.fh-toggle[open] > summary::after {
  content: "▴";
}

/* 조건표 - 청록 계열 */
.fh-toggle--condition > summary {
  background: #0f766e;
}

/* 시설요금 - 인디고 계열 */
.fh-toggle--facility > summary {
  background: #4338ca;
}

/* 음식 - 오렌지 계열 */
.fh-toggle--food > summary {
  background: #7a1f3d;
}

.fh-toggle-content {
  padding: 0 12px 12px;
  border: 1.5px solid;
  border-top: none;
  border-radius: 0 0 14px 14px;
}

.fh-toggle--condition > .fh-toggle-content { border-color: #14b8a6; }
.fh-toggle--facility > .fh-toggle-content { border-color: #6366f1; }
.fh-toggle--food > .fh-toggle-content { border-color: #a3305a; }

.fh-intro {
  margin: 0;
  color: #475569;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.fh-request-section {
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
}

.fh-request-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fh-request-header .fh-section-title {
  margin: 0;
}

.fh-request-help {
  margin: 8px 0 0;
  color: #64748b;
  font-size: 12px;
}

.fh-request-form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.fh-request-field {
  display: grid;
  gap: 6px;
}

.fh-request-field span {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}

.fh-request-field input,
.fh-request-field select,
.fh-request-field textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: #0f172a;
  background: #fff;
}

.fh-request-actions {
  display: grid;
  gap: 8px;
}

.fh-request-submit {
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.fh-request-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.fh-request-status {
  margin: 0;
  font-size: 12px;
  color: #475569;
}

.fh-request-status.is-ok {
  color: #0f766e;
}

.fh-request-status.is-error {
  color: #b91c1c;
}

.fh-request-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1800;
  padding: 14px;
}

.fh-request-modal.is-open {
  display: flex;
}

.fh-request-modal-panel {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 14px;
  border: 1px solid #dbe3ef;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.34);
  padding: 14px;
}

.fh-request-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.fh-request-modal-header h3 {
  margin: 0;
  font-size: 16px;
  color: #0f172a;
}

.fh-request-modal-close {
  border: none;
  background: #f1f5f9;
  color: #334155;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

@media (min-width: 961px) {
  .fh-sheet-photo-wrap {
    margin-left: auto;
    margin-right: auto;
  }
}

/* ── PC 상세 패널 ── */
.fh-detail {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.fh-detail[hidden] {
  display: none;
}
.fh-detail-header {
  padding: 10px 16px 6px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.fh-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s;
}
.fh-detail-back:hover {
  background: #f3f4f6;
}
.fh-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 32px;
}
.fh-detail-body h2 {
  margin: 10px 0 8px;
  font-size: 1.4rem;
  color: #111827;
  line-height: 1.35;
}
.fh-detail-body p {
  margin: 0 0 4px;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.55;
}
.fh-detail-body #fh-detail-conditions {
  margin-top: 16px;
}

/* ── 반응형: 태블릿 이하 ── */
@media (max-width: 960px) {
  .fh-page {
    padding: 18px 0 28px;
  }

  /* 모바일 상세 패널은 화면을 거의 전체 덮도록 확장한다. */
  .fh-sheet:not(.is-pc) {
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    transform: translateY(100%);
  }
  .fh-sheet:not(.is-pc).is-open {
    transform: translateY(0);
  }

  .fh-toolbar {
    padding: 0;
    background: transparent;
    border-radius: 0;
  }
  .fh-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  .fh-map-wrap {
    aspect-ratio: 16 / 9;
    height: auto;
    min-height: 0;
  }
  .fh-control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .fh-autocomplete-wrap {
    order: 1;
    flex: 0 0 100%;
    width: 100%;
  }
  #fh-status-filter,
  #fh-type-filter,
  #fh-region1-filter,
  #fh-region2-filter {
    order: 2;
    flex: 1 1 calc((100% - 24px) / 4);
    min-width: 0;
  }
  .fh-autocomplete-wrap input,
  .fh-control-row select {
    height: 40px;
    border-radius: 12px;
  }
  .fh-autocomplete-wrap input,
  .fh-control-row select {
    border-width: 1px;
    border-color: #d7dee8;
    padding: 0 12px;
    font-size: 13px;
  }
  .fh-autocomplete-wrap input::placeholder {
    font-size: 12px;
  }
  .fh-control-row select {
    min-width: 0;
  }
  .fh-card h3 {
    font-size: 15px;
  }
  .fh-card p {
    font-size: 12px;
  }
  .fh-condition-tags {
    gap: 5px;
    margin-top: 8px;
  }
  .fh-condition-tag {
    min-height: 22px;
    padding: 0 7px;
    font-size: 10px;
    border-radius: 7px;
  }
  .fh-detail {
    display: none !important;
  }
}

/* ── 반응형: 모바일 ── */
@media (max-width: 480px) {
  .fh-toolbar {
    gap: 7px;
  }
  .fh-control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
  }
  .fh-autocomplete-wrap {
    order: 1;
    flex: 0 0 100%;
    width: 100%;
  }
  #fh-status-filter,
  #fh-type-filter,
  #fh-region1-filter,
  #fh-region2-filter {
    order: 2;
    flex: 1 1 calc((100% - 21px) / 4);
    min-width: 0;
  }
  .fh-autocomplete-wrap input,
  .fh-control-row select {
    height: 38px;
    border-radius: 11px;
  }
  .fh-autocomplete-wrap input,
  .fh-control-row select {
    padding: 0 10px;
    font-size: 12px;
  }
  .fh-autocomplete-wrap input::placeholder {
    font-size: 11px;
  }
  .fh-control-row {
    gap: 6px;
  }
  .fh-control-row select {
    padding: 0 8px;
    font-size: 12px;
  }
}
