/* ===================== MAP STYLES - VERSIÓN PROFESIONAL ===================== */

body {
  background: var(--green-500);
  color: var(--white);
  overflow: hidden;
}

/* ===================== MAPA ===================== */
#map {
  width: 100%;
  height: 100vh;
  padding-top: 70px;
}

/* ===================== BÚSQUEDA ===================== */
.search-container {
  position: fixed;
  top: 85px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  width: calc(100% - 40px);
  max-width: 550px;
}

.search-box {
  display: flex;
  gap: 10px;
  background: rgba(22, 56, 50, 0.98);
  backdrop-filter: blur(20px);
  padding: 12px;
  border-radius: 16px;
  border: 2px solid rgba(13, 124, 102, 0.3);
  box-shadow: 0 8px 25px rgba(0,0,0,0.5);
}

.search-input {
  flex: 1;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(13, 124, 102, 0.3);
  border-radius: 10px;
  color: var(--white);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.3s;
}

.search-input:focus {
  outline: none;
  border-color: var(--teal-200);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 15px rgba(13, 124, 102, 0.2);
}

.search-input::placeholder {
  color: rgba(168, 213, 186, 0.5);
}

.search-btn {
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--teal-100), var(--teal-200));
  border: none;
  border-radius: 10px;
  color: var(--white);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(13, 124, 102, 0.3);
  white-space: nowrap;
}

.search-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(13, 124, 102, 0.5);
}

.search-btn:active {
  transform: translateY(0);
}

/* ===================== PANEL LATERAL ===================== */
.side-panel {
  position: fixed;
  top: 165px;
  left: 20px;
  background: rgba(22, 56, 50, 0.98);
  backdrop-filter: blur(20px);
  padding: 14px;
  border-radius: 16px;
  border: 2px solid rgba(13, 124, 102, 0.3);
  box-shadow: 0 8px 25px rgba(0,0,0,0.5);
  z-index: 900;
  width: 240px;
  max-height: calc(100vh - 230px);
  overflow-y: auto;
}

.side-panel::-webkit-scrollbar {
  width: 5px;
}

.side-panel::-webkit-scrollbar-track {
  background: rgba(13, 124, 102, 0.1);
}

.side-panel::-webkit-scrollbar-thumb {
  background: var(--teal-100);
  border-radius: 3px;
}

.panel-title {
  color: var(--white);
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(13, 124, 102, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-card {
  background: rgba(13, 124, 102, 0.15);
  border: 2px solid rgba(13, 124, 102, 0.3);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  transition: all 0.3s;
}

.info-card:hover {
  transform: translateY(-2px);
  border-color: var(--teal-200);
  box-shadow: 0 4px 15px rgba(13, 124, 102, 0.3);
}

.info-card-title {
  color: var(--teal-200);
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-card-value {
  color: var(--white);
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1.2;
}

.info-card-subtitle {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.7rem;
  margin-top: 4px;
}

/* ===================== CONTROLES CON TOOLTIPS ===================== */
.control-buttons {
  position: fixed;
  bottom: 30px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 900;
}

.control-btn {
  position: relative;
  width: 52px;
  height: 52px;
  background: rgba(22, 56, 50, 0.98);
  border: 2px solid rgba(13, 124, 102, 0.3);
  border-radius: 50%;
  color: var(--white);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.control-btn:hover {
  background: rgba(13, 124, 102, 0.5);
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(13, 124, 102, 0.5);
}

.control-btn.active {
  background: linear-gradient(135deg, var(--teal-100), var(--teal-200));
  border-color: var(--teal-200);
  box-shadow: 0 6px 20px rgba(13, 124, 102, 0.6);
}

/* TOOLTIP */
.control-btn::before {
  content: attr(data-tooltip);
  position: absolute;
  right: 65px;
  background: rgba(22, 56, 50, 0.98);
  color: white;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none;
  border: 2px solid rgba(13, 124, 102, 0.3);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  z-index: 1;
}

/* Flecha del tooltip */
.control-btn::after {
  content: '';
  position: absolute;
  right: 57px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 8px;
  border-color: transparent transparent transparent rgba(22, 56, 50, 0.98);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 1;
}

.control-btn:hover::before,
.control-btn:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ANIMACIONES ESPECIALES */
#satelliteBtn.active {
  animation: satellitePulse 2s ease-in-out infinite;
}

@keyframes satellitePulse {
  0%, 100% {
    box-shadow: 0 6px 20px rgba(13, 124, 102, 0.6);
  }
  50% {
    box-shadow: 0 8px 30px rgba(13, 124, 102, 0.9);
  }
}

#layersBtn.active {
  animation: layersGlow 2s ease-in-out infinite;
}

@keyframes layersGlow {
  0%, 100% {
    box-shadow: 0 6px 20px rgba(13, 124, 102, 0.6);
  }
  50% {
    box-shadow: 0 8px 30px rgba(20, 184, 166, 0.8);
  }
}

/* ===================== ALERTA DE INCENDIOS ===================== */
.fire-alert {
  position: fixed;
  top: 170px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #ff3333, #cc0000);
  color: white;
  padding: 16px 24px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(255, 51, 51, 0.6);
  z-index: 1000;
  display: none;
  max-width: calc(100% - 40px);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.fire-alert.show {
  display: flex;
  align-items: center;
  gap: 15px;
  animation: alertPulse 2s infinite;
}

@keyframes alertPulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.03); }
}

