body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
}

/* ======================================================================
   For style of map 
   ====================================================================== */
#map {
  height: calc(100vh - 300px);
  width: 100%;
  z-index: 1 !important;
  /* make it behind the submenu */
}

/* desktop: standard drop down */
.menu-item-has-children {
  position: relative;
}

/* dropdown submenu */
.custom-dropdown {
  display: none;
  height: auto;
  position: absolute !important;
  visibility: hidden;
  /* strange, if don't set it hidden at beginning, it will be shown and flash once before hidden */
  left: 0;
  top: 100%;
  width: 200px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
  padding: 0;
  z-index: 9999;
  transition: opacity 0.3s ease, visibility 0.3s ease, height 0.3s ease, padding 0.3s ease;
}

/* show the dropdown menu when hover upon submenu */
.menu-item-has-children:hover .custom-dropdown,
.menu-item-has-children:focus-within .custom-dropdown {
  display: block;
  visibility: visible;
}

/* ul in the submenu */
.custom-dropdown ul {
  padding: 0;
  margin: 0;
  list-style: none;
  width: 100%;
}

/* submenu item */
.custom-dropdown li {
  padding: 10px 15px;
  transition: background 0.3s ease-in-out;
}

.custom-dropdown li a {
  text-decoration: none;
  color: #3c3c3c;
  font-weight: bold;
  display: block;
}

.custom-dropdown li:hover {
  background: #858585;
}

.custom-dropdown li:hover a {
  color: #fff;
}

/* fading effect */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile: left the submenu open to the right */
@media (max-width: 768px) {
  .menu-item-has-children {
    position: relative !important;
  }

  /* left the submenu open to the right */
  .custom-dropdown {
    display: none;
    position: absolute;
    top: 100% !important;
    /* top aligned */
    left: 0% !important;
    /* open to the right */
    background: rgba(246, 246, 246, 1);
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
    padding: 1px 0;
    min-width: 120px;
    white-space: nowrap;
    z-index: 9999 !important;
  }

  .custom-dropdown li a {
    text-decoration: none;
    color: #1c1c1c !important;
    font-weight: bold;
    display: block;
  }

  .custom-dropdown li:hover {
    background: #858585;
  }

  .custom-dropdown li:hover a {
    color: #fff;
  }

  /* let `.menu-item-has-children` open the submenu when click */
  .menu-item-has-children.active .custom-dropdown {
    display: block;
  }
}

/* =======================================================================
   For the style of the leaflet layer 
   ======================================================================= */

/* make the mouse cursor pointer shape on the interactive layer of the map */
.leaflet-interactive {
  cursor: pointer !important;
}

.leaflet-popup-content {
  max-width: 90vw;
  /* limit the widht less than 90% of that of the viewport */
  max-height: 70vh;
  /* limit the height less than 70% of that of the viewport */
  overflow: auto;
  /* scroll if content is too much */
  white-space: normal;
  /* allow word wrap */
  word-wrap: break-word;
  /* break long word */
  text-align: left;
  /* left-align */
}

/* =======================================================================
   For the style of the data loader 
   ======================================================================= */
