* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#header {
  background: linear-gradient(135deg, #1a5276 0%, #2e86ab 100%);
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

#spot-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Conditions Toggle Button (Map-wide) */
.conditions-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.conditions-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.conditions-toggle-btn.active {
  background: rgba(34, 197, 94, 0.8);
  border-color: rgba(34, 197, 94, 1);
}

.conditions-toggle-btn.loading {
  opacity: 0.7;
  cursor: wait;
}

.toggle-icon {
  font-size: 1.1rem;
}

#map {
  flex: 1;
  width: 100%;
}

.leaflet-popup-content {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

.leaflet-popup-content a {
  color: #2e86ab;
  text-decoration: none;
}

.leaflet-popup-content a:hover {
  text-decoration: underline;
}

.marker-cluster-small {
  background-color: rgba(46, 134, 171, 0.6);
}

.marker-cluster-small div {
  background-color: rgba(46, 134, 171, 0.8);
}

.marker-cluster-medium {
  background-color: rgba(26, 82, 118, 0.6);
}

.marker-cluster-medium div {
  background-color: rgba(26, 82, 118, 0.8);
}

.marker-cluster-large {
  background-color: rgba(23, 37, 42, 0.6);
}

.marker-cluster-large div {
  background-color: rgba(23, 37, 42, 0.8);
}

.marker-cluster div {
  color: white;
  font-weight: 600;
}

/* Loading Overlay */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a5276 0%, #2e86ab 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-content {
  text-align: center;
  color: white;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.loading-progress {
  font-size: 1rem;
  opacity: 0.9;
}

/* Enhanced Popup Styles */
.spot-popup {
  min-width: 220px;
  max-width: 300px;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  gap: 8px;
}

.popup-header .rating {
  color: #f4c430;
  font-size: 0.9rem;
  white-space: nowrap;
}

.popup-location {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 4px;
}

.popup-section {
  margin: 8px 0;
  padding: 8px 0;
  border-top: 1px solid #eee;
}

.section-title {
  font-weight: 600;
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.popup-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  margin: 4px 0;
  line-height: 1.3;
}

.popup-row .icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.popup-hazards {
  background: #fff3cd;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  margin: 8px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.popup-hazards .icon {
  flex-shrink: 0;
}

.popup-links {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #eee;
  flex-wrap: wrap;
  align-items: center;
}

.popup-links a {
  color: #2e86ab;
  text-decoration: none;
  font-size: 0.85rem;
}

.popup-links a:hover {
  text-decoration: underline;
}

.loading-details {
  color: #888;
  font-style: italic;
}

/* Search Bar Styles */
#search-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#search-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

#search-input {
  width: 320px;
  padding: 8px 14px;
  border: none;
  border-radius: 20px;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.95);
  color: #333;
}

#search-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

#search-input::placeholder {
  color: #888;
}

#search-button,
#clear-search {
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#search-button {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

#search-button:hover {
  background: rgba(255, 255, 255, 0.3);
}

#search-button:active {
  transform: scale(0.98);
}

#clear-search {
  background: rgba(255, 100, 100, 0.8);
  color: white;
}

#clear-search:hover {
  background: rgba(255, 100, 100, 1);
}

#clear-search.hidden {
  display: none;
}

#search-status {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.9);
}

#search-status.hidden {
  display: none;
}

/* Responsive header */
@media (max-width: 768px) {
  #header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 15px;
  }

  #header h1 {
    font-size: 1.2rem;
  }

  #search-input {
    width: 200px;
  }

  #search-container {
    order: 3;
    width: 100%;
  }

  #search-form {
    width: 100%;
    justify-content: center;
  }
}

/* Search result markers */
.search-result-marker {
  filter: hue-rotate(280deg) brightness(1.2);
}

/* Similar spots button in popups */
.similar-spots-btn {
  background: #2e86ab;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.2s;
}

.similar-spots-btn:hover {
  background: #1a5276;
}

