* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: #2C2316;
  color: #E8DECE;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* --- Top bar (mobile only) --- */
#topbar {
  display: none;
}

/* --- Sidebar --- */
#sidebar {
  width: 380px;
  min-width: 380px;
  background: #3A2E22;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #5C4A35;
  z-index: 1000;
  overflow: hidden;
}

.sidebar-header {
  padding: 8px 14px;
  background: #2C2316;
  border-bottom: 1px solid #5C4A35;
  flex-shrink: 0;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  height: 40px;
}

.header-text h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1;
}

.subtitle {
  font-size: 0.7rem;
  color: #F5A623;
  margin-top: 2px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* --- Controls --- */
.controls {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid #5C4A35;
  flex-shrink: 0;
}

.locate-buttons {
  display: flex;
  gap: 8px;
}

.locate-buttons button {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  padding: 7px 10px;
  background: #4A3728;
  color: #C8B89A;
  border: 1px solid #5C4A35;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.locate-buttons button:hover {
  background: #5C4A35;
  color: #fff;
}

.locate-buttons button.active {
  background: #F5A623;
  color: #2C2316;
  border-color: #F5A623;
}

#btn-pick.picking {
  background: #E8960C;
  color: #2C2316;
  border-color: #E8960C;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Crosshair cursor when picking location */
#map.picking {
  cursor: crosshair !important;
}

/* --- Pick-mode banner --- */
.pick-banner {
  display: none;
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  background: #F5A623;
  color: #2C2316;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  animation: bannerSlideDown 0.25s ease;
  white-space: nowrap;
}

.pick-banner.visible {
  display: flex;
}

.pick-banner svg {
  flex-shrink: 0;
}

.pick-cancel {
  background: none;
  border: none;
  color: #2C2316;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0 0 0 6px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.pick-cancel:hover {
  opacity: 1;
}

@keyframes bannerSlideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.radius-control {
  display: none;
}

.radius-control.visible {
  display: block;
}

.radius-control label {
  font-size: 0.78rem;
  color: #C8B89A;
}

.radius-control strong {
  color: #F5A623;
}

#radius-slider {
  width: 100%;
  margin-top: 4px;
  accent-color: #F5A623;
}

.search-box input {
  width: 100%;
  padding: 8px 12px;
  background: #2C2316;
  border: 1px solid #5C4A35;
  border-radius: 8px;
  color: #E8DECE;
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input::placeholder {
  color: #8A7A66;
}

.search-box input:focus {
  border-color: #F5A623;
}

/* --- Tag Filters --- */
.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  padding: 4px 10px;
  background: #4A3728;
  color: #C8B89A;
  border: 1px solid #5C4A35;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.tag-pill:hover {
  background: #5C4A35;
  color: #fff;
}

.tag-pill.active {
  background: #F5A623;
  color: #2C2316;
  border-color: #F5A623;
}

/* --- Results --- */
.results-info {
  padding: 6px 14px;
  font-size: 0.75rem;
  color: #8A7A66;
  border-bottom: 1px solid #5C4A35;
  flex-shrink: 0;
}

#bar-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

#bar-list li {
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid #5C4A35;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.bar-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.bar-nearby-btn,
.bar-route-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #4A3728;
  border: 1px solid #5C4A35;
  border-radius: 6px;
  color: #F5A623;
  cursor: pointer;
  transition: background 0.15s;
}

.bar-nearby-btn:hover,
.bar-route-btn:hover {
  background: #5C4A35;
}

.bar-route-btn.in-route {
  background: #F5A623;
  color: #2C2316;
  border-color: #F5A623;
}

#bar-list li:hover {
  background: #2C2316;
}

#bar-list li.active {
  background: #4A3728;
  border-left: 3px solid #F5A623;
}

.bar-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
}

.bar-prato {
  font-size: 0.75rem;
  color: #F5A623;
  margin-top: 2px;
}

.bar-endereco {
  font-size: 0.72rem;
  color: #8A7A66;
  margin-top: 2px;
}

.bar-dist {
  font-size: 0.72rem;
  color: #4A7C3F;
  font-weight: 600;
  margin-top: 2px;
}

/* --- Route Panel --- */
.route-panel {
  border-bottom: 1px solid #5C4A35;
  flex-shrink: 0;
}

.route-panel .route-body {
  display: none;
}

.route-panel.expanded .route-body {
  display: block;
}

.route-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
}

.route-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.route-chevron {
  font-size: 0.7rem;
  color: #8A7A66;
  transition: transform 0.2s;
}

.route-panel.expanded .route-chevron {
  transform: rotate(90deg);
}

.route-header-summary {
  font-size: 0.7rem;
  color: #4A7C3F;
  font-weight: 600;
}

.route-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #F5A623;
}

.route-actions {
  display: flex;
  gap: 6px;
}

