/* =====================
   Global Styles
   ===================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body, html {
  height: 100%;
  font-family: 'Lexend', sans-serif;
  background-color: #1F1F1F;
  color: #FFFFFF;
  overflow: hidden; /* Prevent body scrollbars if map is full screen */
  touch-action: manipulation; /* Apply to the whole
}

/* =====================
   Logo Box Styling
   ===================== */

.logo-box {
  position: fixed;
  top: 10px;
  left: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 8px;
  z-index: 1001;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  border: none;
  cursor: pointer;
}

.logo-box:hover,
.logo-box:focus {
  background-color: rgba(0, 0, 0, 0.8);
}

.logo-box:focus {
  outline: 2px solid #FF6347;
}

.logo-icon {
  width: 30px;
  height: 30px;
  margin-right: 8px;
}

.logo-text {
  font-family: 'Lexend', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #FFFFFF;
  white-space: nowrap;
}

/* =====================
   Notification Banner Styling
   ===================== */
.notification-banner {
  position: fixed;
  top: 10px;
  left: 10px;
  transform: translateY(calc(-100% - 10px));
  background-color: #2B2B2B;
  color: #FFFFFF;
  padding: 10px 15px;
  border-radius: 0 0 8px 8px;
  z-index: 1000;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-start;
  max-width: 380px;
  opacity: 0;
  transition: opacity 0.4s ease-in-out, transform 0.4s ease-in-out;
  cursor: pointer;
}

.notification-banner.show {
  opacity: 1;
  transform: translateY(40px);
}

.notification-content {
  flex-grow: 1;
}

.notification-title {
  font-weight: bold;
  font-size: 0.95em;
  margin-bottom: 4px;
  color: #FF8C00;
}

.notification-details {
  font-size: 0.85em;
  line-height: 1.4;
  color: #E0E0E0;
}

.dismiss-notification-btn {
  background: none;
  border: none;
  color: #AAAAAA;
  font-size: 20px;
  margin-left: 10px;
  cursor: pointer;
  padding: 0 0 0 5px;
  line-height: 1;
  align-self: flex-start;
}
.dismiss-notification-btn:hover {
  color: #FFFFFF;
}


/* =====================
   Layer List Panel Styling
   ===================== */

.layer-list-panel {
  position: absolute;
  top: 60px;
  left: 10px;
  width: 250px;
  max-height: 400px;
  background-color: #2B2B2B;
  border: 1px solid #555;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  padding: 10px;
  z-index: 1002;
  display: none;
  overflow-y: auto;
  border-radius: 5px;
  font-family: 'Nunito', sans-serif;
  transition: top 0.4s ease-in-out; /* Smooth transition for top */
}

/* If notification banner is present and layer list opens, push layer list down */
body.notification-banner-visible .layer-list-panel.active {
  top: calc(40px + 10px + 5px + 80px); /* logo height + banner top + spacing + approx banner actual height */
}


.layer-list-panel.active {
  display: block;
}

.layer-list-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.layer-list-panel .panel-header h3 {
  margin: 0;
  font-size: 1.2em;
  font-family: 'Nunito', sans-serif;
  color: #FFFFFF;
}

.layer-list-panel .close-btn {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: #FFFFFF;
}
.layer-list-panel .close-btn:hover {
    color: #FF6347;
}

.layer-list-panel .panel-content {}

.layer-list-panel .layer-item {
  margin-bottom: 8px;
}

.layer-list-panel .layer-item label { /* General label for checkbox */
  margin-left: 5px;
  font-size: 14px;
  color: #FFFFFF;
  vertical-align: middle;
}

.layer-list-panel .layer-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #FF6347;
  vertical-align: middle;
}

.layer-list-panel .layer-item input[type="checkbox"]:focus {
  outline: 2px solid #FF6347;
}

/* Styles for smoke layer item with opacity slider */
.layer-list-panel .smoke-layer-item {
  display: flex;
  flex-direction: column; /* Stack checkbox/label and slider */
  align-items: flex-start; /* Align items to the start */
}