.fire-alert-icon {
  font-size: 1.8rem;
  animation: fireRotate 3s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes fireRotate {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

.fire-alert-text {
  flex: 1;
  font-weight: 600;
  line-height: 1.4;
  font-size: 0.9rem;
}

.fire-alert-btn {
  background: white;
  color: #cc0000;
  border: none;
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.fire-alert-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.5);
}

/* ===================== LEYENDA ===================== */
.legend {
  position: fixed;
  bottom: 30px;
  left: 20px;
  background: rgba(22, 56, 50, 0.98);
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid rgba(13, 124, 102, 0.3);
  box-shadow: 0 8px 25px rgba(0,0,0,0.5);
  z-index: 900;
  font-size: 0.8rem;
  max-width: 170px;
}

.legend h4 {
  color: var(--white);
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  font-size: 0.75rem;
}

/* ===================== LOADING ===================== */
.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--green-500), var(--green-100));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s;
}

.loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader {
  width: 70px;
  height: 70px;
  border: 6px solid rgba(13, 124, 102, 0.3);
  border-top: 6px solid var(--white);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--white);
  margin-top: 25px;
  font-size: 1.2rem;
  font-weight: 700;
}

/* ===================== ANIMACIONES DE FUEGO ===================== */
@keyframes fireGlow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.8);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 35px rgba(255, 68, 68, 1);
    transform: scale(1.05);
  }
}

@keyframes flameFlicker {
  0%, 100% { transform: scale(1, 1) rotate(0deg); opacity: 1; }
  25% { transform: scale(0.95, 1.05) rotate(-2deg); opacity: 0.9; }
  50% { transform: scale(1.05, 0.95) rotate(2deg); opacity: 1; }
  75% { transform: scale(0.98, 1.02) rotate(-1deg); opacity: 0.95; }
}

/* ===================== LEAFLET POPUPS PERSONALIZADOS ===================== */
.leaflet-popup-content-wrapper {
  background: rgba(22, 56, 50, 0.98);
  border: 2px solid var(--teal-100);
  border-radius: 16px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
}

.leaflet-popup-content {
  color: var(--white);
  font-size: 0.9rem;
  margin: 18px;
  font-family: 'Inter', sans-serif;
}

.leaflet-popup-tip {
  background: rgba(22, 56, 50, 0.98);
}

.popup-title {
  color: var(--white);
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(13, 124, 102, 0.3);
}

.popup-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(13, 124, 102, 0.2);
}

.popup-row:last-child {
  border-bottom: none;
}

.popup-label {
  color: var(--teal-200);
  font-weight: 700;
  font-size: 0.85rem;
}

.popup-value {
  color: var(--white);
  font-weight: 700;
  text-align: right;
}

/* ===================== RESPONSIVE DESIGN ===================== */

/* TABLET (768px - 968px) */
@media (max-width: 968px) {
  #map { 
    padding-top: 75px; 
  }
  
  .search-container { 
    top: 90px;
    width: calc(100% - 30px);
  }
  
  .search-box {
    padding: 10px;
  }

  .search-input {
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .search-btn {
    padding: 10px 18px;
    font-size: 0.85rem;
  }
  
  .side-panel {
    left: 15px;
    top: 180px;
    width: 220px;
    padding: 12px;
  }

  .panel-title {
    font-size: 0.95rem;
  }

  .info-card {
    padding: 10px;
    margin-bottom: 8px;
  }

  .info-card-title {
    font-size: 0.75rem;
  }

  .info-card-value {
    font-size: 1.15rem;
  }
  
  .control-buttons {
    bottom: 25px;
    right: 15px;
    gap: 10px;
  }
  
  .control-btn {
    width: 48px;
    height: 48px;
    font-size: 1.1rem;
  }

  .control-btn::before {
    font-size: 0.8rem;
    padding: 7px 14px;
  }
  
  .legend {
    bottom: 25px;
    left: 15px;
    font-size: 0.7rem;
    padding: 10px 12px;
    max-width: 150px;
  }

  .legend h4 {
    font-size: 0.85rem;
  }

  .legend-item {
    font-size: 0.7rem;
    margin: 5px 0;
  }
  
  .fire-alert {
    top: 175px;
    padding: 14px 20px;
  }

  .fire-alert-icon {
    font-size: 1.5rem;
  }

  .fire-alert-text {
    font-size: 0.85rem;
  }
}

