/* Sidebar-specific styling - Compact Dashboard Design */
#sidebar { 
  border-right: 1px solid #1f2937; 
  padding: 12px 16px; 
  display: grid; 
  grid-template-rows: auto auto 1fr auto; 
  gap: 12px; 
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%); 
  height: 100dvh; 
  overflow-y: auto; /* Allow vertical scrolling in sidebar */
  overflow-x: hidden; /* Prevent horizontal scrolling */
  position: relative; 
  z-index: 1000; 
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

#details { 
  border-top: 1px solid #1f2937; 
  padding-top: 10px; 
  max-height: 40vh; 
  overflow: auto;
  margin-top: 4px;
}

#details h3 { 
  margin: 8px 0 6px; 
  font-size: 13px; 
  font-weight: 600;
  color: #f3f4f6;
  letter-spacing: 0.025em;
  border-bottom: 1px solid #374151;
  padding-bottom: 3px;
}

#details .small { 
  font-size: 11px; 
  color: #9ca3af; 
  line-height: 1.3;
  margin-bottom: 4px;
}

/* Information display improvements - Compact */
.info-section {
  margin-bottom: 8px;
  padding: 6px 8px;
  background: rgba(17, 24, 39, 0.4);
  border-radius: 4px;
  border-left: 2px solid #60a5fa;
}

.info-section h4 {
  margin: 0 0 4px 0;
  font-size: 11px;
  font-weight: 600;
  color: #f3f4f6;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-section p {
  margin: 0 0 3px 0;
  font-size: 10px;
  color: #d1d5db;
  line-height: 1.2;
}

.info-section .highlight {
  color: #60a5fa;
  font-weight: 600;
}

.info-section .muted {
  color: #9ca3af;
  font-size: 10px;
}

#sidebar h2 { 
  margin: 0 0 6px 0; 
  font-size: 16px; 
  font-weight: 700; 
  color: #f3f4f6; 
  letter-spacing: 0.025em;
  line-height: 1.3;
}

#sidebar .section { 
  border-top: 1px solid #1f2937; 
  padding-top: 10px; 
  margin-top: 6px;
}

.sidebar-toggle-btn {
  position: absolute;
  top: 50%;
  right: -22px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1f2937;
  border: 2px solid #60a5fa;
  color: #60a5fa;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: all 0.2s;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle-btn:hover {
  background: #60a5fa;
  color: #1f2937;
  border-color: #3b82f6;
  box-shadow: 0 8px 24px rgba(96, 165, 250, 0.4);
  transform: translateY(-50%) scale(1.1);
}

.reopen-btn {
  left: -22px;
  right: auto;
}

/* Sidebar hide/show controls */
.sidebar-hidden { 
  grid-template-columns: 1fr; 
}

.sidebar-hidden #sidebar { 
  display: none; 
}

#reopenSidebar { 
  display: none; 
}

.sidebar-hidden #reopenSidebar { 
  display: inline-block; 
}

/* Additional sidebar improvements - Compact */
#sidebar label {
  font-size: 11px;
  font-weight: 500;
  color: #d1d5db;
  margin-bottom: 4px;
  display: block;
  letter-spacing: 0.01em;
}

#sidebar input[type="text"], 
#sidebar input[type="number"], 
#sidebar select {
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid #374151;
  border-radius: 4px;
  padding: 6px 8px;
  color: #f3f4f6;
  font-size: 11px;
  transition: all 0.2s ease;
  margin-bottom: 6px;
  width: 100%;
  box-sizing: border-box;
}

#sidebar input[type="text"]:focus, 
#sidebar input[type="number"]:focus, 
#sidebar select:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

#sidebar .title-with-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

#sidebar .title-with-status h2 {
  margin: 0;
  flex: 1;
}

/* Button spacing and layout improvements - Compact */
#sidebar .btn {
  margin: 4px 0;
  margin-top: 6px;
  margin-bottom: 6px;
  padding: 6px 10px;
  font-size: 11px;
}

#sidebar .btn-apply {
  margin: 6px 0;
  margin-top: 8px;
  margin-bottom: 8px;
  padding: 8px 12px;
  font-size: 12px;
}

/* Ensure buttons don't touch other elements - Compact */
#sidebar .section:has(.btn) {
  padding-bottom: 10px;
}

#sidebar .checkboxes {
  margin-bottom: 8px;
}

/* Form group spacing - Compact */
#sidebar .form-group {
  margin-bottom: 8px;
}

#sidebar .form-group:last-child {
  margin-bottom: 4px;
}

/* Compact filter groups */
.filter-group {
  margin-bottom: 8px;
}

.filter-subsection {
  margin-bottom: 6px;
  padding: 4px;
  background: rgba(31, 41, 55, 0.3);
  border-radius: 3px;
  border: 1px solid rgba(55, 65, 81, 0.3);
}

