/* ============================================================
   Hong Kong Hotel Map — Apple Design System
   繁體中文為主，English 為輔
   ============================================================ */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
  /* Colors */
  --color-bg: #f5f5f7;
  --color-surface: #ffffff;
  --color-text: #1d1d1f;
  --color-text-secondary: #86868b;
  --color-text-tertiary: #aeaeb2;
  --color-accent: #0071e3;
  --color-accent-hover: #0077ed;
  --color-separator: #d2d2d7;
  --color-separator-subtle: #e5e5ea;
  --color-shadow: rgba(0, 0, 0, 0.08);
  --color-shadow-strong: rgba(0, 0, 0, 0.15);

  /* Typography */
  --font-display: 'Inter Tight', 'Noto Sans TC', sans-serif;
  --font-body: 'Inter', 'Noto Sans TC', sans-serif;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 980px;

  /* Spacing */
  --nav-height: 56px;
  --sidebar-width: 420px;

  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-smooth: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);

  /* Z-index layers */
  --z-sidebar: 100;
  --z-nav: 200;
  --z-layer-switch: 500;
  --z-mobile-handle: 150;
}

/* --- Base Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* --- Navigation Bar --- */
.nav-bar {
  position: relative;
  z-index: var(--z-nav);
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--color-separator-subtle);
}

.nav-content {
  max-width: 100%;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.nav-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.nav-subtitle {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 12px;
  color: var(--color-text-secondary);
  letter-spacing: 0.01em;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-admin-link {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  transition: all var(--transition-fast);
}
.nav-admin-link:hover {
  color: var(--color-accent);
  background: rgba(0, 113, 227, 0.06);
}

.nav-badge {
  background: var(--color-bg);
  border: 1px solid var(--color-separator);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
}

.nav-badge-text {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-secondary);
  letter-spacing: 0.01em;
}

/* --- Main Layout --- */
.main-container {
  display: flex;
  height: calc(100% - var(--nav-height));
  position: relative;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--z-sidebar);
  border-right: 1px solid var(--color-separator-subtle);
  transition: width 0.3s ease, min-width 0.3s ease, border-right 0.3s ease;
}

/* --- Search --- */
.search-container {
  padding: 16px 20px 8px;
  flex-shrink: 0;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 36px;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  outline: none;
  transition: all var(--transition-fast);
}

.search-input::placeholder {
  color: var(--color-text-tertiary);
}

.search-input:focus {
  background: var(--color-surface);
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.search-clear {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition-fast);
}

.search-clear:hover {
  background: var(--color-separator-subtle);
}

/* --- Filters --- */
.filters-container {
  padding: 8px 20px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--color-separator-subtle);
}

/* Segmented Control */
.segmented-control {
  display: flex;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 2px;
  margin-bottom: 12px;
}

.seg-btn {
  flex: 1;
  height: 32px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  border-radius: 6px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.seg-btn.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 1px 3px var(--color-shadow), 0 0 0 0.5px var(--color-shadow);
}

.seg-btn:hover:not(.active) {
  color: var(--color-text);
}

/* District Dropdown */
.dropdown {
  position: relative;
}

.dropdown-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.dropdown-btn:hover {
  background: var(--color-separator-subtle);
}

.dropdown-btn-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-arrow {
  flex-shrink: 0;
  color: var(--color-text-secondary);
  margin-left: 8px;
  transition: transform var(--transition-fast);
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12), 0 0 0 0.5px rgba(0,0,0,0.08);
  z-index: 200;
  max-height: 340px;
  display: flex;
  flex-direction: column;
}

.dropdown-items {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  max-height: 280px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
  -webkit-user-select: none;
  user-select: none;
}

.dropdown-item:hover {
  background: var(--color-bg);
}

.dropdown-check {
  width: 16px;
  height: 16px;
  accent-color: var(--color-accent);
  cursor: pointer;
  flex-shrink: 0;
}

.dropdown-item-text {
  flex: 1;
  font-size: 13px;
  color: var(--color-text);
}

.dropdown-item-count {
  font-size: 11px;
  color: var(--color-text-tertiary);
  font-weight: 500;
}

.dropdown-footer {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--color-separator-subtle);
  gap: 8px;
}

.dropdown-footer-btn {
  flex: 1;
  height: 30px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  color: var(--color-text-secondary);
}

.dropdown-footer-btn:hover {
  background: var(--color-separator-subtle);
}

