html,
body {
  height: 100%;
  margin: 0;
  overscroll-behavior: contain;
}

body:has(dialog[open]) {
  overflow: hidden;
}

body:has(dialog[open]) #sidebar {
  overflow: hidden;
}

/* Support for custom scrollbars in WebKit-based browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar-track {
  background: var(--active-bg);
}

* {
  scrollbar-width: auto; /* Options: auto (standard wide), thin, or none */
  scrollbar-color: #888888 #f1f1f1; /* Format: [thumb/handle color] [track/background color] */
}

::-webkit-scrollbar-thumb {
  background: var(--active-bg);
  border-radius: 6px; /* Smooth corners */
}
/* ----------------------------------------------------- */

/* Global keyboard focus indicator for accessibility */
:focus-visible {
  outline: 2px solid var(--focus-color) !important;
  outline-offset: 2px !important;
}

#legend-close:focus-visible,
#filter-close:focus-visible {
  outline-color: #fff !important;
  border-radius: 2px;
}

.locate-btn:focus-visible,
.place-search-input:focus-visible {
  outline-offset: -3px !important;
}

/* ------------------------------------------------------*/

#controls-bar {
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid var(--light-gray-border);
  display: flex;
}

.common-controls {
  display: flex;
  gap: 0.3125rem;
  justify-content: flex-start;
  align-items: center;
  width: 30%;
}

.map-tab-controls {
  flex: 1;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
}

.add-watch-zone-btn {
  height: 2.25rem;
  padding: 0 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.add-watch-zone-btn .btn-icon {
  display: block;
  width: 1.55rem;
  height: 1.55rem;
  flex-shrink: 0;
  margin: 0;
  object-fit: contain;
}

.add-watch-zone-mobile {
  display: none;
}

#view-controls {
  display: flex;
  flex-wrap: nowrap;
  flex-shrink: 0;
  gap: 0.375rem;
}

/* overrides on top of .form-select.form-select-sm */
.sort-dropdown {
  width: auto;
  height: 2.25rem;
  border-color: var(--primary-color);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--primary-color) !important;
}

.hazards-viewport {
  height: calc(100vh - 185px);
  overflow: hidden;
}

.incident-map-list {
  flex: 1;
  min-height: 0;
  display: flex;
  height: 100%;
}

#sidebar {
  width: 30%;
  flex-shrink: 0;
  overflow-y: auto;
  contain: layout;
}

#sidebar-content {
  padding: 0.225rem !important;
}

.place-search-input {
  -webkit-appearance: none;
  -webkit-border-radius: 0;
  border-radius: 0;
}

.sidebar-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--color-brown);
  font-size: 0.95rem;
}

.sidebar-loading .spinner-border {
  color: var(--primary-color);
}

#sidebar-scroll-top {
  position: sticky;
  bottom: 1rem;
  float: right;
  margin-right: 1rem;
  z-index: 1000;
  cursor: pointer;
  display: none;

  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--primary-color);
  border: none;
  padding: 0;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease;
}

#sidebar-scroll-top img {
  width: 1rem;
  height: 1rem;
  display: block;
  object-fit: contain;
}

#sidebar-scroll-top:hover {
  background: #003366;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

#sidebar-scroll-top:active {
  background: #002244;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.sidebar-error-banner {
  padding: 0.625rem 0.75rem;
  margin: 0.5rem 0.5rem 0;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 4px;
  color: #664d03;
  font-size: 0.8125rem;
}

.map-container {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  min-width: 0;
}

.sidebar-location-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 0.3rem;
  cursor: pointer;
  border: 0;
  border-bottom: 1px solid #d8d0d0;
  border-radius: 0;
  background: transparent;
  text-align: left;
  transition: background 0.12s;
}

.sidebar-location-item:focus-visible {
  outline: 2px solid var(--focus-color) !important;
  outline-offset: 2px !important;
  background: var(--color-state-bg, var(--color-hover-bg));
}

.sidebar-location-item:hover {
  background: var(--color-state-bg, var(--color-hover-bg)) !important;
}

