/**
 * 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;
}

h3.si2-popup-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 18px;
}

/* 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;
}

@media (max-width: 768px){
  .si2-topbar.mobile .button-group{width: 100%;}
  .si2-topbar.mobile .button-group button.map-btn{flex-grow: 1;}
  .si2-topbar.desktop{display: none;}
}
@media (min-width: 769px){
  .si2-topbar.mobile{ display: none;}
}

.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: sub;
  outline: none;
  box-shadow: none;
  fill: currentColor;
}

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

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

.map-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;
}

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

.map-btn:hover {
  background: #f5f5f5;
}

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

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

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

.si2-sidebar {
  display: none;
  position: absolute;
  width: 264px;
  height: calc(100% - 56px - 20px); /* altura - topbar - 2 x padding */
  overflow-x: hidden;
  overflow-y: auto;
  top: 56px;
  z-index: 800;
  background-color: #fffbff;
}

.si2-sidebar.left{
  left: 0;
}

.si2-sidebar.right{
  right: 0;
}

.si2-sidebar.nav{
  margin-top: 10px;
  margin-left: 10px;
  border-radius: 8px;
  width: 318px;
  min-height: 100px;
  height: calc(60% - 56px - 20px); /* altura - topbar - 2 x padding */
}

@media (max-width: 768px){
  .si2-sidebar.active{
    display: block;
    width: 100%;
    z-index: 1001;
    top: 48px;
  }
}
@media (min-width: 769px){
  .si2-sidebar{ display: block;}
}

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

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

.si2-sidebar summary{
  background-color: #f9f4f5;
  border-radius: 4px;
  padding: 8px;
  cursor: pointer;
}
.si2-sidebar summary:focus{
  outline: none;
}
.si2-sidebar summary.filter-group-title{
  display: flex;
  justify-content: space-between;
}
.si2-sidebar summary.filter-group-title span{
  font-size: 14px;
  font-weight: 700;
}
.si2-sidebar summary.filter-group-title span svg{
  color: #807670;
}

.si2-sidebar summary.filter-group-title svg.filter {
  display: none;
  margin: auto 0;
}
.si2-sidebar details.filter-layer.active summary.filter-group-title svg.filter.on {
  display: block;
  color: #1C1B1F;
}
.si2-sidebar details.filter-layer.active summary.filter-group-title svg.filter.off {
  display: none;
}
.si2-sidebar details.filter-layer:not(.active) summary.filter-group-title svg.filter.on {
  display: none;
}
.si2-sidebar details.filter-layer:not(.active) summary.filter-group-title svg.filter.off {
  display: block;
  color: #B3B3B3;
}

.si2-sidebar .filter-group{
  background-color: #f9f4f5;
  border-radius: 4px;
  font-size: 14px;
  /*padding: 16px 8px;*/
  padding: 8px;
  margin-top: 8px;
}
.si2-sidebar .filters-form .filter-field:not(:last-child) {
  margin-bottom: 1rem;
}
.si2-sidebar .filters-form .filter-field legend{
  display: block;
  color: #655D58;
  font-size: 11px;
  font-weight: 700;
  margin: 0;
  padding: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.si2-sidebar .filters-form .filter-field > label{
  display: block;
  color: #29231F;
  font-size: 11px;
  font-weight: 700;
  margin: 0;
  padding: 0.25rem 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.si2-sidebar .filters-form .filter-field input[type="text"]{
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' focusable='false' aria-hidden='true' viewBox='0 0 24 24'%3E%3Cpath fill='%23655D58' d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14'%3E%3C/path%3E%3C/svg%3E");
  background-position: 0.25rem 50%;
  background-repeat: no-repeat;
  background-size: 1.5rem;
  padding-left: 1.75rem;
}
.si2-sidebar .filters-form .filter-field input[type="text"],
.si2-sidebar .filters-form .filter-field input[type="date"]{
  display: block;
  width: 100%;
  font-size: 12px;
  font-weight: 700;
  background-color: transparent;
  color: #29231F;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid #B8B1AD;
} 
.si2-sidebar .filters-form .filter-field select {
  display: block;
  width: 100%;
  font-size: 12px;
  font-weight: 700;
  border-color: #7F756F;
  background-color: transparent;
  border-radius: 4px;
  color: #29231F;
}
.si2-sidebar .filters-form .filter-field ul.filter-list {
  margin: 0;
  padding: 0;
}
.si2-sidebar .filters-form .filter-field ul.filter-list li{
  list-style: none;
  list-style-type: none;
  font-size: 12px;
  font-weight: 700;
}
.si2-sidebar .filters-form fieldset.filter-checkbox-group{
  border: none;
}

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

.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-list-item .item-header {
  margin-bottom: 1rem;
}

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

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

/* especificidad para sobreescribir .elementor img{} */
.si2-list-item .si2-item-image img {
    height: 100%;
    width: 100%;
    object-fit: cover;
}


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

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

.si2-list-item .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-list-item .si2-item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 1rem;
}

.si2-list-item .si2-item-link{
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1px;
  text-transform: uppercase;
  text-decoration: underline;
  color: #333;
}

.si2-list-item .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;
  }
  
  .map-btn {
    padding: 6px 10px;
  }
}

@media (min-width: 769px) and (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;
}