.loader {
  border: 5px solid rgba(0, 0, 0, 0.2);
  border-top: 5px solid #3498db;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}


/* =======================================================================
   For the style of the top status bar 
   ======================================================================= */

/* the bar is to hold the status and button */
.status-bar {
  display: flex;
  justify-content: space-between;
  /* put the status on the left, buttons on the right */
  align-items: center;
  background-color: #333;
  /* deep-gray background */
  color: #fff;
  /* text color */
  padding: 10px 20px;
  font-size: 16px;
  height: 40px;
  position: relative;
  /* do not cover the map */
}

.status-info {
  position: relative;  /* add an anchor */
  /*flex-grow: 1;*/
  /* let the status part fill the rest space up to the buttons */
}

/* ======================================================================
   For style showing the coordiante on the bottom-left corner of the map 
   ====================================================================== */
.leaflet-control-coordinates {
  background: rgba(51, 50, 50, 0.3);
  padding: 5px 10px;
  border-radius: 0;
  font-size: 10px;
  font-family: Arial, sans-serif;
  box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
  margin: 5px;
}

/* =============================================================== 
   For the toolbar style
   =============================================================== */
.leaflet-control-zoom {
  display: none;
}

/* hide the default +/- buttons on the map */
.toolbar {
  position: absolute;
  top: 20px;
  left: 20px;
  background: white;
  color: black;
  padding: 0px;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 0px;
  z-index: 1000;
  border: 1px solid rgb(179, 179, 179);
  transition: background-color 0.2s ease-in-out;
  user-select: none;
  /* avoid text to be selected */
}

.toolbar button {
  width: 30px;
  height: 30px;
  background: white;
  color: black;
  border: 1px solid rgb(179, 179, 179);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 16px;
  cursor: pointer;
  border-radius: 0;
}

.toolbar button:hover {
  background-color: #b0b0b0;
}

/* google fonts used in the toolbar */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  display: inline-block;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  word-wrap: normal;
  white-space: nowrap;
  direction: ltr;
}

/* =============================================================== 
   For search bar style
   =============================================================== */
.search-container {
  position: absolute;
  top: 20px;
  left: 70px;
  background: white;
  color: black;
  padding: 0px;
  border-radius: 0;
  border: 1px solid #b0b0b0;
  display: flex;
  /*flex-direction: column;*/
  align-items: center;
  gap: 0px;
  z-index: 1000;
}

.search-bar {
  width: 200px;
  padding-left: 10px;
  border: 0px solid black;
  border-radius: 0;
  background: white;
  color: black;
}

.search-button {
  width: 30px;
  height: 30px;
  background: white;
  color: black;
  border: 0px solid black;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 0;
  font-size: 16px;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  width: calc(100% - 10px);
  /* let it as wide as search-container */
  max-height: 150px;
  /* maximum height */
  overflow-y: auto;
  /* show the scroll bar when it is overflow */
  background: white;
  border: 1px solid #ccc;
  border-radius: 5px;
  display: none;
  z-index: 1000;
}

.search-result-item {
  padding: 2px;
  cursor: pointer;
  font-size: 14px;
  background: white;
  transition: background 0.2s ease-in-out;
}

.search-result-item:hover {
  background: #696969;
}

/* =============================================================== 
   For base map selector style
   =============================================================== */
/* Base Map button container */
.basemap-container {
  position: relative;
  display: inline-block;
}

/* main button */
.basemap-toggle {
  width: 30px;
  height: 30px;
  background: white;
  border: 1px solid rgb(179, 179, 179);
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
}

/* hover style */
.basemap-toggle:hover {
  background-color: #f0f0f0;
}

/* hidden button options */
.basemap-options {
  position: absolute;
  top: 0;
  left: 35px;
  /* put them to the right of the main button  */
  display: flex;
  gap: 5px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

/* show options when hover */
.basemap-container:hover .basemap-options {
  opacity: 1;
  visibility: visible;
}

/* buttons in the options */
.basemap-options button {
  width: 60px;
  height: 30px;
  background: white;
  border: 1px solid rgb(179, 179, 179);
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
}

/* color changed when hover */
.basemap-options button:hover {
  background-color: #f0f0f0;
}


/* ======================================================================
   For style of (side) legends 
   ====================================================================== */
/* Legend container: fixed to the top-right below the status bar */
#legend-panel {
  position: absolute;
  top: 100%;   /* this make it stick to the bottom of the status bar on the right */
  right: 0;
  width: 250px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 12px 16px;
  z-index: 999;
  border-radius: 0px;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

#legend-panel hr {
  align-self: stretch;
  border: 0;
  height: 1px;
  background-color: rgba(255, 255, 255, 0.2);
  margin: 8px 0;
}

.legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.legend-title {
  font-weight: bold;
  font-size: 16px;
  color: white;
}

.legend-panel.hidden {
  display: none;
}

#legend-panel h4 {
  margin-top: 0;
  margin-bottom: 10px;
  border-bottom: 1px solid #666;
  padding-bottom: 4px;
}

