/* Style system for Thermal & LaDeco Interactive Map Dashboard */
:root {
  --color-bg-deep: #0f1f1a;
  --color-bg-soft: #f4f1e8;
  --color-panel: rgba(255, 255, 255, 0.88);
  --color-panel-dark: rgba(18, 34, 28, 0.88);

  --color-green-dark: #1f4d3a;
  --color-green: #4f8f64;
  --color-green-soft: #dcebd8;

  --color-bluegreen: #4aa3a2;
  --color-cool: #4f8fd8;

  --color-warm: #f2b84b;
  --color-orange: #ee7b3a;
  --color-heat: #d94b3d;
  --color-extreme: #9e1f2f;

  --color-text-main: #1f2a24;
  --color-text-muted: #66736b;
  --color-border: rgba(31, 77, 58, 0.16);

  --radius-card: 18px;
  --radius-pill: 999px;
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.12);
  
  --sidebar-width: 440px;

  /* Leaflet & Dynamic Component Colors mapped to variables */
  --color-high: var(--color-heat);
  --color-medium: var(--color-orange);
  --color-low: var(--color-green);
  --color-pending: var(--color-bluegreen);
  --color-default: var(--color-text-muted);
  
  --comp-vegetation: var(--color-green);
  --comp-green-blue: var(--color-bluegreen);
  --comp-hardscape: var(--color-text-muted);
  --comp-roadway: #4f6055;
  --comp-architecture: var(--color-green-dark);
  --comp-vehicle: var(--color-warm);
  --comp-human: var(--color-cool);
  --comp-furniture: #6f9f85;

  --temp-low: var(--color-cool);
  --temp-warm: var(--color-bluegreen);
  --temp-potential: var(--color-warm);
  --temp-high: var(--color-orange);
  --temp-extreme: var(--color-heat);

  /* ── Legacy alias variables (keep for backward compat with inline styles) ── */
  --text-muted:    var(--color-text-muted);
  --text-main:     var(--color-text-main);
  --border-color:  var(--color-border);
  --accent-color:  var(--color-bluegreen);
  --accent-glow:   rgba(74, 163, 162, 0.35);
  --bg-secondary:  var(--color-panel-dark);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--color-bg-deep);
  color: #fff;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  font-family: 'Inter', 'Noto Sans TC', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* Language Switcher Buttons (Segmented Control style) */
.language-switcher-container {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 2px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: #a0aec0;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 700;
  pointer-events: auto;
}
.lang-btn:hover {
  color: #fff;
}
.lang-btn.active {
  background: var(--color-green);
  color: #fff;
  box-shadow: 0 2px 6px rgba(79, 143, 100, 0.3);
}

/* Map area */
#map {
  flex: 1;
  height: 100%;
  width: 100%;
  z-index: 1;
}

/* Custom dark theme for Leaflet zoom controls */
.leaflet-bar {
  border: 1px solid var(--color-border) !important;
  box-shadow: var(--shadow-soft) !important;
}
.leaflet-bar a {
  background-color: var(--color-panel-dark) !important;
  color: #fff !important;
  border-bottom: 1px solid var(--color-border) !important;
  transition: all 0.2s;
}
.leaflet-bar a:hover {
  background-color: var(--color-green) !important;
  color: #fff !important;
}

/* Sidebar Dashboard Container */
.sidebar {
  position: absolute;
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: var(--sidebar-width);
  z-index: 10;
  background: var(--color-panel-dark);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
  overflow: hidden;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * (var(--sidebar-width) + 32px)));
  opacity: 0;
  pointer-events: none;
}

/* Floating Controls (Right side over the map, offset to not block Leaflet zoom controls) */
.map-overlay-controls {
  position: absolute;
  top: 16px;
  right: 60px; /* Offset to not block leaflet zoom buttons on top-right */
  left: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 16px;
  pointer-events: none;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding-right: 8px;
}

/* Custom Scrollbar for Floating controls list */
.map-overlay-controls::-webkit-scrollbar {
  width: 4px;
}
.map-overlay-controls::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.control-panel {
  background: var(--color-panel-dark);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 16px;
  pointer-events: auto;
  box-shadow: var(--shadow-soft);
  width: 320px;
  transition: all 0.3s;
}

.control-panel h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

.control-group {
  margin-bottom: 12px;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group label {
  display: block;
  font-size: 0.82rem;
  color: #a0aec0;
  margin-bottom: 6px;
  font-weight: 600;
}

.custom-select, .custom-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #fff;
  padding: 8px 12px;
  font-size: 0.85rem;
  outline: none;
  transition: all 0.3s;
  font-family: inherit;
}

