/* ==========================================================================
   Kompakter Routenvergleich - Gemeindehaus Geestland & Schierholz
   ========================================================================== */

:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Target 1: Gemeindehaus Geestland (Blue) */
  --t1-color: #2563eb;
  --t1-dark: #1d4ed8;
  --t1-bg: #eff6ff;
  --t1-border: #bfdbfe;
  --t1-text: #1e40af;

  /* Target 2: Gemeindehaus Schierholz (Green) */
  --t2-color: #059669;
  --t2-dark: #047857;
  --t2-bg: #ecfdf5;
  --t2-border: #a7f3d0;
  --t2-text: #065f46;

  /* Neutral surfaces */
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  margin: 0;
  padding: 0;
  background-color: var(--bg-body);
  color: var(--text-main);
  font-family: var(--font);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

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

.app-wrapper {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ==========================================================================
   Minimalist Sticky Header
   ========================================================================== */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin: 0;
}

.toggle-map-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--text-main);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 0.35rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.toggle-map-btn:hover {
  opacity: 0.9;
}

/* ==========================================================================
   Collapsible Map Drawer
   ========================================================================== */
.map-drawer {
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  width: 100%;
}

.map-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.map-active-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.map-header-actions {
  display: flex;
  gap: 0.4rem;
}

.btn-map-action {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
}

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

.close-action {
  color: #dc2626;
}

.leaflet-map-box {
  width: 100%;
  height: 320px;
  background: #e2e8f0;
}

.map-drawer-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.legend-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-blue { background-color: var(--t1-color); }
.dot-green { background-color: var(--t2-color); }

/* ==========================================================================
   Dashboard Content & Controls
   ========================================================================== */
.dashboard-content {
  flex: 1;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: 100%;
  max-width: 100%;
}

.action-bar {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
}

/* Search Box */
.search-wrap {
  position: relative;
  width: 100%;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.3rem 0.45rem 0.3rem 0.65rem;
  gap: 0.4rem;
  box-shadow: var(--shadow-sm);
}

.search-box:focus-within {
  border-color: var(--t1-color);
}

.search-icon {
  color: var(--text-light);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--text-main);
  outline: none;
}

.btn-clear {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 5px;
}

.btn-submit {
  background: var(--t1-color);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.32rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-gps {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.32rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  flex-shrink: 0;
}

.suggestions-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 200px;
  overflow-y: auto;
  z-index: 500;
  margin-top: 4px;
}

.suggestion-item {
  padding: 0.55rem 0.8rem;
  font-size: 0.78rem;
  color: var(--text-main);
  cursor: pointer;
  border-bottom: 1px solid var(--bg-subtle);
}

.suggestion-item:hover {
  background: var(--bg-subtle);
}

/* Filter Chips */
.filter-chips {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  width: 100%;
}

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.chip:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.chip.active {
  background: var(--text-main);
  color: #fff;
  border-color: var(--text-main);
}

.chip-equal.active {
  background: #475569;
  border-color: #475569;
}

.chip-minor.active {
  background: #b45309;
  border-color: #b45309;
}

.chip-major.active {
  background: #047857;
  border-color: #047857;
}

/* ==========================================================================
   Locations Grid & Side-by-Side Cards
   ========================================================================== */
.locations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
  width: 100%;
}

.location-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  width: 100%;
  min-width: 0;
}

.location-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.location-card.highlighted {
  border-color: var(--t1-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

/* Card Header */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  min-width: 0;
}

.card-title-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.location-name {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Difference Badges */
.diff-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-equal {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
}

.badge-minor {
  background: #fefce8;
  border: 1px solid #fef08a;
  color: #854d0e;
}

.badge-major-t2 {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.badge-major-t1 {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

/* STRICT SIDE-BY-SIDE METRICS (Always 2 Columns) */
.card-metrics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  width: 100%;
}

.metric-col {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.metric-col.col-t1.is-closer-side {
  background: var(--t1-bg);
  border-color: var(--t1-border);
}

.metric-col.col-t2.is-closer-side {
  background: var(--t2-bg);
  border-color: var(--t2-border);
}

.metric-col-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.2rem;
  min-width: 0;
}

.col-tag {
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-t1 .col-tag { color: var(--t1-color); }
.col-t2 .col-tag { color: var(--t2-color); }

.faster-flag {
  font-size: 0.55rem;
  font-weight: 800;
  background: #10b981;
  color: #fff;
  padding: 0.08rem 0.25rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.metric-values {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.val-km {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
  letter-spacing: -0.02em;
}

.unit-txt {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
}

.sep-dot {
  color: var(--text-light);
  font-weight: 700;
}

.val-min {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1;
}

/* Card Actions (Only Map Button) */
.card-actions-single {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.2rem;
}

.btn-card-map-action {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.28rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-card-map-action:hover {
  background: var(--text-main);
  color: #fff;
  border-color: var(--text-main);
}

/* Custom Search Box */
.custom-result-box {
  width: 100%;
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 1rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.hidden { display: none !important; }

/* Custom Marker */
.origin-marker-pulse {
  width: 18px;
  height: 18px;
  background: #dc2626;
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.4);
}

/* Responsive Fixes */
@media (max-width: 600px) {
  .dashboard-content {
    padding: 0.6rem 0.65rem;
  }
  
  .locations-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .location-card {
    padding: 0.75rem;
  }

  .col-tag {
    font-size: 0.62rem;
  }

  .val-km {
    font-size: 1.05rem;
  }

  .val-min {
    font-size: 0.92rem;
  }
}
