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

/* i18n loading mask */
html[data-i18n='pending'] {
  visibility: hidden;
}

/* Root variables */
:root {
  --sidebar-w: 380px;
}

/* Base */
html,
body {
  height: 100%;
  margin: 0;
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* App layout: mobile-first (column) */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Sidebar */
.sidebar {
  padding: 16px;
  background: #fff;
  overflow: auto;
  width: 100%;
}

/* Map wrapper */
.map-wrap {
  position: relative;
  flex: 1;
}

#map {
  position: absolute;
  inset: 0;
}

/* Inputs & buttons */
.textlike,
.btn {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}

.btn {
  cursor: pointer;
  border-radius: 10px; /* keep existing rounded look for buttons */
}

/* Fields */
.field {
  margin-bottom: 10px;
}

/* Pills */
.pills {
  display: none;           /* JS sets it to flex when route is ready */
  position: relative;
  transition: padding 0.3s ease, opacity 0.3s ease;
  gap: 10px;
  margin-top: 10px;
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2ff;
  display: inline-block;
}

/* Clear (X) pill visibility logic:
   Hidden inside the sidebar; visible when pills are moved out of the sidebar
   (i.e., when desktop is collapsed). */
.sidebar #clearBtn {
  display: none;
}

body.sidebar-collapsed #clearBtn {
  /* style remains when shown outside .sidebar (display controlled by DOM move) */
  cursor: pointer;
  background: #fee2e2 !important;
  color: #b91c1c !important;
  font-weight: bold;
  padding: 6px 12px;
}

body.sidebar-collapsed-mobile .sidebar #clearBtn {
  display: flex;
}

/* Mobile collapse: hide everything inside the sidebar except .pills */
body.sidebar-collapsed-mobile .sidebar > *:not(.pills) {
  display: none !important;
}

/* Desktop/mobile collapsed: float pills for visibility on the map area */
body.sidebar-collapsed .pills {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 1000;
  margin: 0;
}

/* Toggle button (mobile defaults) */
.sidebar-toggle {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 24px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-top: none;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  z-index: 1001;
  padding: 0;
  font-size: 16px;
  font-weight: bold;
  transition: transform 0.3s ease;
}

.sidebar-toggle::before {
  content: '^';
}

.sidebar-toggle.collapsed {
  transform: translateX(-50%) rotate(180deg);
}

/* Toll labels */
.toll-dot {
  width: 8px;
  height: 8px;
  background: red;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.toll-text {
  font-size: 12px;
  background: #fff;
  padding: 1px 3px;
  border-radius: 3px;
}

.toll-label {
  white-space: nowrap;
}

/* Autocomplete dropdown */
.ac-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
  z-index: 9999;
  max-height: 200px;
  font-size: 14px;
}

.ac-item {
  padding: 8px 10px;
  cursor: pointer;
}

.ac-item:hover,
.ac-item.active {
  background: #eef2ff;
}

.ac-muted {
  color: #64748b;
  font-size: 12px;
}

/* Error text */
.error {
  color: #b91c1c;
  font-weight: 600;
}

/* Tablet & desktop */
@media (min-width: 768px) {
  .app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100%;
    transition: grid-template-columns 0.3s ease;
  }

  body.sidebar-collapsed .app {
    grid-template-columns: 0 1fr;
  }

  .sidebar {
    border-right: 1px solid #e5e7eb;
    position: relative;
    transition: padding 0.3s ease, opacity 0.3s ease;
  }

  body.sidebar-collapsed .sidebar {
    padding: 0;
    opacity: 0;
  }

  .sidebar h1 {
    font-size: 16px;
    margin: 0 0 12px;
  }

  .field {
    margin-bottom: 12px;
  }

  /* Map absolute fill kept for desktop as well */
  #map {
    position: absolute;
    inset: 0;
  }

  /* Desktop toggle button on left edge */
  .sidebar-toggle {
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    border: 1px solid #e0e0e0;
    border-left: none;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 0;
  }

  .sidebar-toggle::before {
    content: '<';
  }

  .sidebar-toggle.collapsed {
    transform: translateY(-50%) rotate(180deg);
  }

  /* Language menu */
  .lang-menu {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
  }

  .lang-menu select {
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    cursor: pointer;
  }

  /* Desktop autocomplete tweaks */
  .ac-list {
    max-height: 260px;
    font-size: 12px;
  }
}