.custom-select:focus, .custom-input:focus {
  border-color: var(--color-green);
  box-shadow: 0 0 0 2px rgba(79, 143, 100, 0.25);
  background: rgba(0, 0, 0, 0.35);
}

.custom-select option {
  background: #12221c;
  color: #fff;
}

/* Custom Search Box with Icon styling */
.search-container {
  position: relative;
  display: flex;
  align-items: center;
}
.search-container .custom-input {
  padding-left: 32px;
}
.search-container .search-icon {
  position: absolute;
  left: 10px;
  color: #718096;
  font-size: 0.8rem;
  pointer-events: none;
}

/* Custom Pill Switches for Heatmap */
.switch-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}
.switch-label {
  font-size: 0.8rem;
  color: #e2e8f0;
  cursor: pointer;
  margin-bottom: 0 !important;
  font-weight: 500;
}
.pill-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}
.pill-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.pill-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.pill-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: #fff;
  transition: .3s;
  border-radius: 50%;
}
input:checked + .pill-slider {
  background-color: var(--color-green);
}
input:checked + .pill-slider:before {
  transform: translateX(18px);
}

/* Legend items in filter panel */
.legend-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.15);
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.legend-item {
  display: flex;
  align-items: center;
  font-size: 0.8rem;
  gap: 8px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-gradient {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  margin-top: 4px;
}

/* Sidebar Scrollable Content */
.sidebar-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 17, 26, 0.3);
}

.sidebar-title {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  flex-grow: 1;
  flex-wrap: wrap;
}

.sidebar-title h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  margin: 0;
  white-space: nowrap;
}

.sidebar-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-grow: 1;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  color: #e2e8f0;   /* default light text for dark sidebar background */
}

/* Custom Scrollbar for Sidebar */
.sidebar-content::-webkit-scrollbar {
  width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Priority Badge */
.priority-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-top: 6px;
  width: max-content;
}

.priority-high {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-high);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.priority-medium {
  background: rgba(238, 123, 58, 0.12);
  color: var(--color-orange);
  border: 1px solid rgba(238, 123, 58, 0.25);
}

.priority-low {
  background: var(--color-green-soft);
  color: var(--color-green-dark);
  border: 1px solid rgba(79, 143, 100, 0.25);
}

.priority-pending {
  background: rgba(74, 163, 162, 0.12);
  color: var(--color-bluegreen);
  border: 1px solid rgba(74, 163, 162, 0.25);
}

/* Note Section — sits inside dark sidebar, but styled as a clean light card for readability */
.info-note {
  background: #f2f8f4;
  border: 1px solid rgba(79, 143, 100, 0.15);
  border-left: 4px solid var(--color-green);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--color-text-main);
}

.info-note.note-orange {
  background: #fdf6f0;
  border: 1px solid rgba(238, 123, 58, 0.15);
  border-left: 4px solid var(--color-orange);
  color: var(--color-text-main);
}

/* Amber warning card — used in sidebar details (light background card) */
.card-amber-warning {
  background: #fdf5ea !important;
  border: 1px solid rgba(238, 123, 58, 0.25) !important;
  color: var(--color-text-main) !important;
}
.card-amber-warning h3 {
  color: var(--color-orange) !important;
}

/* Temperature KPI Metrics */
.metrics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metric-card {
  background: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.metric-card.max-temp::before {
  background: linear-gradient(to bottom, var(--color-heat), var(--color-orange));
}

.metric-card.min-temp::before {
  background: linear-gradient(to bottom, var(--color-bluegreen), var(--color-cool));
}

.metric-label {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  font-weight: 700;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--color-text-main);
  display: flex;
  align-items: baseline;
}

.metric-unit {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-left: 2px;
}

/* Photo Gallery Toggle Layout */
.image-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid var(--color-border);
  margin-bottom: 10px;
}

.image-tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--color-text-muted);
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.image-tab-btn.active {
  background: var(--color-green);
  color: #fff;
}

.image-display-container {
  position: relative;
  width: 100%;
  height: 220px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: #000;
}

.gallery-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s;
  cursor: zoom-in;
}

.gallery-image:hover {
  transform: scale(1.03);
}

.image-overlay-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

