/* Rally Map - Frontend CSS */

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

/* ========================================
   MAPA
   ======================================== */

#map {
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

/* ========================================
   INFO OVERLAY
   ======================================== */

.info-overlay {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 10;
  pointer-events: none;
}

.info-panel {
  background: rgba(26, 29, 35, 0.95);
  backdrop-filter: blur(10px);
  padding: 20px 25px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  min-width: 300px;
}

.info-panel h2 {
  font-size: 20px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 12px;
  border-bottom: 2px solid #007bff;
  padding-bottom: 8px;
}

.event-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: #b8bcc8;
}

.event-info span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.event-info span::before {
  content: '•';
  color: #007bff;
  font-size: 16px;
}

/* ========================================
   MARCADORES DE PARTICIPANTES
   ======================================== */

.participant-marker {
  width: 40px;
  height: 40px;
  transform: rotate(0);
  font-family: 'WRC Clean', Arial, sans-serif;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  user-select: none;
  cursor: pointer;
}

.participant-marker:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  z-index: 1000;
}

.marker-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 3px solid #ffffff;
}

.marker-number {
  color: #ffffff;
  font-weight: bold;
  font-size: 16px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  line-height: 1;
}

/* ========================================
   CONTROLES DO MAPA
   ======================================== */

.map-controls {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-btn {
  background: rgba(26, 29, 35, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 12px 16px;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
}

.control-btn:hover {
  background: rgba(0, 123, 255, 0.2);
  border-color: #007bff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.control-btn .icon {
  font-size: 18px;
}

.control-btn.active {
  background: rgba(0, 123, 255, 0.3);
  border-color: #007bff;
}

/* ========================================
   LOADING
   ======================================== */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 29, 35, 0.98);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: #007bff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-overlay p {
  margin-top: 20px;
  color: #b8bcc8;
  font-size: 16px;
  font-weight: 500;
}

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

/* ========================================
   TRACE MODE - Transparent Background
   ======================================== */

html.trace-mode,
body.trace-mode {
  background: transparent !important;
}

body.trace-mode #map {
  background: transparent !important;
}

body.trace-mode .maplibregl-map {
  background: transparent !important;
}

body.trace-mode .maplibregl-canvas-container {
  background: transparent !important;
}

body.trace-mode .maplibregl-canvas {
  background: transparent !important;
}

body.trace-mode .loading-overlay {
  display: none !important;
}

body.trace-mode .info-overlay {
  display: none !important;
}

body.trace-mode .maplibregl-ctrl-bottom-left,
body.trace-mode .maplibregl-ctrl-bottom-right,
body.trace-mode .maplibregl-ctrl-attrib {
  display: none !important;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.toast-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.toast {
  background: rgba(26, 29, 35, 0.95);
  backdrop-filter: blur(10px);
  padding: 16px 20px;
  border-radius: 10px;
  border-left: 4px solid #007bff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease;
  color: #ffffff;
  font-size: 14px;
}

.toast.success {
  border-left-color: #28a745;
}

.toast.error {
  border-left-color: #dc3545;
}

.toast.warning {
  border-left-color: #ffc107;
}

.toast.info {
  border-left-color: #17a2b8;
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
}

.toast-close {
  background: none;
  border: none;
  color: #b8bcc8;
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ========================================
   CUSTOM INFO WINDOW
   ======================================== */

.custom-info-window {
  background: rgba(26, 29, 35, 0.98);
  backdrop-filter: blur(10px);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  color: #ffffff;
  min-width: 280px;
}

.custom-info-window h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.custom-info-window p {
  margin: 8px 0;
  font-size: 14px;
  color: #b8bcc8;
  display: flex;
  justify-content: space-between;
}

.custom-info-window strong {
  color: #ffffff;
  font-weight: 500;
}

.custom-info-window .speed {
  color: #007bff;
  font-size: 16px;
  font-weight: 600;
}

/* ========================================
   POLYLINES E ROTAS
   ======================================== */

.route-line {
  stroke: #007bff;
  stroke-width: 4;
  stroke-opacity: 0.8;
  fill: none;
}

.route-line-highlight {
  stroke: #ffc107;
  stroke-width: 6;
  stroke-opacity: 1;
}

/* ========================================
   ANIMAÇÕES SUAVES
   ======================================== */

.smooth-transition {
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.cinematic-transition {
  transition: all 2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

@media (max-width: 768px) {
  .info-panel {
    padding: 15px 20px;
    min-width: auto;
    max-width: calc(100vw - 40px);
  }

  .info-panel h2 {
    font-size: 18px;
  }

  .event-info {
    font-size: 12px;
  }

  .map-controls {
    top: auto;
    bottom: 20px;
    right: 20px;
    flex-direction: row;
  }

  .control-btn {
    padding: 10px 12px;
  }

  .control-btn .label {
    display: none;
  }

  .toast-container {
    bottom: 20px;
    right: 20px;
    left: 20px;
    max-width: none;
  }
}

/* ========================================
   DARK MODE (padrão)
   ======================================== */

body {
  background: #000000;
}

/* Customização dos controles do Google Maps */
.gm-style .gm-style-iw-c {
  background: rgba(26, 29, 35, 0.98) !important;
  border-radius: 10px !important;
  padding: 0 !important;
}

.gm-style .gm-style-iw-d {
  overflow: auto !important;
}

.gm-style .gm-style-iw-t::after {
  background: rgba(26, 29, 35, 0.98) !important;
}

/* Botão de fechar do InfoWindow */
.gm-ui-hover-effect {
  opacity: 0.8 !important;
  background: rgba(255, 255, 255, 0.1) !important;
  border-radius: 50% !important;
}

.gm-ui-hover-effect:hover {
  opacity: 1 !important;
  background: rgba(255, 255, 255, 0.2) !important;
}

/* ========================================
   UTILIDADES
   ======================================== */

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.5s ease;
}

.fade-out {
  animation: fadeOut 0.5s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ========================================
   PULSE ANIMATION (para novos participantes)
   ======================================== */

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

.participant-marker.new {
  animation: pulse 1s ease-in-out 3;
}
