/* ============================================
   MAP & LAYOUT STYLES
   ============================================ */

/* ── APP LAYOUT ── */
html, body { height: 100%; overflow: hidden; }

#app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: var(--z-header);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  white-space: nowrap;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-icon { font-size: 24px; line-height: 1; }
.logo-text  { letter-spacing: -0.3px; }

/* ── PLATFORM SWITCHER TABS ── */
.platform-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--color-bg-gray, #edf2f7);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}
.platform-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: var(--font-weight-semibold, 600);
  text-decoration: none;
  color: var(--color-text-secondary, #4a5568);
  transition: all var(--transition-fast, 150ms ease);
  white-space: nowrap;
}
.platform-tab:hover {
  color: var(--color-primary-dark, #0f5940);
  background: rgba(255, 255, 255, 0.7);
}
.platform-tab.active {
  background: var(--color-primary, #1a7f5a);
  color: #fff !important;
  box-shadow: 0 2px 5px rgba(26, 127, 90, 0.25);
}

.search-wrapper {
  flex: 1;
  max-width: 600px;
  position: relative;
}

.header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── SEARCH BAR ── */
#search-container { position: relative; }

.search-icon {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  z-index: 1;
  color: var(--color-text-muted);
}

#search-input {
  width: 100%;
  height: 42px;
  padding: 0 40px 0 42px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-base);
  background: var(--color-bg-light);
  color: var(--color-text-primary);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  box-sizing: border-box;
}
#search-input:focus {
  border-color: var(--color-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(26,127,90,0.1);
}
#search-input::placeholder { color: var(--color-text-light); }

#search-clear {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 18px;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}
#search-clear:hover { color: var(--color-text-primary); }

#search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 100;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
}
.suggestion-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f7fafc;
  transition: background var(--transition-fast);
}
.suggestion-item:last-child  { border-bottom: none; }
.suggestion-item:hover,
.suggestion-item[aria-selected="true"] { background: var(--color-primary-bg); }
.suggestion-icon { font-size: 18px; flex-shrink: 0; }
.suggestion-main { font-size: 14px; font-weight: var(--font-weight-medium); color: var(--color-text-primary); }
.suggestion-main strong { color: var(--color-primary); font-weight: var(--font-weight-bold); }
.suggestion-sub  { font-size: 12px; color: var(--color-text-muted); }

/* ── MAIN LAYOUT ── */
#app-main {
  position: fixed;
  top: var(--header-height);
  left: 0; right: 0;
  bottom: var(--mobile-toolbar-height);
  display: flex;
}

/* ── SIDEBAR ── */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  background: #fff;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--z-sidebar);
  flex-shrink: 0;
}

#sidebar-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-bg-light);
  flex-shrink: 0;
}

#result-count {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
}

#list-view { flex: 1; overflow-y: auto; overflow-x: hidden; }