/* Stacked Color Bar for Thermal Ranges */
.thermal-distribution-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.stacked-bar-container {
  width: 100%;
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.bar-segment {
  height: 100%;
  transition: width 0.4s ease;
  position: relative;
  cursor: pointer;
}

.bar-segment:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f1f1a;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 20;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--color-border);
}

.segment-low { background-color: var(--temp-low); }
.segment-warm { background-color: var(--temp-warm); }
.segment-potential { background-color: var(--temp-potential); }
.segment-high { background-color: var(--temp-high); }
.segment-extreme { background-color: var(--temp-extreme); }

/* Range Legend Grid */
.range-legend-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.range-legend-item {
  display: flex;
  align-items: center;
  font-size: 0.75rem;
  gap: 6px;
  color: var(--color-text-muted);
}

.range-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Environment Composition Bars */
.composition-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comp-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.comp-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.comp-name {
  color: var(--color-text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.comp-name i {
  width: 14px;
  text-align: center;
}

.comp-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.comp-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.1, 0.8, 0.2, 1);
}

/* Detailed List Items Card */
.details-card {
  background: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 16px;
  color: var(--color-text-main);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

.details-card h3 {
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: var(--color-green-dark);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(31, 77, 58, 0.06);
  font-size: 0.85rem;
}

.detail-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.detail-row:first-child {
  padding-top: 0;
}

.detail-label {
  color: var(--color-text-muted);
}

.detail-val {
  color: var(--color-text-main);
  font-weight: 700;
  text-align: right;
  max-width: 60%;
  word-break: break-all;
}

/* Floating button to open sidebar when collapsed */
.floating-sidebar-trigger {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 9;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  transition: all 0.2s;
  pointer-events: auto;
}

.floating-sidebar-trigger:hover {
  background: var(--accent-color);
  box-shadow: 0 4px 15px var(--accent-glow);
}

.floating-sidebar-trigger.hidden {
  display: none;
}

/* Stats Overview Panel (Default state when no point selected) */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 30px;
}

.empty-state i {
  font-size: 3rem;
  color: var(--accent-color);
  margin-bottom: 16px;
  opacity: 0.8;
  animation: pulse-slow 3s infinite;
}

.empty-state h3 {
  color: #fff;
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Modal for Image Preview (Fullscreen zoom) */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 11, 20, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content-wrapper {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

.modal-caption {
  color: #fff;
  margin-top: 16px;
  font-size: 1.05rem;
  font-weight: 500;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  text-align: center;
}

.modal-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  transition: transform 0.2s;
}

.modal-close:hover {
  transform: scale(1.1);
}

/* Summary stats list in empty sidebar */
.summary-stats-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
  width: 100%;
}

.summary-card {
  background: rgba(15, 17, 26, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.summary-icon {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-color);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.summary-info {
  display: flex;
  flex-direction: column;
}

.summary-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.summary-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  margin-top: 2px;
}

/* Animations */
@keyframes pulse-slow {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 1; }
}

/* Responsive Layout */
@media (max-width: 768px) {
  #app-container {
    flex-direction: column;
  }
  
  /* Sidebar as Bottom Sheet for Mobile & Tablet */
  .sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 55vh;
    border-radius: 20px 20px 0 0;
    margin: 0;
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
    z-index: 1001;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
  
  .sidebar.collapsed {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
  }
  
  .sidebar-header {
    padding: 12px 16px;
    border-radius: 20px 20px 0 0;
  }
  
  .close-btn {
    transform: rotate(-90deg); /* Point down to collapse downward for chevron-left */
  }
  
  .close-btn:hover {
    transform: rotate(-90deg) scale(1.1);
  }
  
  .floating-sidebar-trigger {
    position: fixed;
    bottom: 20px;
    top: auto;
    left: auto;
    right: 20px;
    z-index: 999;
  }
  
  /* Left panel overlay positioning */
  .map-overlay-controls {
    width: calc(100% - 32px);
    left: 16px;
    right: auto;
    top: auto;
    bottom: 90px;
    max-height: 40vh;
  }
  
  .control-panel {
    width: 100%;
  }
  
  .custom-select, .custom-input, .lang-btn {
    min-height: 38px; /* Easier for touch interaction */
  }
}

@media (max-width: 480px) {
  .sidebar {
    height: 70vh; /* Higher sheet for smaller screens */
  }
  
  .map-overlay-controls {
    bottom: 80px;
    max-height: 35vh;
    gap: 12px;
  }
  
  .control-panel {
    padding: 12px;
  }
  
  .control-panel h2 {
    font-size: 0.95rem;
  }
  
  .range-legend-grid {
    grid-template-columns: repeat(2, 1fr); /* 2 cols instead of 3 on small mobile screen */
  }
}