.layer-list-panel .smoke-layer-item .layer-item-main-controls {
  display: flex; /* For checkbox and its label */
  align-items: center;
  margin-bottom: 5px; /* Space between checkbox/label and slider */
}

.layer-list-panel .opacity-slider-container {
  display: flex;
  align-items: center;
  width: 100%; /* Make slider container take full width of item */
  padding-left: 21px; /* Indent to align with text of checkbox label (16px checkbox + 5px margin) */
}

.layer-list-panel .opacity-slider-label {
  font-size: 12px;
  color: #CCCCCC;
  margin-right: 5px;
  white-space: nowrap;
}

.layer-list-panel .opacity-slider {
  flex-grow: 1; /* Slider takes remaining space */
  height: 6px; /* Reduced height */
  -webkit-appearance: none;
  appearance: none;
  background: #444; /* Slider track color */
  border-radius: 3px; /* Adjusted radius */
  cursor: pointer;
}

.layer-list-panel .opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px; /* Reduced thumb size */
  height: 12px; /* Reduced thumb size */
  background: #FF6347; /* Slider thumb color */
  border-radius: 50%;
  border: 1px solid #FFFFFF;
}

.layer-list-panel .opacity-slider::-moz-range-thumb {
  width: 12px; /* Reduced thumb size */
  height: 12px; /* Reduced thumb size */
  background: #FF6347;
  border-radius: 50%;
  border: 1px solid #FFFFFF;
  cursor: pointer;
}

.layer-list-panel .opacity-value-display {
  font-size: 12px;
  color: #CCCCCC;
  margin-left: 8px;
  min-width: 30px; /* Ensure space for "100%" */
  text-align: right;
}


/* =====================
   Fixed Vertical Toolbar Styling
   ===================== */

.vertical-toolbar {
  position: fixed;
  top: 10px;
  right: 10px;
  width: 60px;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  transition: top 0.4s ease-in-out;
}

body.notification-banner-visible .vertical-toolbar {
    top: calc(40px + 10px + 80px + 10px); /* logo H + banner top + approx banner H + spacing */
    /* Adjust 80px based on actual banner height */
}


.vertical-toolbar .toolbar-btn {
  background-color: transparent;
  border: none;
  color: #FFFFFF;
  font-size: 24px;
  cursor: pointer;
  padding: 15px;
  margin: 10px 0;
  transition: background-color 0.3s ease, color 0.3s ease;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  position: relative;
}

.vertical-toolbar .toolbar-btn:hover,
.vertical-toolbar .toolbar-btn:focus {
  background-color: rgba(255, 255, 255, 0.1);
  color: #FF6347;
  outline: none;
}

.vertical-toolbar .toolbar-btn:active {
  background-color: rgba(255, 255, 255, 0.2);
}

.vertical-toolbar .toolbar-btn#historicalFiresBtn.active {
  background-color: rgba(255, 99, 71, 0.3);
  color: #FF6347;
}


.vertical-toolbar .toolbar-btn[title]::after {
  content: attr(title);
  position: absolute;
  left: -210px;
  top: 50%;
  transform: translateY(-50%);
  background-color: #333;
  color: #fff;
  padding: 5px 8px;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 14px;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out 0.3s, visibility 0s linear 0.5s;
}

.vertical-toolbar .toolbar-btn:hover::after,
.vertical-toolbar .toolbar-btn:focus::after {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0.3s, 0.3s;
}

.vertical-toolbar .toolbar-btn#historicalFiresBtn.active:hover::after,
.vertical-toolbar .toolbar-btn#historicalFiresBtn.active:focus::after {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition-delay: 0s !important;
}


/* =====================
   Basemap Dropdown Styling
   ===================== */

.basemap-dropdown {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 100%;
  margin-right: 10px;
  width: 200px;
  background-color: #2B2B2B;
  padding: 10px;
  border-radius: 8px;
  box-shadow: -2px 2px 6px rgba(0, 0, 0, 0.4);
  z-index: 1001;
  display: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-50%) translateX(10px);
  transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out, visibility 0s linear 0.2s;
}

.basemap-dropdown.active {
  display: block;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
  transition-delay: 0s;
}

