/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   📍 COMMUNITY MAP - แผนที่ชุมชนคนไทยใน SA
   Inline section: Map (left) + Chat panel (right)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* ━━━ Section Container ━━━ */
.community-map-section {
  margin: 2rem 0;
}

/* ━━━ Main Box ━━━ */
.cmap-box {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line, #e2e8f0);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

/* ━━━ Header ━━━ */
.cmap-box-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cmap-box-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cmap-box-stats {
  font-size: 0.8rem;
  opacity: 0.9;
  white-space: nowrap;
}

/* ━━━ F13: Stats Breakdown ━━━ */
.cmap-stats-breakdown {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 12px 20px 16px;
}

.cmap-stats-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

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

.cmap-stats-city {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.9);
  min-width: 90px;
  text-align: right;
}

.cmap-stats-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.cmap-stats-bar-fill {
  height: 100%;
  background: #fff;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.cmap-stats-num {
  font-size: 0.7rem;
  color: #fff;
  font-weight: 700;
  min-width: 20px;
}

/* ━━━ Body — Flex Row ━━━ */
.cmap-box-body {
  display: flex;
  min-height: 380px;
}

/* ━━━ Map Side (left) ━━━ */
.cmap-map-side {
  flex: 3;
  position: relative;
  overflow: hidden;
  background: #f0f4ff;
  min-height: 300px;
}

.cmap-bg-img {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
  -webkit-user-select: none;
}

/* ━━━ F4: Zoom Container ━━━ */
.cmap-zoom-container {
  width: 100%;
  position: relative;
  transform-origin: center center;
  transition: transform 0.2s ease;
}

.cmap-zoom-controls {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 8;
}

.cmap-zoom-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #1e293b;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: background 0.2s;
}

.cmap-zoom-btn:hover {
  background: #f1f5f9;
}

/* ━━━ Location Markers ━━━ */
.cmap-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.2s ease;
}

.cmap-marker:focus-visible {
  outline: 2px solid #667eea;
  outline-offset: 4px;
  border-radius: 4px;
}

.cmap-marker:hover {
  transform: translate(-50%, -50%) scale(1.25);
  z-index: 3;
}

.cmap-marker-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  animation: cmapPulse 2.5s ease-in-out infinite;
}

.cmap-marker.has-people .cmap-marker-dot {
  display: none;
}

.cmap-marker-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
  animation: cmapPulse 2.5s ease-in-out infinite;
}

.cmap-marker-avatars {
  font-size: 1rem;
  line-height: 1;
  margin-bottom: 2px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.cmap-marker.active .cmap-marker-dot,
.cmap-marker.active .cmap-marker-badge {
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3), 0 2px 8px rgba(59, 130, 246, 0.4);
}

.cmap-marker-label {
  font-size: 0.7rem;
  color: #1e293b;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.85);
  padding: 1px 5px;
  border-radius: 4px;
  margin-top: 2px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: none;
}

@keyframes cmapPulse {
  0%, 100% { box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4); }
  50% { box-shadow: 0 2px 12px rgba(59, 130, 246, 0.6), 0 0 0 4px rgba(59, 130, 246, 0.15); }
}

/* ━━━ F2: Bounce Animation ━━━ */
@keyframes cmapBounce {
  0%, 100% { transform: translate(-50%, -50%); }
  25% { transform: translate(-50%, -65%); }
  50% { transform: translate(-50%, -50%); }
  75% { transform: translate(-50%, -60%); }
}

.cmap-marker.bounce {
  animation: cmapBounce 0.6s ease-in-out 3;
  z-index: 4;
}

/* ━━━ F1: Tooltip ━━━ */
.cmap-tooltip {
  position: absolute;
  background: #1e293b;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity 0.2s;
  z-index: 10;
  max-width: 200px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cmap-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1e293b;
}

.cmap-tooltip.visible {
  opacity: 1;
}

.cmap-tooltip-count {
  opacity: 0.8;
  font-size: 0.65rem;
}

