/* ── Feature Detail Panel (sidebar + bottom alternatives to center modal) ── */

#feature-panel {
  position: fixed;
  z-index: 2500;
  background: #fff;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow: hidden;
}

#feature-panel[aria-hidden="true"] {
  pointer-events: none;
}

/* ── Sidebar Mode ────────────────────────────────────── */

#feature-panel.fp-sidebar {
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 85vw;
  box-shadow: -3px 0 12px rgba(0, 0, 0, 0.15);
  transform: translateX(100%);
}

#feature-panel.fp-sidebar.open {
  transform: translateX(0);
}

/* Shrink map when sidebar is open */
body.fp-sidebar-open #map {
  right: 420px;
  transition: right 0.3s ease;
}

/* ── Bottom Mode ─────────────────────────────────────── */

#feature-panel.fp-bottom {
  left: 0;
  right: 0;
  bottom: 0;
  height: 40vh;
  max-height: 70vh;
  box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.15);
  border-radius: 12px 12px 0 0;
  transform: translateY(100%);
}

#feature-panel.fp-bottom.open {
  transform: translateY(0);
}

/* Shrink map when bottom panel is open */
body.fp-bottom-open #map {
  bottom: 40vh;
  transition: bottom 0.3s ease;
}

/* ── Panel Inner Structure ───────────────────────────── */

.fp-header {
  padding: 10px 16px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-height: 48px;
}

.fp-header .fp-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fp-header .btn {
  flex-shrink: 0;
}

.fp-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* Re-use modal body styling inside the panel */
.fp-body .modal-body {
  padding: 1rem;
}

/* Footer inside panel */
.fp-body .border-top {
  position: sticky;
  bottom: 0;
  background: #fff;
}

/* ── Mode Button Group ───────────────────────────────── */

.fp-mode-group .fp-mode-btn {
  font-size: 0.75rem;
  padding: 4px 8px;
  line-height: 1;
}

.fp-mode-group .fp-mode-btn.active {
  background-color: var(--bs-secondary, #6c757d);
  border-color: var(--bs-secondary, #6c757d);
  color: #fff;
  pointer-events: none;
}

/* ── Drawer coexistence (bottom mode) ────────────────── */

body.fp-bottom-open .map-search-drawer {
  max-height: 20vh;
}

/* ── Mobile ──────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Sidebar becomes bottom sheet on mobile */
  #feature-panel.fp-sidebar {
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 55vh;
    border-radius: 12px 12px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.15);
  }

  #feature-panel.fp-sidebar.open {
    transform: translateY(0);
  }

  body.fp-sidebar-open #map {
    right: 0;
    bottom: 55vh;
    transition: bottom 0.3s ease;
  }

  /* Hide sidebar option on mobile — it's identical to bottom */
  .fp-mode-btn[data-mode="sidebar"] {
    display: none !important;
  }

  /* Larger tap targets on mobile */
  .fp-mode-group .fp-mode-btn {
    font-size: 0.85rem;
    padding: 6px 12px;
  }

  /* Buffer Close/Save buttons from bottom edge on mobile */
  #feature-modal .modal-body > .border-top {
    padding-bottom: 4px;
    margin-bottom: env(safe-area-inset-bottom, 4px);
  }
}

/* ── Public view styling (warm, humanist — matches modal) ── */

#feature-panel.wm-public-view .fp-header {
  background: #fafafa;
}
