/* IEM Station Selector (iemss) Styling - Bootstrap 5 Enhanced */

/* Main container improvements */
.iemss-container {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  border: 1px solid rgba(0, 0, 0, 0.125);
  border-radius: 0.375rem;
}

/* Card header styling */
.iemss-container .card-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 1px solid #dee2e6;
  padding: 1rem 1.25rem;
}

.iemss-container .card-title {
  margin-bottom: 0;
  font-weight: 600;
  color: #495057;
}

/* Station selection lists */
#stations_in,
#stations_out {
  min-height: 200px;
  height: 200px;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#stations_in:focus,
#stations_out:focus {
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Selected options styling */
#stations_in option:checked,
#stations_out option:checked {
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
  color: white;
}

#stations_in option:hover,
#stations_out option:hover {
  background-color: #f8f9fa;
}

#stationfilter:focus {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Button group improvements */
.iemss-button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Top row with sort dropdown and filter input */
.iemss-container .d-flex.gap-2 {
  align-items: center;
  margin-bottom: 0.5rem;
  min-height: 38px; /* Match Bootstrap form control height */
}

.iemss-container .d-flex.gap-2 #stationfilter {
  min-width: 150px;
}

/* Right side label container to match left side height */
.iemss-container .d-flex.align-items-center {
  margin-bottom: 0.5rem;
}

/* Labels styling */
.iemss-container label {
  font-weight: 600;
  color: #495057;
  margin-bottom: 0.5rem;
}

.iemss-button-group .btn {
  border-radius: 0.375rem;
  font-weight: 500;
  transition: all 0.15s ease-in-out;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.iemss-button-group .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.iemss-button-group .btn:active {
  transform: translateY(0);
}

/* Dropdown menu improvements */
.iemss-container .dropdown-menu {
  border-radius: 0.375rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.iemss-container .dropdown-item {
  padding: 0.5rem 1rem;
  transition: background-color 0.15s ease-in-out;
}

.iemss-container .dropdown-item:hover {
  background-color: #f8f9fa;
}

/* Map container styling */
#map {
  border-radius: 0.375rem;
  border: 1px solid #dee2e6;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  width: 100%;
  height: 400px;
}

/* Hidden elements */
.iemss-hidden {
  display: none;
}

/* Popup styling */
#popup {
  width: 250px;
}

#popover-content {
  display: none;
}

/* Map legend styling */
.iemss-map-legend {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: #6c757d;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.iemss-legend-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.iemss-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.iemss-legend-dot.online {
  background-color: #198754;
}

.iemss-legend-dot.offline {
  background-color: #dc3545;
}

/* Column spacing improvements */
.iemss-container .col-sm-6 {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

/* Labels styling */
/* Moved above to consolidate with top row styling */

/* Station count displays */
.iemss-station-count {
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
  font-style: italic;
  display: flex;
  align-items: center;
}

.iemss-station-count::before {
  content: "📊";
  margin-right: 0.25rem;
  font-size: 0.75em;
}

/* Form inline improvements - no longer needed */

/* Filter input styling */
#stationfilter {
  border-radius: 0.375rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Responsive improvements */
@media (max-width: 576px) {
  .iemss-container .card-header {
    padding: 0.75rem 1rem;
  }
  
  .iemss-container .card-header .btn {
    margin-top: 0.5rem;
  }
  
  .iemss-container .col-sm-6 {
    margin-bottom: 1rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  #stations_in,
  #stations_out {
    min-height: 150px;
    height: 150px;
  }
  
  #map {
    height: 300px !important;
  }
  
  .iemss-button-group {
    justify-content: center;
  }
  
  .iemss-button-group .btn {
    flex: 1;
    min-width: 120px;
  }
  
  .iemss-map-legend {
    justify-content: center;
    flex-wrap: wrap;
  }
}

@media (min-width: 768px) {
  /* No special desktop overrides needed for new layout */
}

/* Popover styling improvements */
.popover {
  border-radius: 0.375rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.popover-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 1px solid #dee2e6;
  font-weight: 600;
}

.popover-body {
  padding: 0.75rem;
  font-size: 0.875rem;
}

/* Loading state styling */
.iemss-loading {
  opacity: 0.7;
  pointer-events: none;
}

.iemss-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #0d6efd;
  border-radius: 50%;
  animation: iemss-spin 1s linear infinite;
}

@keyframes iemss-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Accessibility improvements */
.iemss-container .btn:focus {
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.iemss-container .dropdown-item:focus {
  background-color: #e9ecef;
  outline: 2px solid #0d6efd;
  outline-offset: -2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  #stations_in,
  #stations_out {
    border-width: 2px;
  }
  
  .iemss-container .btn {
    border-width: 2px;
  }
  
  #map {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .iemss-button-group .btn {
    transition: none;
  }
  
  .iemss-button-group .btn:hover {
    transform: none;
  }
  
  #stationfilter {
    transition: none;
  }
  
  .iemss-loading::after {
    animation: none;
  }
}