/* List items */
.list-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f4f8;
  cursor: pointer;
  transition: background var(--transition-fast);
  align-items: flex-start;
}
.list-item:hover  { background: var(--color-primary-bg); }
.list-item.active { background: #e8f5e9; border-left: 3px solid var(--color-primary); padding-left: 13px; }

.list-item-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--color-bg-gray);
}
.list-item-info   { flex: 1; min-width: 0; }
.list-item-name   { font-size: 13px; font-weight: var(--font-weight-semibold); color: var(--color-text-primary); margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-specialty { font-size: 11px; color: var(--color-primary); margin-bottom: 3px; }
.list-item-location  { font-size: 11px; color: var(--color-text-muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.list-item-distance  { color: var(--color-primary); font-weight: var(--font-weight-medium); }
.list-item-badge     { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; padding: 2px 7px; border-radius: var(--radius-full); margin-top: 3px; }

.load-more { padding: 16px; }

/* ── MAP CONTAINER ── */
#map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

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

/* Map controls */
#map-controls {
  position: absolute;
  right: 12px; top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: var(--z-controls);
}

.map-control-btn {
  width: 40px; height: 40px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
  color: var(--color-text-secondary);
}
.map-control-btn:hover  { background: var(--color-bg-light); color: var(--color-primary); }
.map-control-btn:active { transform: scale(0.95); }

/* Map hint */
.map-hint {
  position: absolute;
  bottom: 40px; left: 50%;
  transform: translateX(-50%);
  background: rgba(26,26,46,0.75);
  backdrop-filter: blur(4px);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  z-index: var(--z-controls);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 1s ease;
}

/* ── CUSTOM MARKERS ── */
.custom-marker {
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  border: 2.5px solid rgba(255,255,255,0.9);
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.custom-marker:hover {
  transform: rotate(-45deg) scale(1.2);
  box-shadow: 0 5px 14px rgba(0,0,0,0.3);
}

.marker-icon {
  transform: rotate(45deg);
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-luong-y    { background: #4caf7d; }
.marker-bac-si     { background: #1565c0; }
.marker-duoc-si    { background: #7b1fa2; }
.marker-co-so-yhct { background: #2e7d32; }
.marker-phong-kham { background: #0288d1; }
.marker-co-so-yte  { background: #f57c00; }

/* ── CLUSTER ── */
.custom-cluster { display: flex; align-items: center; justify-content: center; }

.cluster-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 3px solid #fff;
  color: #fff;
  font-weight: var(--font-weight-bold);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: transform var(--transition-fast);
}
.cluster-icon:hover { transform: scale(1.1); }

.cluster-sm { width: 36px; height: 36px; font-size: 12px; background: var(--color-primary-light); }
.cluster-md { width: 44px; height: 44px; font-size: 14px; background: var(--color-primary); }
.cluster-lg { width: 52px; height: 52px; font-size: 16px; background: var(--color-primary-dark); }

/* User location */
.user-location-marker { position: relative; width: 20px; height: 20px; }
.user-dot {
  position: absolute;
  inset: 4px;
  background: #1565c0;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.user-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: rgba(21,101,192,0.25);
  animation: pulse 2s infinite ease-out;
}
@keyframes pulse { 0%,100% { transform: scale(1); opacity:.6; } 50% { transform: scale(1.6); opacity:0; } }

/* ── LEAFLET POPUP OVERRIDES ── */
.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  padding: 0 !important;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15) !important;
  border: 1px solid var(--color-border) !important;
}
.leaflet-popup-content { margin: 0 !important; min-width: 280px; max-width: 320px; }
.leaflet-popup-tip-container { display: none !important; }
.profile-popup .leaflet-popup-close-button {
  top: 8px !important; right: 8px !important;
  width: 24px; height: 24px;
  font-size: 16px; color: var(--color-text-muted);
  background: rgba(255,255,255,0.9);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* Profile card in popup */
.profile-card-content  { padding: 16px; }
.profile-card-header   { display: flex; gap: 12px; margin-bottom: 10px; align-items: flex-start; }
.profile-card-avatar   { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--color-bg-gray); }
.profile-card-title    { font-weight: var(--font-weight-bold); font-size: 14px; color: var(--color-text-primary); margin-bottom: 2px; }
.profile-card-subtitle { font-size: 12px; color: var(--color-primary); font-weight: var(--font-weight-medium); }
.profile-card-location { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }
.profile-card-meta     { margin: 6px 0; }
.profile-card-tags     { font-size: 12px; color: var(--color-text-secondary); margin: 4px 0; }
.profile-card-actions  { display: flex; gap: 6px; margin-top: 10px; }
.profile-card-actions .btn { flex: 1; font-size: 12px; padding: 7px 10px; border-radius: var(--radius-md); }

/* ── MOBILE TOOLBAR ── */
#mobile-toolbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--mobile-toolbar-height);
  background: #fff;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: var(--z-header);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.07);
  padding: 0 8px;
}

.toolbar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 16px;
  min-height: 50px;
  min-width: 72px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), color var(--transition-fast);
  color: var(--color-text-secondary);
  -webkit-tap-highlight-color: transparent;
}
.toolbar-btn:hover,
.toolbar-btn.active { background: var(--color-primary-bg); color: var(--color-primary); }
.toolbar-btn .icon  { font-size: 22px; line-height: 1.2; display: flex; align-items: center; }
.toolbar-btn .label { font-size: 11px; font-weight: var(--font-weight-medium); }

/* ── OVERLAY ── */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: calc(var(--z-panel) - 1);
  opacity: 0;
  transition: opacity var(--transition-base);
  pointer-events: none;
}
#overlay.visible { opacity: 1; pointer-events: all; }

/* ── FILTER PANEL ── */
#filter-panel {
  position: fixed;
  top: 0; left: -340px;
  width: var(--filter-panel-width);
  height: 100vh;
  background: #fff;
  z-index: var(--z-panel);
  box-shadow: 4px 0 24px rgba(0,0,0,0.1);
  transition: left var(--transition-base);
  display: flex;
  flex-direction: column;
}
#filter-panel.open { left: 0; }
#filter-panel[aria-hidden="false"] { left: 0; }

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.panel-body  { flex: 1; overflow-y: auto; padding: 16px 20px; }
.panel-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.filter-section    { margin-bottom: 24px; }
.filter-section h3 {
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}
.filter-option { display: flex; align-items: center; gap: 10px; padding: 7px 0; cursor: pointer; min-height: 44px; }
.filter-option input[type="radio"],
.filter-option input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}
.filter-option span { font-size: 14px; cursor: pointer; }
.filter-select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: #fff;
  color: var(--color-text-primary);
  appearance: none;
  cursor: pointer;
}
.filter-specialties { display: flex; flex-wrap: wrap; gap: 4px; }
.filter-chip {
  display: inline-block;
  padding: 6px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition-fast);
  user-select: none;
}
.filter-chip.active,
.filter-chip:has(input:checked) {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* ── BOTTOM SHEET (mobile) ── */
#bottom-sheet {
  position: fixed;
  bottom: var(--mobile-toolbar-height);
  left: 0; right: 0;
  background: #fff;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
  z-index: var(--z-panel);
  transform: translateY(100%);
  transition: transform var(--transition-base), opacity var(--transition-fast);
  max-height: 82vh;
  overflow-y: auto;
  pointer-events: none;
  opacity: 0;
  display: none;
}
#bottom-sheet.open {
  transform: translateY(0);
  pointer-events: auto;
  opacity: 1;
  display: block;
}

