/**
 * SI2 Map Widget Styles
 * Estilos para el widget de mapa con Leaflet
 */

/* =============================================================================
  Container Principal
  ============================================================================= */

.si2-map-wrapper {
  position: relative;
  width: 100%;
  min-height: 200px;
  background: #f5f5f5;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.si2-map-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 200px;
  background-color: #cbcbcb;
  z-index: 1;
}

/* =============================================================================
  Loading States
  ============================================================================= */

.si2-map-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.si2-map-loading.active {
  opacity: 1;
  visibility: visible;
}

.si2-map-loading i {
  font-size: 2rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.si2-map-loading span {
  color: #666;
  font-size: 0.9rem;
}

/* =============================================================================
  Marcadores Personalizados
  ============================================================================= */

.custom-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  transform: translate(-50%, -50%);
}

.custom-marker:hover {
  transform: translate(-50%, -50%) scale(1.1);
  z-index: 1000;
}

.custom-marker i {
  font-size: 14px;
}

.marker-label {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  white-space: nowrap;
  margin-top: 2px;
}

.custom-marker:hover .marker-label {
  display: block;
}

/* Marcadores por tipo de post */
.si2-marker.post-type-post {
  background-color: #0073aa;
}

.si2-marker.post-type-page {
  background-color: #00a32a;
}

.si2-marker.post-type-event {
  background-color: #ff6900;
}

.si2-marker.post-type-project {
  background-color: #9b51e0;
}

/* Marcadores por términos de taxonomía */
.si2-marker.term-tecnologia {
  background-color: #007cba;
}

.si2-marker.term-educacion {
  background-color: #00a32a;
}

.si2-marker.term-cultura {
  background-color: #d63384;
}

/* =============================================================================
  Clusters
  ============================================================================= */

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  border-radius: 50%;
  text-align: center;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.3);
}

.marker-cluster-small {
  background-color: rgba(255, 255, 255, 0.4);
  color: #333;
}
.marker-cluster-small div{
  background-color: rgba(255, 255, 255, 0.4);
}

.marker-cluster-medium {
  background-color: rgba(255, 255, 255, 0.6);
  color: #333;
}
.marker-cluster-medium div {
  background-color: rgba(255, 255, 255, 0.6);
}

.marker-cluster-large {
  background-color: rgba(255, 255, 255, 0.8);
  color: #333;
}
.marker-cluster-large div{
  background-color: rgba(255, 255, 255, 0.8);
}

/* Personalizar líneas del spider */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
  transition: transform 0.3s ease-out, opacity 0.3s ease-in;
}

/* =============================================================================
  Popups
  ============================================================================= */

.si2-popup-content {
  padding: 0;
}

