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

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --dustbin-orange: #f97316;
  --dustbin-purple: #a855f7;
  --dustbin-blue: #3b82f6;
  --sidebar-width: 400px;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.municipality {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
}

.lang-toggle {
  display: flex;
  gap: 0.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.2rem;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn.active {
  background: var(--accent);
  color: white;
}

.sidebar-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-lead {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.hero-tagline {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
}

.subtitle {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.content-section {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.65rem;
  color: var(--text);
}

.content-section p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.bin-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.55rem;
}

.bin-card:last-child {
  margin-bottom: 0;
}

.bin-card h3 {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.bin-card-intro {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 0.4rem;
}

.bin-card-items {
  margin: 0 0 0.45rem 1.1rem;
  padding: 0;
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.bin-card-tagline {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text);
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.bin-card.color-orange { border-color: rgba(249, 115, 22, 0.35); }
.bin-card.color-purple { border-color: rgba(168, 85, 247, 0.35); }
.bin-card.color-blue { border-color: rgba(59, 130, 246, 0.35); }

.bin-card.color-orange .bin-card-tagline { color: #fdba74; }
.bin-card.color-purple .bin-card-tagline { color: #d8b4fe; }
.bin-card.color-blue .bin-card-tagline { color: #93c5fd; }

.search-form {
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.search-hint {
  margin-top: 0.55rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.highlight-section {
  background: rgba(59, 130, 246, 0.06);
}

.investment-section {
  background: var(--bg);
}

.investment-amount {
  font-weight: 600;
  color: var(--text) !important;
  margin-bottom: 0.45rem;
}

.footer-tagline {
  margin-top: 0.65rem;
  font-weight: 700;
  color: var(--accent) !important;
  font-size: 0.82rem !important;
}

.search-box {
  position: relative;
}

.search-input-wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  transition: border-color 0.2s;
}

.search-input-wrap:focus-within {
  border-color: var(--accent);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.95rem;
  min-width: 0;
}

#search-input::placeholder {
  color: var(--text-muted);
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.search-input-row #search-input {
  flex: 1;
  min-width: 0;
}

#search-btn,
.search-submit-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

#search-btn:hover {
  background: var(--accent-hover);
}

#search-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.autocomplete-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow-y: auto;
  z-index: 1100;
}

.autocomplete-list.hidden {
  display: none;
}

.autocomplete-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--surface-hover);
}

.autocomplete-item.active {
  border-left: 3px solid var(--accent);
  padding-left: calc(0.85rem - 3px);
}

.autocomplete-item--area .autocomplete-pin {
  color: var(--dustbin-orange);
}

.autocomplete-item--area .autocomplete-subtitle {
  color: #fdba74;
  font-weight: 500;
}

.autocomplete-pin {
  width: 18px;
  height: 18px;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
}

.autocomplete-text {
  min-width: 0;
}

.autocomplete-title {
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 0.15rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.autocomplete-loading,
.autocomplete-empty {
  padding: 0.85rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

.status {
  margin: 0 1.25rem 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status.hidden {
  display: none;
}

.results-panel {
  flex: 1;
  overflow-y: auto;
  padding: 0 1.25rem 1rem;
}

.results-panel.hidden {
  display: none;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.results-header h2 {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  font-size: 0.75rem;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.location-address {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.station-photo-wrap {
  margin-bottom: 0.65rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}

.station-photo-wrap.hidden {
  display: none;
}

.station-photo {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.station-photo-wrap figcaption {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.4rem 0.55rem;
  text-align: center;
}

.photo-gallery-section {
  padding-top: 0.5rem;
}

.station-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
}

.gallery-thumb {
  width: 100%;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.bin-guide-photo {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 0.65rem;
  border: 1px solid var(--border);
}

.nearest-note {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 0.65rem;
  padding: 0.45rem 0.55rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.btn-secondary {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.btn-secondary.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent);
  color: #93c5fd;
}

.marker-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.marker-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.7rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.marker-item:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.marker-item.active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
  transform: translateX(4px);
}

.marker-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px;
}

.marker-icon.color-orange { border-color: rgba(249, 115, 22, 0.5); }
.marker-icon.color-purple { border-color: rgba(168, 85, 247, 0.5); }
.marker-icon.color-blue { border-color: rgba(59, 130, 246, 0.5); }

.marker-info h3 {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.marker-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.marker-waste-hint {
  font-size: 0.7rem !important;
  color: var(--text-muted);
  opacity: 0.85;
  margin-top: 0.1rem;
}

.station-item {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.station-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.station-bin-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.station-badge {
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.station-bins-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding-top: 0.15rem;
}

.bin-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}

.bin-preview.color-orange { border-color: rgba(249, 115, 22, 0.45); }
.bin-preview.color-purple { border-color: rgba(168, 85, 247, 0.45); }
.bin-preview.color-blue { border-color: rgba(59, 130, 246, 0.45); }

.popup-bin-count {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0.15rem 0 0.3rem;
}

.examples {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.example-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.example-btn:hover {
  border-color: var(--accent);
  color: #93c5fd;
}

/* Map */
.map-wrap {
  flex: 1;
  position: relative;
}

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

.map-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 20, 25, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  z-index: 900;
  color: var(--text);
  font-size: 0.9rem;
}

.map-overlay.hidden {
  display: none;
}

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

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

/* Animated marker icon */
.animated-marker {
  background: transparent !important;
  border: none !important;
}

.station-marker-group {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 14px;
  width: 164px;
  height: 60px;
}

.station-marker-group.bounce {
  animation: bounce 0.5s ease;
}

.dustbin-marker {
  position: relative;
  width: 48px;
  height: 60px;
  flex-shrink: 0;
  transform-origin: bottom center;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.38));
  cursor: pointer;
  pointer-events: auto;
}

.dustbin-marker .dustbin-svg {
  pointer-events: none;
}

.leaflet-marker-icon.animated-marker {
  pointer-events: auto !important;
}

.dustbin-lid {
  transform-origin: 24px 18px;
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dustbin-inner {
  transition: fill 0.25s ease;
}

.dustbin-marker:hover .dustbin-lid,
.dustbin-marker.is-open .dustbin-lid {
  transform: rotate(-48deg) translate(-6px, -7px);
}

.dustbin-marker:hover .dustbin-inner,
.dustbin-marker.is-open .dustbin-inner {
  fill: rgba(255, 255, 255, 0.35);
}

.bin-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bin-preview .dustbin-svg {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.dustbin-marker::after {
  content: attr(data-num);
  position: absolute;
  top: 0;
  right: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1a2332;
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid white;
  z-index: 2;
}

.dustbin-marker.color-orange::after { background: var(--dustbin-orange); }
.dustbin-marker.color-purple::after { background: var(--dustbin-purple); }
.dustbin-marker.color-blue::after { background: var(--dustbin-blue); }

.dustbin-svg {
  display: block;
}

.dustbin-marker.drop-in,
.station-marker-group.drop-in {
  animation: dropIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.popup-color {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  margin: 0.2rem 0 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}

.popup-color.color-orange { background: rgba(249, 115, 22, 0.2); color: #fdba74; }
.popup-color.color-purple { background: rgba(168, 85, 247, 0.2); color: #d8b4fe; }
.popup-color.color-blue { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }

/* Dustbin hover tooltip */
.dustbin-hover-tooltip {
  position: fixed;
  z-index: 100000;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  pointer-events: none;
  max-width: 220px;
}

.dustbin-hover-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--surface);
  filter: drop-shadow(0 1px 0 var(--border));
}

/* Dustbin tooltip */
.dustbin-tooltip {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  box-shadow: var(--shadow) !important;
  padding: 0 !important;
}

.dustbin-tooltip::before {
  border-top-color: var(--surface) !important;
}

.tooltip-inner {
  padding: 0.5rem 0.7rem;
  line-height: 1.35;
  min-width: 140px;
}

.tooltip-inner strong {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 0.15rem;
}

.tooltip-inner span {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.tooltip-inner em {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-style: normal;
  margin-top: 0.3rem;
  opacity: 0.8;
}

.tooltip-inner.color-orange strong { color: #fdba74; }
.tooltip-inner.color-purple strong { color: #d8b4fe; }
.tooltip-inner.color-blue strong { color: #93c5fd; }

/* Dustbin popup */
.dustbin-popup .popup-header {
  margin-bottom: 0.5rem;
}

.dustbin-popup .popup-header strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}

.dustbin-popup .popup-intro {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  line-height: 1.45;
}

.dustbin-popup .popup-items {
  margin: 0 0 0.5rem 1rem;
  padding: 0;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.dustbin-popup .popup-items li {
  margin-bottom: 0.15rem;
}

.dustbin-popup .popup-tip {
  font-size: 0.72rem;
  color: var(--text);
  font-weight: 600;
  padding: 0.45rem 0.55rem;
  background: var(--bg);
  border-radius: 6px;
  border-right: 3px solid var(--border);
  line-height: 1.4;
}

.dustbin-popup.color-orange .popup-tip { border-right-color: var(--dustbin-orange); }
.dustbin-popup.color-purple .popup-tip { border-right-color: var(--dustbin-purple); }
.dustbin-popup.color-blue .popup-tip { border-right-color: var(--dustbin-blue); }

[dir="rtl"] .dustbin-popup .popup-tip {
  border-left: none;
  border-right: 3px solid var(--border);
}

[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
}

[dir="rtl"] .marker-item.active {
  transform: translateX(-4px);
}

[dir="rtl"] .autocomplete-item.active {
  border-left: none;
  border-right: 3px solid var(--accent);
  padding-right: calc(0.85rem - 3px);
}

[dir="ltr"] .marker-item.active {
  transform: translateX(4px);
}

[dir="ltr"] .autocomplete-item.active {
  border-right: none;
  border-left: 3px solid var(--accent);
  padding-left: calc(0.85rem - 3px);
}

[dir="ltr"] .dustbin-popup .popup-tip {
  border-right: none;
  border-left: 3px solid var(--border);
}

[dir="ltr"] .dustbin-popup.color-orange .popup-tip { border-left-color: var(--dustbin-orange); }
[dir="ltr"] .dustbin-popup.color-purple .popup-tip { border-left-color: var(--dustbin-purple); }
[dir="ltr"] .dustbin-popup.color-blue .popup-tip { border-left-color: var(--dustbin-blue); }

@keyframes dropIn {
  0% {
    opacity: 0;
    transform: translateY(-60px) scale(0.3);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-14px); }
  70% { transform: translateY(-6px); }
}

/* Leaflet popup dark theme */
.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.leaflet-popup-tip {
  background: var(--surface);
}

.leaflet-popup-content {
  margin: 0.75rem 1rem;
  font-size: 0.88rem;
  line-height: 1.4;
}

.leaflet-popup-content strong {
  display: block;
  margin-bottom: 0.25rem;
}

.leaflet-container {
  background: #1a2332;
  font-family: inherit;
}

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

  .sidebar {
    width: 100%;
    min-width: unset;
    max-height: 45vh;
  }

  .map-wrap {
    min-height: 55vh;
  }
}