.route-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #4A3728;
  border: 1px solid #5C4A35;
  border-radius: 6px;
  color: #C8B89A;
  cursor: pointer;
  transition: all 0.15s;
}

.route-btn:hover:not(:disabled) {
  background: #5C4A35;
  color: #F5A623;
}

.route-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

#route-list {
  list-style: none;
  padding: 0;
  max-height: 180px;
  overflow-y: auto;
}

.route-empty {
  padding: 8px 16px;
  font-size: 0.75rem;
  color: #8A7A66;
}

.route-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
}

.route-number {
  width: 20px;
  height: 20px;
  background: #F5A623;
  color: #2C2316;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.route-item-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.route-item-name {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-item-prato {
  display: block;
  font-size: 0.7rem;
  color: #C8B89A;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-item-dist {
  font-size: 0.7rem;
  color: #4A7C3F;
  font-weight: 600;
  flex-shrink: 0;
}

.route-item-remove {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #8A7A66;
  cursor: pointer;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.route-item-remove:hover {
  color: #e94560;
}

.route-total {
  padding: 0 16px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #4A7C3F;
}

/* --- Popup navigation buttons --- */
.popup-card-nav {
  margin-top: 10px;
}

.popup-card-nav-btn {
  width: 100%;
  padding: 8px;
  border: 1px solid #5C4A35;
  border-radius: 6px;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: #5C4A35;
}

.popup-card-nav-choices {
  display: flex;
  gap: 6px;
}

.popup-card-nav-choice {
  flex: 1;
  padding: 8px;
  border: 1px solid #5C4A35;
  border-radius: 6px;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: #5C4A35;
}

/* --- Popup actions --- */
.popup-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.popup-card-nearby,
.popup-card-route {
  flex: 1;
  padding: 8px;
  border: 1px solid #5C4A35;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.popup-card-nearby {
  background: #4A3728;
  color: #F5A623;
}

.popup-card-nearby:hover {
  background: #5C4A35;
}

.popup-card-route {
  background: #F5A623;
  color: #2C2316;
  border-color: #F5A623;
}

.popup-card-route:hover {
  background: #E8960C;
}

.popup-card-route.in-route {
  background: #4A7A4A;
  border-color: #4A7A4A;
  color: #fff;
}

.popup-card-route.in-route:hover {
  background: #3D6B3D;
}

/* --- Footer --- */
.sidebar-footer {
  padding: 8px 14px;
  border-top: 1px solid #5C4A35;
  text-align: center;
  font-size: 0.65rem;
  color: #8A7A66;
  line-height: 1.5;
  flex-shrink: 0;
}

.sidebar-footer a {
  color: #F5A623;
  text-decoration: none;
  font-weight: 600;
}

.sidebar-footer a:hover {
  text-decoration: underline;
}

/* --- Map --- */
#map {
  flex: 1;
  z-index: 1;
}

/* --- Map disclaimer --- */
#map-disclaimer {
  position: fixed;
  bottom: 4px;
  right: 8px;
  font-size: 0.6rem;
  color: rgba(100, 80, 60, 0.6);
  z-index: 500;
  pointer-events: none;
}

/* --- Overlay (mobile) --- */
#sidebar-overlay {
  display: none;
}

/* --- Map Markers (mini pins) --- */
.map-card-wrapper {
  background: none !important;
  border: none !important;
}

.map-card {
  cursor: pointer;
}

.map-card-mini {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #3A2E22;
  border: 2px solid #F5A623;
  border-radius: 20px;
  padding: 3px 10px 3px 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  transition: all 0.15s;
}

.map-card-dot {
  width: 8px;
  height: 8px;
  background: #F5A623;
  border-radius: 50%;
  flex-shrink: 0;
}

.map-card-name {
  font-size: 0.68rem;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
}

.map-card:hover .map-card-mini {
  background: #4A3728;
  border-color: #fff;
}

/* --- Popup (expanded card on click) --- */
.popup-card-wrapper .leaflet-popup-content-wrapper {
  background: #3A2E22;
  border-radius: 12px;
  border: 1px solid #5C4A35;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  padding: 0;
  overflow: hidden;
}

.popup-card-wrapper .leaflet-popup-tip {
  background: #3A2E22;
}

.popup-card-wrapper .leaflet-popup-content {
  margin: 0;
  width: 100% !important;
}

.popup-card {
  width: 260px;
}

.popup-card-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.popup-card-body {
  padding: 12px 14px;
}

.popup-card-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.popup-card-prato {
  font-size: 0.85rem;
  color: #F5A623;
  font-weight: 600;
}

.popup-card-desc {
  font-size: 0.78rem;
  color: #C8B89A;
  margin-top: 4px;
  line-height: 1.4;
}

.popup-card-addr {
  font-size: 0.75rem;
  color: #8A7A66;
  margin-top: 8px;
}

