/* New Repo UI Styles - Complete Migration */
:root {
  --page-bg: #101114;
  --text-color: #f5f5f5;
  --chrome-bg: rgba(0, 0, 0, 0.75);
  --accent-color: #00c6ff;
  --accent-contrast: #072c3b;
  --search-bg: rgba(0, 0, 0, 0.85);
  --search-border: rgba(255, 255, 255, 0.15);
  --search-hover: rgba(255, 255, 255, 0.1);
  --search-highlight: #00c6ff;
}

html,
body {
  height: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--page-bg);
  color: var(--text-color);
  transition: background 0.5s ease, color 0.3s ease;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden; /* Prevent body scroll, map handles its own */
}

header {
  padding: 0.75rem 1rem;
  background: var(--chrome-bg);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex: 0 0 auto;
  position: relative;
  z-index: 50;
}

.search-toggle {
  display: none;
  border: 1px solid var(--search-border);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text-color);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.search-shell {
  position: relative;
  width: min(320px, 45vw);
  z-index: 30;
}

.search-shell input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--search-border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text-color);
  font-size: 0.95rem;
  position: relative;
  z-index: 210;
}

.search-shell input:focus {
  outline: none;
  border-color: var(--accent-color);
  background: rgba(0, 0, 0, 0.6);
}

.search-results {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  background: var(--search-bg);
  border-radius: 12px;
  border: 1px solid var(--search-border);
  max-height: 240px;
  overflow-y: auto;
  position: absolute;
  width: 100%;
  display: none;
  z-index: 200;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.search-results.visible {
  display: block;
}

.search-results li {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.search-results li strong {
  font-size: 0.95rem;
}

.search-results li span {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.search-results mark {
  background: transparent;
  color: var(--search-highlight);
}

.search-results li.active,
.search-results li:hover {
  background: var(--search-hover);
}

.map-shell {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

h1 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-color);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.basemap-toggle button {
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  margin-left: 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-color);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

.basemap-toggle button:first-child {
  margin-left: 0;
}

.basemap-toggle button.active {
  background: var(--accent-color);
  color: var(--accent-contrast);
}

.theme-switcher {
  position: fixed;
  left: 1rem;
  bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  z-index: 10;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.55);
  color: var(--text-color);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.theme-switcher.open .theme-toggle {
  border-color: var(--accent-color);
}

.theme-panel {
  display: none;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 16px;
  padding: 0.75rem;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  min-width: 220px;
  max-width: 260px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.theme-switcher.open .theme-panel {
  display: grid;
}

.theme-option {
  position: relative;
  border: none;
  border-radius: 12px;
  padding: 0.6rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  transition: transform 0.15s ease, background 0.2s ease;
}

.theme-option::before {
  content: '';
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--swatch, #fff);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}

.theme-option span {
  font-size: 0.85rem;
}

.theme-option.active {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.theme-option:hover {
  transform: translateY(-2px);
}

.map-branding {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  font-weight: 800;
  letter-spacing: 0.3em;
  font-size: 1rem;
  color: var(--text-color);
  opacity: 0.85;
  text-transform: uppercase;
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.maplibregl-ctrl-logo,
.maplibregl-ctrl-attrib {
  display: none !important;
}

/* Override MapLibre default popup styles */
.maplibregl-popup {
  max-width: 280px;
  z-index: 60;
}

.maplibregl-popup-content {
  background: var(--chrome-bg) !important;
  border: 1px solid var(--accent-color) !important;
  color: var(--text-color) !important;
  border-radius: 14px;
  padding: 0 !important;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
}

.maplibregl-popup-content * {
  color: var(--text-color) !important;
}

.maplibregl-popup-tip {
  border-top-color: var(--chrome-bg) !important;
  border-left-color: transparent !important;
  border-right-color: transparent !important;
  border-bottom-color: transparent !important;
}

.maplibregl-popup-close-button {
  color: var(--text-color) !important;
  opacity: 0.8;
}

.maplibregl-popup-close-button:hover {
  opacity: 1;
  color: var(--accent-color) !important;
}

.maplibregl-popup-content.pin-popup--enhanced {
  max-width: 400px;
  max-height: 60vh;
  overflow-y: auto;
}

.pin-popup {
  padding: 0.85rem 1rem;
}

.pin-popup--basic {
  min-width: 200px;
  max-width: 250px;
}

.pin-popup--enhanced {
  min-width: 300px;
  max-width: 400px;
}

.pin-popup__section {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.pin-popup__section:last-child {
  border-bottom: none;
}

.pin-popup__section--header {
  padding-top: 16px;
}

.pin-popup h3,
.pin-popup__title {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-color);
}

.pin-popup h3 {
  font-weight: 600;
}

.pin-popup__title {
  margin: 0 0 4px 0;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.pin-popup__subtitle {
  margin: 0.15rem 0 0.5rem;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.7);
}

/* Basic popup list styling (matches new repo) */
.pin-popup ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pin-popup li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.pin-popup li strong {
  font-weight: 600;
}

/* Theme-aware popup colors */
.pin-popup__section {
  background: transparent;
}

.pin-popup__section--header {
  background: transparent;
}

.pin-popup__section--stats {
  background: transparent;
}

.pin-popup__section--workers {
  background: transparent;
}

.pin-popup__section--custom {
  background: transparent;
}

.pin-popup__section--links {
  background: transparent;
}

.pin-popup__stat .stat-value {
  color: var(--accent-color);
}

.pin-popup__loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 12px 16px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem;
}

.pin-popup__loading .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.pin-popup__section--stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
  padding: 16px;
}

.pin-popup__stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-color);
}

/* Theme-aware stat colors */
.pin-popup__stat .stat-label {
  color: rgba(255, 255, 255, 0.6);
}

.pin-popup__stat .stat-value {
  color: var(--accent-color);
}

.pin-popup__section-title {
  margin: 0 0 10px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pin-popup__workers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pin-popup__worker {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.worker-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-color);
}

.worker-phone {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
}

.pin-popup__more {
  margin: 8px 0 0 0;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
}

.pin-popup__section--custom {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pin-popup__custom-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.custom-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  text-transform: capitalize;
}

.custom-value {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-color);
  text-align: right;
}

.pin-popup__links-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pin-popup__link {
  display: block;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  border: 1px solid var(--accent-color);
  color: var(--accent-color);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.pin-popup__link:hover {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: var(--accent-contrast);
}

@media (max-width: 640px) {
  header {
    flex-direction: column;
  }

  .search-shell {
    width: 100%;
  }

  .theme-switcher {
    top: auto;
    bottom: 0.8rem;
    left: 0.8rem;
  }

  .theme-panel {
    max-width: calc(100vw - 1.6rem);
  }

  .map-branding {
    left: 0.8rem;
    bottom: 0.6rem;
    letter-spacing: 0.2em;
  }
}

@media (max-width: 480px) {
  .basemap-toggle {
    width: 100%;
  }

  .basemap-toggle button {
    flex: 1;
    padding: 0.55rem;
    font-size: 0.95rem;
  }

  .search-toggle {
    display: inline-flex;
  }

  .search-shell {
    display: none;
    width: 100%;
  }

  .search-shell.open {
    display: block;
  }

  header {
    gap: 0.4rem;
  }

  .theme-switcher {
    left: 0.8rem;
  }
}