.hidden {
  display: none !important;
}

/* 灰色底圖濾鏡效果：將原本接近黑色的暗色地圖調亮為高質感中灰色 */
.gray-map-tile {
  filter: grayscale(100%) brightness(3.0) contrast(0.8) opacity(0.95);
  transition: filter 0.3s ease;
}

/* 專案資訊卡樣式 */
.project-info-card {
  background: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
  transition: all 0.3s ease;
  color: var(--color-text-main);
}

.project-info-card:hover {
  border-color: var(--color-green);
  background: var(--color-bg-soft);
}

.project-info-card h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--color-green-dark);
  font-weight: 700;
}

/* Hero intro card: gradient top line via ::before */
.hero-intro-card {
  border-top: none !important;
}
.hero-intro-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(to right, var(--color-cool), var(--color-warm), var(--color-heat));
  border-radius: var(--radius-card) var(--radius-card) 0 0;
}

.project-weather-table {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.weather-grid-item {
  text-align: center;
  padding: 4px;
}

.weather-grid-item .w-label {
  display: block;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.weather-grid-item .w-val {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-main);
}

/* 專案背景展開樣式 (Details Accordion) */
.background-details {
  display: inline;
  transition: all 0.3s ease;
}

.background-details summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  color: #10b981;
  font-weight: 600;
  outline: none;
  font-size: 0.78rem;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease;
  margin-left: 4px;
}

.background-details summary::-webkit-details-marker {
  display: none;
}

.background-details summary:hover {
  color: #34d399;
}

.background-details[open] summary {
  display: none !important;
}

.background-details summary .fa-chevron-down {
  transition: transform 0.3s ease;
  margin-left: 2px;
}

.background-details[open] summary .fa-chevron-down {
  transform: rotate(180deg);
}