.sheet-handle {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--color-border-dark);
  margin: 10px auto 6px;
}
#bottom-sheet-content { padding: 0 16px 24px; }

/* ── SHARE MODAL ── */
.share-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.share-modal-content {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-xl);
}
.share-modal-content h3 { margin-bottom: 12px; font-size: 18px; }
.share-url-box          { display: flex; gap: 8px; margin: 12px 0; }
.share-url-box input    { flex: 1; padding: 8px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md); font-size: 13px; }
.share-buttons          { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.share-close            { width: 100%; margin-top: 4px; }

/* ── LOADING OVERLAY (app init) ── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-primary-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.loading-logo { font-size: 52px; margin-bottom: 16px; }
.loading-text { font-size: 22px; font-weight: var(--font-weight-bold); color: var(--color-primary); margin-bottom: 6px; }
.loading-sub  { font-size: 14px; color: var(--color-text-muted); }
.loading-dots { display: flex; gap: 6px; margin-top: 28px; }
.loading-dot  {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: bounce 1.4s infinite ease-in-out;
}
.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,80%,100% { transform: scale(0); } 40% { transform: scale(1); } }

/* ── LEAFLET DEFAULT OVERRIDES ── */
.leaflet-control-zoom { border: none !important; box-shadow: var(--shadow-md) !important; }
.leaflet-control-zoom a {
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 18px !important;
  color: var(--color-text-secondary) !important;
  border: none !important;
  border-bottom: 1px solid var(--color-border) !important;
}
.leaflet-control-zoom a:hover { color: var(--color-primary) !important; background: var(--color-bg-light) !important; }
.leaflet-control-zoom-in  { border-radius: var(--radius-md) var(--radius-md) 0 0 !important; }
.leaflet-control-zoom-out { border-radius: 0 0 var(--radius-md) var(--radius-md) !important; border-bottom: none !important; }
.leaflet-bar { border-radius: var(--radius-md) !important; overflow: hidden; }
.leaflet-attribution-flag { display: none !important; }
