/* ---------- Base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0b1220;
  color: #eaf0ff;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body {
  /* Notch/safe-area destegi (iPhone) */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.hidden { display: none !important; }

/* ---------- Map ---------- */
#map {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1;
  background: #0b1220;
}

/* Leaflet ust uste binmesin */
.leaflet-container { background: #0b1220; }
.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(0,0,0,0.5) !important;
  color: #aaa !important;
}
.leaflet-control-attribution a { color: #ddd !important; }

/* ---------- Top bar (hiz + uyari ozeti) ---------- */
.top-bar {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 0; right: 0;
  z-index: 1000;
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  pointer-events: none;
}

.speed-box {
  background: rgba(11, 18, 32, 0.92);
  border: 1px solid #1d2a44;
  border-radius: 14px;
  padding: 8px 14px;
  min-width: 88px;
  text-align: center;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.speed-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #4ade80;
}
.speed-value.over { color: #ef4444; }
.speed-unit {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.alert-box {
  flex: 1;
  background: rgba(11, 18, 32, 0.92);
  border: 1px solid #1d2a44;
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.25s, border-color 0.25s;
}
.alert-box.warn { background: rgba(202, 138, 4, 0.92); border-color: #facc15; color: #fff; }
.alert-box.danger { background: rgba(220, 38, 38, 0.95); border-color: #fca5a5; color: #fff; }

.alert-label { font-size: 14px; font-weight: 600; line-height: 1.2; }
.alert-distance {
  font-size: 18px; font-weight: 700; margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Buyuk uyari (yaklasinca tum ekran efekti) ---------- */
.warning-overlay {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1500;
  pointer-events: none;
  animation: warningPulse 0.8s ease-in-out infinite;
}
.warning-content {
  background: rgba(220, 38, 38, 0.97);
  border: 4px solid #fff;
  border-radius: 28px;
  padding: 24px 32px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  min-width: 240px;
}
.warning-icon {
  font-size: 56px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
}
.warning-title {
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  margin-top: 6px;
  letter-spacing: 0.04em;
}
.warning-info {
  font-size: 18px;
  color: #fee2e2;
  margin-top: 4px;
  font-weight: 600;
}
@keyframes warningPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -50%) scale(1.05); }
}

/* ---------- Bottom panel ---------- */
.bottom-panel {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 1000;
  background: rgba(11, 18, 32, 0.97);
  border-top: 1px solid #1d2a44;
  border-radius: 18px 18px 0 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
  transition: transform 0.3s ease;
}
.bottom-panel.collapsed .panel-body { display: none; }
.bottom-panel.collapsed .toggle-btn { transform: rotate(180deg); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  color: #cbd5e1;
  border-bottom: 1px solid #1d2a44;
}
.toggle-btn {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s;
}

.panel-body {
  padding: 14px 18px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.row-flex { display: flex; gap: 8px; }

select {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%2394a3b8' d='M2 4l4 4 4-4z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
select:disabled { opacity: 0.5; }

button {
  font-family: inherit;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  transition: filter 0.15s, background 0.15s, transform 0.05s;
}
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.primary-btn {
  width: 100%;
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  border: none;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  margin-top: 4px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.primary-btn:hover:not(:disabled) { filter: brightness(1.1); }

.ghost-btn {
  width: 100%;
  margin-top: 8px;
  background: transparent;
  border: 1px solid #334155;
  color: #cbd5e1;
  padding: 10px;
  font-size: 13px;
}

.danger-btn {
  width: 100%;
  background: #dc2626;
  border: none;
  color: #fff;
  padding: 14px;
  margin-top: 12px;
  font-weight: 700;
}

.status-line {
  margin-top: 10px;
  font-size: 13px;
  color: #94a3b8;
  text-align: center;
  min-height: 18px;
}
.status-line.error { color: #f87171; }
.status-line.success { color: #4ade80; }

/* ---------- Route summary ---------- */
.route-summary { margin-top: 16px; padding-top: 14px; border-top: 1px solid #1d2a44; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.summary-item {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 12px 6px;
  text-align: center;
}
.summary-num {
  font-size: 22px;
  font-weight: 800;
  color: #f1f5f9;
}
.summary-lbl {
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.city-breakdown {
  font-size: 13px;
  color: #cbd5e1;
  max-height: 140px;
  overflow-y: auto;
  border-top: 1px solid #1e293b;
  padding-top: 10px;
}
.city-breakdown .city-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed #1e293b;
}
.city-breakdown .city-row:last-child { border-bottom: none; }
.city-breakdown .city-name { font-weight: 600; }
.city-breakdown .city-stats {
  font-size: 12px;
  color: #94a3b8;
}
.city-breakdown .badge {
  display: inline-block;
  min-width: 18px;
  text-align: center;
  background: #dc2626;
  color: #fff;
  border-radius: 9px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 4px;
}
.city-breakdown .badge.green { background: #16a34a; }

/* ---------- Custom map markers ---------- */
.user-marker {
  width: 22px;
  height: 22px;
  background: #3b82f6;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.25), 0 2px 8px rgba(0,0,0,0.5);
}
.user-marker.has-heading {
  background: transparent;
  border: none;
  box-shadow: none;
}
.user-arrow {
  width: 0; height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-bottom: 26px solid #3b82f6;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
  transform-origin: center 70%;
}

.radar-marker, .corridor-marker {
  font-size: 0;
  text-align: center;
}
.radar-marker .pin, .corridor-marker .pin {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  position: relative;
}
.radar-marker .pin { background: #ef4444; }
.corridor-marker .pin { background: #f59e0b; }
.radar-marker .pin::after, .corridor-marker .pin::after {
  content: "R";
  color: #fff;
  font-family: -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 800;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.corridor-marker .pin::after { content: "K"; }

/* ---------- Loading spinner ---------- */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #475569;
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
