/* Grayscale Color Palette */
:root {
  --gray-darkest: #1a1a1a;
  --gray-dark: #333333;
  --gray-medium: #666666;
  --gray-light: #cccccc;
  --gray-lightest: #f5f5f5;
  --white: #ffffff;
  --accent: #555555;
  --red: #cc0000;
}

/* Dark Mode Color Palette */
body.dark-mode {
  --gray-darkest: #e8e8e8;
  --gray-dark: #c0c0c0;
  --gray-medium: #999999;
  --gray-light: #4a4a4a;
  --gray-lightest: #1e1e1e;
  --white: #121212;
  --accent: #aaaaaa;
  --red: #ff4444;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--gray-dark);
  background-color: var(--gray-lightest);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background-color: #d4c4a8;
  background-image: url('../images/coastal%20camo%20light.png');
  background-repeat: repeat;
  background-size: 400px auto;
  color: #ffffff;
  padding: 0.75rem 1.5rem;
  text-align: left;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  position: relative;
  flex-shrink: 0;
}

/* Dark mode header - slightly lighter */
body.dark-mode header {
  background-color: #2a2a2a;
  background-image: url('../images/coastal%20camo%20dark.png');
  background-repeat: repeat;
  background-size: 400px auto;
  color: #e8e8e8;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.header-text {
  flex: 1;
}

header h1 {
  font-family: 'Yellowtail', cursive;
  font-size: clamp(1.75rem, 5.5vw, 4.5rem);
  font-weight: 400;
  margin-bottom: 0;
  line-height: 1;
  text-shadow:
    2px 2px 4px rgba(0, 0, 0, 0.8),
    -1px -1px 2px rgba(0, 0, 0, 0.6),
    0 0 8px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.5px;
}

header .subtitle {
  font-size: clamp(0.65rem, 1.6vw, 1rem);
  color: #ffffff;
  margin-top: 0.25rem;
  line-height: 1.2;
  text-shadow:
    1px 1px 3px rgba(0, 0, 0, 0.8),
    -1px -1px 2px rgba(0, 0, 0, 0.6),
    0 0 6px rgba(0, 0, 0, 0.5);
  font-weight: 500;
}

body.dark-mode header .subtitle {
  color: #e8e8e8;
}

/* Menu Toggle Button (Hamburger) */
.menu-toggle {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  position: relative;
  z-index: 1001;
}

.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(6px);
  transform: scale(1.05);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

body.dark-mode .menu-toggle {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

body.dark-mode .menu-toggle:hover {
  background: rgba(0, 0, 0, 0.5);
}

.menu-icon {
  width: 20px;
  height: 2px;
  background-color: #ffffff;
  border-radius: 2px;
  transition: all 0.3s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Transform to X when menu is open */
.menu-toggle.active .menu-icon:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.menu-toggle.active .menu-icon:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active .menu-icon:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Menu Backdrop */
.menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 999;
}

.menu-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Side Menu */
.side-menu {
  position: fixed;
  top: 0;
  right: -300px;
  width: 300px;
  height: 100%;
  background-color: var(--white);
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.2);
  transition: right 0.3s ease;
  z-index: 1000;
  overflow-y: auto;
}

.side-menu.active {
  right: 0;
}

.menu-content {
  padding: 5rem 1.5rem 1.5rem;
}

.menu-item {
  margin-bottom: 1.5rem;
}

.menu-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.menu-label span {
  font-size: 1rem;
  font-weight: 500;
  color: var(--gray-darkest);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 50px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--gray-light);
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--gray-darkest);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Menu Divider */
.menu-divider {
  height: 1px;
  background-color: var(--gray-light);
  margin: 1.5rem 0;
}

/* Compare Button */
.compare-button {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--gray-darkest);
  background-color: transparent;
  border: 2px solid var(--gray-medium);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'IBM Plex Sans', sans-serif;
}

.compare-button:hover:not(:disabled) {
  background-color: var(--gray-lightest);
  border-color: var(--gray-darkest);
}