#legend-panel ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#legend-panel li {
  margin-bottom: 8px;
  font-weight: bold;
  display: flex;
  align-items: center;
}

.legend-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border-radius: 3px;
}

/* for SWOT lake */
.legend-icon.swot {
  display: inline-block;
  width: 20px;
  height: 12px;
  background-color: #3399ff; /* identify the lake color used in SWOT data */
  border: 1px solid #004080; /* bank color */
  border-radius: 2px;
  box-shadow: inset 0 0 2px rgba(0,0,0,0.3); /* water-like */
  margin-right: 8px;
}

/* for USACE pinpoint */
.legend-icon.usace {
  width: 16px;
  height: 16px;
  background-color: #aa0101;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

/* for OWRB pinpoint */
.legend-icon.owrb {
  width: 16px;
  height: 16px;
  background-color: #077923;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

/* for USGS pinpoint */
.legend-icon.usgs {
  width: 16px;
  height: 16px;
  background-color: #1100ff;
  border-radius: 50%;
  border: 2px solid rgb(255, 255, 255);
  box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

/* for Mesonet legend symbols */
.legend-icon.mesonet.triangle {
    width: 0px;
    height: 0px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 14px solid rgb(0, 0, 0);
}

.legend-icon.mesonet.square {
    width: 14px;
    height: 14px;
    background-color: white;
    border: 1px solid black;
    box-sizing: border-box;
    border-radius: 0 !important;
}

#legend-close-btn {
  background-color: #cc0000;
  color: white;
  border: none;
  font-weight: bold;
  float: right;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  margin-bottom: 8px;
}

/* for CSS on the reset button on chart */
.chart-reset {
  background-color: #eee;
  border: 1px solid #ccc;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
}
.chart-reset:hover {
  background-color: #ddd;
}

/* add version tag next to the logo (for test deployment only) */
#logoVer::after {
    content: "V0.3.0-alpha"; 
    font-size: 14px;
    color: "red";
    margin-left: 8px;
    vertical-align: middle;
    display: inline-block;
}

/* 
 * for download and query
*/
/* ---------- Generic ---------- */
/* utilities */

:root{
  --w: 440px;
  --gap: 12px;
  --radius: 12px;
  --border: 1px solid #ddd;
}

#query-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4); /* 半透明背景 */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
    width: 780px;      /* 原本可能是 340px 或更小，這裡改寬一點 */

}

#query-modal .dialog {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0,0,0,.25);
  width: min(640px, 200vw);
  max-height: 90vh;
  overflow-y: auto;
}

/* header */
.query-header{
  display:flex; align-items:center; justify-content:space-between;
  padding: 10px 14px; border-bottom: var(--border);
}
.query-header h3{ margin:0; font-size:18px; }
#query-close{
  border:0; background:transparent; font-size:22px; padding:2px 6px; cursor:pointer;
}

/* body */
.query-body{ padding: 12px 14px 16px; display:grid; gap: var(--gap); }

fieldset{
  border: var(--border); border-radius: 8px;
  padding: 10px 12px;
}
legend{ padding: 0 6px; font-weight: 600; }

/* inline labels */
fieldset label{
  display:inline-flex; align-items:center; gap:6px;
  margin: 4px 12px 4px 0;
}

/* multi-select & dates */
#q-site{ width:100%; min-height: 9.5em;   width: 460px;  /* 你可以根據選項文字長度調整 */
}
#q-start, #q-end{ width: 11rem; }

/* grid for Options and Output */
fieldset:has(#q-resample),
fieldset:has(#q-format){
  display:grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr));
  gap: 8px 12px;
}
fieldset:has(#q-resample) label,
fieldset:has(#q-format) label{ margin:0; }

/* actions */
.query-actions{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.query-actions button{
  padding:6px 12px; border-radius:6px; border:1px solid #cfcfcf; background:#f7f7f7; cursor:pointer;
}
.query-actions button:hover{ background:#eee; }
#q-progress{ width:170px; height:10px; }

@media (max-width: 420px){
  :root{ --w: 360px; }
  #q-start, #q-end{ width:100%; }
}