.cmap-tooltip-preview {
  margin-top: 4px;
  font-size: 0.7rem;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ━━━ Chat Side (right) ━━━ */
.cmap-chat-side {
  flex: 2;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line, #e2e8f0);
  background: #f8fafc;
  min-width: 0;
}

.cmap-chat-header {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.95rem;
  color: #1e293b;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}

/* ━━━ F7: Time Filter ━━━ */
.cmap-time-filter {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}

.cmap-time-btn {
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.cmap-time-btn:hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

.cmap-time-btn.active {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

/* ━━━ Feature 12: Avatar Type Filter ━━━ */
.cmap-avatar-filter {
  display: flex;
  gap: 4px;
  padding: 6px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}

.cmap-avatar-filter-btn {
  padding: 3px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.cmap-avatar-filter-btn:hover {
  border-color: #a78bfa;
  color: #7c3aed;
}

.cmap-avatar-filter-btn.active {
  background: #7c3aed;
  color: #fff;
  border-color: #7c3aed;
}

.cmap-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  max-height: clamp(250px, 40vh, 400px);
}

/* Location group in chat */
.cmap-chat-group {
  padding: 0;
}

.cmap-chat-group-title {
  padding: 10px 16px 6px;
  font-weight: 700;
  font-size: 0.8rem;
  color: #3b82f6;
  display: flex;
  align-items: center;
  gap: 6px;
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
  cursor: pointer;
}

.cmap-chat-group-title:hover {
  color: #2563eb;
}

.cmap-chat-group-count {
  background: #3b82f6;
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

/* ━━━ F9: Share Button ━━━ */
.cmap-share-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
  margin-left: auto;
}

.cmap-share-btn:hover {
  opacity: 1;
}

/* Individual message */
.cmap-msg-item {
  display: flex;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.2s;
}

.cmap-msg-item:last-child {
  border-bottom: none;
}

.cmap-msg-avatar {
  font-size: 1.3rem;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border-radius: 50%;
}

.cmap-msg-body {
  flex: 1;
  min-width: 0;
}

.cmap-msg-nickname {
  font-weight: 600;
  font-size: 0.75rem;
  color: #475569;
}

.cmap-msg-text {
  font-size: 0.85rem;
  color: #1e293b;
  margin-top: 2px;
  word-break: break-word;
}

.cmap-msg-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.cmap-msg-time {
  font-size: 0.65rem;
  color: #64748b;
}

/* ━━━ F8: Reaction Button ━━━ */
.cmap-react-btn {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1px 8px;
  font-size: 0.65rem;
  cursor: pointer;
  color: #64748b;
  transition: all 0.2s;
}

.cmap-react-btn:hover {
  border-color: #f87171;
  color: #f87171;
}

.cmap-react-btn.reacted {
  background: #fef2f2;
  border-color: #f87171;
  color: #ef4444;
}

/* ━━━ F11: Renew Button ━━━ */
.cmap-renew-btn {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 12px;
  padding: 1px 8px;
  font-size: 0.65rem;
  cursor: pointer;
  color: #92400e;
  transition: background 0.2s;
}

.cmap-renew-btn:hover {
  background: #fde68a;
}

.cmap-renew-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Pin expiry countdown */
.cmap-expiry {
  font-size: 0.65rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 8px;
}

.cmap-expiry-warn {
  color: #dc2626;
  background: #fef2f2;
  font-weight: 600;
}

/* Message highlight animation (Feature 11: View my pin) */
.cmap-msg-highlight {
  animation: cmapMsgHighlight 2s ease;
}

@keyframes cmapMsgHighlight {
  0% { background: #dbeafe; }
  100% { background: transparent; }
}

/* "View my pin" button */
.cmap-mypin-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f0f7ff;
  color: #3b82f6;
  border: 1px solid #bfdbfe;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.2s;
  font-family: inherit;
}

.cmap-mypin-btn:hover {
  background: #dbeafe;
}

.cmap-msg-empty {
  padding: 40px 16px;
  text-align: center;
  color: #64748b;
  font-size: 0.9rem;
}

/* Highlight a chat group when its marker is clicked */
.cmap-chat-group.highlight {
  background: #eff6ff;
}

/* ━━━ Chat Footer (button) ━━━ */
.cmap-chat-footer {
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}

.cmap-add-btn {
  width: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.cmap-add-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ━━━ Form Panel (below box, collapsible) ━━━ */
.cmap-form-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
  background: #fff;
  border-top: 1px solid #e2e8f0;
}

.cmap-form-panel.open {
  max-height: 600px;
  max-height: clamp(450px, 70vh, 600px);
}

.cmap-form-inner {
  padding: 20px;
}

.cmap-form-title {
  font-weight: 700;
  font-size: 1rem;
  color: #1e293b;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cmap-form-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: #64748b;
  padding: 4px;
  line-height: 1;
}

.cmap-form-close:hover {
  color: #1e293b;
}

.cmap-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.cmap-form-group {
  margin-bottom: 0;
}

.cmap-form-group.full-width {
  grid-column: 1 / -1;
}

.cmap-form-label {
  display: block;
  font-weight: 600;
  font-size: 0.8rem;
  color: #334155;
  margin-bottom: 6px;
}

/* Avatar Picker */
.cmap-avatar-picker {
  display: flex;
  gap: 10px;
}

.cmap-avatar-option {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #e2e8f0;
  background: #f8fafc;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, transform 0.2s;
}

.cmap-avatar-option:hover {
  border-color: #667eea;
}

.cmap-avatar-option.selected {
  border-color: #764ba2;
  background: #f3e8ff;
  transform: scale(1.1);
}

/* Location Dropdown */
.cmap-location-select {
  width: 100%;
  padding: 8px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #1e293b;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s;
}

.cmap-location-select:focus {
  outline: none;
  border-color: #667eea;
}

/* ━━━ F10: Custom City Input ━━━ */
.cmap-custom-city-input {
  width: 100%;
  padding: 8px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #1e293b;
  background: #fff;
  margin-top: 8px;
  transition: border-color 0.2s;
}

.cmap-custom-city-input:focus {
  outline: none;
  border-color: #667eea;
}

/* Nickname Input */
.cmap-nickname-input {
  width: 100%;
  padding: 8px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #1e293b;
  background: #fff;
  transition: border-color 0.2s;
}

.cmap-nickname-input:focus {
  outline: none;
  border-color: #667eea;
}

/* Message Textarea */
.cmap-message-input {
  width: 100%;
  padding: 8px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #1e293b;
  background: #fff;
  resize: vertical;
  min-height: 60px;
  max-height: 100px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.cmap-message-input:focus {
  outline: none;
  border-color: #667eea;
}

.cmap-char-count {
  text-align: right;
  font-size: 0.7rem;
  color: #64748b;
  margin-top: 4px;
}

.cmap-char-count.warn {
  color: #ef4444;
}

/* Form Actions */
.cmap-form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  grid-column: 1 / -1;
}

.cmap-form-submit {
  flex: 1;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.cmap-form-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.cmap-form-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.cmap-form-delete {
  background: #fee2e2;
  color: #dc2626;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.cmap-form-delete:hover {
  background: #fecaca;
}

/* ━━━ Loading State ━━━ */
.cmap-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #64748b;
  font-size: 0.9rem;
  gap: 8px;
  height: 100%;
}

.cmap-loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: cmapSpin 0.6s linear infinite;
}

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

/* ━━━ F5: Confetti ━━━ */
.cmap-confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.cmap-confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  opacity: 0;
  animation: cmapConfettiFall 3s ease-out forwards;
}

.cmap-confetti.circle {
  border-radius: 50%;
}

.cmap-confetti.square {
  border-radius: 2px;
}

.cmap-confetti.star {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

@keyframes cmapConfettiFall {
  0% {
    opacity: 1;
    transform: translateY(-100px) rotate(0deg) scale(1);
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg) scale(0.5);
  }
}

/* Undo Toast */
.cmap-undo-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  animation: cmapToastIn 0.3s ease;
}

@keyframes cmapToastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.cmap-undo-btn {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.cmap-undo-btn:hover {
  background: #2563eb;
}

.cmap-undo-timer {
  font-size: 0.7rem;
  opacity: 0.6;
  min-width: 14px;
  text-align: center;
}

/* ━━━ F9: Toast ━━━ */
.cmap-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cmap-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ━━━ Mobile Tab Toggle — hidden, not used ━━━ */
.cmap-mobile-tabs {
  display: none;
}

/* ━━━ Floating Pin Button (bottom-right) ━━━ */
.cmap-mobile-pin-btn {
  display: none;
}

@media (max-width: 768px) {
  .cmap-mobile-pin-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    bottom: 80px;
    right: 16px;
    z-index: 999;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 12px 18px;
    border-radius: 28px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.45);
    font-family: inherit;
    white-space: nowrap;
    animation: cmap-pin-pulse 2s ease-in-out 3;
  }

  .cmap-mobile-pin-btn:active {
    transform: scale(0.95);
  }

  @keyframes cmap-pin-pulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(102, 126, 234, 0.45); }
    50% { box-shadow: 0 4px 24px rgba(102, 126, 234, 0.8); }
  }
}