.compare-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Smooth transition for dark mode */
body {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Main Content */
main {
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#map {
  flex: 1;
  width: 100%;
  min-height: 0;
  border-top: 3px solid var(--gray-medium);
  border-bottom: 3px solid var(--gray-medium);
}

/* Status Bar */
#status-bar {
  background-color: #d4c4a8;
  background-image: url('../images/coastal%20camo%20light.png');
  background-repeat: repeat;
  background-size: 400px auto;
  padding: 0.5rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(0, 0, 0, 0.2);
  font-size: 0.7rem;
  color: #ffffff;
  flex-shrink: 0;
  text-shadow:
    1px 1px 3px rgba(0, 0, 0, 0.8),
    -1px -1px 2px rgba(0, 0, 0, 0.6),
    0 0 6px rgba(0, 0, 0, 0.5);
}

#status-bar span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

#status-bar .time {
  color: #ffffff;
}

.status-bar-left {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}

.status-bar-updates {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.status-bar-credit {
  font-size: 0.65rem;
  opacity: 0.9;
  font-style: italic;
}

/* Dark mode status bar */
body.dark-mode #status-bar {
  background-color: #2a2a2a;
  background-image: url('../images/coastal%20camo%20dark.png');
  background-repeat: repeat;
  background-size: 400px auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #e8e8e8;
}

body.dark-mode #status-bar .time {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

body.dark-mode #status-bar span {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
  background: var(--white);
  color: var(--gray-dark);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
  margin: 0;
  min-width: 600px;
  max-width: 700px;
  max-height: 500px;
  overflow-y: auto;
}

.leaflet-popup-tip {
  background: var(--white);
}

/* Station Popup Styles */
.station-popup {
  padding: 1rem;
}

.station-popup h2 {
  color: var(--gray-darkest);
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 3px solid var(--gray-light);
}

.station-popup h3 {
  color: var(--gray-dark);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.section {
  margin: 0.35rem 0;
  padding: 0.35rem 0.5rem;
  border-left: 3px solid var(--gray-medium);
  background-color: var(--gray-lightest);
}

.section:first-of-type {
  margin-top: 0;
}

.section p {
  margin: 0.25rem 0;
  color: var(--gray-dark);
  font-size: 0.9rem;
}

.section strong {
  color: var(--gray-darkest);
  font-weight: 600;
}

/* Tide Levels Display */
.tide-levels {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0.15rem 0;
}

.tide-levels span {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.1rem 0;
  font-size: 0.85rem;
}

.tide-levels .observed {
  color: var(--gray-darkest);
}

.tide-levels .predicted {
  color: var(--gray-medium);
}

.tide-levels .delta {
  color: var(--gray-dark);
  font-style: italic;
}

/* Phase Display */
.phase {
  font-size: 0.85rem;
  color: var(--gray-darkest);
  margin-top: 0.25rem;
  padding: 0.3rem;
  background-color: var(--white);
  border-radius: 4px;
  text-align: center;
}

/* Two-Column Layout */
.two-column-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.two-column-row .section {
  flex: 1;
  margin: 0;
  min-width: 0;
}

.two-column-row .section h3 {
  font-size: 0.9rem;
}

.two-column-row .section p {
  font-size: 0.85rem;
}

/* Compact Section - for minimal data blocks */
.section.compact {
  padding: 0.35rem 0.5rem;
}

.section.compact h3 {
  font-size: 0.8rem;
  margin-bottom: 0.15rem;
}

.section.compact p {
  font-size: 0.85rem;
  margin: 0;
}

.section.compact .data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.section.compact .data-value {
  color: var(--gray-darkest);
  font-size: 1rem;
}

/* Inline data layout for single values */
.inline-data {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.inline-data .label {
  font-size: 0.8rem;
  color: var(--gray-medium);
}

.inline-data .value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-darkest);
}

/* Next Tide optimized styling */
.section.next-tide {
  padding: 0.35rem 0.5rem;
}

.section.next-tide h3 {
  margin-bottom: 0.25rem;
}

.section.next-tide .tide-event {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.15rem 0;
  font-size: 0.85rem;
}

