/* Viewer for Zagreb road stretch acceleration analysis */

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: #222;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  max-height: 50vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
  z-index: 1000;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 500px) {
  #panel {
    top: 12px;
    left: 12px;
    width: 280px;
    max-height: calc(100vh - 24px);
    border-radius: 8px;
  }
}

h1 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

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

#panel hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 4px 0;
}

label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
}

select {
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 4px;
}

.tab {
  padding: 5px 4px;
  font-size: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f5f5f5;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-align: center;
  line-height: 1.3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab.active {
  background: #1a73e8;
  color: #fff;
  border-color: #1a73e8;
}

.view-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.hidden { display: none; }

.hint {
  font-size: 12px;
  color: #555;
  line-height: 1.4;
}

.hint .dot-green, .hint .dot-red {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}
.hint .dot-green { background: #2ecc71; }
.hint .dot-red   { background: #e74c3c; }

input[type=range] {
  width: 100%;
  cursor: pointer;
  accent-color: #1a73e8;
}

.cross-icon {
  font-size: 15px;
  line-height: 1;
  vertical-align: middle;
}

.section-note {
  font-size: 11px;
  font-weight: normal;
  color: #888;
}

.accel-preset-note {
  font-size: 11px;
  font-weight: normal;
  color: #888;
  margin-left: 4px;
}

.preset-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.preset-buttons button {
  flex: 1;
  font-size: 11px;
  padding: 3px 4px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f5f5f5;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}

.preset-buttons button.active {
  background: #d2e3fc;
  border-color: #1a73e8;
  color: #1a73e8;
}

.stats-box {
  background: #f0f4ff;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.6;
}
.stats-box.hidden { display: none; }
.stats-box span { font-weight: 700; }

#legend {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.legend-swatch {
  width: 24px;
  height: 6px;
  border-radius: 3px;
  flex-shrink: 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: #222;
  cursor: pointer;
}

.checkbox-label input[type=checkbox] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: #e74c3c;
  flex-shrink: 0;
}

.checkbox-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.add-hump-btn {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f5f5f5;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s;
}

.add-hump-btn:hover { background: #e8e8e8; }

.add-hump-btn.active {
  background: #fff3cd;
  border-color: #e0a800;
  color: #7d5a00;
}

#decel-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 6px;
}

#def-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#def-modal.hidden { display: none; }

#def-modal-box {
  background: #fff;
  border-radius: 8px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px 24px 24px;
  position: relative;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

#def-modal-box h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #222;
  padding-right: 28px;
}

#def-modal-box h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  margin: 16px 0 6px;
}

#def-modal-box p {
  font-size: 13px;
  line-height: 1.6;
  color: #444;
  margin-bottom: 6px;
}

#def-modal-box ul {
  margin: 0 0 4px 18px;
  padding: 0;
}

#def-modal-box li {
  font-size: 13px;
  line-height: 1.6;
  color: #444;
  margin-bottom: 3px;
}

#def-modal-box a { color: #1a73e8; }

#def-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #888;
  padding: 3px 7px;
  border-radius: 4px;
}

#def-modal-close:hover { background: #f0f0f0; color: #222; }

#street-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 130px;
  overflow-y: auto;
  margin-top: 4px;
}

@media (min-width: 500px) {
  #street-list { max-height: 220px; }
}

.street-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.3;
  transition: background 0.1s;
}

.street-row:hover { background: #f0f4ff; }
.street-row.active { background: #d2e3fc; }

.street-rank {
  font-size: 10px;
  color: #aaa;
  width: 16px;
  flex-shrink: 0;
  text-align: right;
}

.street-bar-wrap {
  flex: 1;
  height: 5px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
}

.street-bar {
  height: 100%;
  background: #e74c3c;
  border-radius: 3px;
}

.street-name {
  flex: 2;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.street-metres {
  font-size: 11px;
  color: #888;
  flex-shrink: 0;
}

.seg-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 12px;
}

.seg-label {
  width: 80px;
  flex-shrink: 0;
  color: #555;
}

.seg-bar-wrap {
  flex: 1;
  height: 8px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
}

.seg-bar {
  height: 100%;
  background: #4575b4;
  border-radius: 3px;
}

.seg-km {
  font-size: 11px;
  color: #888;
  width: 42px;
  flex-shrink: 0;
  text-align: right;
}

.type-km-note {
  font-size: 10px;
  color: #aaa;
  padding: 0 0 4px 0;
  margin-top: -2px;
}

#stretch-info {
  border-top: 1px solid #eee;
  padding-top: 8px;
  font-size: 12px;
  line-height: 1.5;
}

#stretch-info.hidden { display: none; }

#info-name {
  font-size: 13px;
  display: block;
  margin-bottom: 4px;
}

#info-details { color: #555; }

.footer {
  font-size: 11px;
  color: #888;
  border-top: 1px solid #eee;
  padding-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.footer a { color: #1a73e8; }

#loading {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 15px;
  color: #444;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #ddd;
  border-top-color: #1a73e8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#speed-probe-pill {
  position: absolute;
  display: none;
  background: rgba(20, 20, 20, 0.88);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 12px;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%) translateY(calc(-100% - 10px));
  z-index: 1500;
  line-height: 1.6;
}

.probe-sep {
  color: #bbb;
  font-weight: 400;
  margin: 0 3px;
}

.probe-unit {
  color: #bbb;
  font-weight: 400;
  margin-left: 2px;
}