/* ━━━ Responsive ━━━ */
@media (max-width: 768px) {
  .cmap-box-body {
    flex-direction: column;
  }

  .cmap-map-side {
    min-height: 45vh;
  }

  .cmap-chat-side {
    border-left: none;
    border-top: 1px solid var(--line, #e2e8f0);
  }

  /* Compact chat on mobile — collapse filters into one row */
  .cmap-chat-header {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .cmap-chat-messages {
    max-height: clamp(200px, 35vh, 350px);
    min-height: 150px;
  }

  /* Hide duplicate "ฉันอยู่ตรงนี้" button in chat footer on mobile */
  .cmap-chat-footer .cmap-add-btn {
    display: none;
  }

  /* Form as bottom-sheet overlay on mobile */
  .cmap-form-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 0;
    border-top: none;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
    overflow-y: auto;
  }

  .cmap-form-panel.open {
    max-height: 85vh;
  }

  .cmap-form-grid {
    grid-template-columns: 1fr;
  }

  .cmap-box-header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 4px;
  }

  .cmap-box-title {
    font-size: 1rem;
  }

  .cmap-box-stats {
    font-size: 0.75rem;
  }

  .cmap-marker-label {
    display: none;
  }

  .cmap-stats-city {
    min-width: 70px;
    font-size: 0.75rem;
  }

  .cmap-time-filter {
    padding: 6px 12px;
    overflow-x: auto;
  }

  .cmap-time-btn {
    font-size: 0.75rem;
    padding: 5px 10px;
    white-space: nowrap;
  }

  .cmap-avatar-filter {
    padding: 6px 12px;
    overflow-x: auto;
  }

  .cmap-avatar-filter-btn {
    font-size: 0.75rem;
    padding: 4px 10px;
    white-space: nowrap;
  }

  /* Larger touch targets for chat messages */
  .cmap-msg-nickname {
    font-size: 0.8rem;
  }

  .cmap-msg-text {
    font-size: 0.9rem;
  }

  .cmap-msg-time {
    font-size: 0.7rem;
  }

  .cmap-react-btn {
    font-size: 0.75rem;
    padding: 3px 10px;
  }

  .cmap-chat-group-title {
    font-size: 0.85rem;
  }

  .cmap-chat-group-count {
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  .community-map-section {
    margin: 0.5rem 0;
  }

  .cmap-avatar-picker {
    justify-content: center;
  }

  .cmap-form-actions {
    flex-direction: column;
  }

  .cmap-zoom-controls {
    bottom: 6px;
    right: 6px;
  }

  .cmap-zoom-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
}

/* ━━━ F14: Search Bar ━━━ */
.cmap-search-bar {
  padding: 8px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}

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

.cmap-search-input {
  width: 100%;
  padding: 7px 32px 7px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 20px;
  font-size: 0.8rem;
  color: #1e293b;
  background: #f8fafc;
  transition: border-color 0.2s, background 0.2s;
  outline: none;
}

.cmap-search-input:focus {
  border-color: #667eea;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.cmap-search-input::placeholder {
  color: #64748b;
}

.cmap-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  background: #e2e8f0;
  color: #64748b;
  border-radius: 50%;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  line-height: 1;
  padding: 0;
}