.section.next-tide .tide-event .tide-kind {
  font-weight: 600;
  color: var(--gray-darkest);
  min-width: 35px;
}

.section.next-tide .tide-event .tide-time {
  color: var(--gray-dark);
}

.section.next-tide .tide-event .tide-height {
  color: var(--gray-darkest);
}

/* Tide Status optimized */
.section.tide-status {
  padding: 0.35rem 0.5rem;
}

.section.tide-status h3 {
  margin-bottom: 0.25rem;
}

/* Chart Container */
.chart-container {
  background-color: var(--white);
  padding: 0.5rem;
  margin: 0.5rem 0;
  border-left: 3px solid var(--accent);
}

#tide-chart {
  width: 100% !important;
  height: 220px !important;
}

#water-temp-chart {
  width: 100% !important;
  height: 220px !important;
}

/* Loading State */
.loading {
  padding: 2rem;
  text-align: center;
  color: var(--gray-medium);
  font-size: 1.1rem;
}

.loading::after {
  content: '...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* Error State */
.error {
  padding: 2rem;
  text-align: center;
  color: var(--red);
  font-size: 1rem;
  background-color: rgba(255, 68, 68, 0.1);
  border: 2px solid var(--red);
  border-radius: 4px;
}

/* Data Unavailable */
.unavailable {
  color: var(--gray-medium);
  font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
  .side-menu {
    width: 280px;
    right: -280px;
  }

  .menu-content {
    padding: 4rem 1.25rem 1.25rem;
  }

  .menu-toggle {
    width: 36px;
    height: 36px;
  }

  .menu-icon {
    width: 18px;
  }

  #status-bar {
    padding: 0.5rem 1rem;
    font-size: 0.65rem;
  }

  .status-bar-credit {
    font-size: 0.6rem;
  }

  .leaflet-popup-content {
    min-width: 280px;
    max-width: 320px;
  }

  .station-popup {
    padding: 0.5rem;
  }

  .station-popup h2 {
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
    padding-bottom: 0.25rem;
  }

  .station-popup h3 {
    font-size: 0.8rem;
    margin-bottom: 0.15rem;
  }

  .section {
    padding: 0.35rem 0.5rem;
  }

  .section.compact {
    padding: 0.25rem 0.4rem;
  }

  .section.compact h3 {
    font-size: 0.75rem;
  }

  .section.compact .data-value {
    font-size: 0.9rem;
  }

  .two-column-row {
    gap: 0.35rem;
    margin: 0.35rem 0;
  }

  .tide-levels span {
    font-size: 0.8rem;
  }

  .section.next-tide .tide-event {
    font-size: 0.8rem;
    padding: 0.1rem 0;
  }

  .phase {
    font-size: 0.8rem;
    padding: 0.25rem;
  }

  #tide-chart {
    height: 200px !important;
  }

  #water-temp-chart {
    height: 200px !important;
  }

  .chart-container {
    padding: 0.35rem;
    margin: 0.35rem 0;
  }
}

@media (max-width: 480px) {
  .side-menu {
    width: 260px;
    right: -260px;
  }

  .menu-content {
    padding: 3.5rem 1rem 1rem;
  }

  .menu-toggle {
    width: 34px;
    height: 34px;
  }

  .menu-icon {
    width: 16px;
  }

  header {
    padding: 1rem;
  }

  .leaflet-popup-content {
    min-width: 260px;
    max-width: 290px;
  }

  .station-popup {
    padding: 0.4rem;
  }

  .station-popup h2 {
    font-size: 1rem;
  }

  .two-column-row {
    gap: 0.25rem;
  }

  .section.compact {
    padding: 0.2rem 0.35rem;
  }

  .section.compact h3 {
    font-size: 0.7rem;
  }

  .section.compact .data-row {
    font-size: 0.8rem;
  }

  .section.compact .data-value {
    font-size: 0.85rem;
  }

  .tide-levels {
    font-size: 0.8rem;
  }

  .tide-levels span {
    font-size: 0.75rem;
  }

  #tide-chart {
    height: 180px !important;
  }

  #water-temp-chart {
    height: 180px !important;
  }
}
