/* Reset & Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: "Poppins", sans-serif;
  background: linear-gradient(120deg, #f0f3f5 0%, #ffffff 100%);
  color: #333;
  height: 100vh;
  overflow: hidden;
}

/* Primary Colors - LNG Industry Theme */
:root {
  --primary-color: #525390;       /* Deep purple - primary brand color */
  --primary-light: #6667A7;       /* Lighter purple for hover states */
  --primary-dark: #424279;        /* Darker purple for active elements */
  --accent-color: #00b4c4;        /* Teal accent */
  --accent-light: #33d6e2;        /* Light teal for highlights */
  --accent-dark: #008d99;         /* Dark teal for contrast */
  --text-light: #ffffff;          /* Light text on dark backgrounds */
  --text-dark: #333333;           /* Dark text on light backgrounds */
  --text-muted: #6c757d;          /* Muted text color */
  --border-color: rgba(10, 92, 145, 0.2); /* Border color based on primary */
  --sidebar-bg: #f8fbfd;          /* Very light blue background */
  --card-bg: #ffffff;             /* Card background */
  --hover-bg: rgba(10, 92, 145, 0.05); /* Hover background */
  --shadow-color: rgba(10, 92, 145, 0.15); /* Shadow color */
}

/* Spinner Overlay */
#spinner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.loader {
  border: 8px solid #f3f3f3;
  border-top: 8px solid #007bff;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* MAP CONTAINER */
#map {
  position: absolute;
  left: 280px;
  top: 0;
  right: 0;
  bottom: 0;
  transition: left 0.3s ease;
}

/* SIDEBAR */
#sidebar {
  position: absolute;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  background-color: white;
  z-index: 20; /* Reduced z-index to be lower than search */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  margin: 0;
  border-right: 1px solid #ddd;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  transform: translateX(0); /* Default is visible */
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

/* Collapsed state - move offscreen by exactly its width */
#sidebar.collapsed {
  transform: translateX(-280px);
}

/* Improved toggle button */
#toggle-sidebar {
  position: absolute;
  top: 50%;
  right: -40px;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background-color: #525390;
  color: white;
  border: 2px solid white;
  border-radius: 0 8px 8px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
  transition: background-color 0.2s ease;
}

#toggle-sidebar:hover {
  background-color: #424279;
}

#toggle-sidebar i {
  color: white;
  font-size: 18px;
  transition: transform 0.3s ease;
}

#sidebar.collapsed #toggle-sidebar i {
  transform: rotate(180deg);
}

/* Enhanced sidebar header with toggle functionality */
.sidebar-header {
  padding: 15px;
  background-color: #525390;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sidebar-header:hover {
  background-color: #424279;
}

.logo {
  display: flex;
  align-items: center;
  font-weight: 600;
  color: white;
}

.logo i {
  font-size: 20px;
  margin-right: 10px;
}

.logo span {
  font-size: 18px;
  font-weight: 600;
}

/* Toggle icon in header */
.header-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.collapse-icon {
  font-size: 14px;
  transition: transform 0.3s ease;
}

/* Rotate icon when sidebar is collapsed */
#sidebar.collapsed .collapse-icon {
  transform: rotate(180deg);
}

/* SIDEBAR HEADINGS */
#sidebar h2 {
  color: var(--primary-color);
  font-size: 1.4rem;
  font-weight: 600;
  margin: 20px 0 15px 0;
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 8px;
}

/* Filters section */
.filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 15px 20px 15px;
}

/* Vertical filter button styling */
.filter-toggle-button {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  background: white;
  color: #525390;
  border: 1px solid rgba(82, 83, 144, 0.15);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  text-align: left;
}

.filter-toggle-button i {
  margin-right: 10px;
  font-size: 14px;
}

.filter-toggle-button:hover {
  background: #f8f9ff;
  border-color: rgba(82, 83, 144, 0.3);
}

.filter-toggle-button.active {
  background: #525390;
  color: white;
  border-color: #525390;
}

/* TOGGLE LABELS BUTTON */
#toggle-labels {
  width: 100%;
  padding: 12px 15px;
  border: none;
  border-radius: 8px;
  background: var(--accent-color);
  color: var(--text-light);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  box-shadow: 0 2px 5px var(--shadow-color);
}

#toggle-labels i {
  margin-right: 8px;
}

#toggle-labels:hover {
  background: var(--accent-light);
}

#toggle-labels.active {
  background: var(--accent-dark);
}

/* FAVORITES LIST */
#favorites-list {
  flex: 1;
  overflow-y: auto;
  min-height: 100px;
  margin: 0;
  padding: 0 15px 15px;
  list-style-type: none;
}

.favorites-group-header {
  display: flex;
  align-items: center;
  padding: 10px 5px 8px 5px;
  margin-top: 15px;
  border-bottom: 1px solid rgba(82, 83, 144, 0.2);
}

.favorites-group-header .group-name {
  font-weight: 600;
  font-size: 13px;
  color: #525390;
  flex: 1;
}