.sidebar-location-item.active,
.sidebar-location-item[aria-current='true'] {
  background: var(--color-state-bg, var(--color-hover-bg)) !important;
  box-shadow: inset 3px 0 0 var(--focus-color, #004f6f);
}

/* icon in a subtle circle */
.sidebar-item-icon-wrap {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-item-icon {
  width: 100%;
  height: auto;
  object-fit: contain !important;
  flex-shrink: 0 !important;
}

.sidebar-details {
  flex: 1;
  min-width: 0;
}

/* title + pill on one line */
.sidebar-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.sidebar-detail-category {
  font-size: 0.9rem;
  font-weight: 600;
  color: #0a0a0b;
  line-height: 1.35;
}

.sidebar-status-text {
  white-space: nowrap;
}

.sidebar-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.sidebar-distance,
.sidebar-time-reported,
.sidebar-status-text {
  color: var(--primary-color) !important;
}

ul.sidebar-location-list {
  list-style: none !important;
  margin: 0 !important;
  padding: 0.1875rem 0 0 0 !important;
}

ul.sidebar-location-list li {
  padding-left: 0 !important;
  margin-block: 0.125rem !important;
  margin-inline: 0.05rem !important;
}

ul.sidebar-location-list li::before {
  content: none !important;
  display: none !important;
}

.footer-controls {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.5rem;
  border-top: 1px solid var(--light-gray-border);
  position: relative;
}

.footer-left {
  width: 30%;
  display: flex;
  align-items: center;
  justify-content: start;
  gap: 0.5rem;
  margin-right: 0.5rem;
}

#text-only-btn {
  height: 2.25rem;
  justify-self: start;
  white-space: nowrap;
  gap: 0;
}

#text-only-btn img {
  width: 1.2rem;
  height: 1.2rem;
}

.last-updated-time {
  font-size: 0.9rem;
}

label.incident-name {
  /* text-transform: uppercase; */
  font-size: 0.9rem;
}

.filter-list p,
.filter-list-box p {
  font-size: 1rem !important;
  margin: 0.6rem 0rem;
}

.filter-list {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  border-bottom: 0.5px solid #ede5e5;
  padding: 0.375rem 0;
  border-radius: 4px;
  transition: background 0.2s;
  width: 30%;
}

.filter-item:hover {
  background: var(--color-hover-bg);
}

.filter-additional-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
}

.filter-additional-options fieldset {
  min-width: 0;
}

.filter-additional-options .filter-item {
  width: 100%;
}

#warningsList h4 {
  margin-top: 1rem !important;
}

.fieldset-header {
  font-weight: 600;
}

.filter-item input[type='checkbox'] {
  cursor: pointer;
  width: 1.125rem;
  height: 1.125rem;
}

.filter-item label {
  flex: 1;
  cursor: pointer;
  margin: 0;
  font-weight: 600;
  /* font-size: 0.75rem; */
}

.filter-item img {
  width: 2rem;
  height: auto;
  margin-right: 0.25rem;
}

.always-on {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.always-on img {
  width: 2.8125rem;
  height: 100%;
  margin: 0;
}

.total-alerts {
  font-weight: bold;
  color: var(--primary-color);
  font-size: 0.9rem;
  padding: 0.2rem 0.75rem;
}

.sidebar-empty-status {
  color: #999 !important;
}

/* Legend toggle button styles */
#legend-toggle,
#filter-toggle {
  height: 2.25rem;
  flex-shrink: 0;
  white-space: nowrap;
}

#legend-toggle img,
#filter-toggle img {
  width: 1rem;
  height: 1rem;
}

#filter-toggle.active img {
  filter: brightness(0) invert(1);
}

#filter-toggle.active #filter-text {
  color: var(--color-white);
}

#map-legend,
#filter-popup {
  box-shadow:
    rgba(0, 0, 0, 0.25) 0px 54px 55px,
    rgba(0, 0, 0, 0.12) 0px -12px 30px,
    rgba(0, 0, 0, 0.12) 0px 4px 6px,
    rgba(0, 0, 0, 0.17) 0px 12px 13px,
    rgba(0, 0, 0, 0.09) 0px -3px 5px;
  padding: 0;
  border-radius: 5px;
}

#map-legend {
  width: min(80rem, calc(100vw - 2rem));
}

.filter-item-list {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

#map-legend::backdrop,
#filter-popup::backdrop {
  overflow: hidden; /* Needed to make this a scroll container */
  overscroll-behavior: contain;
  background: rgba(0, 0, 0, 0.5);
}