.dropdown-footer-btn.primary {
  color: var(--color-surface);
  background: var(--color-accent);
}

.dropdown-footer-btn.primary:hover {
  opacity: 0.9;
}

/* --- Quick Filter Chips --- */
.quick-filters {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border: 1px solid var(--color-separator);
  border-radius: var(--radius-pill);
  transition: all var(--transition-fast);
}

.chip:hover {
  border-color: var(--color-text-tertiary);
  color: var(--color-text);
}

.chip.active {
  color: var(--color-accent);
  background: rgba(0, 113, 227, 0.08);
  border-color: var(--color-accent);
}

/* --- Results Summary --- */
.results-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--color-separator-subtle);
}

.results-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.btn-reset {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-accent);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  transition: all var(--transition-fast);
}

.btn-reset:hover {
  background: rgba(0, 113, 227, 0.08);
}

/* --- Hotel List --- */
.hotel-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.hotel-list::-webkit-scrollbar {
  width: 4px;
}

.hotel-list::-webkit-scrollbar-thumb {
  background: var(--color-separator);
  border-radius: 2px;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--color-text-secondary);
  gap: 12px;
  font-size: 14px;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--color-separator);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--color-text-secondary);
  gap: 8px;
}

.empty-state-icon {
  font-size: 32px;
  margin-bottom: 4px;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

.empty-state-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
}

/* Hotel Card */
.hotel-card {
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-separator-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.hotel-card:hover {
  background: #fafafa;
}

.hotel-card.active {
  background: rgba(0, 113, 227, 0.05);
  border-left: 3px solid var(--color-accent);
  padding-left: 17px;
}

.hotel-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.hotel-name-zh {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
  word-break: break-word;
}

.hotel-type-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}

.hotel-type-badge.hotel {
  background: rgba(0, 113, 227, 0.08);
  color: var(--color-accent);
}

.hotel-type-badge.guesthouse {
  background: rgba(147, 51, 234, 0.08);
  color: #9333ea;
}

.hotel-name-en {
  font-size: 12px;
  color: var(--color-text-tertiary);
  line-height: 1.3;
  margin-bottom: 6px;
  word-break: break-word;
}

.hotel-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.hotel-address {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.hotel-meta-sep {
  color: var(--color-separator);
}

.hotel-district-tag {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--color-bg);
  border-radius: var(--radius-pill);
  color: var(--color-text-secondary);
  font-weight: 500;
}

/* Show More Button */
.show-more {
  width: 100%;
  padding: 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-accent);
  text-align: center;
  transition: background var(--transition-fast);
}

.show-more:hover {
  background: rgba(0, 113, 227, 0.04);
}

/* --- Map Container --- */
.map-container {
  flex: 1;
  position: relative;
  height: 100%;
}

#map {
  width: 100%;
  height: 100%;
}

/* --- Layer Switch --- */
.layer-switch {
  position: absolute;
  bottom: 20px;
  right: 12px;
  z-index: var(--z-layer-switch);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px var(--color-shadow), 0 0 0 0.5px var(--color-shadow);
  overflow: hidden;
}

.layer-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}

.layer-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.layer-btn.active {
  background: rgba(0, 113, 227, 0.08);
  color: var(--color-accent);
}

/* --- Leaflet Overrides --- */

/* Popup */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.08) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0 !important;
  min-width: 220px;
}

.leaflet-popup-close-button {
  z-index: 10;
  color: var(--color-text-secondary) !important;
  font-size: 20px !important;
  padding: 6px 8px !important;
}

.leaflet-popup-close-button:hover {
  color: var(--color-text) !important;
}

.leaflet-popup-tip {
  box-shadow: none !important;
}

/* Custom Popup Content */
.popup-card {
  padding: 0;
}

.popup-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--color-separator-subtle);
}

.popup-name-zh {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
  margin-bottom: 2px;
}

.popup-name-en {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.3;
}

.popup-body {
  padding: 10px 16px 14px;
}

.popup-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.popup-row:last-child {
  margin-bottom: 0;
}

.popup-icon {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--color-text-tertiary);
}

.popup-text {
  color: var(--color-text);
}

.popup-text-secondary {
  color: var(--color-text-secondary);
}

.popup-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.popup-link {
  flex: 1;
  display: block;
  text-align: center;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-accent);
  background: rgba(0, 113, 227, 0.06);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  text-decoration: none;
}