.favorites-group-header .group-actions {
  display: flex;
  gap: 8px;
}

.favorites-group-header .group-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #6c757d;
  font-size: 14px;
  padding: 2px;
  transition: color 0.2s ease;
}

.favorites-group-header .group-action-btn:hover {
  color: #525390;
}

/* Eye toggle for visibility */
.group-visibility-toggle {
  color: #525390;
}

.group-visibility-toggle.hidden {
  color: #adb5bd;
}

/* Favorites item styling */
#favorites-list li {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  margin: 5px 0;
  background: white;
  transition: all 0.2s ease;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

#favorites-list li .vessel-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

#favorites-list li .vessel-name {
  font-weight: 500;
  font-size: 12px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#favorites-list li .vessel-details {
  font-size: 10px;
  color: #6c757d;
  display: flex;
  align-items: center;
}

#favorites-list li img.favorite-icon {
  margin-right: 10px;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

#favorites-list li .actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#favorites-list li:hover .actions {
  opacity: 1;
}

#favorites-list li .action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #6c757d;
  font-size: 12px;
  padding: 2px;
  transition: color 0.2s ease;
}

#favorites-list li .action-btn:hover {
  color: #525390;
}

/* Empty message styling */
.empty-favorites-message {
  text-align: center;
  padding: 20px;
  color: #6c757d;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  margin: 15px 0;
}

.empty-favorites-message i {
  font-size: 24px;
  color: #adb5bd;
  margin-bottom: 10px;
}

.empty-favorites-message p {
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
}

/* Empty group message */
.empty-group-message {
  text-align: center;
  padding: 8px;
  color: #6c757d;
  font-size: 11px;
  font-style: italic;
}

/* Quick filter buttons */
.quick-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.quick-filters button {
  padding: 8px 15px;
  border: none;
  border-radius: 20px;
  background: var(--card-bg);
  color: var(--primary-color);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px var(--shadow-color);
  display: flex;
  align-items: center;
}

.quick-filters button i {
  margin-right: 6px;
}

.quick-filters button:hover {
  background: var(--hover-bg);
  transform: translateY(-2px);
}

.quick-filters button.active {
  background: var(--primary-color);
  color: var(--text-light);
}

.quick-filters button.active i {
  color: var(--text-light);
}

/* Group Selection Popup */
.group-selection-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  border-radius: 8px;
  z-index: 1000;
  width: 300px;
  max-width: 90vw;
  overflow: hidden;
}

.group-selection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
}

.group-selection-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #777;
}

.group-selection-content {
  padding: 10px 0;
  max-height: 300px;
  overflow-y: auto;
}

.group-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 15px;
}

.group-item {
  display: flex;
  align-items: center;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.group-item:hover {
  background: #f5f5f5;
}

.group-item.active {
  background: #e6f2ff;
}

.group-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  margin-right: 10px;
}

.group-item .group-name {
  font-size: 14px;
}

.group-item.new-group {
  margin-top: 8px;
  border-top: 1px solid #eee;
  padding-top: 12px;
}

.group-item.new-group .group-name {
  color: #666;
}

/* Original Favorites (for compatibility) */
#favorites-list li {
  padding: 8px;
  margin-bottom: 8px;
  background: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
#favorites-list li img.favorite-icon {
  width: 16px;
  height: 16px;
}
#favorites-list li:hover {
  background: #f0f0f0;
}

/* Clean, simplified search container styling */
.search-container {
  position: relative;
  margin: 15px;
  width: 280px;
}

/* Clean, simplified search input styling */
.search-container input[type="text"] {
  width: 100%;
  height: 48px;
  padding: 0 15px 0 45px;
  background-color: white;
  color: #333;
  font-size: 13px;
  border: 1px solid rgba(82, 83, 144, 0.2);
  border-radius: 24px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  
  /* Remove all browser default styling */
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.search-container input[type="text"]:focus {
  border-color: rgba(82, 83, 144, 0.5);
  box-shadow: 0 4px 15px rgba(82, 83, 144, 0.15);
}

.search-container i {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(82, 83, 144, 0.7);
  font-size: 16px;
  pointer-events: none; /* Prevent icon from interfering with input */
}

/* Search results area */
#search-results {
  position: absolute;
  top: 100%;
  left: 15px;
  width: 280px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, margin-top 0.3s ease;
  z-index: 100;
  margin-top: 0;
  border: none; /* Remove any border */
}

#search-results.active {
  max-height: 300px;
  margin-top: 10px;
  overflow-y: auto;
}

/* Search result item styling */
.search-result-item {
  padding: 10px 15px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  cursor: pointer;
}

.search-result-item:hover {
  background: rgba(82, 83, 144, 0.05);
}

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

/* Glassmorphic popup styling */
.mapboxgl-popup-content {
  padding: 0; /* Remove default padding for full-width header */
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  max-width: 380px;
  min-width: 320px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #333;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  max-height: 280px;
  overflow: hidden;
}

