/* Lane Width Measurement Viewer */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f1f5f9;
  min-height: 100vh;
}

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  font-size: 18px;
  color: #64748b;
  z-index: 9999;
}
#loading.hidden { display: none; }

#topbar {
  background: #0f172a;
  color: #f8fafc;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
#topbar h1 { font-size: 16px; font-weight: 700; white-space: nowrap; }

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.controls button {
  background: #334155;
  color: #f8fafc;
  border: none;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.controls button:hover { background: #475569; }
#counter {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  min-width: 80px;
  text-align: center;
}
.controls select {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #475569;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.controls label { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.filter-count { font-size: 11px; color: #94a3b8; }

#main {
  display: flex;
  gap: 16px;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
  height: calc(100vh - 60px);
}

/* Map section */
#map-section { flex: 1; min-width: 400px; }
#map {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

/* Detail section */
#detail-section {
  width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.detail-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
}
.detail-card h2 {
  font-size: 14px;
  color: #0f172a;
  margin-bottom: 8px;
}

.meta-line { font-size: 11px; color: #64748b; line-height: 1.5; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.stat-item { display: flex; flex-direction: column; }
.stat-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
}
.stat-label {
  font-size: 10px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-value.high { color: #16a34a; }
.stat-value.medium { color: #d97706; }
.stat-value.low { color: #94a3b8; }

/* Lane width bars */
#lane-bars { display: flex; flex-direction: column; gap: 4px; }

.lane-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.lane-bar-label {
  font-size: 11px;
  color: #475569;
  width: 50px;
  text-align: right;
  flex-shrink: 0;
}
.lane-bar {
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  min-width: 30px;
}
.lane-bar.edge { background: #3b82f6; }
.lane-bar.lane { background: #475569; }

/* Profile image */
#profile-img {
  width: 100%;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}
#profile-img[src=""] { display: none; }

/* Method tags */
.method-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  margin-top: 4px;
}
.method-tag.marking_detection { background: #dcfce7; color: #166534; }
.method-tag.edge_divided_by_osm_lanes { background: #dbeafe; color: #1e40af; }
.method-tag.cadastral_corridor_estimate { background: #fef3c7; color: #92400e; }
.method-tag.insufficient_data { background: #f1f5f9; color: #64748b; }

/* Lane count labels on OSM ways */
.lane-count-label {
  background: transparent !important;
  border: none !important;
}
.lane-count-label span {
  display: inline-block;
  background: rgba(0, 0, 0, 0.75);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

@media (max-width: 900px) {
  #main { flex-direction: column; height: auto; }
  #map-section { min-height: 400px; }
  #detail-section { width: 100%; }
}