.cmap-search-clear:hover {
  background: #cbd5e1;
  color: #1e293b;
}

.cmap-search-result-count {
  font-size: 0.7rem;
  color: #3b82f6;
  font-weight: 600;
  margin-top: 4px;
  padding-left: 4px;
}

.cmap-search-result-count.no-results {
  color: #ef4444;
}

/* F14: Search — marker highlight states */
.cmap-marker.search-dim {
  opacity: 0.3;
  transition: opacity 0.3s ease;
}

.cmap-marker.search-match {
  opacity: 1;
  z-index: 4;
}

.cmap-marker.search-match .cmap-marker-badge {
  animation: cmapSearchGlow 1.5s ease-in-out infinite;
}

.cmap-marker.search-match .cmap-marker-dot {
  animation: cmapSearchGlow 1.5s ease-in-out infinite;
}

@keyframes cmapSearchGlow {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3), 0 2px 8px rgba(59, 130, 246, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.15), 0 2px 12px rgba(59, 130, 246, 0.6);
  }
}

/* F14: Responsive adjustments for search */
@media (max-width: 768px) {
  .cmap-search-bar {
    padding: 6px 12px;
  }

  .cmap-search-input {
    font-size: 0.75rem;
    padding: 6px 28px 6px 10px;
  }
}

