/* Reset & base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-gray-50: #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-400: #9ca3af;
  --color-gray-600: #4b5563;
  --color-gray-800: #1f2937;
  --color-gray-900: #111827;
  --color-teal: #0d9488;
  --panel-width: 340px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--color-gray-800);
}

/* Carte plein écran */
.map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Titre flottant */
.floating-header {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 14px;
  padding: 12px 18px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.04);
  pointer-events: auto;
}

.floating-title h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-gray-900);
  line-height: 1.2;
}

.floating-subtitle {
  font-size: 0.75rem;
  color: var(--color-gray-400);
  letter-spacing: 0.03em;
}

/* Stats flottantes */
.floating-stats {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 10px 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  gap: 18px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 48px;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-gray-900);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--color-gray-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--color-gray-200);
}

/* Bouton escales */
.btn-escales {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-gray-700);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn-escales:hover {
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.06);
}

/* Info panel */
.info-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--panel-width);
  height: 100%;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid rgba(0, 0, 0, 0.06);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.06);
}

.info-panel.open {
  transform: translateX(0);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.1);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--color-gray-200);
}

.panel-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.panel-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-gray-400);
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s;
}

.panel-close:hover {
  background: var(--color-gray-100);
}

/* Waypoint list */
.waypoint-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.waypoint-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s;
  text-align: left;
}

.waypoint-item:hover {
  background: var(--color-gray-100);
}

.waypoint-item.waypoint-current {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.waypoint-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  flex-shrink: 0;
  opacity: 0.5;
}

.waypoint-current .waypoint-icon {
  width: 10px;
  height: 10px;
  background: var(--color-primary);
  opacity: 1;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.waypoint-info {
  flex: 1;
  min-width: 0;
}

.waypoint-name {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--color-gray-800);
}

.waypoint-date {
  font-size: 0.72rem;
  color: var(--color-gray-400);
  margin-top: 1px;
}

.badge-current {
  display: inline-block;
  background: var(--color-primary);
  color: white;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

/* Country group headers */
.country-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 4px;
  margin-top: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-gray-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.country-flag {
  font-size: 0.85rem;
}

/* Boat marker */
.boat-marker {
  background: none !important;
  border: none !important;
}

.boat-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.boat-emoji {
  font-size: 28px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  z-index: 2;
  position: relative;
}

.boat-pulse {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.25);
  animation: pulse 2s ease-out infinite;
}

.boat-pulse-ring {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, 0.3);
  animation: pulse-ring 2s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

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

/* Waypoint dot */
.waypoint-marker {
  background: none !important;
  border: none !important;
}

.waypoint-dot {
  width: 10px;
  height: 10px;
  background: white;
  border: 2.5px solid var(--color-primary);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}

.waypoint-marker:hover .waypoint-dot {
  transform: scale(1.3);
}

/* Popup */
.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-popup-content {
  margin: 12px 14px !important;
}

.popup-content strong {
  font-size: 0.9rem;
  color: var(--color-gray-900);
}

.popup-date {
  font-size: 0.78rem;
  color: var(--color-gray-400);
}

.popup-desc {
  font-size: 0.82rem;
  color: var(--color-gray-600);
  margin-top: 4px;
  display: block;
}

/* Popup weather */
.popup-weather {
  margin-top: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--color-gray-200);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--color-gray-600);
}

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

.weather-temp {
  font-weight: 600;
  color: var(--color-gray-800);
}

.weather-desc {
  color: var(--color-gray-600);
}

.weather-wind {
  width: 100%;
  font-size: 0.75rem;
  color: var(--color-gray-400);
}

/* Popup actions */
.popup-actions {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--color-gray-200);
}

.popup-share {
  background: var(--color-gray-100);
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  color: var(--color-gray-600);
  cursor: pointer;
  transition: background 0.15s;
}

.popup-share:hover {
  background: var(--color-gray-200);
}

/* Legend */
.map-legend {
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.04);
  font-size: 0.75rem;
  line-height: 1.6;
}

.map-legend h4 {
  margin-bottom: 4px;
  font-size: 0.78rem;
  color: var(--color-gray-800);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-gray-600);
}

.legend-line {
  display: inline-block;
  width: 20px;
  height: 3px;
  border-radius: 2px;
}

.legend-line.legend-dashed {
  background: none !important;
  border-top: 2.5px dashed;
  height: 0;
  border-color: inherit;
}

.legend-item:nth-child(3) .legend-dashed {
  border-color: #6b7280;
}

.legend-item:nth-child(4) .legend-dashed {
  border-color: #0d9488;
}

.legend-dot {
  width: 10px;
  height: 10px;
  background: white;
  border: 2.5px solid var(--color-primary);
  border-radius: 50%;
}

.legend-boat {
  font-size: 0.9rem;
}

/* Mobile */
@media (max-width: 768px) {
  .floating-header {
    top: 10px;
    left: 10px;
    padding: 10px 14px;
    border-radius: 12px;
  }

  .floating-title h1 {
    font-size: 1.1rem;
  }

  .btn-escales {
    top: 10px;
    right: 10px;
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .floating-stats {
    bottom: 16px;
    padding: 8px 16px;
    gap: 12px;
    border-radius: 14px;
  }

  .stat-value {
    font-size: 1rem;
  }

  .info-panel {
    width: 100%;
    height: 55%;
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    border-left: none;
    border-top: 1px solid var(--color-gray-200);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }

  .info-panel.open {
    transform: translateY(0);
  }
}