.basemap-dropdown select {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 4px;
  background-color: #1F1F1F;
  color: #FFFFFF;
  font-size: 14px;
  cursor: pointer;
}

.basemap-dropdown select:focus {
  outline: 2px solid #FF6347;
}

/* =====================
   Search Panel Styling
   ===================== */

#searchPanel {
  position: fixed;
  top: 60px;
  left: 10px;
  width: 300px;
  max-height: 350px;
  background-color: #2B2B2B;
  color: #FFFFFF;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
  z-index: 1002;
  padding: 20px;
  border-radius: 8px;
  display: none;
  overflow-y: auto;
  transition: top 0.4s ease-in-out; /* Smooth transition for top */
}

body.notification-banner-visible #searchPanel.active {
    top: calc(40px + 10px + 5px + 80px); /* logo H + banner top + spacing + approx banner H */
}


#searchPanel.active {
  display: block;
}

#searchPanel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

#searchPanel h2 {
  font-size: 20px;
}

#searchPanel .close-panel-btn {
  font-size: 24px;
  color: #fff;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
}
#searchPanel .close-panel-btn:hover {
  color: #FF6347;
}

#searchPanel input[type="text"] {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  background-color: #1F1F1F;
  color: #FFFFFF;
  border: 1px solid #555;
  border-radius: 4px;
}

#searchResults {
  list-style-type: none;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
}

#searchResults li {
  padding: 10px;
  border-bottom: 1px solid #444;
  cursor: pointer;
}

#searchResults li:hover {
  background-color: #333;
}

/* =====================
   Map Container Styling
   ===================== */

#map {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

/* =====================
   Fullscreen About Panel Styling
   ===================== */

#aboutPanel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(43, 43, 43, 0.98);
  color: #FFFFFF;
  z-index: 1500;
  padding: 20px;
  display: none;
  overflow-y: auto;
}

#aboutPanel.active {
  display: block;
}

#aboutPanel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

#aboutPanel h2 {
  font-size: 24px;
}

#aboutPanel p {
  margin-bottom: 15px;
  font-size: 16px;
  line-height: 1.6;
}

#aboutPanel a {
  color: #FF6347;
  text-decoration: none;
}

#aboutPanel a:hover {
  text-decoration: underline;
}

#aboutPanel .close-panel-btn {
  font-size: 36px;
  color: #fff;
  background: none;
  border: none;
  cursor: pointer;
}
#aboutPanel .close-panel-btn:hover {
  color: #FF6347;
}

#aboutPanel .panel-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

/* =====================
   Modal Styling (Share Map & Smoke Info)
   ===================== */

.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
}
.modal.active {
    display: flex;
}

.modal-content {
  background-color: #1F1F1F;
  padding: 25px 20px;
  border: 1px solid #444;
  width: 80%;
  max-width: 550px;
  color: #FFFFFF;
  border-radius: 8px;
  position: relative;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  animation: fadeInModal 0.3s ease-out;
  max-height: 80vh;
  overflow-y: auto;
}

/* Specific styles for Smoke Info Modal content */
.smoke-info-modal-content h2 {
  font-size: 1.5em;
  margin-bottom: 15px;
  color: #FF8C00;
}
.smoke-info-modal-content h4 {
  font-size: 1.1em;
  color: #FF6347;
  margin-top: 15px;
  margin-bottom: 8px;
  border-bottom: 1px solid #444;
  padding-bottom: 4px;
}
.smoke-info-modal-content p,
.smoke-info-modal-content li {
  font-size: 0.95em;
  line-height: 1.6;
  margin-bottom: 8px;
  color: #E0E0E0;
}
.smoke-info-modal-content ul {
  list-style-type: disc;
  padding-left: 20px;
  margin-bottom: 15px;
}
.smoke-info-modal-content li strong {
  color: #FFFFFF;
}
.smoke-info-modal-content .modal-intro {
  margin-bottom: 20px;
}
.smoke-info-modal-content .modal-separator {
  border: 0;
  height: 1px;
  background-color: #444;
  margin: 20px 0;
}
.smoke-info-modal-content .modal-disclaimer {
  font-style: italic;
  font-size: 0.9em;
  color: #B0B0B0;
}


