/* Interactive Map Manager - Frontend Styles */

.imm-map-container {
  width: 100%;
  margin: 0 auto;
}

/* Improved sidebar layout with wider filter panel and equal heights */
.imm-layout-sidebar {
  display: flex;
  gap: 20px;
  align-items: stretch;
  /* Use CSS variable for map height */
  min-height: var(--imm-map-height, 600px);
}

.imm-layout-sidebar .imm-filter-panel {
  flex: 0 0 var(--imm-filter-panel-width, 400px);
  margin-bottom: 0;
  order: 2;
  /* Use CSS variable for height */
  height: var(--imm-map-height, 600px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.imm-layout-sidebar .imm-map-wrapper {
  flex: 1;
  order: 1;
  /* Use CSS variable for height */
  height: var(--imm-map-height, 600px);
}

.imm-layout-sidebar #imm-map {
  height: 100%;
}

@media (max-width: 1024px) {
  .imm-layout-sidebar {
    flex-direction: column;
    min-height: auto;
  }

  .imm-layout-sidebar .imm-filter-panel {
    flex: 1;
    width: 100%;
    height: auto;
    max-height: none;
    order: 1;
  }

  .imm-layout-sidebar .imm-map-wrapper {
    order: 2;
    height: 500px;
  }
}

/* Modern filter panel design inspired by the reference image */
.imm-filter-panel {
  /* Use CSS variables for customizable colors */
  background: var(--imm-filter-bg, linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%));
  color: var(--imm-filter-text, #ffffff);
  padding: 24px;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.imm-filter-panel h3 {
  margin: 0 0 8px 0;
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.5px;
}

.imm-filter-subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  margin: 0 0 20px 0;
  font-weight: 400;
}

/* Added search container and results styling */
.imm-search-container {
  margin-bottom: 24px;
  position: relative;
}

.imm-search-wrapper {
  position: relative;
}

/* Update search input to use CSS variables */
.imm-search-input {
  width: 100%;
  padding: 14px 48px 14px 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--imm-filter-text, #ffffff);
  font-size: 15px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.imm-search-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.imm-search-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.imm-search-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: rgba(255, 255, 255, 0.6);
  pointer-events: none;
}

.imm-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
}

.imm-search-results.active {
  display: block;
}

.imm-search-result-item {
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.15s ease;
}

.imm-search-result-item:last-child {
  border-bottom: none;
}

.imm-search-result-item:hover {
  background-color: #f8f9fa;
}

.imm-search-result-title {
  font-size: 15px;
  font-weight: 600;
  color: #1e3a5f;
  margin-bottom: 4px;
}

.imm-search-result-meta {
  font-size: 13px;
  color: #666;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.imm-search-result-categories {
  font-size: 12px;
  color: #888;
  font-style: italic;
}

.imm-search-no-results {
  padding: 20px;
  text-align: center;
  color: #666;
  font-size: 14px;
}

/* Added category type header and grid styling */
.imm-filter-type-header {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  margin: 24px 0 14px 0;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.25);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.imm-filter-type-header:first-child {
  margin-top: 0;
}

/* Improved grid layout for better icon alignment */
.imm-filter-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

.imm-filter-categories {
  display: flex;
  flex-direction: column;
}

/* Completely redesigned filter items for consistent icon positioning */
.imm-filter-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  min-height: 100px;
  position: relative;
  color: var(--imm-filter-text, #ffffff);
}

.imm-filter-item:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.imm-filter-item.active {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

.imm-filter-checkbox {
  display: none;
}

/* Fixed icon wrapper for perfect centering and consistent sizing */
.imm-filter-icon-wrapper {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 10px;
  flex-shrink: 0;
  transition: all 0.25s ease;
}

.imm-filter-item.active .imm-filter-icon-wrapper {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(1.05);
}

/* Ensured all icons are perfectly centered and same size */
.imm-filter-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  display: block;
}

.imm-filter-color {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 3px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  transition: all 0.25s ease;
}