/* Colored glassmorphic header */
.popup-header {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(82, 83, 144, 0.95) 0%, rgba(82, 83, 144, 0.85) 100%);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  width: 100%;
  flex-shrink: 0;
  position: relative; /* For positioning the age indicator */
}

.popup-header .vessel-name {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  flex: 1;
  margin-right: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Flag icon in header */
.popup-header .flag-icon {
  margin-left: 5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}

/* Scrollable container with padding */
.popup-scroll-container {
  overflow-y: auto;
  padding: 10px 12px;
  flex-grow: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(82, 83, 144, 0.5) rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.8);
}

/* Small custom scrollbar */
.popup-scroll-container::-webkit-scrollbar {
  width: 4px;
}

.popup-scroll-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.popup-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(82, 83, 144, 0.5);
  border-radius: 2px;
}

/* Popup list with subtle shadows */
.popup-list {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 4px;
}

/* Horizontal layout for items with subtle hover effect */
.popup-item {
  display: flex;
  align-items: baseline;
  padding: 6px 2px;
  border-bottom: 1px solid rgba(82, 83, 144, 0.07);
  height: 26px;
  transition: background 0.2s ease;
}

.popup-item:hover {
  background: rgba(82, 83, 144, 0.05);
}

.popup-item:last-child {
  border-bottom: none;
}

/* Label styling */
.popup-label {
  font-size: 9px;
  color: rgba(82, 83, 144, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
  width: 42%;
  min-width: 100px;
  padding-right: 8px;
  flex-shrink: 0;
}

/* Value styling */
.popup-value {
  font-size: 11px;
  font-weight: 500;
  color: #333;
  line-height: 1.3;
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 80px;
}

/* Hide the default close button */
.mapboxgl-popup-close-button {
  display: none;
}

/* FLOATING CONTROLS ON MAP */
#map-floating-controls {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 999;
}
#toggle-view-floating {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(8px);
  transition: background 0.2s;
}
#toggle-view-floating:hover {
  background: rgba(255, 255, 255, 1);
}

/* TABLE VIEW STYLES */
#table-view {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.list-header {
  padding: 15px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--sidebar-bg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1002; /* Higher than before to ensure it's always on top */
  height: 60px; /* Fixed height for calculations */
}

.list-header .search-container {
  margin-left: auto;
  flex: 1;
  max-width: 500px;
  margin-right: 15px;
}

.list-header .search-container input[type="text"] {
  width: 100%;
  padding: 10px 15px 10px 40px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
  font-size: 14px;
  background-color: white;
  transition: all 0.3s ease;
}

.list-header .search-container input[type="text"]:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(10, 92, 145, 0.15);
  outline: none;
}

.list-header .search-container i {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary-color);
  font-size: 16px;
}

.list-title {
  font-size: 16px;
  font-weight: 500;
  margin: 0 20px;
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-toggle-button {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.2s;
}

.filter-toggle-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.filter-toggle-button.active {
  background: rgba(255, 255, 255, 0.3);
}

.filter-toggle-button i {
  font-size: 14px;
}

.table-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 60px); /* Adjust to account for header height */
  margin-top: 60px; /* Match the height of the list-header */
  position: relative;
}

.table-filters-sidebar {
  width: 280px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  padding: 20px;
  overflow-y: auto;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  z-index: 10;
  transform: translateX(0);
}

.table-filters-sidebar.collapsed {
  transform: translateX(-100%);
  box-shadow: none;
}

/* Toggle button for filter sidebar - ensure proper styling and visibility */
#toggle-filters {
  position: absolute;
  top: 70px; /* Position it right below the header */
  left: 280px; /* By default positioned at the end of the sidebar */
  width: 24px;
  height: 36px;
  background-color: #525390;
  color: white;
  border-radius: 0 4px 4px 0;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 3px 0 5px rgba(0, 0, 0, 0.1);
  z-index: 1001; /* Just below the header */
  transition: left 0.3s ease, background-color 0.2s ease;
}

#toggle-filters:hover {
  background-color: #6667A7;
  transform: scale(1.05);
}

#toggle-filters i {
  transition: transform 0.3s ease;
  font-size: 12px;
}

/* When sidebar is collapsed, move toggle button to the left edge */
.table-filters-sidebar.collapsed ~ #toggle-filters {
  left: 0;
}

/* Header for filter section, to include a toggle button */
.filter-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-light);
  margin-bottom: 15px;
}

.filter-section-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--primary-color);
}

/* Table content adjustments for expanded state */
#table-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  border: none;
  background: white;
  height: 100%;
  width: calc(100% - 280px); /* Width reduced by sidebar width */
  margin-left: 280px; /* Add margin for the sidebar */
  transition: width 0.3s ease, margin-left 0.3s ease;
  position: relative;
  overflow-anchor: none;
}

/* When sidebar is collapsed, table takes full width */
.table-filters-sidebar.collapsed ~ #table-content {
  width: 100%;
  margin-left: 0;
}