.filter-subsection .checkboxes {
  margin-bottom: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
  gap: 2px;
}

.filter-subsection .filter-buttons {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.filter-subsection .filter-buttons .btn {
  flex: 1;
  padding: 3px 5px;
  font-size: 7px;
}

.filter-subsection .checkboxes label {
  padding: 2px 1px;
  font-size: 8px;
  min-height: 24px;
}

.filter-subtitle {
  font-size: 7px;
  color: #6b7280;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 500;
}

/* Country search and chip system */
.country-search-container {
  position: relative;
  margin-bottom: 8px;
}

.country-search-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 11px;
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid #374151;
  border-radius: 4px;
  color: #f3f4f6;
  transition: all 0.2s ease;
}

.country-search-input:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.1);
}

.country-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 4px;
  max-height: 150px;
  overflow-y: auto;
  z-index: 10000;
  margin-top: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.country-search-item {
  padding: 6px 8px;
  cursor: pointer;
  font-size: 10px;
  color: #e5e7eb;
  border-bottom: 1px solid #374151;
  transition: all 0.2s;
  user-select: none;
  position: relative;
}

.country-search-item:hover {
  background: #374151;
  transform: translateX(2px);
}

.country-search-item:active {
  background: #4b5563;
  transform: translateX(1px);
}

.country-search-item.selected {
  background: #3b82f6;
  color: white;
}

.country-search-item.selected .country-code {
  color: white;
}

.country-search-item.selected .country-count {
  color: rgba(255, 255, 255, 0.8);
}

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

.country-search-item .country-code {
  font-weight: 600;
  color: #60a5fa;
}

.country-search-item .country-count {
  color: #9ca3af;
  font-size: 9px;
}

.country-search-item .selected-indicator {
  color: #10b981;
  font-weight: bold;
  margin-left: 4px;
}

/* Selected countries chips */
.selected-countries {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.country-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: #374151;
  border: 1px solid #4b5563;
  border-radius: 12px;
  font-size: 9px;
  color: #e5e7eb;
  transition: all 0.2s;
}

.country-chip.all-selected {
  background: #10b981;
  border-color: #059669;
  color: white;
}

.country-chip:hover {
  background: #4b5563;
  border-color: #6b7280;
}

.country-chip.all-selected:hover {
  background: #059669;
  border-color: #047857;
}

.remove-chip {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 10px;
  font-weight: bold;
  padding: 0;
  margin: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  flex-shrink: 0;
}

.remove-chip:hover {
  background: rgba(255, 255, 255, 0.2);
}

.filter-label {
  font-size: 10px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.filter-buttons {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.filter-buttons .btn {
  flex: 1;
  margin: 0;
  padding: 4px 8px;
  font-size: 10px;
}

/* Compact timeline filters header */
.timeline-filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.timeline-filters-header .muted {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Compact legend */
.legend-label {
  font-size: 10px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

/* Legend - compact and static */
#legend {
  padding: 4px;
  border: 1px solid #374151;
  border-radius: 4px;
  background: #1f2937;
  max-height: 300px;
  overflow-y: auto;
}

.legend-item-static {
  display: flex;
  align-items: center;
  padding: 2px 4px;
  margin-bottom: 2px;
  font-size: 8px;
  line-height: 1.2;
}

.legend-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
}

.legend-name-text {
  color: #e5e7eb;
  margin-right: 6px;
  flex: 1;
  font-size: 8px;
}

.legend-count-text {
  color: #9ca3af;
  font-size: 7px;
  font-weight: 500;
}

/* Responsive legend for mobile */
@media (max-width: 768px) {
  .legend-item-static {
    padding: 1px 3px;
    font-size: 7px;
  }

  .legend-color-dot {
    width: 6px;
    height: 6px;
    margin-right: 4px;
  }

  .legend-name-text {
    font-size: 7px;
  }

  .legend-count-text {
    font-size: 6px;
  }
}

@media (max-width: 480px) {
  .legend-item-static {
    padding: 1px 2px;
    font-size: 6px;
  }

  .legend-color-dot {
    width: 5px;
    height: 5px;
    margin-right: 3px;
  }

  .legend-name-text {
    font-size: 6px;
  }

  .legend-count-text {
    font-size: 5px;
  }
}

/* Compact attribution */
.attribution {
  font-size: 7px;
  line-height: 1.1;
}

.attribution a {
  color: #60a5fa;
  text-decoration: none;
}

.attribution a:hover {
  text-decoration: underline;
}

/* Center the signature */
.signature {
  text-align: center;
  font-size: 8px;
  color: #6b7280;
  margin-top: 4px;
}

/* Compact warning */
.warning {
  font-size: 10px;
  padding: 4px 6px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 3px;
  margin-bottom: 6px;
}

/* Compact pill status */
.pill {
  background: #374151;
  color: #d1d5db;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}