#map-legend p {
  font-size: 0.9rem;
  font-weight: bold;
}

.legend-content {
  padding: 0.125rem 1.5rem 1.5rem 1.5rem;
}

.legend-content h4 {
  /* margin-top: 0 !important; */
  margin: 0.5rem 0rem !important;
}

.legend-content li {
  font-size: 0.9rem;
}

.legend-warning-list {
  padding: 0 !important;
  margin: 0 !important;
}

/* Grid layout for hazard icons in legend (3 per row) */
.legend-grid {
  display: flex;
  flex-wrap: wrap;
  /* grid-template-columns: repeat(3, minmax(0, 1fr)); */
  gap: 0.5rem 0.75rem;
  /* align-items: center; */
  list-style: none !important;
  list-style-type: none !important;
  margin: 0 !important;
  padding: 0;
  /* padding-left: 0.25em !important; */
  font-size: 0.9rem;
}

.legend-grid li {
  padding-left: 0 !important;
  flex: 1 1 100px;
  text-align: center;
  line-height: 1rem;
  margin: 0.5rem 0px !important;
}

.legend-grid > li:first-child {
  margin-top: 0.75em !important;
}

.legend-grid li::before {
  content: none !important;
  display: none !important;
}

p.legend-text {
  font-weight: normal !important;
  margin: 0 !important;
}

.legend-content div {
  display: flex;
  align-items: center;
  justify-content: center;
}

.legend-content img {
  width: 1.75rem;
  height: 1.75rem;
  margin-right: 0.5rem;
}

img.warning-img {
  width: 3.5rem;
  height: 3.5rem;
}

.australian-warning-levels {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0 0.25rem !important;
}

.australian-warning-levels div {
  display: block;
  font-weight: bold !important;
}

.legend-title,
.filter-popup-title {
  background: var(--primary-color);
  color: #fff !important;
  position: sticky;
  top: 0;
  z-index: 10;
}

.legend-title {
  padding: 0.625rem 1.5rem;
  width: 100%;
}

.filter-popup-title {
  padding: 1rem 1.5rem;
  margin-bottom: 0;
  text-align: left;
}

#legend-close,
#filter-close {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--color-white);
}

.filter-popup-content {
  padding: 0 1.5rem 0.5rem;
}

.filter-popup-content .filter-list-box {
  margin-bottom: 0.625rem;
}

.legend-title h3,
.filter-popup-title h3 {
  color: #fff !important;
  margin: 0 !important;
  /* font-size: 0.9375rem !important; */
}

.legend-title h3::before,
.filter-popup-title h3::before,
#map-legend *::before,
#filter-popup *::before {
  content: none !important;
  display: none !important;
}

.about-alertsa {
  background-color: var(--primary-color);
  display: flex;
  padding: 2.5rem 5.5rem;
  justify-content: center;
  align-items: center;
}

.about-imgContainer {
  flex: 1;
  text-align: center;
}

.about-alertsa-container {
  color: white !important;
  flex: 1;
  font-size: 0.9rem;
}

.about-alertsa-text h2 {
  margin-top: 0 !important;
  padding-top: 0 !important;
  font-size: 2.5rem !important;
}

.footer-btns {
  height: 2.25rem;
}

#pause-btn.active {
  border: 1px solid var(--primary-color);
  background-color: var(--primary-color);
}

#pause-btn.active img {
  filter: brightness(0) invert(1);
}

#loading-indicator {
  display: none;
  font-size: 0.5rem;
  color: #333;
  justify-content: center;
  align-items: center;
}

#loading-indicator img {
  vertical-align: middle;
  margin-right: 0.5rem;
}

.footer-btns img,
#loading-indicator img {
  width: 1rem !important;
  height: 1rem !important;
}

.about-imgContainer img {
  height: auto !important;
  max-height: 400px;
}

.marker-icon {
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.marker-icon__image {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

button#apply-filter-btn,
button#clear-filter-btn {
  padding: 0.5rem 1rem;
  margin-top: 0.625rem;
  margin-bottom: 1.25rem;
}

.custom-gps-dot {
  width: 1rem;
  height: 1rem;
  background-color: #1e88e5;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -50%);
}

/* View modes */
#container[data-view='map'] #sidebar {
  display: none;
}

#container[data-view='list'] .map-container {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  position: relative; /* keep layout stable; don't collapse */
}

