/**
 * Interactive Map Editor - Modern Apple Design
 * Clean, minimal, premium aesthetic
 * Author: Morris Kahn Marine Research Station
 */

/* ========================================
   RESET & BASE STYLES
   ======================================== */

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

html,
body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue',
    sans-serif;
  background: #0a0a0a;
  color: #f5f5f7;
  overflow: hidden;
}

/* ========================================
   LAYOUT STRUCTURE
   ======================================== */

.container {
  display: flex;
  height: 100vh;
  flex-direction: column;
  position: relative;
}

.map-container {
  position: relative;
  height: 60vh;
  width: 100%;
  flex-shrink: 0;
  background: #1a1a1a;
  border-bottom: 1px solid #424245;
}

#map {
  width: 100%;
  height: 100%;
  border-bottom: none;
}

.resizer {
  height: 12px;
  background: #424245;
  cursor: ns-resize;
  position: relative;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.resizer:hover {
  background: #62646b;
  height: 16px;
}

.resizer-handle {
  width: 100px;
  height: 12px;
  background: #62646b;
  border-radius: 3px;
  transition: all 0.2s ease;
  position: relative;
}

.resizer-handle::before {
  content: '≡';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #ffffff;
  font-size: 18px;
  line-height: 1;
}

.resizer:hover .resizer-handle {
  background: #a1a1a6;
  height: 11px;
}
.info-panel {
  background: #0a0a0a;
  padding: 32px;
  overflow-y: scroll !important;
  box-shadow: none;
  border-top: 1px solid #424245;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.info-panel::-webkit-scrollbar {
  width: 10px;
  height: 60px; /* Shorter scrollbar thumb */
}

.info-panel::-webkit-scrollbar-track {
  background: #1a1a1a;
  border-radius: 6px;
}

.info-panel::-webkit-scrollbar-thumb {
  background: #424245;
  border-radius: 6px;
  min-height: 60px; /* Minimum thumb height */
}

.info-panel::-webkit-scrollbar-thumb:hover {
  background: #62646b;
}

/* Firefox */
.info-panel {
  scrollbar-width: auto; /* Normal width instead of thin */
  scrollbar-color: #424245 #1a1a1a;
}

.info-panel::-webkit-scrollbar-thumb {
  background: #424245;
  border-radius: 6px;
  min-height: 40px;
  cursor: pointer;
}

.info-panel::-webkit-scrollbar-thumb:active {
  background: #62646b;
  cursor: grabbing;
}
/* ========================================
   TYPOGRAPHY
   ======================================== */

.info-panel h2 {
  margin-bottom: 16px;
  color: #f5f5f7;
  border: none;
  padding-bottom: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.4px;
}

p {
  color: #86868b;
  font-size: 15px;
  line-height: 1.6;
}

/* ========================================
   INSTRUCTIONS & INFO BOXES
   ======================================== */

.instructions {
  background: #1a1a1a;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #f5f5f7;
  border-left: none;
}

.shape-info {
  background: #1a1a1a;
  padding: 12px 14px;
  border-radius: 8px;
  border-left: none;
  color: #86868b;
  font-size: 13px;
  margin-bottom: 16px;
  min-height: 30px;
}

/* ========================================
   BUTTONS
   ======================================== */

.button-row {
  margin-bottom: 24px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
  margin: 0;
  font-weight: 500;
  background: #424245;
}

.btn:hover {
  background: #62646b;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

/* Enlarge icons in buttons */
.btn-icon {
  font-size: 18px;
  margin-right: 4px;
}

/* Enlarge icons in buttons */
.btn-icon {
  font-size: 18px;
  margin-right: 4px;
}

.btn-street {
  background: #424245;
}

.btn-street:hover {
  background: #62646b;
}

.btn-satellite {
  background: #424245;
}

.btn-satellite:hover {
  background: #62646b;
}

.btn-clear {
  background: #ff3b30;
}

.btn-clear:hover {
  background: #ff453a;
}

.btn-download {
  background: #424245;
}

.btn-download:hover {
  background: #62646b;
}

.btn-upload {
  background: #424245;
}

.btn-upload:hover {
  background: #62646b;
}

/* ========================================
   ZOOM INDICATOR
   ======================================== */

.zoom-indicator {
  background: #1a1a1a;
  padding: 8px 12px;
  border-radius: 8px;
  border-left: none;
  color: #f5f5f7;
  font-weight: 500;
  font-size: 13px;
}

/* ========================================
   STYLE CONTROLS PANEL
   ======================================== */

.style-controls {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  background: #1a1a1a;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 24px;
  border-left: none;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.control-group label {
  color: #f5f5f7;
  font-size: 13px;
  min-width: 100px;
  font-weight: 500;
}

.control-group input[type='color'] {
  width: 44px;
  height: 44px;
  border: 1px solid #424245;
  border-radius: 8px;
  cursor: pointer;
}

.control-group input[type='range'] {
  width: 120px;
  cursor: pointer;
  height: 5px;
  border-radius: 3px;
  background: #424245;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.control-group input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f5f5f7;
  cursor: pointer;
  border: none;
}

.control-group input[type='range']::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f5f5f7;
  cursor: pointer;
  border: none;
}

.control-group span {
  color: #86868b;
  font-weight: 500;
  min-width: 35px;
  font-size: 13px;
}

/* ========================================
   TEXT & MARKER CONTROLS
   ======================================== */

.text-controls {
  background: #1a1a1a;
  padding: 16px;
  border-radius: 12px;
  border-left: none;
  color: #f5f5f7;
  margin-bottom: 24px;
}

.text-controls h3 {
  color: #f5f5f7;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
}

.text-controls .control-group {
  margin-bottom: 10px;
}

.text-controls input[type='text'] {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #424245;
  background: #1a1a1a;
  color: #f5f5f7;
  font-size: 13px;
  transition: border-color 0.2s ease;
}

.text-controls input[type='text']:focus {
  outline: none;
  border-color: #62646b;
  background: #262626;
}

/* ========================================
   COORDINATES DISPLAY
   ======================================== */

.coordinates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.coord-item {
  background: #1a1a1a;
  padding: 12px;
  border-left: 3px solid #424245;
  border-radius: 8px;
  font-family: 'Menlo', 'Monaco', monospace;
  font-size: 12px;
  color: #f5f5f7;
  line-height: 1.5;
}

.coord-item strong {
  color: #f5f5f7;
  font-weight: 600;
}

/* ========================================
   LEAFLET MAP CUSTOMIZATION
   ======================================== */

/* Lower the zoom controls to avoid overlap with drawing tools */
.leaflet-top.leaflet-left {
  top: 150px !important;
}

/* ========================================
   CUSTOM MAP MARKERS
   ======================================== */

.text-marker {
  background: transparent;
  border: none;
}

.text-display {
  color: #f5f5f7;
  font-size: 15px;
  font-weight: 500;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(26, 26, 26, 0.95);
  /* backdrop-filter: blur(10px); */
  border: 1px solid rgba(100, 100, 107, 0.3);
}

.center-marker {
  background: #ff3b30;
  border: 2px solid white;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  cursor: move;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.custom-marker {
  background: #f5f5f7;
  border: 2px solid #1a1a1a;
  border-radius: 50%;
  width: 12px;
  height: 12px;
  cursor: grab;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* ========================================
   TOGGLE MENU BUTTON
   ======================================== */

.toggle-menu-btn {
  position: absolute;
  top: 15px;
  right: 60px;
  z-index: 2000;
  background: rgb(255, 255, 255);
  color: #000000;
  border: 1px solid #424245;
  border-radius: 0px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  /* backdrop-filter: blur(10px); */
}

.toggle-menu-btn:hover {
  background: rgba(255, 255, 255, 0.799);
  border-color: #62646b;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
  .button-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }

  .zoom-indicator {
    width: 100%;
    text-align: center;
  }

  .coordinates {
    grid-template-columns: 1fr;
  }

  .marker-text-container {
    flex-direction: column;
  }

  .marker-text-container .text-controls {
    margin-bottom: 24px;
  }
}

@media (max-width: 480px) {
  .button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .btn {
    width: 100%;
  }

  .zoom-indicator {
    grid-column: 1 / -1;
    width: 100%;
    text-align: center;
  }

  .style-controls {
    gap: 16px;
    padding: 16px;
  }

  .control-group {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }

  .control-group input[type='range'] {
    width: 100%;
  }

  .coordinates {
    grid-template-columns: 1fr;
  }

  .marker-text-container {
    flex-direction: column;
  }

  .marker-text-container .text-controls {
    margin-bottom: 24px;
  }
  #logoOverlay {
    top: 5px !important;
    left: 5px !important;
  }
  #logoOverlay img {
    width: 80px !important;
  }

  .leaflet-top.leaflet-left {
    top: 90px !important;
  }

  .marker-text-container .text-controls {
    flex: 1;
    width: 100%;
  }
  /* .text-controls h3,
  .text-controls label {
    text-align: center;
  } */

  .text-controls input[type='text'] {
    width: 100% !important;
  }
  /* .btn #toggleThemeBtn {
    width: 100% !important;
  } */
  #toggleThemeBtn {
    grid-column: 1 / -1;
  }

  .info-panel {
    padding: 24px;
    overflow-y: scroll !important;
    max-height: calc(40vh - 12px);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    position: relative;
  }

  body {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }
}
/* ========================================
   MARKER & TEXT SIDE-BY-SIDE LAYOUT
   ======================================== */

