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

:root {
  --bg: #0f1117;
  --bg-surface: #181b23;
  --bg-elevated: #1f2230;
  --border: #2a2d3a;
  --text: #e4e4e7;
  --text-muted: #9ca3af;
  --accent: #f5a623;
  --accent-dim: rgba(245, 166, 35, 0.15);
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 10px;
  --sidebar-w: 360px;
  --detail-w: 340px;
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ── Map ── */
#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* ── Sidebar (left) ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.accent {
  color: var(--accent);
}

.user-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  transition: border-color 0.2s;
}

.user-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.user-email {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

/* ── Geocoder ── */
.geocoder-container {
  margin-bottom: 16px;
}

.geocoder-container .mapboxgl-ctrl-geocoder {
  width: 100%;
  max-width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  box-shadow: none;
}

.geocoder-container .mapboxgl-ctrl-geocoder input {
  color: var(--text);
  font-size: 0.9rem;
}

.geocoder-container .mapboxgl-ctrl-geocoder .suggestions {
  background: var(--bg-elevated);
  border-color: var(--border);
}

.geocoder-container .mapboxgl-ctrl-geocoder .suggestions > li > a {
  color: var(--text);
}

.geocoder-container .mapboxgl-ctrl-geocoder .suggestions > .active > a {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ── Form fields ── */
.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.input-field {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.input-field:focus {
  border-color: var(--accent);
}

/* Date input color scheme */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
}

/* ── Toggle group ── */
.toggle-group {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.toggle-btn {
  flex: 1;
  padding: 8px 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Sun info ── */
.sun-info {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 16px;
}

.sun-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.sun-row + .sun-row {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 10px;
}

.sun-icon {
  font-size: 1.4rem;
}

.sun-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sun-value {
  font-size: 1rem;
  font-weight: 600;
}

.sun-azimuth {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
}

/* ── Buttons ── */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.9;
}

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

.btn-find {
  margin-bottom: 16px;
}

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s;
}

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

/* ── Loading skeleton ── */
.loading {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.skeleton {
  height: 60px;
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius);
  animation: shimmer 1.5s infinite;
}

.skeleton.short {
  width: 60%;
  height: 20px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Results list ── */
.results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  animation: fadeInUp 0.3s ease both;
}

.result-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.result-rank {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 8px;
  border-radius: 10px;
}

.result-score {
  font-size: 0.85rem;
  font-weight: 600;
}

.result-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Detail panel (right) ── */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--detail-w);
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  z-index: 10;
  padding: 20px;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.detail-panel.hidden {
  transform: translateX(100%);
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.detail-close:hover {
  color: var(--text);
}

.detail-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  padding-right: 30px;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.detail-value {
  font-size: 0.9rem;
  font-weight: 500;
}

.score-bar-container {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 60%;
}

.score-bar {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.score-bar::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: var(--score, 0%);
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.score-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 40px;
  text-align: right;
}

.detail-actions {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Auth Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  z-index: 1;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--bg-elevated);
  color: var(--text);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form input {
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.auth-form input:focus {
  border-color: var(--accent);
}

.auth-error {
  color: var(--danger);
  font-size: 0.8rem;
  text-align: center;
}

/* ── Landmark selector ── */
.landmark-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-landmark {
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-landmark.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.landmark-info {
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.landmark-info.set {
  color: var(--accent);
}

.landmark-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.landmark-clear:hover {
  color: var(--danger);
}

/* ── Line of sight ── */
.los-section {
  border-top: 1px solid var(--accent-dim);
  margin-top: 6px;
  padding-top: 6px;
}

.los-profile {
  margin-top: 10px;
  height: 80px;
  background: var(--bg);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.los-profile canvas {
  width: 100%;
  height: 100%;
}

/* ── Numbered vantage markers ── */
.vantage-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.marker-number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%) rotate(45deg);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  pointer-events: none;
  line-height: 1;
}

/* ── Preview button ── */
.btn-accent {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-accent:hover {
  opacity: 0.9;
}

/* ── Back from preview overlay ── */
.back-preview-btn {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  transition: border-color 0.2s, opacity 0.3s;
  animation: fadeInDown 0.4s ease;
}

.back-preview-btn:hover {
  border-color: var(--accent);
}

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

/* ── SV toggle ── */
.sv-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sv-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* ── Feedback tags ── */
.vote-tags-section {
  width: 100%;
  max-width: 720px;
}

.vote-tags-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.vote-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vote-tag {
  padding: 5px 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.vote-tag:hover {
  border-color: var(--text-muted);
}

.vote-tag.selected.positive {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--success);
  color: var(--success);
}

.vote-tag.selected.negative {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Street View preview (detail panel) ── */
.streetview-section {
  margin-bottom: 14px;
}

.streetview-container {
  width: 100%;
  height: 160px;
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  margin-bottom: 8px;
}

.streetview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.streetview-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  background: var(--bg);
}

.streetview-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ── Vote buttons (detail panel) ── */
.vote-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.vote-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.vote-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.vote-btn.vote-up:hover, .vote-btn.vote-up.voted {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--success);
  color: var(--success);
}

.vote-btn.vote-down:hover, .vote-btn.vote-down.voted {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}

.vote-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 60px;
  text-align: center;
}

/* ── Vote Mode button ── */
.btn-vote-mode {
  width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-vote-mode:hover {
  background: var(--accent-dim);
}

/* ── Vote Mode Overlay ── */
.vote-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.vote-overlay.hidden {
  display: none !important;
}

.vote-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.vote-overlay-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}

.vote-progress {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 4px 10px;
  border-radius: 12px;
}

.vote-overlay-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.vote-overlay-close:hover {
  color: var(--text);
}

.vote-overlay-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
  gap: 16px;
}

.vote-sv-container {
  width: 100%;
  max-width: 720px;
  aspect-ratio: 16 / 9;
  background: var(--bg-surface);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.vote-sv-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vote-point-info {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.9rem;
}

.vote-point-rank {
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
}

.vote-point-elev {
  color: var(--text);
}

.vote-point-score {
  color: var(--text-muted);
}

.vote-comment {
  width: 100%;
  max-width: 720px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

.vote-comment:focus {
  border-color: var(--accent);
}

.vote-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 720px;
}

.vote-action-btn {
  flex: 1;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.vote-action-up {
  background: rgba(34, 197, 94, 0.1);
  border-color: var(--success);
  color: var(--success);
}

.vote-action-up:hover {
  background: rgba(34, 197, 94, 0.25);
}

.vote-action-down {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

.vote-action-down:hover {
  background: rgba(239, 68, 68, 0.25);
}

.vote-action-skip {
  background: var(--bg-elevated);
  color: var(--text-muted);
  flex: 0.5;
}

.vote-action-skip:hover {
  border-color: var(--text-muted);
}

/* Map cursor when selecting landmark */
.cursor-crosshair .mapboxgl-canvas {
  cursor: crosshair !important;
}

/* ── Utility ── */
.hidden {
  display: none !important;
}

/* ── Map marker popup override ── */
.mapboxgl-popup-content {
  background: var(--bg-surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  padding: 10px 14px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 0.85rem !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4) !important;
}

.mapboxgl-popup-tip {
  border-top-color: var(--bg-surface) !important;
}

.mapboxgl-popup-close-button {
  color: var(--text-muted) !important;
  font-size: 1.2rem !important;
}

/* ── Mapbox controls dark ── */
.mapboxgl-ctrl-group {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
}

.mapboxgl-ctrl-group button {
  background-color: transparent !important;
}

.mapboxgl-ctrl-group button + button {
  border-top: 1px solid var(--border) !important;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 45vh;
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
  }

  .sidebar-header {
    cursor: grab;
  }

  .detail-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 55vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
  }

  .detail-panel.hidden {
    transform: translateY(100%);
  }
}
