.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

.sidebar {
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 300px;
  max-width: 80vw;
}

.left-pane-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.left-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.left-tab-btn {
  flex: 1;
  border: none;
  border-right: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  padding: 0.625rem 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 0.15s,
    color 0.15s;
}

.left-tab-btn:last-child {
  border-right: none;
}

.left-tab-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.left-tab-btn:focus-visible {
  outline: 0.125rem solid var(--accent-color);
  outline-offset: -0.125rem;
}

.left-tab-btn.active {
  background: var(--bg-secondary);
  color: var(--accent-color);
}

.left-tab-panel {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.routes-tab-panel {
  padding: 0;
  gap: 0;
}

.routes-tab-panel .search-container {
  border-bottom: 1px solid var(--border-color);
}

.routes-tab-panel .route-list {
  padding: 0.75rem;
}

.left-panel-title {
  margin: 0;
  font-size: 1rem;
}

.settings-section {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.about-list {
  margin-top: 0.25rem;
}

.search-container {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.search-title {
  font-size: 1.25rem;
  margin: 0 0 0.5rem;
}

.input-group {
  margin-bottom: 0.5rem;
}

.input-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-group input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  transition:
    border-color 0.2s,
    background-color 0.2s;
}

.input-group input.input-error {
  border-color: #dc3545;
  background-color: rgba(220, 53, 69, 0.05);
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.input-group input.input-error:focus {
  border-color: #dc3545;
}

.swap-locations-row {
  display: flex;
  justify-content: flex-end;
  margin: -0.25rem 0;
}

.swap-locations-btn {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.2rem 0.6rem;
  transition:
    background-color 0.2s,
    border-color 0.2s;
}

.swap-locations-btn:hover:not(:disabled) {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: #fff;
}

.swap-locations-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.route-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.route-empty {
  padding: 1rem;
}

.route-walking-distance {
  margin-top: 0.25rem;
  font-size: 0.8rem;
}

.route-card {
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition:
    transform 0.2s,
    border-color 0.2s;
}

.route-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-color);
}

.route-card.selected {
  border-color: var(--accent-color);
  background-color: rgba(0, 123, 255, 0.05);
}

.route-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-weight: bold;
}

.route-details {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.resizer {
  width: 10px;
  background-color: var(--divider-color);
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  z-index: 10;
}

.resizer:hover,
.resizer.active {
  background-color: var(--accent-color);
}

.resizer::after {
  content: "⋮";
  color: var(--text-secondary);
  font-size: 1.2rem;
  line-height: 0;
}

.map-container {
  flex: 1;
  position: relative;
  background-color: #e5e5e5;
}

.map-component-wrapper {
  position: relative;
  height: 100%;
  width: 100%;
}

.leaflet-mount {
  height: 100%;
  width: 100%;
}

.leaflet-container {
  height: 100%;
  width: 100%;
}

/* ── Time picker row ─────────────────────────────────────────── */
.time-row {
  display: flex;
  gap: 0.5rem;
}

.time-row select,
.time-row input[type="datetime-local"] {
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: border-color 0.2s;
}

.time-row select {
  flex: 0 0 auto;
}

.time-row input[type="datetime-local"] {
  flex: 1 1 0;
  min-width: 0;
}

.time-row select:focus,
.time-row input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--accent-color);
}

/* ── Form helpers ────────────────────────────────────────────── */
.search-error {
  margin: 0.25rem 0 0.25rem;
  font-size: 0.875rem;
  color: #dc3545;
}

.search-loading {
  margin: 0.25rem 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.search-tip {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ── Route polyline arrowheads ───────────────────────────────── */
.route-arrow-icon {
  background: transparent !important;
  border: none !important;
}

.route-arrow {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  filter: drop-shadow(0 0 0.125rem rgba(255, 255, 255, 0.9));
}

/* ── Map click popup ─────────────────────────────────────────── */
.map-click-menu-anchor {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 1001;
}

.map-click-menu-anchor::before {
  content: "";
  position: absolute;
  left: -0.375rem;
  top: -0.375rem;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: #fff;
  border: 0.125rem solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 0.0625rem 0.1875rem rgba(0, 0, 0, 0.18);
}

.map-click-popup {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, calc(-100% - 1rem));
  display: inline-flex;
  align-items: center;
  width: max-content;
  gap: 0.5rem;
  padding: 0.375rem 1.75rem 0.375rem 0.375rem;
}

.map-click-popup,
.leaflet-popup-content-wrapper {
  border-radius: 0.5rem;
  background: #fff;
  border: 0.0625rem solid rgba(0, 0, 0, 0.16);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.2);
}

.map-click-popup-close.leaflet-popup-close-button,
.leaflet-popup-close-button {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 1;
  width: 1.5rem;
  height: 1.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #999;
  padding: 0;
  transition: color 0.15s;
}

.map-click-popup-close.leaflet-popup-close-button:hover,
.leaflet-popup-close-button:hover {
  color: #333;
}

.map-click-popup::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.5rem;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 0.5rem solid transparent;
  border-right: 0.5rem solid transparent;
  border-top: 0.5rem solid #fff;
}

.map-popup-btn {
  padding: 0.375rem 0.75rem;
  border: none;
  border-radius: 0.25rem;
  background: var(--accent-color, #007ac9);
  color: #fff;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: background-color 0.15s;
}

.map-popup-btn:hover {
  background: var(--accent-hover, #005f99);
}

/* ── Leaflet popup styling (stop information) ──────────────────── */
.leaflet-popup {
  border-radius: 0.5rem;
}

.leaflet-popup-content-wrapper {
  padding: 0.75rem;
}

.leaflet-popup-content {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.leaflet-popup-tip-container {
  width: 100%;
  height: 1rem;
}

.leaflet-popup-tip {
  background: #fff;
  border: 0.0625rem solid rgba(0, 0, 0, 0.16);
  border-radius: 0 0 0.5rem 0.5rem;
}

.stop-sticky-tooltip {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 0.375rem;
  color: var(--text-primary) !important;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.375rem;
  box-shadow: 0 0.125rem 0.375rem rgba(0, 0, 0, 0.16);
  pointer-events: auto;
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
}

.leaflet-tooltip.stop-sticky-tooltip.leaflet-interactive {
  pointer-events: auto !important;
}

.stop-sticky-tooltip * {
  -webkit-user-select: text;
  user-select: text;
}

.stop-sticky-tooltip::before {
  border-top-color: var(--border-color);
}

/* ── Stats panel ─────────────────────────────────────────────── */
.stats-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stats-error {
  margin: 0;
  font-size: 0.8125rem;
  color: #dc3545;
}

.stats-section {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.stats-section-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-list {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.stats-row.stats-total {
  font-weight: 700;
  border-top: 1px solid var(--border-color);
  padding-top: 0.25rem;
  margin-top: 0.125rem;
}

.stats-row dt {
  color: var(--text-secondary);
  font-weight: normal;
}

.stats-row dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.stats-btn {
  align-self: flex-start;
  padding: 0.3125rem 0.625rem;
  border: 1px solid var(--border-color);
  border-radius: 0.25rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.8125rem;
  cursor: pointer;
  transition:
    background-color 0.15s,
    border-color 0.15s;
}

.stats-btn:hover:not(:disabled) {
  background: var(--bg-secondary);
  border-color: var(--accent-color);
}

.stats-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.stats-btn-danger {
  color: #dc3545;
  border-color: #dc3545;
}

.stats-btn-danger:hover:not(:disabled) {
  background: rgba(220, 53, 69, 0.08);
  border-color: #dc3545;
}