.marker-text-container {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.marker-text-container .text-controls {
  flex: 0.25;
  margin-bottom: 0;
}
/* Bigger, clearer Leaflet scale control */
.leaflet-control-scale-line {
  text-align: center;
}

.separator {
  height: 2px;
  background: linear-gradient(
    20deg,
    transparent,
    rgb(0, 132, 255),
    transparent
  );
  margin: 6px 0;
  border-radius: 1px;
}
.credits {
  text-align: center;
  font-size: 12px;
  color: #ffffff !important;
  padding: 12px 0;
}
#creditss p {
  color: #ffffff !important;
}
.leaflet-control-coordinates {
  background-color: rgba(226, 226, 226, 0.835);
  color: rgb(0, 0, 0);
  cursor: pointer;
  align-items: center;
  font-size: 15px;
  border: 1px solid rgba(34, 3, 3, 0.946);
  display: flex;
  height: 30px;
  box-shadow: #000000 2px 2px 4px;
}
.leaflet-control-coordinates,
.leaflet-control-coordinates .uiElement input {
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.leaflet-control-coordinates .uiElement {
  margin: 4px;
}
.leaflet-control-coordinates .uiElement .labelFirst {
  margin-right: 4px;
}

.leaflet-control-coordinates .uiElement.label {
  display: none !important;  /* hide the plain-text label; only show input boxes */
}

/* Always show the input container (override the uiHidden default) */
.leaflet-control-coordinates .uiElement.input {
  display: inline-flex !important;
  align-items: center;
}

.leaflet-control-coordinates .uiElement input {
  width: 80px;
  border: 1px solid rgba(34, 3, 3, 0.946);
  background: white;
  box-shadow: none;
  outline: none;
  font-size: 14px;
  color: black;
  padding: 0px;
  margin: 5px;
  text-align: center;
}
#readmeContent {
  line-height: 1.6;
}

