*, *::before, *::after {
  transition: var(--color-transition);
  box-sizing: border-box; 
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  margin: 0;
  background: #f4f4f4;
  color: #333;
  transition: background 0.5s ease, color 0.5s ease;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

#app-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#map-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  padding-top: 0; /* Add padding for the moved title */
}

#map {
  width: 100%;
  height: 100%;
  z-index: 100;
}

/* 
  The definitive, high-specificity rule to override all other conflicting styles.
  This version provides a comfortable touch area with a wider visual indicator.
*/
body > #app-container > #dragHandle {
  /* Overriding properties from the culprit rule in components.css */
  position: static !important; 
  width: 70% !important; 
  height: 12px !important; /* A comfortable touch-target height */
  z-index: auto !important;
  padding: 0 !important;

  /* Our original styling */
  margin: 0 auto;
  background-color: transparent;
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* The visible line, now half the screen's width */
body > #app-container > #dragHandle::before {
  content: '' !important;
  width: 40vw !important; /* 50% of the viewport width */
  height: 4px !important;
  background-color: #bbb !important; 
  border-radius: 2px !important;
  box-shadow: none !important;
  transition: none !important;
}


#searchContainer {
    cursor: default; 
}

#mainContent {
  /* flex-basis: 30%; */ /* Removed this property to prevent conflict with width */
  background: #fff5f0;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  padding: 20px;
  padding-top: 10px;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

#mainContent h1 {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  color: #007BFF;
  background-color: transparent;
  padding: 0;
  margin: 0;
  text-align: center;
  font-size: 1.5em;
  width: 100%;
  z-index: 400;
  text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff;
}

#mainContent::-webkit-scrollbar {
  display: none;
}

#mapControls {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  width: 90%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

#mapControls > * {
  pointer-events: auto;
}

#mapControls h1 {
  color: #007BFF;
  background-color: transparent;
  display: inline;
  padding: 0;
}

#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 1);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 900;
  transition: opacity 0.5s ease;
  opacity: 1;
}

#loadingOverlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

#loadingContent {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#loadingText {
  font-size: 1.5em;
  color: #007BFF;
  text-align: center;
}

.leaflet-top.leaflet-left {
    top: 5px; 
}

.leaflet-top .leaflet-control {
    margin-top: 4px;
}

.leaflet-bar {
  box-shadow: 0 1px 5px rgba(0,0,0,0.65);
  border-radius: 4px;
}

.leaflet-bar a, 
.leaflet-bar a:hover {
    background-color: #fff;
    color: #333;
    border-bottom: 1px solid #ccc;
    width: 30px; 
    height: 30px; 
    line-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.leaflet-bar a:last-child {
    border-bottom: none;
}

.leaflet-bar a:hover {
    background-color: #f4f4f4;
}

.leaflet-control-custom .material-icons {
    font-size: 16px; 
    color: #333;
}

.leaflet-control-custom.active .material-icons {
    color: #007BFF !important;
}

.leaflet-control-custom.disabled {
    cursor: not-allowed;
    background-color: #e0e0e0 !important;
}

.leaflet-control-custom.disabled .material-icons {
    color: #999 !important;
}

.dark-mode .leaflet-bar a,
.dark-mode .leaflet-bar a:hover {
    background-color: #383838;
    color: #ddd;
    border-color: rgba(255, 255, 255, 0.3);
}

.dark-mode .leaflet-bar a:hover {
    background-color: #4a4a4a;
}

.dark-mode .leaflet-control-custom .material-icons {
    color: #ddd;
}

.dark-mode .leaflet-control-custom.active .material-icons {
    color: #4dabf7 !important; 
}

.dark-mode .leaflet-control-custom.disabled {
    background-color: #555 !important;
}

.dark-mode .leaflet-control-custom.disabled .material-icons {
    color: #777 !important;
}

.dark-mode #mainContent h1 {
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}


/* Desktop layout */
@media (min-width: 768px) {
  #app-container {
    flex-direction: row-reverse;
  }

  #mainContent {
    height: 100%;
    /* flex-basis: 35%; */ /* This was causing the issue, so I removed it. */
    border-top-left-radius: 0;
    border-top-right-radius: 20px;
    border-bottom-right-radius: 20px;
    border-bottom-left-radius: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  }

  #map-wrapper {
    flex: 1; /* Take up remaining space */
    height: 100%;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 0;
    padding-top: 0; /* Reset padding for desktop */
  }

  #mainContent h1 {
    position: static; /* Reset position for desktop */
    transform: none;
    margin-top: 15px;
    margin-bottom: 2px;
  }

  #dragHandle {
    width: 12px !important;
    height: 70% !important;
    cursor: ew-resize;
  }

  #dragHandle::before {
    width: 4px !important;
    height: 40vh !important;
  }

  #mapControls {
    left: auto;
    right: 20px; /* Adjust as needed */
    transform: none;
    align-items: flex-end;
  }
}