.popup-featured-image {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.popup-title {
  margin: 0 0 8px 0;
  padding: 12px 16px 0;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
}

.popup-title a {
  color: #333;
  text-decoration: none;
}

.popup-title a:hover {
  color: #0073aa;
}

.popup-excerpt {
  padding: 0 16px;
  color: #666;
  font-size: 0.9rem;
  line-height: 1.4;
  margin-bottom: 12px;
}

.popup-taxonomy {
  padding: 0 16px 8px;
  font-size: 0.85rem;
}

.popup-taxonomy strong {
  color: #333;
  margin-right: 4px;
}

.popup-term {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-right: 4px;
  margin-bottom: 2px;
}

.popup-meta {
  padding: 8px 16px;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #666;
}

.popup-actions {
  padding: 12px 16px;
  background: #f8f9fa;
  text-align: center;
}

.popup-link {
  display: inline-block;
  padding: 8px 16px;
  background: #0073aa;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: background-color 0.2s ease;
}

.popup-link:hover {
  background: #005a87;
  color: white;
}

/* Flecha del popup */
.leaflet-popup-tip {
  background: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* =============================================================================
  Controles del Mapa
  ============================================================================= */

.si2-map-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  background: white;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  padding: 8px;
}

/* Personalizar controles de Leaflet */
.leaflet-control-container .leaflet-control {
  border-radius: 6px;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.leaflet-control-zoom a {
  background: white;
  color: #333;
  border: none;
  width: 30px;
  height: 30px;
  line-height: 30px;
  font-size: 14px;
  text-align: center;
  transition: background-color 0.2s ease;
}

.leaflet-control-zoom a:hover {
  background: #f0f0f0;
  color: #0073aa;
}

.leaflet-control-zoom a:first-child {
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}

.leaflet-control-zoom a:last-child {
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
}

/* Control de capas */
.leaflet-control-layers {
  background: white;
  border-radius: 6px;
  padding: 8px;
  min-width: 120px;
}

.leaflet-control-layers-toggle {
  background-image: none;
  width: 30px;
  height: 30px;
  border-radius: 6px;
}

.leaflet-control-layers-toggle::after {
  content: "\f0c9"; /* FontAwesome bars icon */
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  font-size: 14px;
  line-height: 30px;
  text-align: center;
  display: block;
  color: #333;
}

/* =============================================================================
  Conexiones entre marcadores
  ============================================================================= */

.leaflet-curve-path {
  stroke-dasharray: 5, 5;
  animation: dash 2s linear infinite;
}

@keyframes dash {
  to {
    stroke-dashoffset: -10;
  }
}

/* =============================================================================
  Estados Responsivos
  ============================================================================= */

@media (max-width: 768px) {
  .si2-map-container {
    min-height: 300px;
  }

  .leaflet-popup-content {
    min-width: 250px;
    max-width: 280px;
  }

  .popup-title {
    font-size: 1rem;
  }

  .custom-marker {
    min-width: 25px;
    height: 25px;
    font-size: 10px;
  }

  .marker-cluster-small,
  .marker-cluster-medium,
  .marker-cluster-large {
    width: 35px !important;
    height: 35px !important;
    line-height: 35px !important;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .si2-map-container {
    min-height: 250px;
  }

  .leaflet-popup-content {
    min-width: 220px;
    max-width: 250px;
  }

  .popup-featured-image {
    height: 100px;
  }

  .leaflet-control-zoom a {
    width: 25px;
    height: 25px;
    line-height: 25px;
    font-size: 12px;
  }
}

/* =============================================================================
  Estados de Interacción
  ============================================================================= */

.si2-marker.highlighted {
  filter: brightness(1.2);
  transform: scale(1.1);
  z-index: 1000;
}

.si2-marker.dimmed {
  opacity: 0.4;
  filter: grayscale(50%);
}

.si2-marker.active {
  border: 3px solid #ff6900;
  box-shadow: 0 0 0 3px rgba(255, 105, 0, 0.3);
  z-index: 1001;
}

/* =============================================================================
  Animaciones
  ============================================================================= */

.leaflet-marker-icon {
  transition: all 0.2s ease;
}

.leaflet-marker-icon:hover {
  transform: scale(1.1);
}

.si2-map-wrapper.loading .si2-map-container {
  pointer-events: none;
}

/* Fade in animation para marcadores */
@keyframes markerFadeIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.leaflet-marker-icon.new-marker {
  animation: markerFadeIn 0.3s ease-out;
}

/* =============================================================================
  Dark Mode Support
  ============================================================================= */

@media (prefers-color-scheme: dark) {
  .si2-map-wrapper {
    background: #2c2c2c;
  }

  .si2-map-loading {
    background: rgba(44, 44, 44, 0.9);
    color: #e0e0e0;
  }

  .leaflet-popup-content-wrapper {
    background: #333;
    color: #e0e0e0;
  }

  .popup-title a {
    color: #e0e0e0;
  }

  .popup-title a:hover {
    color: #66b3ff;
  }

  .popup-meta,
  .popup-actions {
    background: #404040;
    border-color: #555;
  }

  .popup-link {
    background: #66b3ff;
    color: #000;
  }

  .popup-link:hover {
    background: #4da6ff;
  }
}

/* =============================================================================
  Utilidades
  ============================================================================= */

.si2-map-wrapper.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  border-radius: 0;
}

.si2-hidden {
  display: none !important;
}

.si2-loading {
  pointer-events: none;
  opacity: 0.7;
}

/* Estructura base del widget */
.si2-widget-wrapper {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Topbar Container */
.si2-topbar-container {
  flex-shrink: 0;
  width: 100%;
}

/* Topbar */
.si2-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  background: #000000;
  border-bottom: 1px solid #e1e1e1;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 1000;
}

.si2-topbar-left {
  flex: 1;
}

.si2-topbar-label {
  /* pasar a elementor? */
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

.si2-topbar-center {
  flex: 2;
  display: inline-flex;
  gap: 1rem;

  /* pasar a elementor? */
  color: white;
  font-size: 12px;
  font-weight: 700;
}
.si2-topbar-center .layer-control{
  display: inline;
  font-size: 16px;
}

.svg-icon{
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  vertical-align: middle;
  outline: none;
  box-shadow: none;
  fill: currentColor;
}

.si2-topbar-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

/* View Switcher */
.si2-view-switcher {
  display: flex;
  border: 1px solid #7F756F;
  overflow: hidden;
}

.si2-view-btn {
  background: #000000;
  color: #fff;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-right: 1px solid #7F756F;
  
  /* pasar a elementor? */
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

.si2-view-btn:last-child {
  border-right: none;
}

.si2-view-btn:hover {
  background: #f5f5f5;
}

.si2-view-btn.active {
  background: #B8B1AD;
  color: white;
}

.si2-view-btn i {
  font-size: 14px;
}

/* Contenedores de vistas */
.si2-map-view,
.si2-list-view {
  flex: 1;
  position: relative;
}


.si2-sidebar-nav{
  position: absolute;
  float: left;
  margin-top: 10px;
  margin-left: 10px;
  background-color: #F9F3F5;
  border-radius: 8px;
  width: 318px;
  height: 456px;
  z-index: 800;
}

.si2-sidebar-nav-header h3{
  font-size: 13px;
  font-weight: 700;
  padding: 10px;
  text-transform: uppercase;
}


.si2-sidebar-filters {
  position: absolute;
  width: 340px;
  height: calc(100% - 56px - 10px);
  padding: 10px;
  overflow-x: hidden;
  overflow-y: scroll;
  right: 0;
  top: 56px;
  z-index: 800;
  background-color: #fffbff;
}

.si2-sidebar-filters .filters-label h3{
  font-size: 13px;
  font-weight: 700;
  padding: 10px;
  text-transform: uppercase;
  margin: 0;
}

.si2-sidebar-filters details{
  margin-bottom: 8px;
}
.si2-sidebar-filters details summary::-webkit-details-marker { display: none; } /* Chrome */
.si2-sidebar-filters  details summary { list-style-type: none; } /* Firefox, por separado, juntos con comas no las interpreta con la de Chrome */
.si2-sidebar-filters  details summary::marker { display: none; } /* Firefox, por separado, juntos con comas no las interpreta con la de Chrome */

.si2-sidebar-filters summary{
  background-color: #f9f4f5;
  border-radius: 4px;
  padding: 8px;
  font-size: 14px;
  font-weight: 700;
}
.si2-sidebar-filters summary svg{
  color: #807670;
}

.si2-sidebar-filters .filter-group{
  background-color: #f9f4f5;
  border-radius: 4px;
  font-size: 14px;
  /*padding: 16px 8px;*/
  padding: 8px;
  margin-top: 8px;
}

.si2-sidebar-filters .map-filters-form .filter-field label{
  display: block;
  color: #655D58;
  font-size: 11px;
  font-weight: 700;
}
.si2-sidebar-filters .map-filters-form .filter-field select {
  display: block;
  width: 100%;
  font-size: 12px;
}

/* Vista de lista */
.si2-list-container {
  height: 100%;
  overflow-y: auto;
}

.si2-list-grid {
  padding: 20px;
}

/* Cards de la lista */
.si2-list-item {
  background: #fff;
  border: 1px solid #e1e1e1;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.si2-list-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.si2-item-image {
  position: relative;
  height: 160px;
  overflow: hidden;
  background: #f5f5f5;
}

.si2-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.si2-no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
  font-size: 24px;
}

.si2-item-content {
  padding: 15px;
}

.si2-item-title {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  line-height: 1.3;
}

.si2-item-excerpt {
  margin: 0 0 10px 0;
  color: #666;
  font-size: 14px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.si2-item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #999;
}

.si2-item-date::before {
  content: "📅";
  margin-right: 4px;
}

/* Responsive */
@media (max-width: 768px) {
  .si2-list-grid {
    grid-template-columns: 1fr !important;
    padding: 10px;
    gap: 15px;
  }
  
  .si2-topbar {
    padding: 8px 10px;
  }
  
  .si2-topbar-label {
    font-size: 14px;
  }
  
  .si2-view-btn {
    padding: 6px 10px;
  }
}

@media (max-width: 1024px) {
  .si2-list-grid[style*="repeat(3"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  .si2-list-grid[style*="repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Estados especiales de la lista */
.si2-list-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  padding: 40px 20px;
}

.si2-empty-content {
  text-align: center;
  color: #666;
}

.si2-empty-content i {
  font-size: 48px;
  color: #ddd;
  margin-bottom: 20px;
}

.si2-empty-content h3 {
  margin: 0 0 10px 0;
  font-size: 18px;
  color: #333;
}

.si2-empty-content p {
  margin: 0;
  font-size: 14px;
  color: #666;
}

.si2-list-item-error {
  border-color: #ff6b6b !important;
  background: #fff5f5 !important;
}

.si2-list-item-error .si2-item-title {
  color: #e53e3e !important;
}

.si2-list-item-error:hover {
  transform: none !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

/* =============================================================================
  Marcadores Personalizados por Post Type
  ============================================================================= */

.si2-marker {
  background: transparent !important;
  border: none !important;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.si2-marker-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 2px solid black;
  border-radius: 50%;
  backdrop-filter: blur(4px);
  transition: all 0.2s ease;
}

.si2-marker:hover .si2-marker-icon {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.si2-marker-icon svg {
  width: 20px;
  height: 20px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
  outline: none;
  box-shadow: none;
}

.si2-marker-icon svg:focus {
  outline: none !important;
  box-shadow: none !important;
}

/* Estilos específicos por post_type */

.si2-marker-post .si2-marker-icon {
  background: rgba(59, 130, 246, 0.1);
  border: 2px solid #3b82f6;
}

.si2-marker-page .si2-marker-icon {
  background: rgba(139, 92, 246, 0.1);
  border: 2px solid #8b5cf6;
}

.si2-marker-agenda-urbana2 .si2-marker-icon {
  background: rgba(249, 115, 22, 0.1);
  border: 2px solid #f97316;
}

.si2-marker-default .si2-marker-icon {
  background: rgba(34, 197, 94, 0.1);
  border: 2px solid #22c55e;
}