#table-content.expanded {
  width: 100%;
  margin-left: 0;
}

/* Ensure correct stacking context */
#table-content table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-top: 25px; /* Increased space at the top to avoid overlapping with toggle button */
}

/* Fixed table header with correct z-index and no flicker */
#table-content thead {
  background-color: #525390 !important; /* Purple theme color with !important to prevent overrides */
  color: white;
  position: sticky;
  top: 0;
  z-index: 10; /* Increased to ensure it stays above content */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  pointer-events: auto; /* Ensure it captures mouse events */
  backface-visibility: hidden; /* Prevent flicker */
  will-change: transform; /* Optimize rendering */
}

/* Improve header hover stability */
#table-content th {
  padding: 8px 10px;  /* Reduced padding to match cells */
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  border: none;
  white-space: nowrap;
  position: relative;
  color: white;
  cursor: pointer; /* Indicate clickable for sorting */
  background-color: #525390 !important; /* Ensure th elements maintain the same color */
}

/* Override any hover effect */
#table-content th:hover {
  background-color: #525390 !important; /* Same as regular color with !important */
  color: white !important; /* Ensure text color doesn't change */
}

/* Improve table row hover behavior */
#table-content tbody tr {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

#table-content tbody tr:hover {
  background-color: rgba(82, 83, 144, 0.1);
}

/* Ensure td styling is consistent */
#table-content td {
  padding: 8px 10px;  /* Reduced padding */
  border-bottom: 1px solid #e0e0e0;
  font-size: 12px;   /* Reduced font size */
}

.filter-section {
  margin-bottom: 25px;
}

.filter-section h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  color: var(--primary-color);
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-light);
}

.clear-filters-btn {
  background-color: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.clear-filters-btn:hover {
  color: var(--primary-color);
  background-color: rgba(0, 0, 0, 0.05);
}

.filter-group {
  margin-bottom: 15px;
}

.filter-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-dark);
  font-size: 14px;
}

.filter-input,
.filter-select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: white;
  color: var(--text-dark);
  font-size: 14px;
  transition: all 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23525390%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 32px;
}

.filter-select {
  cursor: pointer;
  background-color: #f8f8fa;
  border: 1px solid #ddddea;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.filter-select:hover {
  background-color: #f0f0f8;
  border-color: #cacad8;
}

.filter-input:focus,
.filter-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(82, 83, 144, 0.15);
  outline: none;
  background-color: white;
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.range-inputs input {
  flex: 1;
}

.range-inputs span {
  color: var(--text-muted);
  font-size: 13px;
}

#table-content table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#table-content th:nth-child(1), #table-content td:nth-child(1) { width: 120px; } /* Ship name */
#table-content th:nth-child(2), #table-content td:nth-child(2) { width: 120px; } /* Owner */
#table-content th:nth-child(3), #table-content td:nth-child(3) { width: 100px; } /* Last updated */
#table-content th:nth-child(4), #table-content td:nth-child(4) { width: 70px; } /* Speed */
#table-content th:nth-child(5), #table-content td:nth-child(5) { width: 90px; } /* Status */
#table-content th:nth-child(6), #table-content td:nth-child(6) { width: 120px; } /* Destination */
#table-content th:nth-child(7), #table-content td:nth-child(7) { width: 120px; } /* ETA */
#table-content th:nth-child(8), #table-content td:nth-child(8) { width: 100px; } /* Ship type */
#table-content th:nth-child(9), #table-content td:nth-child(9) { width: 100px; } /* Tank Capacity */
#table-content th:nth-child(10), #table-content td:nth-child(10) { width: 100px; } /* Location */
#table-content th:nth-child(11), #table-content td:nth-child(11) { width: 80px; } /* IMO */

/* Prevent overflow and add ellipsis for cell content */
#table-content td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px; /* Maximum width for any cell */
}

.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

/* OVERLAY CONTROLS */
#map-overlay-controls {
  position: absolute !important;
  top: 20px !important;
  left: calc(280px + (100% - 280px) / 2 - 140px) !important; /* Center between sidebar and right edge */
  width: 280px !important;
  z-index: 30 !important; /* Higher z-index than sidebar */
  transition: left 0.3s ease !important;
}

/* When sidebar is collapsed, adjust search position */
#sidebar.collapsed ~ #map-overlay-controls {
  left: calc(50% - 140px) !important; /* Center in full map width */
}

/* Reset all styles for the map search container */
#map-overlay-controls .search-container {
  margin: 0;
  width: 100%;
  position: relative;
}

/* Completely reset the search input styling */
#map-overlay-controls input[type="text"] {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 15px 0 45px;
  background: white;
  color: #333;
  font-size: 13px;
  border: 1px solid rgba(82, 83, 144, 0.2);
  border-radius: 24px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  
  /* Aggressive reset of browser styling */
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  outline: none !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  font-family: inherit !important;
}

/* Clean focus state */
#map-overlay-controls input[type="text"]:focus {
  border-color: rgba(82, 83, 144, 0.5);
  box-shadow: 0 4px 15px rgba(82, 83, 144, 0.15);
  outline: none !important;
}