.imm-filter-item.active .imm-filter-color {
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.35);
  transform: scale(1.05);
}

/* Improved label styling for better readability */
.imm-filter-label {
  font-size: 12px;
  font-weight: 600;
  user-select: none;
  text-align: center;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.3;
  letter-spacing: 0.2px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.imm-filter-count {
  display: none;
}

/* Search input styling */
.imm-filter-search {
  margin-bottom: 20px;
}

.imm-filter-search input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 14px;
  transition: all 0.2s ease;
}

.imm-filter-search input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.imm-filter-search input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.15);
}

.imm-map-wrapper {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

#imm-map {
  width: 100%;
  height: 500px;
  z-index: 1;
}

/* Custom Marker Styles */
.imm-custom-marker {
  background: none;
  border: none;
}

/* Completely remove all background styling from custom markers - only show the uploaded icon */
.imm-marker-icon.imm-marker-custom {
  width: 36px;
  height: 36px;
  background: none !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  transform: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.imm-marker-icon.imm-marker-custom::after {
  display: none !important;
}

.imm-marker-icon.imm-marker-custom img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: none !important;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Default colored pin marker styles */
.imm-marker-icon {
  width: 36px;
  height: 36px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  border: 3px solid #fff;
  position: relative;
}

.imm-marker-icon img {
  width: 20px;
  height: 20px;
  transform: rotate(45deg);
  object-fit: contain;
}

.imm-marker-icon::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 10px solid;
  border-top-color: inherit;
  bottom: -13px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
}

/* Popup Styles */
.leaflet-popup-content-wrapper {
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0;
  min-width: 250px;
  max-width: 350px;
}

.imm-popup {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

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

.imm-popup-content {
  padding: 15px;
}

.imm-popup-title {
  margin: 0 0 10px 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  line-height: 1.3;
}

.imm-popup-description {
  margin: 0 0 12px 0;
  font-size: 14px;
  line-height: 1.5;
  color: #666;
}

.imm-popup-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.imm-popup-meta-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: #555;
}

.imm-popup-meta-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.imm-popup-meta-text {
  flex: 1;
  line-height: 1.4;
}

.imm-popup-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.imm-popup-category {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: #f5f5f5;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

/* Added category icon styling */
.imm-popup-category-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}

.imm-popup-category-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Loading State */
.imm-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 500px;
  background: #f5f5f5;
  border-radius: 8px;
  font-size: 16px;
  color: #666;
}

.imm-loading::after {
  content: "";
  width: 40px;
  height: 40px;
  border: 4px solid #ddd;
  border-top-color: #333;
  border-radius: 50%;
  animation: imm-spin 0.8s linear infinite;
  margin-left: 12px;
}

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

/* Added directions button styling */
.imm-directions-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #3388ff 0%, #2563eb 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(51, 136, 255, 0.3);
}

.imm-directions-btn:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 4px 12px rgba(51, 136, 255, 0.4);
  transform: translateY(-1px);
}

.imm-directions-btn:active {
  transform: translateY(0);
}

.imm-directions-icon {
  width: 18px;
  height: 18px;
}

/* Added custom button styling */
.imm-custom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 10px 16px;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.imm-custom-btn:hover {
  opacity: 0.9;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

.imm-custom-btn:active {
  transform: translateY(0);
}

.imm-custom-btn-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

/* Added modal styling */
.imm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: imm-fade-in 0.2s ease;
}

@keyframes imm-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.imm-modal {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  animation: imm-slide-up 0.3s ease;
}