/* MÓVIL GRANDE (481px - 768px) */
@media (max-width: 768px) {
  #map {
    padding-top: 75px;
  }

  .search-container {
    top: 90px;
  }

  .search-box {
    flex-direction: column;
    gap: 8px;
  }

  .search-btn {
    width: 100%;
    justify-content: center;
  }

  .search-text {
    display: inline;
  }
  
  .side-panel {
    width: 200px;
    top: 175px;
    padding: 10px;
  }

  .panel-title {
    font-size: 0.85rem;
    margin-bottom: 10px;
  }

  .info-card {
    padding: 8px;
  }

  .info-card-value {
    font-size: 1.1rem;
  }

  .info-card-title {
    font-size: 0.7rem;
  }

  .info-card-subtitle {
    font-size: 0.65rem;
  }
  
  .legend {
    font-size: 0.65rem;
    padding: 8px 10px;
    max-width: 130px;
  }

  .legend h4 {
    font-size: 0.75rem;
    margin-bottom: 8px;
  }

  .legend-item {
    font-size: 0.65rem;
    gap: 6px;
    margin: 4px 0;
  }

  .control-btn {
    width: 46px;
    height: 46px;
    font-size: 1.05rem;
  }

  .control-btn::before {
    font-size: 0.75rem;
    padding: 6px 12px;
  }

  .fire-alert {
    flex-direction: column;
    text-align: center;
    gap: 10px;
    top: 170px;
  }

  .fire-alert-btn {
    width: 100%;
  }
}

/* MÓVIL PEQUEÑO (320px - 480px) */
@media (max-width: 480px) {
  #map {
    padding-top: 70px;
  }

  .search-container {
    top: 85px;
    width: calc(100% - 20px);
  }

  .search-box {
    padding: 8px;
  }

  .search-input {
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .search-btn {
    padding: 10px 16px;
    font-size: 0.8rem;
  }

  /* Ocultar panel lateral en móviles pequeños */
  .side-panel {
    display: none;
  }

  .control-buttons {
    bottom: 20px;
    right: 10px;
    gap: 8px;
  }

  .control-btn {
    width: 44px;
    height: 44px;
    font-size: 1rem;
  }

  /* Tooltip arriba en móvil pequeño */
  .control-btn::before {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    bottom: 55px;
    font-size: 0.7rem;
    padding: 5px 10px;
  }

  .control-btn::after {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    bottom: 47px;
    border-width: 8px 6px 0 6px;
    border-color: rgba(22, 56, 50, 0.98) transparent transparent transparent;
  }

  .legend {
    bottom: 20px;
    left: 10px;
    padding: 8px;
    max-width: 120px;
  }

  .legend h4 {
    font-size: 0.7rem;
    margin-bottom: 6px;
  }

  .legend-item {
    font-size: 0.6rem;
    gap: 5px;
    margin: 3px 0;
  }

  .legend-item i {
    font-size: 0.8rem;
  }

  .fire-alert {
    top: 155px;
    padding: 12px 16px;
    width: calc(100% - 20px);
  }

  .fire-alert-icon {
    font-size: 1.3rem;
  }

  .fire-alert-text {
    font-size: 0.8rem;
  }

  .fire-alert-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  /* Popups más compactos */
  .popup-title {
    font-size: 1rem;
  }

  .popup-label,
  .popup-value {
    font-size: 0.8rem;
  }
}

/* LANDSCAPE EN MÓVILES */
@media (max-width: 768px) and (orientation: landscape) {
  .side-panel {
    width: 180px;
    top: 85px;
    max-height: calc(100vh - 100px);
  }

  .control-buttons {
    bottom: 15px;
    right: 10px;
  }

  .legend {
    bottom: 15px;
    left: 10px;
    max-width: 110px;
  }

  .search-container {
    top: 80px;
  }

  .fire-alert {
    top: 80px;
  }
}