/* Normalize rules previously supplied by Bulma */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: BlinkMacSystemFont, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.24;
  margin-left: 0px; margin-right:0px;
}
button, input, select, textarea { font-family: inherit; font-size: 100%; }
button { -webkit-appearance: none; appearance: none; cursor: pointer; }
h1, h2, h3, h4, h5, h6 { font-size: 100%; font-weight: normal; margin: 0 0 0.5em; }
a { color: #3273dc; }
a:hover { color: #363636; }

.input-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap; /* Allow items to wrap on small screens */
  align-items: center;
}

/* Flex-grow column wrapper (replaces the single Bulma .column usage) */
.column {
  display: block;
  flex-grow: 1;
  flex-shrink: 1;
}

/* Mobile-first responsive design */
@media (max-width: 768px) {
  .input-row {
    gap: 10px; /* Reduce gap on mobile */
    flex-direction: column; /* Stack vertically on mobile */
    align-items: stretch; /* Full width on mobile */
  }

  .input-row > div {
    width: 100%; /* Full width containers on mobile */
  }
}

.flat-button {
    display: none;
}

/* Global button styles - used for all selector row (system, variable, statistic, etc) buttons */
.flat-button-label {
  display: inline-block;
  padding: 2px 10px;
  margin: 4px 2px;
  background: #ddd;
  border: 1px solid transparent;
  box-sizing: border-box;
  font-size: 13px;
  cursor: pointer;
  color: black;
  transition: background-color 0.4s ease;
  white-space: nowrap; /* Prevent text wrapping */
  overflow: hidden; /* Hide overflowing text */
  text-overflow: ellipsis; /* Show ellipsis (...) for truncated text */
  max-width: 200px; /* Set reasonable max width - increased for scrollable rows */
  flex-shrink: 0; /* Prevent buttons from shrinking in flex container */
}

/* Tighter multi-row domain spacing only */
.domain-list {
  column-gap: 4px;
  row-gap: 1px;      /* was effectively 4px via gap */
  align-content: flex-start;
}

/* Tighter domain button shape only */
.domain-item .flat-button-label {
  margin: 1px 1px;   /* overrides global 4px 2px */
  padding: 4px 8px; /* slightly tighter vertical padding */
  line-height: 1.1;
}

/* Mobile responsive button labels */
@media (max-width: 768px) {
  .flat-button-label {
    padding: 4px 8px; /* Slightly larger touch targets on mobile */
    margin: 2px 1px; /* Reduce margins on mobile */
    font-size: 12px; /* Slightly smaller text on mobile */
    max-width: 150px; /* Allow more text to show on mobile with scrolling */
  }
}

.flat-button-label.active {
  background-color: #00BFFF;
  border: 1px solid black;
}

.flat-button-label:hover {
  background-color: #87CEFA;
}

.statistic-group-wrapper {
  position: relative;
  display: inline-block;
}

.statistic-group-button {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  margin: 4px 2px;
  padding: 2px 10px;
  line-height: inherit;
  background: #e8f4f8;
  border: 1px solid #00BFFF;
  cursor: pointer;
  font-weight: 600;
}

.statistic-group-button:hover {
  background: #d0ecf5;
}

.statistic-group-button.active {
  background-color: #00BFFF;
  border: 1px solid black;
}

.statistic-group-droplist {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 9999;
  min-width: 280px;
  max-width: 400px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px 0;
}

.statistic-group-droplist.hidden {
  display: none;
}

.statistic-dropitem {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  border-bottom: 1px solid #f0f0f0;
}

.statistic-dropitem:last-child {
  border-bottom: none;
}

.statistic-dropitem input[type="checkbox"] {
  display: none;
}

.statistic-dropitem-label {
  display: block;
  flex: 1;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: #333;
  padding: 2px 4px;
  border-radius: 2px;
}

.statistic-dropitem-label:hover {
  background: #f5f5f5;
}

.statistic-dropitem input[type="checkbox"]:checked + .statistic-dropitem-label {
  font-weight: bold;
  color: #00BFFF;
}

.statistic-item {
  display: inline-flex;
}

/* no text selection by mouse on label, button, etc */
.no-text-select {
  -webkit-user-select: none; /* Safari */
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* IE10+/Edge */
  user-select: none; /* Standard */
}

/* Responsive image sizing */
#plot-image img {
  max-width: 100%;
  height: auto;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  #variable-area {
    margin-left: 0 !important; /* Remove left margin on mobile */
    padding: 0 5px; /* Add small horizontal padding */
  }

  #plot-window {
    width: 100% !important; /* Full width on mobile */
    padding: 0;
  }

  /* Make labels stack better on mobile */
  label {
    white-space: nowrap;
  }
}

/* Scrollable button containers - smooth scrolling on mobile */
#realm, #category, [id^="domain"], [id^="statistic"], [id^="variable"], [id^="forecast"] {
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  scrollbar-width: thin; /* Firefox thin scrollbar */
}

/* Custom scrollbar styling for webkit browsers */
#realm::-webkit-scrollbar,
#category::-webkit-scrollbar,
[id^="domain"]::-webkit-scrollbar,
[id^="statistic"]::-webkit-scrollbar,
[id^="variable"]::-webkit-scrollbar,
[id^="forecast"]::-webkit-scrollbar {
  height: 6px;
}