/* ━━━ F6b: Heatmap Density Mode ━━━ */

/* Heatmap toggle button — highlighted when active */
.cmap-heatmap-btn {
  font-size: 0.85rem;
  line-height: 1;
}

.cmap-heatmap-btn.active {
  background: #ff6b35;
  color: #fff;
  border-color: #ff6b35;
  box-shadow: 0 0 8px rgba(255, 107, 53, 0.5);
}

/* Heatmap circles — hidden by default, shown when .heatmap-active */
.cmap-heat-circle {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.3s ease, transform 0.2s ease;
}

.heatmap-active .cmap-heat-circle {
  opacity: 0.7;
  pointer-events: auto;
  animation: cmapHeatPulse 2.5s ease-in-out infinite;
}

.cmap-heat-circle:hover {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.2);
  z-index: 5;
}

/* Count number inside circle */
.cmap-heat-count {
  font-size: 0.7rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  line-height: 1;
}

/* City label below heatmap circle */
.cmap-heat-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  margin-top: 1px;
  pointer-events: none;
}

/* Size tiers */
.cmap-heat-sm { min-width: 28px; min-height: 28px; }
.cmap-heat-md { min-width: 36px; min-height: 36px; }
.cmap-heat-lg { min-width: 44px; min-height: 44px; }
.cmap-heat-xl { min-width: 54px; min-height: 54px; }

.cmap-heat-xl .cmap-heat-count { font-size: 0.85rem; }
.cmap-heat-lg .cmap-heat-count { font-size: 0.75rem; }

/* Pulsing glow animation for heatmap circles */
@keyframes cmapHeatPulse {
  0%, 100% {
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.35), 0 0 40px rgba(255, 255, 255, 0.1);
  }
}