/* Position the search icon */
#map-overlay-controls .search-container i {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(82, 83, 144, 0.7);
  font-size: 16px;
  pointer-events: none;
  z-index: 11;
}

/* You can hide it by default when in table view */
#table-view ~ #map-overlay-controls {
  display: none;
}

#table-view-button button {
  padding: 6px 6px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid #ccc;
  border-radius: 1px;
  cursor: pointer;
  box-shadow: 0 2px 0px rgba(0, 0, 0, 0.2);
}

#table-view-button button:hover {
  background: rgba(255, 255, 255, 1);
}

#map-search-box input[type="text"] {
  padding: 0px 0px;
  font-size: 14px;
  border: 0px solid #ccc;
  border-radius: 4px;
}
.vessel-label {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: #000;
  background: rgba(255, 255, 255, 0.9);
  padding: 3px 6px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: auto; /* Make labels clickable */
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.8);
  font-weight: 600;
  z-index: 15; /* Higher z-index to ensure labels appear above markers */
  max-width: 120px; /* Increased from 80px to show more of the name */
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Make important vessel labels stand out more */
.vessel-marker.favorite .vessel-label,
.vessel-marker.lng .vessel-label {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  font-weight: 700;
  z-index: 16; /* Slightly higher z-index */
}

/* Hidden label style */
.vessel-label.hidden {
  opacity: 0;
}

/* Table favorite indicators */
.favorite-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}

.favorite-group-indicator {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid #fff;
  box-shadow: 0 0 2px rgba(0,0,0,0.2);
}

.favorite-icon-table {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

#table-content tr {
  cursor: pointer;
  transition: background 0.2s;
}

#table-content tr:hover {
  background-color: #f5f5f5;
}

/* Add vessel to favorites section */
.add-vessel-section {
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.add-vessel-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
}

.add-vessel-header span {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

.add-vessel-header i {
  color: #666;
  margin-right: 8px;
  font-size: 14px;
}

.add-vessel-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vessel-select, .group-select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-size: 13px;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) inset;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.vessel-select:focus, .group-select:focus {
  outline: none;
  border-color: rgba(0, 123, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.add-vessel-content .small-btn {
  align-self: flex-end;
  padding: 6px 12px;
  background: #007bff;
  color: white;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: background 0.2s;
}

.add-vessel-content .small-btn:hover:not(:disabled) {
  background: #0069d9;
}

.add-vessel-content .small-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: #6c757d;
}

/* Map Filter Bar - Vertical Style */
#map-filter-bar {
  position: absolute;
  top: 20px;
  right: 20px;
  left: auto;
  transform: none;
  display: flex;
  flex-direction: column; /* Vertical layout */
  background: var(--card-bg);
  padding: 4px;
  border-radius: 12px;
  box-shadow: 0 2px 6px var(--shadow-color);
  z-index: 25; /* Between sidebar and search z-index */
  border: 1px solid var(--border-color);
  overflow: hidden;
  margin-left: 0;
  font-size: 12px;
  width: 80px; /* Set fixed width for the vertical bar */
}

.filter-segment {
  display: flex;
  flex-direction: column; /* Changed back to column to have number on top, text below */
  align-items: center;
  justify-content: center;
  margin: 2px 0;
  cursor: pointer;
  padding: 8px 5px;
  transition: all 0.2s ease;
  position: relative;
  width: 100%;
  border-radius: 8px;
}

.filter-segment:hover {
  background-color: #9495C2;
  color: var(--text-light);
}

.filter-segment.active {
  background-color: #525390;
  color: var(--text-light);
}

.filter-number {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px; /* Margin below the number */
  text-align: center;
}

.filter-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}

/* Simplified position age indicator */
.position-age {
  display: flex;
  align-items: center;
  margin-right: 10px;
  position: relative;
}

.position-age .age-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

/* Age indicator colors */
.age-recent {
  background-color: #4CAF50; /* Green for recent updates */
  animation: pulse 2s infinite; /* Add pulsating effect */
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
  }
  70% {
    box-shadow: 0 0 0 5px rgba(76, 175, 80, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
  }
}

.age-medium {
  background-color: #FFC107; /* Yellow/amber for medium age */
}

.age-old {
  background-color: #F44336; /* Red for old position data */
}

/* Simple popup for position age on hover */
.position-age-popup {
  position: absolute;
  top: -50px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(48, 48, 64, 0.95);
  color: white;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 1000;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Arrow for the popup */
.position-age-popup:after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: rgba(48, 48, 64, 0.95) transparent transparent transparent;
}

/* Show popup on hover */
.position-age:hover .position-age-popup {
  opacity: 1;
  visibility: visible;
}

