/* ═══════════════════════════════════════════════════════════════
   Marine Depth Finder — app.css
   Tema: Oceánico oscuro premium con glassmorphism
═══════════════════════════════════════════════════════════════ */

/* ── VARIABLES ─────────────────────────────────────────────── */
:root {
  --bg: #050D1A;
  --surface: rgba(8, 20, 45, 0.90);
  --surface2: rgba(10, 28, 60, 0.85);
  --border: rgba(0, 229, 255, 0.15);
  --border2: rgba(0, 229, 255, 0.08);

  --cyan: #00E5FF;
  --cyan-dim: #31A7C0;
  --blue: #1E90FF;
  --orange: #FF6B35;
  --green: #4CAF50;
  --red: #FF4444;

  --text: #E8F4F8;
  --text-dim: #7EC8E3;
  --text-muted: #3A6070;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-cyan: 0 0 20px rgba(0, 229, 255, 0.12);

  --header-h: 60px;
  --font: 'Inter', -apple-system, system-ui, sans-serif;
}

/* ── RESET ─────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button {
  cursor: pointer;
  border: none;
  outline: none;
  font-family: var(--font);
}

.hidden {
  display: none !important;
}

/* ── HEADER ─────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(5, 13, 26, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border2);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon {
  font-size: 24px;
  filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.6));
}

.header-text h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.header-sub {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.4px;
}

/* GPS badge */
.gps-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
}

.gps-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #888;
  transition: background 0.3s;
}

.gps-badge.active .gps-dot {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse-gps 2s infinite;
}

.gps-badge.error .gps-dot {
  background: var(--red);
}

@keyframes pulse-gps {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.gps-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.8px;
}

/* ── MAPA ───────────────────────────────────────────────────── */
#map {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

/* Ocultar controles nativos de Leaflet que no necesitamos */
.leaflet-control-zoom {
  display: none !important;
}

.leaflet-control-attribution {
  font-size: 9px !important;
  opacity: 0.5 !important;
  background: rgba(0, 0, 0, 0.5) !important;
  color: #aaa !important;
}

/* ── PANEL DE PROFUNDIDAD ───────────────────────────────────── */
.depth-panel {
  position: fixed;
  top: calc(var(--header-h) + 10px);
  left: 12px;
  right: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.depth-card {
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow), var(--shadow-cyan);
  pointer-events: all;
  transition: opacity 0.3s;
}

.card-selected {
  border-left-color: var(--orange);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.card-icon {
  font-size: 14px;
}

.card-title {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  flex: 1;
}

.card-close {
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  padding: 2px 5px;
  border-radius: 4px;
  transition: color 0.2s;
}

.card-close:hover {
  color: var(--red);
}

.card-body {}

.depth-display {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  margin-bottom: 4px;
}

.depth-value {
  font-size: 40px;
  font-weight: 800;
  color: var(--cyan);
  line-height: 1;
  transition: color 0.4s;
  letter-spacing: -1px;
}

.depth-unit {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.zone-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.15);
  margin-bottom: 8px;
  color: var(--cyan);
}

.wave-info,
.temp-info,
.wind-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  margin-left: 6px;
  flex-shrink: 0;
}

.wave-info {
  background: rgba(0, 229, 255, 0.15);
  border: 1px solid rgba(0, 229, 255, 0.4);
  color: #00E5FF;
}

.temp-info {
  background: rgba(255, 152, 0, 0.15);
  border: 1px solid rgba(255, 152, 0, 0.4);
  color: #FF9800;
}

.wind-info {
  background: rgba(186, 104, 200, 0.15);
  border: 1px solid rgba(186, 104, 200, 0.4);
  color: #BA68C8;
}

.wave-icon,
.zone-emoji {
  font-size: 24px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  flex-shrink: 0;
}

.wave-text {
  font-weight: 700;
}

/* ── PREVISIÓN 7 DÍAS ──────────────────────────────────────── */
.forecast-7d {
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 10px;
}

