@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap');

/* =================================
   1. GLOBAL & BASE STYLES
   ================================= */

body {
  font-family: 'Inter', sans-serif;
  margin: 0;
}

/* =================================
   2. MAIN APP LAYOUT
   ================================= */

/* This container holds the sidebar and map */
#app-container {
  display: flex; /* Arrange sidebar and map in a row */
  height: 100vh; /* Full browser height */
}

/* The sidebar container */
#sidebar {
  width: 340px;
  padding: 10px 10px 0 10px; /* <-- CHANGED (Top, Right, Bottom, Left) */
  background-color: #ffffff;
  display: flex;
  flex-direction: column; /* Stack children vertically */
}

/* The map container */
#map {
  flex-grow: 1; /* Take up all remaining space */
  height: 100%;
}

/* =================================
   3. SIDEBAR: HEADER & CONTROLS
   ================================= */

#sidebar h2 {
  font-size: 22px;
  text-align: center;
  margin-top: 0px;
  margin-bottom: 10px;
}

#sidebar h2 .title-icon {
  width: 22px;
  height: 22px;
  vertical-align: middle;
}

/* --- Global Search (Top) --- */
#global-search-container {
  position: relative;
}

#global-search-box {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  box-sizing: border-box;
  border: 1px solid #696969;
  border-radius: 50px;
  font-size: 14px;
}

#clear-search-btn {
  position: absolute;
  right: 5px;
  top: 40%;
  transform: translateY(-50%);
  width: 25px;
  height: 25px;
  padding: 0;
  font-weight: normal;
  font-size: 16px;
  color: #999;
  background: transparent;
  border: none;
  cursor: pointer;
}

#clear-search-btn:hover {
  color: #333;
}

/* --- Filter Search (Traffic Lights) --- */
#filter-search-container {
  position: relative;
  margin-bottom: 10px;
}

#search-box {
  width: 100%;
  padding: 12px;
  box-sizing: border-box;
  border: 1px solid #696969;
  border-radius: 50px;
  padding-right: 35px;
  margin-bottom: 0;
  font-size: 14px;
}

#clear-filter-btn {
  position: absolute;
  right: 5px;
  top: 53%;
  transform: translateY(-50%);
  width: 25px;
  height: 25px;
  padding: 0;
  font-weight: normal;
  font-size: 16px;
  color: #999;
  background: transparent;
  border: none;
  cursor: pointer;
}

#clear-filter-btn:hover {
  color: #333;
}

/* --- "Find My Location" Button --- */
#find-me-btn {
  width: 100%;
  padding: 10px;
  margin-bottom: 15px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-size: 16px;
}

#find-me-btn:hover {
  background-color: #0056b3;
}

/* =================================
   4. SIDEBAR: SCROLLABLE CONTENT
   ================================= */

/* This area holds the filters and list */
#scrollable-area {
  flex-grow: 1;       /* Make this area fill the sidebar */
  overflow-y: hidden;   /* This container itself does NOT scroll */
  min-height: 0;      /* Required for flex scrolling */
  display: flex;
  flex-direction: column; /* Stack filters on top of list */
}

/* --- Traffic Light List (DESKTOP DEFAULT) --- */
#traffic-light-list {
  padding-left: 0;
  list-style-type: none; /* (You already have this) */
  flex-grow: 1;       /* Make the list fill the remaining space */
  overflow-y: auto;   /* Make the list scrollable */
  min-height: 0;      /* Required for flex scrolling */
}

/* --- Filter Checkbox Section --- */
#filter-controls {
  margin-bottom: 1px;
  padding-bottom: 6px;
  border-bottom: 1px solid #ddd;
}

#filter-controls strong {
  display: inline-block;
  margin-bottom: 8px;
}

/* This hides any old filter buttons */
#filter-controls button {
  display: none;
}

/* Wrappers for horizontal filter groups */
#filter-options-wrapper,
#intersection-options-wrapper {
  display: flex;   /* Aligns children in a row */
  flex-wrap: wrap; /* Allows them to wrap to the next line */
  margin-top: 5px;
}

#intersection-options-wrapper {
  margin-top: 0;
}

/* Individual filter (checkbox + label) */
.filter-option {
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  margin-right: 15px; /* Adds space between filters */
}

.filter-option input[type="checkbox"] {
  margin-right: 8px;
  width: 16px;
  height: 16px;
}

.filter-option label {
  font-size: 15px;
  cursor: pointer;
}

.filter-option label:hover {
  color: #007bff;
}

#traffic-light-list li {
  padding: 8px;
  cursor: pointer;
  border-radius: 10px;
  font-size: 15px;
  list-style-type: none;
}

#traffic-light-list li:hover {
  background-color: #ddd;
}

/* This class is added by JS */
#traffic-light-list li.active-list-item {
  background-color: #cedbfd;
  font-weight: normal;
  color: #005c99;
}

/* =================================
   5. RESPONSIVE STYLES (Mobile)
   ================================= */

@media (max-width: 700px) {

  /* 1. Stack the main containers */
  #app-container {
    flex-direction: column; /* Stack sidebar on top of map */
    height: auto;
  }

  /* 2. Sidebar takes top 50% */
  #sidebar {
    width: 100%;
    height: 50vh;
    box-sizing: border-box;
  }

  /* 3. Map takes bottom 50% */
  #map {
    width: 100%;
    height: 50vh;
  }

  #scrollable-area {
    display: block;     /* Revert from flex */
    overflow-y: auto;   /* Make this container scroll */
  }
  #traffic-light-list {
    flex-grow: 0;       /* Revert */
    overflow-y: visible; /* Revert */
    min-height: auto;   /* Revert */
  }

}