@keyframes fadeInModal {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal .close-btn {
  color: #aaa;
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.2s ease;
  background: none;
  border: none;
  padding: 5px;
  line-height: 1;
}

.modal .close-btn:hover,
.modal .close-btn:focus {
  color: #fff;
}

#shareMapURL {
    width: 100%;
    padding: 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #2B2B2B;
    color: #FFFFFF;
    font-size: 0.9em;
    margin-bottom: 15px;
}
#copyURLBtn {
    margin-top: 0;
    padding: 8px 12px;
    font-size: 0.9em;
    background-color: #FF6347;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
#copyURLBtn:hover {
    background-color: #E0523A;
}

.modal-content::-webkit-scrollbar { width: 8px; }
.modal-content::-webkit-scrollbar-track { background: #2b2b2b; border-radius: 4px; }
.modal-content::-webkit-scrollbar-thumb { background-color: #555; border-radius: 4px; }

/* =====================
   Info Box Styling
   ===================== */

#infoBox {
  position: fixed;
  top: 80px;
  right: 80px;
  width: 300px;
  max-width: 300px;
  max-height: 250px;
  overflow-y: auto;
  background-color: rgba(43, 43, 43, 0.9);
  color: #FFFFFF;
  padding: 10px;
  border-radius: 8px;
  z-index: 1000;
  display: none;
}

#infoBox.active {
  display: block;
}

#infoBox h2, #infoBox h3 {
  margin-top: 0;
  font-size: 14px;
  margin-bottom: 8px;
}

#infoBox p {
  font-size: 10px;
  line-height: 1.2;
  margin-bottom: 4px;
}

#infoBox strong {
  font-size: 11px;
  font-weight: bold;
  color: #FF6347;
}

#infoBox span.value {
  font-size: 10px;
  font-weight: normal;
  color: #FFFFFF;
}

#infoBox a {
  color: #FF6347;
  text-decoration: none;
  font-size: 10px;
}

#infoBox a:hover {
  text-decoration: underline;
}

#infoBox::-webkit-scrollbar { width: 6px; }
#infoBox::-webkit-scrollbar-track { background: #2b2b2b; border-radius: 4px; }
#infoBox::-webkit-scrollbar-thumb { background-color: #555; border-radius: 4px; }


/* =====================
   Historical Fires Control Panel
   ===================== */
#historicalFiresPanel {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(43, 43, 43, 0.9);
  padding: 10px 15px;
  border-radius: 8px;
  display: none;
  width: auto;
  min-width: 260px;
  max-width: 320px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  font-size: 0.9em;
}

#historicalFiresPanel .year-input-container {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

#historicalFiresPanel .year-input-container label {
  color: white;
  margin-right: 8px;
  margin-bottom: 0;
  font-size: 1em;
  white-space: nowrap;
}

#historicalFiresPanel input[type="number"] {
  flex-grow: 1;
  width: 100px;
  padding: 6px;
  border-radius: 4px;
  border: 1px solid #555;
  background-color: #1F1F1F;
  color: #FFFFFF;
  font-size: 1em;
}

#historicalFiresPanel .checkbox-container {
  margin-top: 0;
  display: flex;
  align-items: center;
}
#historicalFiresPanel .checkbox-container input[type="checkbox"] {
  margin-right: 8px;
  width: 15px;
  height: 15px;
  accent-color: #FF6347;
  flex-shrink: 0;
}
#historicalFiresPanel .checkbox-container label {
  margin-bottom: 0;
  font-size: 1em;
  color: #f0f0f0;
}


/* =====================
   Popup Content Styling (Mapbox GL Popups)
   ===================== */