.forecast-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.forecast-days {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  padding-right: 4px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.forecast-days::-webkit-scrollbar {
  display: none;
}

.forecast-day {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 6px 8px;
  text-align: center;
  min-width: 50px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.fday-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 4px;
}

.fday-temp {
  font-size: 12px;
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-bottom: 3px;
}

.fday-hot {
  color: #FF7043;
  font-weight: 700;
}

.fday-cold {
  color: #64B5F6;
  font-weight: 700;
}

.fday-wind {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.fday-wave {
  font-size: 11px;
  color: #4FC3F7;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.fday-weather {
  font-size: 24px;
  margin: 4px 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
}

.fday-text-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: capitalize;
}

/* ── SVG ICONS PREMIUM ─────────────────────────────────────── */
.icon-svg-inline {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2.5;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  flex-shrink: 0;
}

.fday-svg-mini {
  display: inline-flex;
  vertical-align: middle;
}

.fday-svg-mini svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}

.zone-emoji .icon-svg-inline {
  width: 28px;
  height: 28px;
  color: var(--cyan);
}

/* Fail-safe para asegurar que cualquier SVG en contenedores de iconos tenga tamaño */
.wave-icon svg,
#current-wave-icon svg,
#current-temp-icon svg,
#current-wind-icon svg,
#selected-wave-icon svg,
#selected-temp-icon svg,
#selected-wind-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}

/* ── AIS SHIPS (RADAR) ───────────────────────────────────────── */
.ais-marker {
  transition: transform 1.5s linear;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  z-index: 999 !important;
  pointer-events: auto !important;
  cursor: pointer !important;
}

.ais-marker:hover {
  filter: drop-shadow(0 0 10px rgba(255, 64, 129, 0.8));
}

.btn-active-ais {
  background: rgba(255, 64, 129, 0.9) !important;
  color: #fff !important;
  box-shadow: 0 0 15px rgba(255, 64, 129, 0.6) !important;
  border-color: #FF80AB !important;
}

.zone-emoji {
  font-size: 24px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.zone-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--cyan);
  transition: color 0.4s;
}

.coords-line {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  margin-top: 2px;
  min-height: 14px;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-action {
  flex: 1;
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 4px;
  font-size: 11px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

.btn-action:active {
  background: rgba(0, 229, 255, 0.15);
  color: var(--cyan);
}

/* ── FABs ───────────────────────────────────────────────────── */
.fab-group {
  position: fixed;
  bottom: 30px;
  right: 14px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fab {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow), var(--shadow-cyan);
  transition: background 0.2s, color 0.2s, transform 0.15s;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.fab svg {
  width: 20px;
  height: 20px;
}

.fab:active {
  transform: scale(0.92);
  background: rgba(0, 229, 255, 0.15);
  color: var(--cyan);
}

.fab-danger {
  border-color: rgba(255, 68, 68, 0.3);
}

.fab-danger:active {
  background: rgba(255, 68, 68, 0.15);
  color: var(--red);
}

/* ── PANEL LATERAL (HISTORIAL) ─────────────────────────────── */
.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 92vw);
  z-index: 1100;
  background: rgba(5, 13, 30, 0.97);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.6);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.side-panel.open {
  transform: translateX(0);
  display: flex !important;
}

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border2);
}

.side-panel-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.panel-close {
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s;
}

.panel-close:hover {
  color: var(--text);
}

.side-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 40px;
  line-height: 1.7;
}

/* Tarjeta de punto guardado */
.history-card {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.history-card:hover {
  border-color: var(--border);
}

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

.history-depth {
  font-size: 20px;
  font-weight: 800;
  color: var(--cyan);
}

.history-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.history-zone {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.history-coords {
  font-size: 10px;
  color: var(--text-muted);
}

.history-time {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
}

.history-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
}

.history-card:hover .history-delete {
  opacity: 1;
}

.history-delete:hover {
  color: var(--red);
}

.side-panel-footer {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border2);
}