#container[data-view='map'] .map-container,
#container[data-view='both'] .map-container {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

#container[data-view='list'] #sidebar {
  width: 100%;
}
/* Anything smaller than the tablet breakpoint */
@media screen and (max-width: 1024px) {
  .add-watch-zone-mobile {
    display: inline-flex;
  }

  .add-watch-zone-desktop {
    display: none;
  }

  .view-tab[data-view='both'] {
    display: none;
  }

  .hazards-viewport {
    height: calc(100vh - 180px);
  }
}

/* Mobile Devices*/
@media screen and (max-width: 767px) {
  #container:not([data-view]) #sidebar {
    display: none;
  }

  #sidebar {
    width: 45%;
    padding: 0;
  }

  #controls-bar {
    flex-direction: column-reverse;
    padding: 0.5rem;
  }

  .common-controls {
    width: 100%;
    gap: 0.5rem;
  }

  .filter-legend-container {
    margin-left: auto;
  }

  .map-tab-controls {
    margin-bottom: 0.625rem;
    gap: 0.25rem;
  }

  #view-controls {
    gap: 0.175rem;
  }

  .hazards-viewport {
    height: calc(100vh - 225px);
  }

  .total-alerts-wrapper {
    margin-bottom: 0.1875rem;
  }

  .total-alerts {
    margin-bottom: 0;
  }

  .app-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }

  .legend-content,
  .filter-popup-content {
    padding-bottom: 1.25rem;
  }

  .filter-item-list {
    gap: 0.5rem;
  }

  button.gm-ui-hover-effect {
    z-index: 200 !important;
  }

  .about-alertsa {
    padding: 1.25rem;
  }

  .about-alertsa-container {
    padding: 0;
  }

  .view-tab {
    flex: 1;
    padding: 0.5rem;
    text-align: center;
  }
  .search-container {
    flex: 1;
    min-width: 0;
  }

  .legend-content img {
    margin-right: 0 !important;
  }

  .sidebar-loading {
    font-size: 0.85rem;
  }

  .sidebar-error-banner {
    font-size: 0.7125rem;
  }

  .sidebar-meta {
    font-size: 0.775rem;
  }

  .footer-left {
    width: auto;
  }

  .last-updated-time {
    font-size: 0.8rem;
  }

  #legend-close,
  #filter-close {
    font-size: 1.15rem;
  }

  #loading-indicator {
    font-size: 0.4rem;
  }
  .filter-item {
    width: 100%;
  }

  #filter-text,
  #legend-text {
    display: none;
  }
}

/* Narrow phones (Galaxy S8+, Galaxy Z Fold5 cover screen, iPhone SE) */
@media screen and (max-width: 400px) {
  .view-tab {
    padding: 0.375rem;
  }

  .locate-me-text {
    display: none;
  }
}

/* Adjust location search bar for tablets */
@media (min-width: 768px) and (max-width: 1024px) {
  #controls-bar {
    gap: 0.75rem;
  }

  .common-controls {
    width: auto;
    flex-shrink: 0;
  }

  #sidebar {
    width: 40%;
    padding: 0;
  }

  .about-alertsa {
    padding: 1.25rem 2.5rem;
  }

  .about-alertsa-container {
    padding: 0;
  }

  .map-tab-controls {
    gap: 0.75rem;
  }

  .view-tab {
    padding: 0.375rem 0.775rem;
  }

  .locate-me-text {
    display: none;
  }

  #filter-text,
  #legend-text {
    color: inherit;
    display: none;
  }

  .filter-item {
    width: 46%;
  }
}

/* Large tablets  */
@media (min-width: 1025px) and (max-width: 1440px) {
  #legend-text,
  #filter-text {
    display: block;
  }

  #controls-bar {
    gap: 0.75rem;
  }

  .common-controls {
    width: auto;
    min-width: 30%;
    flex-shrink: 0;
  }

  #view-controls {
    flex-wrap: wrap;
    flex-shrink: 1;
    min-width: 0;
    justify-content: flex-end;
    row-gap: 0.375rem;
  }
}

dialog {
  border: none;
  outline: none;
}

/* Desktop screen */
@media (min-width: 64.0625em) {
  .filter-additional-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .legend-warning-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem 0.75rem;
  }
}