/* 全局網站底部標註 */
.site-footer {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(15, 17, 26, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 18px;
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 0.72rem;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.5px;
}

@media (max-width: 768px) {
  .site-footer {
    display: none !important;
  }
}

/* 專案背景段落樣式 */
.project-background-text {
  font-size: 0.78rem;
  line-height: 1.75;
  font-weight: 400;
  color: var(--color-text-main);
  margin: 0 0 1rem 0;
  text-align: left;
}

.nowrap-desktop {
  white-space: nowrap;
}

@media (max-width: 768px) {
  .nowrap-desktop {
    white-space: normal;
  }
}

/* ==========================================================================
   Mobile-Only Layout Styles (max-width: 768px)
   ========================================================================== */

/* Hide mobile-specific elements on desktop by default */
.mobile-header,
.mobile-bottom-bar,
.mobile-sheet-overlay,
.mobile-bottom-sheet {
  display: none !important;
}

@media (max-width: 768px) {
  /* Flex direction column to push header to the top and let map take remaining space */
  #app-container {
    flex-direction: column !important;
    overflow: hidden;
  }

  .mobile-header {
    display: flex !important;
    order: -1;
    background: var(--color-panel-dark);
    border-bottom: 1px solid var(--color-border);
    padding: 12px 16px;
    align-items: center;
    justify-content: space-between;
    z-index: 1002;
    height: 54px;
    flex-shrink: 0;
  }

  .mobile-header-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
  }

  /* Bottom Bar Navigation */
  .mobile-bottom-bar {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--color-panel-dark);
    border-top: 1px solid var(--color-border);
    justify-content: space-around;
    align-items: center;
    padding: 6px 0;
    z-index: 1002;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .mobile-bar-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.72rem;
    cursor: pointer;
    width: 33.33%;
    height: 100%;
    transition: all 0.2s;
    pointer-events: auto;
  }

  .mobile-bar-btn i {
    font-size: 1.1rem;
  }

  .mobile-bar-btn.active {
    color: var(--color-green);
    font-weight: 700;
  }

  /* Overlay Mask */
  .mobile-sheet-overlay {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
  }

  .mobile-sheet-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* General Bottom Sheets styling */
  .mobile-bottom-sheet {
    display: block !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-panel-dark);
    border-radius: 20px 20px 0 0;
    border-top: 1px solid var(--color-border);
    z-index: 1002;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.45);
    padding: 16px 16px 76px 16px; /* extra bottom padding for navbar spacing */
    max-height: 75vh;
    overflow-y: auto;
    color: #fff;
  }

  .mobile-bottom-sheet.active {
    transform: translateY(0);
  }

  .sheet-handle {
    width: 44px;
    height: 5px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    margin: -6px auto 14px auto;
    cursor: pointer;
  }

  /* Accordion Layout */
  .mobile-accordion-item {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
  }

  .mobile-accordion-header {
    background: rgba(255, 255, 255, 0.04);
    padding: 14px 16px;
    font-weight: 700;
    font-size: 0.88rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
  }

  .mobile-accordion-content {
    padding: 16px;
    display: none;
    border-top: 1px solid var(--color-border);
    background: rgba(0, 0, 0, 0.15);
  }

  .mobile-accordion-item.open .mobile-accordion-content {
    display: block;
  }

  .mobile-accordion-item.open .mobile-accordion-header i {
    transform: rotate(180deg);
  }

  .mobile-accordion-header i {
    transition: transform 0.25s ease;
  }

  /* 3-Height Details Sheet specific layout overrides */
  #mobile-details-sheet {
    padding: 0 !important;
    overflow-y: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    max-height: 90vh !important;
    transition: height 0.35s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
  }

  #mobile-details-sheet.sheet-collapsed {
    transform: translateY(0) !important;
    height: 110px !important;
  }

  #mobile-details-sheet.sheet-half {
    transform: translateY(0) !important;
    height: 65vh !important;
  }

  #mobile-details-sheet.sheet-full {
    transform: translateY(0) !important;
    height: 88vh !important;
  }

  #mobile-details-sheet.hidden-state {
    transform: translateY(100%) !important;
  }

  .mobile-details-header {
    padding: 14px 18px 8px 18px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    flex-shrink: 0;
  }

  .mobile-details-scrollable {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 16px 18px 90px 18px; /* extra bottom space for nav bar */
  }

  /* Hide desktop items */
  .map-overlay-controls,
  .sidebar,
  .floating-sidebar-trigger,
  .site-footer {
    display: none !important;
  }

  /* Map occupies remaining screen space */
  #map {
    width: 100vw !important;
    height: calc(100vh - 114px) !important; /* viewport minus header and bottom bar heights */
    flex: 1 !important;
  }

  /* Touch Targets optimization for mobile UI accessibility */
  .custom-select,
  .custom-input,
  .lang-btn,
  .mobile-bar-btn {
    min-height: 44px !important;
    font-size: 0.9rem !important;
  }

  .project-info-card,
  .details-card {
    padding: 14px !important;
    border-radius: 12px !important;
  }
}

/* ==========================================================================
   Map Marker Visibility Enhancement
   - Adds white border + drop-shadow to all markers for satellite basemap
   - Hover: brightens + enlarges
   - Selected: pulse ring glow
   ========================================================================== */

/* All markers: white stroke + deep shadow for satellite contrast */
.leaflet-interactive.map-point-marker {
  filter:
    drop-shadow(0 1px 3px rgba(0, 0, 0, 0.80))
    drop-shadow(0 0 1px rgba(0, 0, 0, 0.50));
  cursor: pointer;
}

/* Hover state: brighten with white glow (radius enlargement handled by JS setStyle) */
.leaflet-interactive.map-point-marker:hover {
  filter:
    drop-shadow(0 2px 7px rgba(0, 0, 0, 0.90))
    drop-shadow(0 0 5px rgba(255, 255, 255, 0.75));
}

/* Selected / glowing marker state */
.leaflet-marker-glow {
  filter:
    drop-shadow(0 0 8px rgba(255, 255, 255, 1.0))
    drop-shadow(0 2px 10px rgba(0, 0, 0, 0.95))
    drop-shadow(0 0 20px rgba(79, 143, 100, 0.85));
  animation: marker-pulse 1.8s infinite ease-in-out;
  transform-origin: center;
}

@keyframes marker-pulse {
  0%, 100% {
    filter:
      drop-shadow(0 0 6px rgba(255, 255, 255, 0.95))
      drop-shadow(0 2px 8px rgba(0, 0, 0, 0.90))
      drop-shadow(0 0 14px rgba(79, 143, 100, 0.70));
  }
  50% {
    filter:
      drop-shadow(0 0 12px rgba(255, 255, 255, 1.0))
      drop-shadow(0 2px 14px rgba(0, 0, 0, 0.95))
      drop-shadow(0 0 24px rgba(79, 143, 100, 1.0));
  }
}