@keyframes imm-slide-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Updated modal header to use separate CSS variables for header and content */
.imm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
  /* Using separate header background and text color variables */
  background: var(--imm-modal-header-bg, var(--imm-modal-bg, #1e3a5f));
  color: var(--imm-modal-header-text, var(--imm-modal-text, #ffffff));
}

.imm-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  /* Using header text color variable */
  color: var(--imm-modal-header-text, var(--imm-modal-text, #ffffff));
}

.imm-modal-close {
  background: none;
  border: none;
  /* Using header text color variable */
  color: var(--imm-modal-header-text, var(--imm-modal-text, #ffffff));
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.imm-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.imm-modal-body {
  padding: 24px;
  /* Using separate content background and text color variables */
  background: var(--imm-modal-content-bg, #ffffff);
  color: var(--imm-modal-content-text, #374151);
}

.imm-modal-body > p {
  margin: 0 0 16px 0;
  font-size: 15px;
  /* Using content text color variable */
  color: var(--imm-modal-content-text, #374151);
  font-weight: 500;
}

.imm-modal-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.imm-modal-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.imm-modal-btn-primary {
  background: linear-gradient(135deg, #3388ff 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(51, 136, 255, 0.3);
}

.imm-modal-btn-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 4px 12px rgba(51, 136, 255, 0.4);
  transform: translateY(-1px);
}

.imm-modal-btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 2px solid #e5e7eb;
}

.imm-modal-btn-secondary:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
}

.imm-custom-location {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.imm-location-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.imm-location-input:focus {
  outline: none;
  border-color: #3388ff;
}

/* Added route display styling */
.imm-route-loading {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  padding: 12px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  z-index: 1000;
  animation: imm-fade-in 0.2s ease;
}

.imm-route-info {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  animation: imm-slide-up 0.3s ease;
}

.imm-route-info-content {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 20px;
}

.imm-route-info-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #374151;
}

.imm-route-info-item svg {
  color: #3388ff;
}

.imm-route-clear {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 12px;
}

.imm-route-clear:hover {
  background: #fecaca;
}

.imm-route-marker-wrapper {
  background: none;
  border: none;
}

.imm-route-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.imm-route-start {
  background: #10b981;
}

.imm-route-end {
  background: #ef4444;
}

/* Responsive Design */
@media (max-width: 768px) {
  .imm-filter-panel {
    padding: 20px;
  }

  .imm-filter-categories {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 10px;
  }

  .imm-filter-item {
    padding: 12px 8px;
    min-height: 80px;
  }

  .imm-filter-icon-wrapper {
    width: 36px;
    height: 36px;
  }

  .imm-filter-color {
    width: 36px;
    height: 36px;
  }

  .imm-filter-label {
    font-size: 11px;
  }

  .imm-popup-content {
    padding: 12px;
  }

  .imm-popup-title {
    font-size: 16px;
  }

  .imm-popup-description {
    font-size: 13px;
  }

  #imm-map {
    height: 400px;
  }

  .imm-modal {
    width: 95%;
  }

  .imm-modal-header {
    padding: 16px 20px;
  }

  .imm-modal-body {
    padding: 20px;
  }

  .imm-route-info-content {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
  }

  .imm-route-info {
    left: 10px;
    right: 10px;
    transform: none;
  }
}

@media (max-width: 480px) {
  .imm-filter-categories {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
  }

  .imm-filter-item {
    padding: 10px 6px;
    min-height: 70px;
  }

  .imm-filter-icon-wrapper {
    width: 32px;
    height: 32px;
  }

  .imm-filter-color {
    width: 32px;
    height: 32px;
  }

  #imm-map {
    height: 350px;
  }
}

/* Cluster Styles - Use CSS variables for customizable colors */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: var(--imm-cluster-bg, rgba(51, 136, 255, 0.6));
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: var(--imm-cluster-bg, rgba(51, 136, 255, 0.8));
  color: var(--imm-cluster-text, #ffffff);
  font-weight: 600;
}

/* Accessibility */
.imm-filter-item:focus-within {
  outline: 2px solid #3388ff;
  outline-offset: 2px;
}

.leaflet-popup-close-button:focus {
  outline: 2px solid #3388ff;
  outline-offset: 2px;
}

/* Optional: Add CSS to completely hide attribution if needed */
.imm-map-container[data-hide-attribution="true"] .leaflet-control-attribution {
  display: none !important;
}