.popup-card-dist {
  font-size: 0.75rem;
  color: #4A7C3F;
  font-weight: 600;
  margin-top: 4px;
}

.popup-card-nearby {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  background: #4A3728;
  color: #F5A623;
  border: 1px solid #5C4A35;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.popup-card-nearby:hover {
  background: #5C4A35;
}

.user-marker {
  background: #4A7C3F;
  border: 3px solid #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  box-shadow: 0 0 12px rgba(74, 124, 63, 0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(74, 124, 63, 0.6); }
  50% { box-shadow: 0 0 24px rgba(74, 124, 63, 0.9); }
}

/* Cluster style overrides */
.marker-cluster-small {
  background-color: rgba(245, 166, 35, 0.3) !important;
}
.marker-cluster-small div {
  background-color: #F5A623 !important;
  color: #2C2316 !important;
  font-weight: 700;
}
.marker-cluster-medium {
  background-color: rgba(232, 150, 12, 0.3) !important;
}
.marker-cluster-medium div {
  background-color: #E8960C !important;
  color: #2C2316 !important;
  font-weight: 700;
}
.marker-cluster-large {
  background-color: rgba(74, 55, 40, 0.4) !important;
}
.marker-cluster-large div {
  background-color: #4A3728 !important;
  color: #F5A623 !important;
  font-weight: 700;
}

/* ============================
   MOBILE (max-width: 768px)
   ============================ */
@media (max-width: 768px) {
  #app {
    flex-direction: column;
  }

  /* Top bar visible - fixed at top */
  #topbar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    background: #2C2316;
    border-bottom: 1px solid #5C4A35;
    z-index: 1100;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
  }

  #topbar .header-text {
    text-align: center;
  }

  #topbar .header-text h1 {
    font-size: 1rem;
  }

  /* Hamburger button */
  #btn-menu {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
  }

  #btn-menu span {
    display: block !important;
    height: 3px;
    width: 100%;
    background: #F5A623;
    border-radius: 2px;
    transition: all 0.3s;
  }

  #btn-menu.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  #btn-menu.open span:nth-child(2) {
    opacity: 0;
  }
  #btn-menu.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* Hide desktop header inside sidebar */
  .desktop-only {
    display: none !important;
  }

  /* Sidebar = slide-over panel below fixed topbar */
  #sidebar {
    position: fixed;
    top: 48px;
    left: -100%;
    width: 85%;
    max-width: 340px;
    min-width: unset;
    height: calc(100dvh - 48px);
    z-index: 2000;
    transition: left 0.3s ease;
    border-right: 1px solid #5C4A35;
  }

  #sidebar.open {
    left: 0;
  }

  /* Overlay behind sidebar */
  #sidebar-overlay {
    display: none;
    position: fixed;
    top: 48px;
    left: 0;
    width: 100%;
    height: calc(100dvh - 48px);
    background: rgba(0, 0, 0, 0.5);
    z-index: 1500;
  }

  #sidebar-overlay.visible {
    display: block;
  }

  /* Map takes full space below fixed topbar */
  #map {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
  }
}

/* ── Welcome Tutorial Dialog ── */

.welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: welcomeFadeIn 0.3s ease;
}

@keyframes welcomeFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.welcome-dialog {
  background: #3A2E22;
  border: 1px solid #5C4A35;
  border-radius: 16px;
  max-width: 400px;
  width: 100%;
  padding: 32px 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: welcomeSlideUp 0.3s ease;
}

@keyframes welcomeSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.welcome-steps {
  min-height: 200px;
  display: flex;
  align-items: center;
}

.welcome-step {
  display: none;
  text-align: center;
  width: 100%;
}

.welcome-step.active {
  display: block;
  animation: welcomeStepIn 0.25s ease;
}

@keyframes welcomeStepIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

.welcome-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.welcome-step h2 {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: #F5A623;
  margin: 0 0 12px;
}

.welcome-step p {
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  color: #E8DECE;
  line-height: 1.5;
  margin: 0 0 8px;
}

.welcome-step p:last-child {
  margin-bottom: 0;
}

.welcome-step strong {
  color: #F5A623;
}

.welcome-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 24px 0 20px;
}

.welcome-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5C4A35;
  transition: background 0.2s, transform 0.2s;
  cursor: pointer;
}

.welcome-dot.active {
  background: #F5A623;
  transform: scale(1.25);
}

.welcome-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.welcome-btn-skip {
  background: none;
  border: none;
  color: #8A7A66;
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 8px 4px;
  transition: color 0.15s;
}

.welcome-btn-skip:hover {
  color: #C8B89A;
}

.welcome-btn-next {
  background: #F5A623;
  color: #2C2316;
  border: none;
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 28px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.welcome-btn-next:hover {
  background: #E8960C;
}