/* Solid purple section header */
.section-header {
  background: #525390; /* Solid purple color */
  padding: 12px 15px;
  margin: 0;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.section-header h2 {
  color: white;
  font-size: 15px;
  font-weight: 500;
  margin: 0;
  border: none !important;
  padding: 0;
}

/* Favorites controls section */
.favorites-controls {
  padding: 15px 15px 10px;
  display: flex;
  gap: 8px;
}

/* Mini search for favorites */
.search-mini {
  position: relative;
  flex: 1;
}

.search-mini input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border-radius: 6px;
  border: 1px solid rgba(82, 83, 144, 0.2);
  font-size: 12px;
  background: white;
  color: #333;
  transition: all 0.2s ease;
}

.search-mini input:focus {
  outline: none;
  border-color: rgba(82, 83, 144, 0.5);
  box-shadow: 0 0 0 2px rgba(82, 83, 144, 0.1);
}

.search-mini i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(82, 83, 144, 0.6);
  font-size: 12px;
}

/* Small button style */
.small-btn {
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  background: #525390;
  color: white;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.small-btn i {
  font-size: 12px;
}

.small-btn:hover {
  background: #9495C2;
}

/* Search results styling with better buttons */
.search-results-mini {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: white;
  margin: 0 15px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.search-results-mini.active {
  max-height: 220px;
  margin-top: 10px;
  margin-bottom: 10px;
  overflow-y: auto;
}

.search-result-item-mini {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-result-item-mini:hover {
  background: rgba(82, 83, 144, 0.05);
}

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

.search-result-item-mini .vessel-name {
  font-size: 12px;
  font-weight: 500;
  margin-right: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.search-result-item-mini .already-added {
  font-size: 10px;
  color: #6c757d;
  background: #e9ecef;
  padding: 2px 6px;
  border-radius: 4px;
}

.search-result-item-mini .add-actions {
  display: flex;
  gap: 6px;
}

.search-result-item-mini .add-btn {
  padding: 3px 6px;
  background: #525390;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  transition: background 0.2s ease;
}

.search-result-item-mini .add-btn:hover {
  background: #9495C2;
}

.search-result-item-mini .add-btn.add-to-group {
  background: #396bae;
}

.search-result-item-mini .add-btn.add-to-group:hover {
  background: #4d85d4;
}

/* Modal overlay styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.modal-header {
  background: #525390;
  color: white;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

.modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
}

.modal-body {
  padding: 15px;
}

.modal-body p {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 14px;
}

.modal-footer {
  padding: 10px 15px 15px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid #ced4da;
  font-size: 14px;
}

.form-control:focus {
  outline: none;
  border-color: #525390;
  box-shadow: 0 0 0 2px rgba(82, 83, 144, 0.25);
}

/* Back button styling */
.back-button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.back-button:hover {
  background-color: var(--primary-light);
  transform: scale(1.05);
}

.back-button i {
  font-size: 18px;
}

/* Map controls */
#map-controls {
  position: absolute;
  right: 20px;
  bottom: 30px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}

.map-control-btn {
  width: 40px;
  height: 40px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.map-control-btn:hover {
  background: #f8f9ff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.map-control-btn i {
  color: #525390;
  font-size: 16px;
}

.map-control-btn.active {
  background: #525390;
}

.map-control-btn.active i {
  color: white;
}

/* Hide sidebar in table view */
body.list-view #sidebar {
  display: none;
}

.toggle-text {
  display: none;
  margin-left: 5px;
  font-size: 12px;
  font-weight: 500;
}

#sidebar.collapsed #toggle-sidebar .toggle-text {
  display: inline-block;
}

/* Sidebar footer for bottom controls */
.sidebar-footer {
  padding: 15px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin-top: auto; /* Push to bottom */
  background-color: #f7f7f7;
}

/* Improved list view button */
.sidebar-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #525390;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sidebar-button:hover {
  background: #424279;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.sidebar-button i {
  font-size: 16px;
}

/* When sidebar is collapsed, expand map */
#sidebar.collapsed ~ #map {
  left: 0;
}

/* Expand button (visible only when sidebar is collapsed) */
.expand-button {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 40px;
  height: 40px;
  background-color: #525390;
  color: white;
  border: 2px solid white;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 980;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.expand-button:hover {
  background-color: #424279;
}

/* Show expand button when sidebar is collapsed */
#sidebar.collapsed ~ .expand-button {
  opacity: 1;
  visibility: visible;
}

.location-container {
  position: relative;
  cursor: pointer;
}

.map-preview {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 150px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 1000;
  margin-top: 5px;
}

.map-preview::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid white;
}

.map-preview::after {
  content: '';
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 9px solid #ddd;
  z-index: -1;
}

.filter-section h3 {
  font-size: 14px;
  margin-bottom: 16px;
}

.filter-group label {
  font-size: 12px;
}

.filter-input,
.filter-select {
  font-size: 13px;
}

/* Multiselect dropdown styling */
.multiselect-container {
  position: relative;
  width: 100%;
  margin-bottom: 10px;
}