.similar-spots-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Conditions Toggle Checkbox */
.conditions-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
}

.conditions-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #f4c430;
}

.toggle-label {
  white-space: nowrap;
}

/* Current Conditions Display */
#current-conditions {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.2);
  padding: 4px 10px;
  border-radius: 12px;
  margin-top: 4px;
}

#current-conditions.hidden {
  display: none;
}

/* Condition Match Badge Styles */
.condition-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
}

.condition-badge.excellent {
  background: #22c55e;
  color: white;
}

.condition-badge.good {
  background: #84cc16;
  color: white;
}

.condition-badge.fair {
  background: #eab308;
  color: #333;
}

.condition-badge.poor {
  background: #f97316;
  color: white;
}

.condition-badge.bad {
  background: #ef4444;
  color: white;
}

/* Condition Details in Popup */
.condition-details {
  font-size: 0.8rem;
  color: #666;
  margin-top: 4px;
  padding: 6px 8px;
  background: #f5f5f5;
  border-radius: 4px;
}

.condition-details .detail-row {
  display: flex;
  justify-content: space-between;
  margin: 2px 0;
}

.condition-details .match-bar {
  width: 60px;
  height: 6px;
  background: #ddd;
  border-radius: 3px;
  overflow: hidden;
  margin-left: 8px;
}

.condition-details .match-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.match-bar-fill.excellent { background: #22c55e; }
.match-bar-fill.good { background: #84cc16; }
.match-bar-fill.fair { background: #eab308; }
.match-bar-fill.poor { background: #f97316; }
.match-bar-fill.bad { background: #ef4444; }

/* Period Bonus/Penalty Display */
.condition-details .period-bonus {
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
}

.condition-details .period-bonus:first-of-type {
  background: #f0f0f0;
}

/* Popup recommendation section */
.popup-recommendation {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin: 8px 0;
  border-radius: 6px;
  font-size: 0.85rem;
}

.popup-recommendation.excellent { background: rgba(34, 197, 94, 0.15); color: #16a34a; }
.popup-recommendation.good { background: rgba(132, 204, 22, 0.15); color: #65a30d; }
.popup-recommendation.fair { background: rgba(234, 179, 8, 0.15); color: #ca8a04; }
.popup-recommendation.poor { background: rgba(249, 115, 22, 0.15); color: #ea580c; }
.popup-recommendation.bad { background: rgba(239, 68, 68, 0.15); color: #dc2626; }

/* Live conditions button in popup */
.check-conditions-btn {
  background: linear-gradient(135deg, #2e86ab 0%, #1a5276 100%);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.check-conditions-btn:hover {
  opacity: 0.9;
}

.check-conditions-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Responsive adjustments for conditions toggle */
@media (max-width: 768px) {
  .conditions-toggle {
    font-size: 0.75rem;
  }

  #search-form {
    flex-wrap: wrap;
    gap: 6px;
  }

  .conditions-toggle {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }

  .header-right {
    gap: 8px;
  }

  .conditions-toggle-btn {
    padding: 4px 8px;
    font-size: 0.8rem;
  }

  .toggle-text {
    display: none;
  }
}

/* Condition Marker Styles */
.condition-marker {
  background: transparent;
}

.condition-marker-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Condition Cluster Styles */
.condition-cluster {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  border: 3px solid white;
}

.condition-cluster-small {
  width: 40px;
  height: 40px;
  font-size: 12px;
}

.condition-cluster-medium {
  width: 50px;
  height: 50px;
  font-size: 14px;
}

.condition-cluster-large {
  width: 60px;
  height: 60px;
  font-size: 16px;
}

/* Tide Display Styles */
.tide-station {
  font-size: 0.7rem;
  color: #888;
  font-style: italic;
}

.tide-next {
  font-size: 0.8rem;
  color: #555;
}

.popup-row.tide-next {
  background: rgba(0, 0, 0, 0.03);
  padding: 4px 6px;
  border-radius: 4px;
  margin-top: 4px;
}