.btn-export,
.btn-clear-all {
  flex: 1;
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 6px;
  font-size: 11px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

.btn-export:active {
  background: rgba(0, 229, 255, 0.15);
  color: var(--cyan);
}

.btn-clear-all:active {
  background: rgba(255, 68, 68, 0.15);
  color: var(--red);
}

/* ── LEYENDA ────────────────────────────────────────────────── */
.legend {
  position: fixed;
  bottom: 30px;
  left: 14px;
  z-index: 500;
}

.legend-toggle {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  box-shadow: var(--shadow);
  transition: background 0.2s, color 0.2s;
}

.legend-toggle:active {
  background: rgba(0, 229, 255, 0.15);
  color: var(--cyan);
}

.legend-content {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-width: 180px;
  box-shadow: var(--shadow), var(--shadow-cyan);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 11px;
  color: var(--text-dim);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* ── MARCADORES LEAFLET CUSTOM ──────────────────────────────── */
.leaflet-marker-depth {
  background: var(--cyan);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
  transition: background 0.3s;
}

/* Pulso del marcador de ubicación actual */
.leaflet-user-pulse {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 229, 255, 0.3);
  border: 2px solid var(--cyan);
  position: relative;
}

.leaflet-user-pulse::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% {
    opacity: 1;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    transform: scale(2);
  }
}

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  background: rgba(8, 24, 50, 0.95);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  white-space: nowrap;
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ── LOADING OVERLAY ────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.loading-overlay p {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.sonar {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sonar-dot {
  font-size: 28px;
  z-index: 10;
  filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.8));
}

.sonar-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  animation: sonar-wave 2.5s infinite;
  opacity: 0;
}

.sonar-ring.r2 {
  animation-delay: 0.8s;
}

.sonar-ring.r3 {
  animation-delay: 1.6s;
}

@keyframes sonar-wave {
  0% {
    transform: scale(0.5);
    opacity: 0.8;
  }

  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* ── SPINNER INLINE ─────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 229, 255, 0.2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

/* ── CARD HOVER (cursor) ────────────────────────────────────── */
.card-hover {
  border-left-color: #A855F7;
  /* Púrpura — diferencia de GPS (cyan) y click (naranja) */
}

.card-hover .depth-value {
  color: #A855F7;
}

.card-hover .zone-name {
  color: #A855F7;
}

.hover-status {
  font-size: 9px;
  font-weight: 600;
  color: rgba(168, 85, 247, 0.7);
  letter-spacing: 0.5px;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 10px;
  padding: 2px 7px;
}

/* ── ZOOM CONTROLS ──────────────────────────────────────────── */
.zoom-controls {
  position: fixed;
  left: 14px;
  bottom: 110px;
  /* encima de la leyenda */
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  box-shadow: var(--shadow), var(--shadow-cyan);
}

.zoom-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 20px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}

.zoom-btn:hover {
  background: rgba(0, 229, 255, 0.1);
  color: var(--cyan);
}

.zoom-btn:active {
  background: rgba(0, 229, 255, 0.2);
  color: var(--cyan);
  transform: scale(0.92);
}

.zoom-level {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  min-width: 20px;
  text-align: center;
  padding: 2px 0;
  border-top: 1px solid var(--border2);
  border-bottom: 1px solid var(--border2);
  width: 100%;
}


/* ── MEDIA: tablets / desktop ───────────────────────────────── */
@media (min-width: 600px) {
  .depth-panel {
    left: 16px;
    right: auto;
    width: 300px;
  }

  .depth-value {
    font-size: 48px;
  }

  .fab-group {
    bottom: 40px;
    right: 20px;
  }

  .legend {
    bottom: 40px;
    left: 20px;
  }

  .zoom-controls {
    bottom: 120px;
  }

  .leaflet-tooltip.distance-tooltip {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--orange);
    border-radius: 8px;
    padding: 6px 12px;
    box-shadow: var(--shadow);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.3;
    overflow: visible;
    max-width: 440px;
  }

  .leaflet-tooltip.distance-tooltip::before {
    border-right-color: var(--orange);
  }

  .custom-pin {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}