.multiselect-dropdown {
  width: 100%;
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.multiselect-dropdown:hover {
  border-color: var(--primary-color);
  background-color: var(--hover-bg);
}

.multiselect-dropdown.active, 
.multiselect-dropdown:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(82, 83, 144, 0.15);
  outline: none;
}

.multiselect-dropdown-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  color: var(--text-dark);
}

.multiselect-dropdown-arrow {
  margin-left: 8px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.multiselect-dropdown.active .multiselect-dropdown-arrow {
  transform: rotate(180deg);
}

.multiselect-items {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 0 0 6px 6px;
  margin-top: 2px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 8px 0;
  display: none;
}

.multiselect-search {
  width: calc(100% - 16px);
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin: 0 8px 8px 8px;
  font-size: 13px;
}

.multiselect-search:focus {
  outline: none;
  border-color: var(--primary-color);
}

.multiselect-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 8px 0;
}

.multiselect-option {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  transition: background-color 0.2s;
  cursor: pointer;
}

.multiselect-option:hover {
  background-color: var(--hover-bg);
}

.multiselect-checkbox {
  margin-right: 8px;
}

/* Back button and filter button styling */
.list-header .back-button,
.list-header #toggle-filters-header {
  margin-right: 10px;
  transition: all 0.2s ease;
}

.list-header #toggle-filters-header:hover {
  background-color: #6667A7;
}

/* Group the action buttons in the header */
.header-action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Update the header toggles styling */
#toggle-filters-header {
  position: relative;
  transition: background-color 0.2s ease;
}

#toggle-filters-header:hover {
  background-color: #6667A7;
}

/* CSS for rotating the filter icon */
#toggle-filters-header i {
  transition: transform 0.3s ease;
}

.table-filters-sidebar.collapsed ~ .list-header #toggle-filters-header i {
  transform: rotate(180deg);
}

/* List View Spinner Overlay */
#list-view-spinner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  z-index: 1010; /* Above the table view */
}

#list-view-spinner .spinner-text {
  margin-top: 15px;
  color: var(--primary-color);
  font-weight: 500;
}

/* Vessel warning notice in popups */
.vessel-warning-notice {
  border: none !important;
  margin: 5px 0;
  padding: 5px 8px;
  background-color: #fff7ed;
}

.vessel-warning-notice .popup-value {
  font-style: italic;
  color: #d35400;
  text-align: center;
  font-size: 0.9em;
  line-height: 1.4;
  width: 100%;
  white-space: normal;
  overflow-wrap: break-word;
}

/* Map logo */
.map-logo {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 10;
  background-color: rgba(255, 255, 255, 0.7);
  padding: 5px;
  border-radius: 4px;
}

.map-logo img {
  height: 30px;
  width: auto;
}

/* Map notification */
.map-notification {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(82, 83, 144, 0.95);
  color: white;
  padding: 10px 20px;
  border-radius: 50px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  font-size: 14px;
  font-weight: 500;
  animation: fadeInOut 3s ease forwards;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translate(-50%, 20px); }
  10% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 0); }
}
/* Map loading spinner */
.map-loading-spinner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #525390; /* Use your app's primary color */
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 10px;
}

.spinner-text {
  font-size: 14px;
  color: #525390;
  font-weight: 500;
}

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

/* Spinner Overlay - Override to ensure spinners stay hidden */
#spinner[style*="display: none"],
.map-loading-spinner[style*="display: none"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Mobile Media Queries */
@media screen and (max-width: 767px) {
  /* Auto-collapse sidebar on mobile */
  #sidebar {
    transform: translateX(-280px); /* Default to collapsed on mobile */
    width: 250px; /* Narrower sidebar on mobile */
    z-index: 50; /* Higher z-index to ensure it appears above other elements when expanded */
  }
  
  /* When sidebar is expanded on mobile */
  #sidebar:not(.collapsed) {
    transform: translateX(0); /* Restore to visible when not collapsed */
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2); /* Add shadow for better visibility */
  }
  
  /* Show expand button by default on mobile */
  .expand-button {
    opacity: 1;
    visibility: visible;
  }
  
  /* Position search with collapsed sidebar (default mobile state) */
  #map-overlay-controls {
    top: 20px !important;
    left: 65px !important;
    width: calc(100% - 150px) !important;
    z-index: 30 !important;
    transition: none !important;
  }
  
  /* Adjust search when sidebar is expanded */
  #sidebar:not(.collapsed) ~ #map-overlay-controls {
    left: 265px !important; /* Position to the right of expanded sidebar */
    width: calc(100% - 280px - 65px) !important; /* Adjust width */
  }
  
  /* Adjust map positioning with expanded sidebar */
  #sidebar:not(.collapsed) ~ #map {
    left: 250px; /* Match sidebar width */
  }
  
  /* Make the search box smaller on mobile */
  #map-overlay-controls input[type="text"] {
    height: 36px;
    font-size: 12px;
    border-radius: 18px;
    padding: 0 10px 0 35px;
  }
  
  /* Adjust the search icon position */
  #map-overlay-controls .search-container i {
    left: 12px;
    font-size: 14px;
  }
  
  /* Make sidebar header smaller */
  .sidebar-header {
    padding: 12px 10px;
  }
  
  .logo i {
    font-size: 18px;
    margin-right: 8px;
  }
  
  .logo span {
    font-size: 16px;
  }
  
  /* Adjust filter bar for mobile */
  #map-filter-bar {
    top: 15px;
    right: 15px;
    border-radius: 10px;
    width: 70px; /* Slightly smaller for mobile */
    z-index: 10; /* Ensure filter bar appears above search */
  }
  
  /* Make filter segments more touch-friendly */
  .filter-segment {
    padding: 6px 4px;
  }
  
  /* Reduce the size of filter text */
  .filter-label {
    font-size: 11px;
  }
  
  /* Make the expand button more visible and positioned better */
  .expand-button {
    top: 15px;
    left: 15px;
    width: 38px;
    height: 38px;
  }
  
  /* Hide expand button when sidebar is expanded */
  #sidebar:not(.collapsed) ~ .expand-button {
    opacity: 0;
    visibility: hidden;
  }
  
  /* Fix map logo position for mobile */
  .map-logo {
    bottom: 10px;
    right: 10px;
  }
  
  /* Make marker labels more mobile-friendly */
  .vessel-label {
    font-size: 10px;
    max-width: 80px; /* Limit label width on mobile */
  }
  
  /* Adjust map position for collapsed sidebar */
  #map {
    left: 0;
  }
}