#realm::-webkit-scrollbar-track,
#category::-webkit-scrollbar-track,
[id^="domain"]::-webkit-scrollbar-track,
[id^="statistic"]::-webkit-scrollbar-track,
[id^="variable"]::-webkit-scrollbar-track,
[id^="forecast"]::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

#realm::-webkit-scrollbar-thumb,
#category::-webkit-scrollbar-thumb,
[id^="domain"]::-webkit-scrollbar-thumb,
[id^="statistic"]::-webkit-scrollbar-thumb,
[id^="variable"]::-webkit-scrollbar-thumb,
[id^="forecast"]::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

#realm::-webkit-scrollbar-thumb:hover,
#category::-webkit-scrollbar-thumb:hover,
[id^="domain"]::-webkit-scrollbar-thumb:hover,
[id^="statistic"]::-webkit-scrollbar-thumb:hover,
[id^="variable"]::-webkit-scrollbar-thumb:hover,
[id^="forecast"]::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Pulse animation for progress indicators */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.1);
  }
}

.pulse-icon {
  animation: pulse 2s ease-in-out infinite;
}

/* Sidebar styles */
#sidebar {
  width: 140px;
  min-width: 140px;
  max-width: 140px;
  padding: 10px;
  background-color: #f5f5f5;
  border-radius: 5px;
}

.sidebar-icon-menu {
  display: grid;
  grid-template-columns: repeat(3, 32px);
  grid-auto-rows: 32px;
  gap: 8px;
  justify-content: start;
}

/* Sidebar toggle button */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1px;
  left: 1px;
  z-index: 1000;
  background-color: #4fc1ff;
  color: white;
  border: 1px solid rgba(15, 106, 235, 0.25);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  padding: 0;
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.sidebar-toggle:hover {
  background-color: #37b7f7;
}

.sidebar-toggle.open {
  background-color: #37b7f7;
}

/* Mobile sidebar styles */
@media (max-width: 768px) {
  .sidebar-toggle {
    display: block;
  }

  #sidebar {
    width: 140px;
    min-width: 140px;
    max-width: 140px;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    overflow-y: auto;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  /* Overlay when sidebar is open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 998;
  }

  .sidebar-overlay.active {
    display: block;
  }
}

/* Sidebar icon styling */
.sidebar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 20%;
    color: slategrey;
    background: lightblue;
    text-decoration: none;
    font-size: 24px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.sidebar-icon:hover {
    background: #4fc1ff;
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.hidden {
  display: none !important;
}

.domain-selector {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-left: 10px;
  min-width: 0;
  flex: 1;
}

.domain-selector-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.domain-search-wrap {
  position: relative;
  width: 100%;
  max-width: 380px;
}

.domain-search-input {
  width: 100%;
  max-width: 100%;
  padding: 4px 8px;
  padding-right: 28px;
  border: 1px solid #999;
  border-radius: 4px;
}

.domain-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #666;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.domain-search-clear:hover {
  color: #222;
}

.domain-map-toggle {
  padding: 4px 10px;
  border: 1px solid #666;
  background: #f0f0f0;
  border-radius: 4px;
  cursor: pointer;
}

.domain-list {
  display: flex;
  flex-wrap: wrap;
  max-height: 130px;
  overflow-y: auto;
  gap: 4px;
}

.domain-option {
  border: 1px solid #aaa;
  background: #eee;
  border-radius: 3px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 12px;
}

.domain-option.active {
  background: #00bfff;
  border-color: #222;
}

/* domain-item wraps a hidden checkbox + its visible label */
.domain-item {
  display: inline-flex;
}

/* Domain buttons are slightly more compact than other selectors. */
.domain-item .flat-button-label {
  font-size: 12px;
}

/* Station domains: sand tint */
label.domain-type-stn {
  background: #fff0d4;
}
label.domain-type-stn:hover {
  background-color: #ffd990;
}

/* Region domains: light amber tint */
label.domain-type-rgn {
  background: #fff0d4;
}
label.domain-type-rgn:hover {
  background-color: #ffd990;
}

/* Zone domains: light green tint */
label.domain-type-zne {
  background: #dcf9f0;
}
label.domain-type-zne:hover {
  background-color: #b8f0df;
}

/* Tide gauge domains: light blue tint */
label.domain-type-tig {
  background: #d8ecff;
}
label.domain-type-tig:hover {
  background-color: #a8d4ff;
}

/* Active state overrides type colour */
label.domain-type-stn.active,
label.domain-type-rgn.active,
label.domain-type-zne.active,
label.domain-type-tig.active {
  background-color: #00bfff;
  border: 1px solid black;
}

.domain-map-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.domain-map-card {
  width: min(90vw, 700px);
  background: #fff;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transform: translate(var(--drag-x, 0px), var(--drag-y, 0px));
}

.domain-map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  cursor: move;
  user-select: none;
}

.domain-map-header.dragging {
  cursor: grabbing;
}

.domain-map-close {
  border: 1px solid #444;
  background: #fafafa;
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
}

.domain-map-canvas {
  height: 420px;
  border: 1px solid #ccc;
  border-radius: 5px;
  overflow: hidden;
}

.domain-map-canvas .leaflet-container {
  width: 100%;
  height: 100%;
  font: inherit;
}

.domain-map-empty {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #bbb;
  border-radius: 4px;
  color: #555;
  font-size: 12px;
  padding: 6px 8px;
}