/* When heatmap is active, hide normal markers */
.heatmap-active .cmap-marker {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* When heatmap is NOT active, heat circles are hidden (default via opacity: 0) */

/* Legend — bottom-left of map, hidden unless heatmap active */
.cmap-heat-legend {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(30, 41, 59, 0.9);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.65rem;
  z-index: 6;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.heatmap-active .cmap-heat-legend {
  opacity: 1;
  pointer-events: auto;
}

.cmap-heat-legend-title {
  font-weight: 700;
  font-size: 0.7rem;
  margin-bottom: 4px;
  opacity: 0.9;
}

.cmap-heat-legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  line-height: 1.4;
}

.cmap-heat-legend-row:last-child {
  margin-bottom: 0;
}

.cmap-heat-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* F6b: Responsive heatmap adjustments */
@media (max-width: 768px) {
  .cmap-heat-label {
    font-size: 0.6rem;
    max-width: 55px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .cmap-heat-legend {
    bottom: 6px;
    left: 6px;
    padding: 6px 10px;
    font-size: 0.7rem;
  }

  .cmap-heat-legend-title {
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .cmap-heatmap-btn {
    font-size: 0.8rem;
  }

  .cmap-heat-sm { min-width: 24px; min-height: 24px; }
  .cmap-heat-md { min-width: 32px; min-height: 32px; }
  .cmap-heat-lg { min-width: 40px; min-height: 40px; }
  .cmap-heat-xl { min-width: 48px; min-height: 48px; }

  .cmap-heat-count {
    font-size: 0.65rem;
  }

  .cmap-heat-xl .cmap-heat-count { font-size: 0.8rem; }
  .cmap-heat-lg .cmap-heat-count { font-size: 0.7rem; }
}

/* ━━━ F16: Adelaide Suburb Detail View ━━━ */
.cmap-adl-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 50%, #f5f3ff 100%);
  display: flex;
  flex-direction: column;
  z-index: 6;
  overflow: auto;
}

.cmap-adl-header {
  padding: 12px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  flex-shrink: 0;
}

.cmap-adl-back {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 8px;
  display: inline-block;
}

.cmap-adl-back:hover {
  background: rgba(255, 255, 255, 0.35);
}

.cmap-adl-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.cmap-adl-stats {
  font-size: 0.75rem;
  opacity: 0.9;
  margin-top: 2px;
}

/* Grid layout — geographic: 4 rows x 3 cols */
.cmap-adl-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  padding: 16px;
  flex: 1;
  position: relative;
  min-height: 0;
}

/* Direction indicators */
.cmap-adl-direction {
  position: absolute;
  font-size: 0.7rem;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 1px;
  pointer-events: none;
  z-index: 1;
}

.cmap-adl-dir-n {
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
}

.cmap-adl-dir-s {
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
}

.cmap-adl-dir-w {
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
}

.cmap-adl-dir-e {
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
}

/* Suburb card */
.cmap-adl-card {
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  min-height: 0;
}

.cmap-adl-card:hover {
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.cmap-adl-card.active {
  border-color: #667eea;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.cmap-adl-card.has-people {
  border-color: #3b82f6;
  background: #f0f7ff;
}

.cmap-adl-card.has-people .cmap-adl-card-count {
  color: #2563eb;
}

/* CBD card — special highlight */
.cmap-adl-card-cbd {
  border-color: #a78bfa;
  background: linear-gradient(135deg, #faf5ff 0%, #f5f3ff 100%);
}

.cmap-adl-card-cbd .cmap-adl-card-name {
  color: #6d28d9;
  font-size: 0.85rem;
}

.cmap-adl-card-name {
  font-size: 0.7rem;
  font-weight: 700;
  color: #334155;
  line-height: 1.2;
}

.cmap-adl-card-count {
  font-size: 0.65rem;
  font-weight: 600;
  color: #64748b;
  background: #f1f5f9;
  padding: 1px 8px;
  border-radius: 10px;
}

/* Suburb select in form */
.cmap-suburb-select {
  margin-top: 8px;
}

/* Responsive — Adelaide grid */
@media (max-width: 768px) {
  .cmap-adl-grid {
    gap: 6px;
    padding: 10px;
  }

  .cmap-adl-card {
    padding: 10px 6px;
    border-radius: 8px;
  }

  .cmap-adl-card-name {
    font-size: 0.7rem;
  }

  .cmap-adl-card-count {
    font-size: 0.65rem;
    padding: 2px 8px;
  }

  .cmap-adl-header {
    padding: 10px 12px;
  }

  .cmap-adl-title {
    font-size: 0.95rem;
  }
}

@media (max-width: 480px) {
  .cmap-adl-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
    gap: 6px;
    padding: 10px;
  }

  .cmap-adl-card {
    padding: 10px 6px;
  }

  .cmap-adl-card-name {
    font-size: 0.7rem;
  }

  .cmap-adl-card-count {
    font-size: 0.65rem;
  }

  .cmap-adl-direction {
    display: none;
  }
}

/* ━━━ F15: Admin Mode ━━━ */

/* Admin badge in header */
.cmap-admin-badge {
  display: none;
  font-size: 0.65rem;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.2);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  animation: cmapAdminPulse 2s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes cmapAdminPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Header red border-top when admin mode active */
.cmap-box-header.cmap-admin-active {
  border-top: 2px solid #ef4444;
}

/* Admin panel below stats */
.cmap-admin-panel {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #fff;
}

.cmap-admin-panel-inner {
  padding: 12px 20px;
}

.cmap-admin-panel-header {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.cmap-admin-panel-stats {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cmap-admin-panel-stats strong {
  color: #fff;
}

.cmap-admin-panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cmap-admin-cleanup-btn {
  padding: 6px 14px;
  border: 1px solid rgba(239, 68, 68, 0.5);
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.cmap-admin-cleanup-btn:hover {
  background: rgba(239, 68, 68, 0.3);
}

.cmap-admin-cleanup-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cmap-admin-close-btn {
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.cmap-admin-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Admin delete button on each message */
.cmap-admin-delete-btn {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 12px;
  padding: 1px 8px;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  color: #dc2626;
  transition: background 0.2s;
  margin-left: auto;
  white-space: nowrap;
}

.cmap-admin-delete-btn:hover {
  background: #fecaca;
  border-color: #f87171;
}

/* Message hover tint in admin mode */
.cmap-admin-mode .cmap-msg-item:hover {
  background: rgba(239, 68, 68, 0.04);
}

/* Mobile responsive admin panel */
@media (max-width: 768px) {
  .cmap-admin-panel-inner {
    padding: 10px 16px;
  }

  .cmap-admin-panel-actions {
    flex-direction: column;
  }

  .cmap-admin-cleanup-btn,
  .cmap-admin-close-btn {
    width: 100%;
    text-align: center;
  }
}