.mapboxgl-popup-content {
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  color: #333;
  background-color: #ffffff;
  padding: 10px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.mapboxgl-popup-content h3 { margin: 0 0 5px; font-size: 16px; }
.mapboxgl-popup-close-button { color: #333; }
.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip { border-top-color: #ffffff; }
.mapboxgl-popup-anchor-top .mapboxgl-popup-tip { border-bottom-color: #ffffff; }
.mapboxgl-popup-anchor-left .mapboxgl-popup-tip { border-right-color: #ffffff; }
.mapboxgl-popup-anchor-right .mapboxgl-popup-tip { border-left-color: #ffffff; }


/* =====================
   Marker Styling (Disaster, Volcano)
   ===================== */
.marker {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.disaster-marker { width: 20px; height: 20px; }

/* =====================
   Legend Styling
   ===================== */

.legend-toggle-btn {
  position: fixed;
  bottom: 30px;
  left: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  color: #FFFFFF;
  border: none;
  border-radius: 4px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.legend-toggle-btn:hover,
.legend-toggle-btn:focus {
  background-color: rgba(0, 0, 0, 0.9);
  color: #FF6347;
  outline: none;
}

.legend-toggle-btn:focus {
  outline: 2px solid #FF6347;
  outline-offset: 1px;
}

.legend-panel {
  position: fixed;
  bottom: 75px;
  left: 10px;
  width: 280px;
  max-height: calc(100vh - 95px - 20px);
  background-color: #2B2B2B;
  border: 1px solid #555;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  padding: 10px;
  z-index: 1002;
  display: none;
  overflow-y: auto; /* This can clip absolutely positioned children if they extend outside */
  border-radius: 5px;
  font-family: 'Nunito', sans-serif;
  color: #FFFFFF;
}

.legend-panel.active {
  display: block;
}

.legend-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.legend-panel .panel-header h3 {
  margin: 0;
  font-size: 1.1em;
  font-family: 'Nunito', sans-serif;
  color: #FFFFFF;
}

.legend-panel .close-btn {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: #FFFFFF;
}
.legend-panel .close-btn:hover {
    color: #FF6347;
}

.legend-panel .panel-content {}

.legend-panel .panel-content h4 {
  font-size: 1em;
  margin-top: 12px;
  margin-bottom: 8px;
  color: #FF6347;
  padding-bottom: 3px;
  border-bottom: 1px solid #444;
}
.legend-panel .panel-content h4:first-child {
  margin-top: 0;
}

.legend-panel .legend-group {
  list-style: none;
  padding-left: 0;
  margin-bottom: 15px;
}

.legend-panel .legend-group li {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  font-size: 13px;
  color: #E0E0E0;
}

.legend-panel .legend-color {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  display: inline-block;
  flex-shrink: 0;
  box-sizing: border-box;
  border-radius: 3px;
  vertical-align: middle;
}
.legend-panel .legend-group li > span[style*="background-color: rgba"],
.legend-panel .legend-group li > span[style*="background-color: #ff0000"],
.legend-panel .legend-group li > span[style*="background-color: #ff4500"],
.legend-panel .legend-group li > span[style*="background-color: #ff7f50"],
.legend-panel .legend-group li > span[style*="background-color: #696969"] {
  border-radius: 50%; /* Make specific fire status colors circular */
}

/* Gradient icon for smoke legend item */
.legend-panel .legend-group li#smokeLegendTrigger .smoke-gradient-icon {
  /* Representative gradient of the 13-step ramp */
  background-image: linear-gradient(to right, #81d4fa 0%, #a5d6a7 25%, #ffee58 50%, #ff9800 70%, #d81b60 85%, #4a148c 100%);
  border: 1px solid #444; /* Add a subtle border to the gradient box */
}


.legend-panel .legend-icon-img {
  width: 20px;
  height: 20px;
  margin-right: 10px;
  vertical-align: middle;
  flex-shrink: 0;
}

.legend-panel::-webkit-scrollbar { width: 6px; }
.legend-panel::-webkit-scrollbar-track { background: #1F1F1F; border-radius: 3px; }
.legend-panel::-webkit-scrollbar-thumb { background-color: #555; border-radius: 3px; }

/* =====================
   Smoke Legend Color Ramp Popup
   ===================== */

#smokeLegendItemContainer {
  position: relative; /* Establishes positioning context for the popup */
}

.legend-panel .legend-group li#smokeLegendTrigger {
  cursor: help;
}

.smoke-color-ramp-popup {
  display: none;
  position: absolute;
  /* Positioned to appear above its containing section (#smokeLegendItemContainer) */
  top: 0; /* Align top of popup with top of #smokeLegendItemContainer */
  left: 10px; /* Indent slightly from the left edge of legend panel */
  transform: translateY(-100%) translateY(-10px); /* Moves it up by its own height + 10px gap */
  
  width: 230px;
  background-color: #1F1F1F;
  color: #E0E0E0;
  border: 1px solid #555;
  border-radius: 5px;
  padding: 10px 12px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
  z-index: 1005; /* Ensures it's above other legend panel content (if panel is not scrolling to clip) */
  font-family: 'Nunito', sans-serif;
}

.smoke-color-ramp-popup .legend-ramp-title {
  font-weight: bold;
  font-size: 0.9em;
  margin-bottom: 8px;
  color: #FFFFFF;
  text-align: center;
}

.smoke-color-ramp-popup .legend-ramp-item {
  display: flex;
  align-items: center;
  margin-bottom: 3px; /* Slightly reduced margin for more items */
  font-size: 0.8em; /* Slightly smaller text for ramp details */
}
.smoke-color-ramp-popup .legend-ramp-item:last-child {
  margin-bottom: 0;
}

.smoke-color-ramp-popup .legend-ramp-item .color-box {
  width: 18px; /* Slightly smaller to fit more items if needed */
  height: 10px; /* Slightly smaller */
  margin-right: 8px;
  border: 1px solid #333;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Updated colors for smoke ramp based on SLD */
.smoke-color-ramp-popup .legend-ramp-item .color-s1  { background-color: #81d4fa; } /* 1 µg/m³ */
.smoke-color-ramp-popup .legend-ramp-item .color-s2  { background-color: #4dd0e1; } /* 10 µg/m³ */
.smoke-color-ramp-popup .legend-ramp-item .color-s3  { background-color: #a5d6a7; } /* 20 µg/m³ */
.smoke-color-ramp-popup .legend-ramp-item .color-s4  { background-color: #66bb6a; } /* 30 µg/m³ */
.smoke-color-ramp-popup .legend-ramp-item .color-s5  { background-color: #d4e157; } /* 40 µg/m³ */
.smoke-color-ramp-popup .legend-ramp-item .color-s6  { background-color: #ffee58; } /* 50 µg/m³ */
.smoke-color-ramp-popup .legend-ramp-item .color-s7  { background-color: #ffca28; } /* 60 µg/m³ */
.smoke-color-ramp-popup .legend-ramp-item .color-s8  { background-color: #ff9800; } /* 70 µg/m³ */
.smoke-color-ramp-popup .legend-ramp-item .color-s9  { background-color: #f44336; } /* 80 µg/m³ */
.smoke-color-ramp-popup .legend-ramp-item .color-s10 { background-color: #e53935; } /* 90 µg/m³ */
.smoke-color-ramp-popup .legend-ramp-item .color-s11 { background-color: #d81b60; } /* 100 µg/m³ */
.smoke-color-ramp-popup .legend-ramp-item .color-s12 { background-color: #8e24aa; } /* 250 µg/m³ */
.smoke-color-ramp-popup .legend-ramp-item .color-s13 { background-color: #4a148c; } /* 500 µg/m³ */


/* =====================
   Responsive Adjustments
   ===================== */

@media (max-width: 767px) {
  .logo-box { top: 10px; left: 10px; padding: 5px 8px; }
  .logo-icon { width: 25px; height: 25px; margin-right: 5px; }
  .logo-text { font-size: 14px; }
  
  .notification-banner { max-width: calc(100vw - 20px); }
  body.notification-banner-visible .layer-list-panel.active,
  body.notification-banner-visible #searchPanel.active {
      top: calc(40px + 10px + 5px + 80px);
  }
  body.notification-banner-visible .vertical-toolbar {
      top: calc(40px + 10px + 80px + 5px);
  }


  .basemap-dropdown { width: 180px; margin-right: 5px; }

  .modal-content {
    width: 90%; margin: 10% auto; padding: 15px 10px;
  }
  .modal .close-btn { font-size: 20px; top: 8px; right: 10px; }

  #infoBox {
    width: 250px;
    max-width: calc(100vw - 60px - 10px - 10px - 10px);
    right: calc(60px + 10px + 10px);
    top: 60px;
    font-size: 0.9em;
  }
  body.notification-banner-visible #infoBox { /* Push down infobox if banner is active */
    top: calc(40px + 10px + 5px + 80px + 10px); /* banner offset + default top */
  }


  #infoBox h2, #infoBox h3 { font-size: 13px; }
  #infoBox p { font-size: 9px; }
  #infoBox strong { font-size: 10px; }
  #infoBox span.value, #infoBox a { font-size: 9px; }

  #searchPanel {
    width: calc(100vw - 20px - 60px - 10px);
    left: 10px; top: 60px;
    max-height: 60vh;
  }
  #searchPanel input[type="text"] {
    font-size: 16px !important;
    padding: 10px 8px;
  }
  #searchResults { max-height: calc(60vh - 100px); }

  .layer-list-panel {
    width: 220px; max-height: 60vh; top: 60px;
  }
   .layer-list-panel .opacity-slider-container {
    padding-left: 19px; /* Adjust for potentially smaller checkbox */
  }
  .layer-list-panel .opacity-slider-label,
  .layer-list-panel .opacity-value-display {
    font-size: 11px;
  }
  .layer-list-panel .opacity-slider {
    height: 6px; 
  }
  .layer-list-panel .opacity-slider::-webkit-slider-thumb {
    width: 12px; 
    height: 12px;
  }
  .layer-list-panel .opacity-slider::-moz-range-thumb {
    width: 12px; 
    height: 12px;
  }


  #historicalFiresPanel {
    max-width: 280px; padding: 8px 12px; bottom: 15px;
  }
  #historicalFiresPanel input[type="number"] {
    font-size: 16px !important;
    padding: 8px 6px;
  }
  #historicalFiresPanel .year-input-container label,
  #historicalFiresPanel .checkbox-container label {
    font-size: 0.9em;
  }

  .legend-panel {
    width: 240px;
    max-height: calc(100vh - 95px - 20px);
  }
  .smoke-color-ramp-popup {
      width: 210px; 
      left: 5px;
      font-size: 0.95em; /* Adjust font size inside popup */
  }
  .smoke-color-ramp-popup .legend-ramp-item {
      font-size: 0.75em; /* Further adjust item font size */
  }
}

@media (max-width: 480px) {
  .vertical-toolbar { width: 48px; right: 5px; padding: 5px 0; top:10px; } /* Reset top for mobile */
  .vertical-toolbar .toolbar-btn { font-size: 18px; padding: 8px; margin: 5px 0; width: 32px; height: 32px; }
  .vertical-toolbar .toolbar-btn[title]::after { left: -180px; font-size: 12px; }

  .logo-box { padding: 3px 5px; }
  .logo-icon { width: 20px; height: 20px; }
  .logo-text { font-size: 12px; }

  .notification-banner {
    font-size: 0.8em;
    padding: 8px 10px;
    max-width: calc(100vw - 20px); /* Almost full width */
  }
   .notification-banner.show {
    transform: translateY(28px);
  }
  body.notification-banner-visible .layer-list-panel.active,
  body.notification-banner-visible #searchPanel.active {
      top: calc(28px + 10px + 5px + 90px);
  }
  body.notification-banner-visible .vertical-toolbar {
      top: calc(28px + 10px + 90px + 10px);
  }
  body.notification-banner-visible #infoBox { /* Push down infobox if banner is active on mobile */
    top: calc(28px + 10px + 5px + 90px + 10px);
  }


  #infoBox {
    width: auto;
    max-width: calc(100vw - 48px - 5px - 5px - 10px);
    right: calc(48px + 5px + 5px);
    top: 50px; /* Default */
    padding: 8px;
    font-size: 0.85em;
  }
  #infoBox h2, #infoBox h3 { font-size: 12px; margin-bottom: 5px;}
  #infoBox p, #infoBox strong, #infoBox span.value, #infoBox a { font-size: 0.9em; }


  .layer-list-panel {
    top: 40px;
    left: 5px;
    width: calc(100vw - 10px - 48px - 5px - 5px); /* Adjusted width */
    max-height: 40vh;
    padding: 8px;
    font-size: 0.9em;
  }
  .layer-list-panel .panel-header h3 { font-size: 1em; }
  .layer-list-panel .layer-item label { font-size: 13px; }
  .layer-list-panel .opacity-slider-container {
    padding-left: 18px; /* Fine-tune for mobile */
  }
  .layer-list-panel .opacity-slider-label,
  .layer-list-panel .opacity-value-display {
    font-size: 10px; /* Make text smaller for mobile slider */
  }
  .layer-list-panel .opacity-slider {
    height: 4px; /* Make slider track even smaller for mobile */
  }
  .layer-list-panel .opacity-slider::-webkit-slider-thumb {
    width: 10px; /* Make thumb smaller for mobile */
    height: 10px;
  }
  .layer-list-panel .opacity-slider::-moz-range-thumb {
    width: 10px; /* Make thumb smaller for mobile */
    height: 10px;
  }


  #searchPanel {
    top: 40px;
    left: 5px;
    width: calc(100vw - 10px - 48px - 5px - 5px); /* Adjusted width */
    max-height: 45vh;
    padding: 10px;
    font-size: 0.9em;
  }
  #searchPanel h2 { font-size: 1.1em; margin-bottom: 10px; }
  #searchPanel input[type="text"] {
    font-size: 16px !important;
    padding: 8px 6px;
    margin-bottom: 8px;
  }
  #searchResults { max-height: calc(45vh - 80px); }


  .basemap-dropdown { width: 160px; margin-right: 5px; padding: 8px; }
  .basemap-dropdown select { font-size: 13px; padding: 6px; }

  .modal-content {
    width: calc(100% - 20px); margin: 5% auto; padding: 10px; font-size: 0.9em;
  }
  .modal-content h2 { font-size: 1.2em; margin-bottom: 10px; }
  .modal .close-btn { font-size: 18px; top: 5px; right: 8px; }
  #shareMapURL { padding: 6px; font-size: 0.85em; margin-bottom: 10px;}
  #copyURLBtn { padding: 6px 10px; font-size: 0.85em; }

  #historicalFiresPanel {
    width: calc(100% - 10px);
    left: 5px; transform: translateX(0);
    bottom: 5px; padding: 8px;
    font-size: 0.9em;
    min-width: 0;
  }
  #historicalFiresPanel input[type="number"] {
    font-size: 16px !important;
    padding: 6px 4px;
    width: 70px;
  }
  #historicalFiresPanel .year-input-container label,
  #historicalFiresPanel .checkbox-container label {
    font-size: 0.9em;
  }
  #historicalFiresPanel .checkbox-container { margin-top: 3px; }

  .legend-toggle-btn {
    bottom: 25px;
    left: 10px;
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  .legend-panel {
    bottom: 65px;
    left: 5px;
    width: calc(100vw - 10px);
    max-width: 260px;
    max-height: 45vh;
    font-size: 0.9em;
  }
  .legend-panel .panel-header h3 {
    font-size: 1em;
  }
  .legend-panel .legend-group li {
    font-size: 12px;
  }
  .legend-panel .legend-color, .legend-panel .legend-icon-img {
    width: 16px;
    height: 16px;
    margin-right: 8px;
  }

  .smoke-color-ramp-popup {
      width: calc(100% - 10px); 
      left: 5px;
      font-size: 0.9em; 
      padding: 8px;
      /* transform is inherited, no change needed here unless vertical spacing differs */
  }
  .smoke-color-ramp-popup .legend-ramp-item {
    font-size: 0.7em; /* Even smaller for more compact display */
    margin-bottom: 2px;
  }
  .smoke-color-ramp-popup .legend-ramp-item .color-box {
      width: 16px;
      height: 8px;
      margin-right: 5px;
  }
}