.popup-link:hover {
  background: rgba(0, 113, 227, 0.12);
  text-decoration: none;
}

/* Cluster Styling */
.marker-cluster-small {
  background: rgba(0, 113, 227, 0.15) !important;
}
.marker-cluster-small div {
  background: var(--color-accent) !important;
  color: white !important;
  font-family: var(--font-display) !important;
  font-weight: 600 !important;
  font-size: 13px !important;
}

.marker-cluster-medium {
  background: rgba(0, 113, 227, 0.2) !important;
}
.marker-cluster-medium div {
  background: var(--color-accent) !important;
  color: white !important;
  font-family: var(--font-display) !important;
  font-weight: 600 !important;
  font-size: 14px !important;
}

.marker-cluster-large {
  background: rgba(0, 113, 227, 0.25) !important;
}
.marker-cluster-large div {
  background: var(--color-accent) !important;
  color: white !important;
  font-family: var(--font-display) !important;
  font-weight: 700 !important;
  font-size: 15px !important;
}

/* --- Mobile Handle --- */
.mobile-handle {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-mobile-handle);
  padding: 8px 0 0;
  pointer-events: none;
}

.handle-bar {
  width: 36px;
  height: 4px;
  background: var(--color-separator);
  border-radius: 2px;
  margin: 0 auto;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .nav-content {
    padding: 0 14px;
  }

  .nav-title {
    font-size: 16px;
  }

  .nav-subtitle {
    display: none;
  }

  .nav-admin-link span {
    display: none;
  }

  .nav-badge {
    padding: 4px 10px;
  }

  .nav-badge-text {
    font-size: 10px;
  }

  .main-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    height: 45%;
    flex-shrink: 0;
    border-right: none;
    border-top: 1px solid var(--color-separator-subtle);
    box-shadow: 0 -2px 12px var(--color-shadow);
    order: 2;
    transition: height var(--transition-smooth);
  }

  .sidebar.expanded {
    height: 70%;
  }

  .map-container {
    height: 55%;
    flex-shrink: 0;
    order: 1;
    transition: height var(--transition-smooth);
  }

  .map-container.collapsed {
    height: 30%;
  }

  .mobile-handle {
    display: block;
  }

  .search-container {
    padding: 12px 14px 8px;
  }

  .filters-container {
    padding: 8px 14px 10px;
  }

  .results-summary {
    padding: 10px 14px;
  }

  .hotel-card {
    padding: 12px 14px;
  }

  .layer-switch {
    bottom: 12px;
    right: 10px;
  }

  .layer-btn {
    padding: 6px 10px;
    gap: 4px;
    font-size: 11px;
  }

  .layer-btn span {
    display: none;
  }

	  .sidebar-toggle-btn {
	    display: none;
	  }
}

/* --- Popup Notes --- */
.popup-notes {
  margin: 0 16px 14px;
  padding: 10px 12px;
  background: rgba(0, 113, 227, 0.04);
  border-left: 3px solid var(--color-accent);
  border-radius: 6px;
}

.popup-notes-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: 4px;
}

.popup-notes-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text);
}

/* --- Hotel Card Note Badge --- */
.hotel-card-note-badge {
  font-size: 12px;
  vertical-align: middle;
  margin-left: 4px;
  cursor: default;
}

/* --- Sidebar Toggle Button --- */
.sidebar-toggle-btn {
  position: absolute;
  left: var(--sidebar-width);
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 500;
  width: 26px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8e8ed;
  border: 1px solid var(--color-separator);
  border-radius: 13px;
  color: var(--color-text-secondary);
  cursor: pointer;
  box-shadow: 0 1px 8px rgba(0,0,0,0.10);
  transition: left 0.3s ease, color 0.15s, background 0.15s, transform 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-toggle-btn:hover {
  color: var(--color-text);
  background: #dcdce0;
  box-shadow: 0 1px 10px rgba(0,0,0,0.15);
}
.sidebar-toggle-btn svg {
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

/* Collapsed state: sidebar hidden, button moves to left edge */
.sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  border-right: none !important;
  padding: 0 !important;
}
.sidebar-toggle-btn.collapsed {
  left: 14px;
  transform: translate(0, -50%);
}
.sidebar-toggle-btn.collapsed svg {
  transform: rotate(180deg);
}

/* --- Utility --- */
.hidden {
  display: none !important;
}