#readmeContent h1 {
  color: #42a5f5;
  margin-top: 40px;
  padding-bottom: 10px;
  border-bottom: 2px solid #424245;
}

#readmeContent h2 {
  color: #64b5f6;
  margin-top: 30px;
  margin-bottom: 15px;
}

#readmeContent h3 {
  color: #86b7fe;
  margin-top: 20px;
}

#readmeContent p {
  margin: 15px 0;
}

#readmeContent ul,
#readmeContent ol {
  margin-left: 20px;
  margin-bottom: 15px;
}

#readmeContent li {
  margin: 8px 0;
}

#readmeContent code {
  background: #2a2a2a;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
}

#readmeContent pre {
  background: #2a2a2a;
  padding: 15px;
  border-radius: 8px;
  overflow-x: auto;
}

#readmeContent table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
}

#readmeContent th,
#readmeContent td {
  border: 1px solid #424245;
  padding: 10px;
  text-align: left;
}

#readmeContent th {
  background: #2a2a2a;
}

#readmeContent hr {
  border: none;
  border-top: 1px solid #424245;
  margin: 30px 0;
}

#readmeContent img {
  max-width: 200px;
  margin: 20px 0;
}

#readmeContent blockquote {
  border-left: 4px solid #42a5f5;
  padding-left: 20px;
  margin: 20px 0;
  color: #999;
}
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  overflow: auto;
}