/* iPhone SE and other very small screens */
@media screen and (max-width: 375px) {
  /* Even smaller sidebar header for tiny screens */
  .sidebar-header {
    padding: 10px 8px;
  }
  
  .logo i {
    font-size: 16px;
    margin-right: 6px;
  }
  
  .logo span {
    font-size: 14px;
  }
  
  /* Adjust search position and size for tiny screens */
  #map-overlay-controls {
    width: calc(100% - 120px) !important;
    left: 60px !important;
    top: 20px !important;
  }
  
  /* Adjust search when sidebar is expanded on very small screens */
  #sidebar:not(.collapsed) ~ #map-overlay-controls {
    left: 250px !important; /* Position to the right of expanded sidebar */
    width: calc(100% - 260px) !important; /* Adjust width to make it narrower */
  }
  
  #map-overlay-controls input[type="text"] {
    height: 32px;
    font-size: 11px;
    padding: 0 8px 0 30px;
    border-radius: 16px;
  }
  
  #map-overlay-controls .search-container i {
    left: 10px;
    font-size: 12px;
  }
  
  /* Smaller expand button */
  .expand-button {
    width: 34px;
    height: 34px;
  }
  
  #map-filter-bar {
    width: 60px; /* Even smaller for tiny screens */
  }
  
  .filter-number {
    font-size: 13px;
  }
  
  .filter-label {
    font-size: 10px;
  }
}

/* Very small browser window (desktop resized to minimum width) */
@media screen and (min-width: 376px) and (max-width: 600px) {
  /* Adjust search bar for small browser windows */
  #map-overlay-controls {
    top: 20px !important;
    left: 65px !important; /* Keep right of the expand button */
    width: calc(100% - 155px) !important; /* Allow space for filter bar */
    z-index: 30 !important;
    transition: none !important;
  }
  
  /* Different position when sidebar is open */
  #sidebar:not(.collapsed) ~ #map-overlay-controls {
    left: 265px !important;
    width: calc(100% - 335px) !important; /* Ensure no overflow */
  }
  
  /* More compact search input */
  #map-overlay-controls input[type="text"] {
    height: 36px;
    font-size: 12px;
    border-radius: 18px;
    padding: 0 10px 0 35px;
  }
  
  /* Adjust filter bar position to ensure no overlap */
  #map-filter-bar {
    width: 70px; /* Same as mobile */
    right: 15px;
  }
}

/* Mobile Media Queries - add more specificity to override the default collapsed sidebar behavior */
@media screen and (max-width: 767px) {
  /* Keep search bar in the fixed position on mobile, even when sidebar is collapsed */
  #sidebar.collapsed ~ #map-overlay-controls {
    top: 20px !important;
    left: 65px !important;
    width: calc(100% - 150px) !important;
    transition: none !important;
  }
}

/* iPhone SE and other very small screens */
@media screen and (max-width: 375px) {
  /* Override the default collapsed sidebar behavior for tiny screens */
  #sidebar.collapsed ~ #map-overlay-controls {
    width: calc(100% - 120px) !important;
    left: 60px !important;
    top: 20px !important;
    transition: none !important;
  }
}

/* Very small browser window (desktop resized to minimum width) */
@media screen and (min-width: 376px) and (max-width: 600px) {
  /* Override the default collapsed sidebar behavior for small browser windows */
  #sidebar.collapsed ~ #map-overlay-controls {
    top: 20px !important;
    left: 65px !important; 
    width: calc(100% - 155px) !important;
    transition: none !important;
  }
}
