/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #334155;
  --accent: #f97316;
  --accent2: #fb923c;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --border: #334155;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --header-h: 56px;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
  /* Global overflow hidden for app feeling */
}

/* ===== HEADER ===== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 16px;
  max-width: 640px;
  margin: 0 auto;
}

.logo {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--accent);
}

/* ===== TABS ===== */
.tab-nav {
  display: flex;
  gap: 4px;
  background: var(--bg2);
  border-radius: 10px;
  padding: 3px;
}

.tab-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ===== TAB CONTENT ===== */
.tab-content {
  display: none;
  padding: calc(var(--header-h) + 16px) 16px 32px;
  max-width: 640px;
  margin: 0 auto;
}

.tab-content.active {
  display: block;
}

/* Spezial-Layout für Plan-Tab: Oben Karte fix, unten scrollen */
#tab-content-plan.active {
  display: flex !important;
  flex-direction: column;
  padding: var(--header-h) 0 0;
  height: 100%;
  max-width: none;
}

.tab-scroll-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

/* Standard-Scroll für andere Tabs */
#tab-content-checkpoints.active,
#tab-content-navigate.active {
  overflow-y: auto;
  height: calc(100% - 0px);
  /* Fill screen */
}

/* ===== CARDS ===== */
.section-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 8px;
}

/* ===== INPUTS ===== */
.input-row {
  margin-bottom: 10px;
}

.label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-field {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
}

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

.input-field::placeholder {
  color: var(--text2);
}

.input-small {
  width: 100px;
}

.coords-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.coords-row .input-field {
  flex: 1;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent2);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--border);
}

.btn-icon {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 6px 12px;
}

.btn-full {
  width: 100%;
  margin-top: 4px;
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}

/* ===== PRIORITY BUTTONS ===== */
.priority-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  /* Hide scrollbar for cleaner look */
}

.priority-group::-webkit-scrollbar {
  display: none;
}

.prio-btn {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  background: var(--bg3);
  color: var(--text2);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.prio-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(249, 115, 22, 0.12);
}

/* ===== CP LIST ===== */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.list-header .section-title {
  margin-bottom: 0;
}

.cp-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}

.cp-item:hover {
  border-color: var(--accent);
}

.cp-prio-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.prio-must {
  background: var(--red);
}

.prio-high {
  background: var(--yellow);
}

.prio-medium {
  background: #3b82f6;
}

.prio-low {
  background: var(--text2);
}

.cp-info {
  flex: 1;
  min-width: 0;
}

.cp-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cp-coords-text {
  font-size: 0.75rem;
  color: var(--text2);
  font-family: monospace;
}

.cp-pts {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 700;
}

.cp-delete {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
}

.cp-delete:hover {
  color: var(--red);
}

.empty-state {
  text-align: center;
  color: var(--text2);
  font-size: 0.9rem;
  padding: 24px 0;
}

/* ===== MAP ===== */
.map-pick {
  height: 280px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 8px;
  border: 2px solid var(--accent);
}

.map-hint {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text2);
  margin-bottom: 16px;
  padding: 8px;
  background: var(--bg2);
  border-radius: var(--radius-sm);
}

.map-plan {
  height: 35vh;
  width: 100%;
  flex-shrink: 0;
  border-bottom: 2px solid var(--border);
  border-top: none;
  border-left: none;
  border-right: none;
  margin-top: 0;
}

.map-nav {
  height: calc(100vh - var(--header-h) - 220px);
  min-height: 200px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.hidden {
  display: none !important;
}

/* ===== PROFILE GRID ===== */
.profile-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text2);
}

.profile-chip:has(input:checked) {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(249, 115, 22, 0.12);
}

.profile-chip input {
  display: none;
}

/* ===== PROGRESS ===== */
.progress-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
  width: 0%;
  transition: width 0.3s;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text2);
  text-align: center;
  margin-top: 6px;
}

/* ===== RESULT CARDS ===== */
.result-card {
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.result-card.selected {
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.07);
}

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

.result-rank {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--accent);
}

.result-profile {
  font-size: 0.78rem;
  color: var(--text2);
  background: var(--bg3);
  padding: 3px 8px;
  border-radius: 99px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.result-stat {
  text-align: center;
}

.result-stat-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.result-stat-lbl {
  font-size: 0.7rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-cps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.result-cp-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg3);
  color: var(--text2);
}

.result-cp-tag.must {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.result-cp-tag.high {
  background: rgba(234, 179, 8, 0.2);
  color: #fde047;
}

.btn-use-route {
  width: 100%;
  margin-top: 10px;
  background: var(--green);
  color: #fff;
  padding: 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-use-route:hover {
  opacity: 0.85;
}

/* ===== NAVIGATION HUD ===== */
.nav-hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.hud-stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}

.hud-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hud-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--accent);
}

.hud-next {
  font-size: 0.9rem;
}

.nav-cp-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-cp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: all 0.2s;
}

.nav-cp-item.done {
  opacity: 0.45;
  border-color: var(--green);
}

.nav-cp-item.current {
  border-color: var(--accent);
  background: rgba(249, 115, 22, 0.08);
}

.nav-cp-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: none;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.nav-cp-check:hover {
  border-color: var(--green);
}

.nav-cp-item.done .nav-cp-check {
  background: var(--green);
  border-color: var(--green);
}

.nav-cp-name {
  font-weight: 600;
  font-size: 0.9rem;
  flex: 1;
}

.nav-cp-pts {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 700;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 9999;
  border: 1px solid var(--border);
  animation: fadeInUp 0.3s ease;
}

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

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ===== LEAFLET OVERRIDES ===== */
.leaflet-container {
  background: #1e293b;
}

.leaflet-tile {
  filter: brightness(0.85) saturate(0.9);
}

/* ===== UTILS ===== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hint-text {
  font-size: 0.78rem;
  color: var(--text2);
  margin: 6px 0 12px;
  padding: 6px 10px;
  background: rgba(249, 115, 22, 0.07);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

/* ===== INLINE CP MAP ===== */
.map-cp-inline {
  height: 220px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid var(--border);
  cursor: crosshair;
  transition: border-color 0.2s;
}

.map-cp-inline:hover {
  border-color: var(--accent);
}

/* ===== ADRESSSUCHE ===== */
.search-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.search-row .input-field {
  flex: 1;
}

.autocomplete-list {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  list-style: none;
  z-index: 500;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.addr-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.addr-item:hover {
  background: var(--bg3);
}

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

.addr-type {
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: capitalize;
  font-weight: 600;
}

.addr-empty {
  color: var(--text2);
  font-size: 0.85rem;
  cursor: default;
}

.addr-empty:hover {
  background: none;
}

/* ===== CP EDIT PANEL ===== */
.cp-item {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
}

.cp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.cp-item-editing {
  border-color: var(--accent) !important;
}

.cp-edit-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}

.cp-edit-btn:hover {
  color: var(--accent);
}

.cp-edit-panel {
  border-top: 1px solid var(--border);
  padding: 12px;
  background: rgba(249, 115, 22, 0.04);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  animation: slideDown 0.15s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.edit-row {
  margin-bottom: 10px;
}

.edit-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 4px;
}

/* ===== MAP LABELS ===== */
.cp-label {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 6px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.leaflet-tooltip-left.cp-label::before {
  border-left-color: rgba(15, 23, 42, 0.85);
}

.leaflet-tooltip-right.cp-label::before {
  border-right-color: rgba(15, 23, 42, 0.85);
}