.modal-content {
  background-color: #1a1a1a;
  margin: 3% auto;
  padding: 40px;
  border: 1px solid #424245;
  border-radius: 12px;
  width: 90%;
  max-width: 900px;
  color: #f5f5f7;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.close {
  color: #ffffff;
  position: fixed; /* CHANGED from absolute to fixed */
  top: 5%; /* Stays at top of viewport */
  right: calc(5% + 30px); /* Aligned with modal edge */
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10002; /* Above modal content */
  background: #ce12efaf; /* Background so it's visible over content */
  width: 50px;
  height: 75px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #424245;
  transition: all 0.2s ease;
}

.close:hover {
  color: #fff;
  background: #ff3b30;
  border-color: #ff3b30;
}

.neon-btn {
  position: relative;
  display: inline-block;
  padding: 10px 16px;
  color: #03e9f4;
  text-decoration: none;
  text-transform: uppercase;
  transition: 0.5s;
  letter-spacing: 2px;
  overflow: hidden;
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.neon-btn:hover {
  background: #03e9f4;
  color: #050801;
  box-shadow: 0 0 5px #03e9f4, 0 0 25px #03e9f4, 0 0 50px #03e9f4,
    0 0 100px #03e9f4;
}

.neon-btn span {
  position: absolute;
  display: block;
}

.neon-btn span:nth-child(1) {
  top: 0;
  left: -100%;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #03e9f4);
  animation: animate1 4s linear infinite;
}

@keyframes animate1 {
  0% {
    left: -100%;
  }
  50%,
  100% {
    left: 100%;
  }
}

.neon-btn span:nth-child(2) {
  top: -100%;
  right: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg, transparent, #03e9f4);
  animation: animate2 4s linear infinite;
  animation-delay: 1s;
}

@keyframes animate2 {
  0% {
    top: -100%;
  }
  50%,
  100% {
    top: 100%;
  }
}

.neon-btn span:nth-child(3) {
  bottom: 0;
  right: -100%;
  width: 100%;
  height: 2px;
  background: linear-gradient(270deg, transparent, #03e9f4);
  animation: animate3 4s linear infinite;
  animation-delay: 2s;
}

@keyframes animate3 {
  0% {
    right: -100%;
  }
  50%,
  100% {
    right: 100%;
  }
}

.neon-btn span:nth-child(4) {
  bottom: -100%;
  left: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(360deg, transparent, #03e9f4);
  animation: animate4 4s linear infinite;
  animation-delay: 3s;
}

@keyframes animate4 {
  0% {
    bottom: -100%;
  }
  50%,
  100% {
    bottom: 100%;
  }
}
/* When ruler is active, keep crosshair and disable marker interaction */
.leaflet-ruler-clicked .leaflet-marker-pane {
  pointer-events: none !important;
}

.leaflet-ruler-clicked .leaflet-overlay-pane .leaflet-interactive {
  pointer-events: none !important;
}

/* Keep ruler's own markers clickable */
.leaflet-ruler-clicked .leaflet-ruler .leaflet-marker-icon {
  pointer-events: auto !important;
}

/* Ensure crosshair stays during ruler mode */
.leaflet-ruler-clicked {
  cursor: crosshair !important;
}

/* Force crosshair cursor when ruler is active, even over markers */
.leaflet-ruler-clicked * {
  cursor: crosshair !important;
}

/* Disable marker interaction during ruler mode */
.leaflet-ruler-clicked .leaflet-marker-pane,
.leaflet-ruler-clicked .leaflet-marker-icon {
  pointer-events: none !important;
  cursor: crosshair !important;
}

/* Keep ruler markers interactive */
.leaflet-ruler .leaflet-marker-icon {
  pointer-events: auto !important;
}

.leaflet-grid-label .gridlabel-vert {
  margin-left: 2px;
  -webkit-transform: rotate(90deg);
  transform: rotate(90deg);
}
.leaflet-grid-label .gridlabel-horiz {
  margin-top: -4px;
}
.leaflet-grid-label .gridlabel-vert,
.leaflet-grid-label .gridlabel-horiz {
  padding-left: 2px;
  text-shadow: -2px 0 #ffffff, 0 2px #ffffff, 2px 0 #ffffff, 0 -2px #ffffff;
  font-size: 11px;
  color: #111;
  white-space: nowrap;
}
.leaflet-left {
  left: 10px !important;
}
.leaflet-right {
  left: 10px !important;
}
#logoOverlay {
  left: 20px !important;
  top: 20px !important;
}

.leaflet-ruler {
  top: 5px !important;
}
/* ============================================
   RESIZER - MOBILE TOUCH STYLES
   ============================================
   

/* Mobile only */
@media (max-width: 768px) {
  .resizer {
    height: 28px;
    min-height: 28px;
  }

  .resizer-handle {
    height: 20px;
  }

  /* Green when actively dragging on mobile - uses JS class */
  .resizer.dragging {
    background: #4caf50;
    height: 35px;
  }

  .resizer.dragging .resizer-handle {
    background: #16911a;
    height: 24px;
  }

  .resizer.dragging .resizer-handle::before {
    color: #ffffff;
  }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
  .resizer {
    height: 24px;
    min-height: 24px;
  }

  .resizer.dragging {
    background: #4caf50;
  }

  .resizer.dragging .resizer-handle {
    background: #16911a;
  }
}
@media (max-width: 600px) {
  #mt-fullscreen button {
    padding: 4px 8px !important;
    font-size: 10px !important;
  }
}

/* ============================================================
   MOBILE — LEGEND / FILTER PANELS & CHART PANELS
   ============================================================ */
@media (max-width: 768px) {

  /* Filter panels: initial size set in JS (30vh × 50vw); CSS just ensures
     overflow and z-index — no max-height so JS resize can grow them freely */
  .scientific-legend,
  .guitarfish-legend {
    overflow-y: auto !important;
    border-radius: 12px !important;
    box-sizing: border-box !important;
    z-index: 1200 !important;
  }

  /* Drag pill hint on header */
  .scientific-legend #legend-header::before,
  .guitarfish-legend #gf-legend-header::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: #555;
    border-radius: 2px;
    margin: 0 auto 8px;
  }

  .scientific-legend #legend-header,
  .guitarfish-legend #gf-legend-header {
    touch-action: none;
    cursor: move;
  }

  /* Month / week grids — fewer columns on small screens */
  #month-grid,
  #gf-month-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  #week-grid,
  #gf-week-grid {
    grid-template-columns: repeat(6, 1fr) !important;
  }

  /* Chart resize handle — bigger tap target on mobile (size set in JS) */
  .chart-resize-handle {
    min-width: 36px !important;
    min-height: 36px !important;
  }
}

