/* Filter Panel Responsive Behavior */

/* Full desktop - filter panel visible */
@media (min-width: 1300px) {
  .filter-panel {
    display: block;
    position: fixed;
    left: 20px;
    top: 110px;
    width: 280px;
    background: var(--card-bg);
    border: 1px solid rgba(102, 126, 234, 0.4);
    border-radius: 12px;
    padding: 16px;
    z-index: 100;

    max-height: calc(100vh - 130px);
    overflow-y: auto;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.15);
  }
}

/* Medium desktop - filter panel hidden, mobile button shown */
@media (min-width: 1000px) and (max-width: 1299px) {
  .filter-panel {
    display: none;
  }
}

/* Small desktop - filter panel hidden, mobile button shown */
@media (min-width: 993px) and (max-width: 999px) {
  .filter-panel {
    display: none;
  }
}

/* Mobile - filter panel hidden, mobile button shown */
@media (max-width: 992px) {
  .filter-panel {
    display: none;
  }
  
  .mobile-filter-btn {
    display: flex;
  }
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--secondary-border-color);
}

.filter-header h3 {
  margin: 0;
  font-size: 1.1em;
  color: var(--text-color);
}

.clear-filters-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  font-size: 0.8em;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
  letter-spacing: -0.01em;
}

.clear-filters-btn:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

.clear-filters-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
}

.filter-section {
  margin-bottom: 14px; /* Reduced from 18px for more compact design */
}

.filter-section:last-child {
  margin-bottom: 0;
}

.filter-section h4 {
  margin: 0 0 10px 0;
  font-size: 0.9em;
  color: var(--text-color);
  font-weight: 600;
}

.filter-section.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Range Slider */
.range-slider {
  position: relative;
  height: 35px;
  margin-bottom: 16px;
}

.range-input {
  position: absolute;
  top: 16px; /* aligns both sliders vertically */
  left: 0;
  width: 100%;
  pointer-events: none; /* disable dragging except thumb */
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--secondary-border-color);
  border-radius: 3px;
  outline: none;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent-color);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto; /* allow thumb dragging */
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  position: relative;
  z-index: 2;
}

.range-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent-color);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  border: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  position: relative;
  z-index: 2;
}

.range-values {
  margin-top: 12px;  /* reduced spacing */
  text-align: center;
  font-size: 0.8em;
  color: var(--secondary-text);
  position: relative;
  z-index: 1;
}

/* AI Assessment section - ensure single line layout */
.filter-section:has(.checkbox-group) {
  min-width: 0;
  margin-bottom: 12px; /* Match market section compactness */
}

.filter-section:has(.checkbox-group) h4 {
  margin-bottom: 6px; /* Match market section title spacing */
}

/* Market section - more compact spacing */
.filter-section:has(.market-filters) {
  margin-bottom: 12px; /* Even more compact for market section */
}

.filter-section:has(.market-filters) h4 {
  margin-bottom: 6px; /* Reduced spacing between title and checkboxes */
}

/* Force single line for AI Assessment */
.checkbox-group {
  display: flex;
  flex-direction: row;
  gap: 6px; /* Match market-filters gap */
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  overflow-x: auto;
  /* Add border styling similar to market-filters */
  background: var(--secondary-bg, rgba(0, 0, 0, 0.02));
  border-radius: 6px;
  padding: 2px 4px; /* Symmetric padding - removed padding-bottom */
  border: 1px solid var(--secondary-border-color, rgba(0, 0, 0, 0.1));
  transition: all 0.2s ease;
  min-height: 32px;
}

/* Hide scrollbar but keep functionality */
.checkbox-group::-webkit-scrollbar {
  height: 3px;
}

.checkbox-group::-webkit-scrollbar-track {
  background: transparent;
}

.checkbox-group::-webkit-scrollbar-thumb {
  background: rgba(102, 126, 234, 0.3);
  border-radius: 2px;
}

.checkbox-group::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 126, 234, 0.5);
}

/* Hover effects for AI Assessment container */
.checkbox-group:hover {
  background: var(--secondary-bg, rgba(0, 0, 0, 0.04));
  border-color: #667eea;
}

/* Focus state for AI Assessment container */
.checkbox-group:focus-within {
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

/* Dark theme support for AI Assessment */
[data-theme="dark"] .checkbox-group {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .checkbox-group:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: #667eea;
}

/* Medium screen responsive for AI Assessment */
@media (max-width: 768px) {
  .checkbox-group {
    gap: 6px;
    padding: 2px 3px;
    min-height: 30px;
  }
  
  .checkbox-group .checkbox-label {
    padding: 2px 4px; /* Reduced vertical padding for tablet */
  }
}

/* Compact AI Assessment checkboxes */
.checkbox-group .checkbox-label {
  flex: 0 0 auto;
  font-size: 0.8em;
  padding: 2px 6px; /* Reduced vertical padding for better centering */
  min-height: 28px;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.checkbox-group .checkmark {
  width: 16px;
  height: 16px;
  margin-right: 5px;
}

/* Responsive checkbox layout */
@media (max-width: 480px) {
  .checkbox-group {
    gap: 6px;
    padding: 2px 3px; /* Match market filters mobile padding */
    min-height: 30px; /* Slightly smaller on mobile */
  }
  
  .checkbox-group .checkbox-label {
    font-size: 0.75em;
    padding: 2px 4px; /* Reduced vertical padding for mobile */
    min-height: 26px;
  }
  
  .checkbox-group .checkmark {
    width: 14px;
    height: 14px;
    margin-right: 4px;
  }
}

.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 0.85em;
  color: var(--text-color);
  padding: 6px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  user-select: none;
  min-height: 32px;
}

.checkbox-label:hover {
  background-color: rgba(102, 126, 234, 0.08);
  transform: translateY(-1px);
}

.checkbox-label:focus-within {
  outline: 2px solid #667eea;
  outline-offset: 2px;
  background-color: rgba(102, 126, 234, 0.05);
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--secondary-border-color);
  border-radius: 4px;
  margin-right: 5px;
  position: relative;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.checkmark:hover {
  border-color: #667eea;
  background-color: rgba(102, 126, 234, 0.1);
}

/* Theme-specific checkbox styling */
[data-theme="light"] .checkmark {
  border-color: #d1d5db;
  background-color: #ffffff;
}

[data-theme="light"] .checkmark:hover {
  border-color: #667eea;
  background-color: rgba(102, 126, 234, 0.05);
}

[data-theme="dark"] .checkmark {
  border-color: var(--secondary-border-color);
  background-color: var(--card-bg);
}

[data-theme="dark"] .checkmark:hover {
  border-color: #667eea;
  background-color: rgba(102, 126, 234, 0.15);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
}

/* Select and Input */
.filter-select,
.filter-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--secondary-border-color);
  border-radius: 6px;
  background: var(--bg-color);
  color: var(--text-color);
  font-size: 0.9em;
  outline: none;
  transition: border-color 0.2s ease;
}

.filter-select:focus,
.filter-input:focus {
  border-color: var(--accent-color);
}

/* Time Buttons */
.time-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.time-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  border-radius: 16px;
  color: var(--text-color);
  font-size: 0.8em;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  min-width: 0;
}

/* Light theme override for time buttons */
html.light .time-btn {
  background: var(--secondary-border-color);
  border: 1px solid transparent;
}

.time-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-color);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(80,130,255,.3);
  border: 1px solid rgba(80,130,255,.35);
}

.time-btn:active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-color);
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(80,130,255,.2);
  border: 1px solid rgba(80,130,255,.35);
}

.time-btn:focus {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-color);
  outline: 2px solid rgba(80,130,255,.6);
  outline-offset: 2px;
  box-shadow: 0 2px 8px rgba(80,130,255,.3);
}

.time-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: rgba(102, 126, 234, 0.5);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Light theme overrides for time buttons */
html.light .time-btn:hover {
  background: var(--secondary-border-color);
  border: 1px solid rgba(80,130,255,.35);
}

html.light .time-btn:active {
  background: var(--secondary-border-color);
  border: 1px solid rgba(80,130,255,.35);
}

html.light .time-btn:focus {
  background: var(--secondary-border-color);
}

/* Mobile Filter Button */
.mobile-filter-btn {
  display: none;
  flex: 1;
  background: var(--card-bg);
  color: var(--text-color);
  border: none;
  border-left: 0.5px solid var(--secondary-border-color);
  border-radius: 0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 0.9em;
  font-weight: 600;
  background-color: var(--bg-color);
  padding: 12px 20px;
}

.mobile-filter-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.mobile-filter-btn::after {
  content: "▼";
  margin-left: 8px;
  transition: transform 0.3s ease;
}

.mobile-filter-btn.expanded::after {
  transform: rotate(180deg);
}

/* Mobile Filter Modal - Global styles (work at all screen sizes) */
.mobile-filter-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10002;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  visibility: hidden;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Theme-aware backdrop */
[data-theme="light"] .mobile-filter-modal {
  background: rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .mobile-filter-modal {
  background: rgba(0, 0, 0, 0.7);
}

.mobile-filter-modal.show {
  display: flex !important;
  align-items: flex-end;
  justify-content: center;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Enhanced mobile modal styles for better visibility */
@media (max-width: 992px) {
  .mobile-filter-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
  }
  
  .mobile-filter-modal.show {
    display: flex !important;
    align-items: flex-end !important;
    justify-content: center !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
}

.mobile-filter-content {
  position: relative;
  width: 100%;
  background: var(--card-bg);
  border-radius: 24px 24px 0 0;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 -8px 32px var(--shadow-color);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--secondary-border-color);
  border-bottom: none;
}

/* Theme-aware shadow */
[data-theme="light"] .mobile-filter-content {
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .mobile-filter-content {
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
}

.mobile-filter-modal.show .mobile-filter-content {
  transform: translateY(0);
}

/* Mobile Filter Animation */
@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
.mobile-filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 24px 20px 24px;
  border-bottom: 1px solid var(--secondary-border-color);
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 1;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.mobile-filter-header h3 {
  margin: 0;
  font-size: 1.3em;
  font-weight: 700;
  color: var(--text-color);
  letter-spacing: -0.02em;
}

.close-mobile-filter {
  background: transparent;
  border: 1px solid var(--secondary-border-color);
  font-size: 1.4em;
  color: var(--text-color);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-mobile-filter:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
}

/* Light theme close button */
html.light .close-mobile-filter {
  border-color: rgba(0, 0, 0, 0.2);
  color: var(--text-color);
}

html.light .close-mobile-filter:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
}

.mobile-filter-body {
  padding: 24px;
}

.mobile-filter-footer {
  display: flex;
  gap: 16px;
  padding: 20px 24px 32px 24px;
  border-top: 1px solid var(--secondary-border-color);
  background: var(--card-bg);
  position: sticky;
  bottom: 0;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.apply-filters-btn {
  flex: 1;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 16px;
  border-radius: 12px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.apply-filters-btn:hover {
  background: var(--strong-buy-color);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--shadow-color);
}

.apply-filters-btn:active {
  transform: translateY(0);
}

/* Filter Panel Scrollbar */
.filter-panel::-webkit-scrollbar {
  width: 6px;
}

.filter-panel::-webkit-scrollbar-track {
  background: var(--secondary-border-color);
  border-radius: 3px;
}

.filter-panel::-webkit-scrollbar-thumb {
  background: var(--accent-color);
  border-radius: 3px;
}

.filter-panel::-webkit-scrollbar-thumb:hover {
  background: var(--strong-buy-color);
}

/* Hide panels when not needed */
.panels-hidden .filter-panel {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

/* Focus styles for accessibility */
.filter-panel:focus-within {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Dark mode specific adjustments */
html.light .filter-panel {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

/* Mobile Responsive - Updated for gradual collapse */
@media (max-width: 1299px) {
  .mobile-filter-btn {
    display: flex;
    background: var(--card-bg);
    border: 1px solid var(--secondary-border-color);
  }
}

@media (min-width: 1300px) {
  .mobile-filter-btn {
    display: none;
  }
}

@media (max-width: 480px) {
  .filter-section {
    margin-bottom: 1.5rem;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .filter-panel {
    border-width: 0.5px;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  .filter-panel,
  .mobile-filter-modal {
    transition: none;
  }
}

/* Filter Panel Styles - Additional styles for backend integration */

/* Modern Loading States */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  gap: 0.75rem;
}

.loading-spinner::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2.5px solid transparent;
  border-top: 2.5px solid var(--accent-color);
  border-right: 2.5px solid var(--accent-color);
  border-radius: 50%;
  animation: modernSpin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  filter: drop-shadow(0 0 4px rgba(102, 126, 234, 0.3));
}

@keyframes modernSpin {
  0% { 
    transform: rotate(0deg);
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
  100% { 
    transform: rotate(360deg);
    opacity: 1;
  }
}

/* Dark mode spinner adjustments */
[data-theme="dark"] .loading-spinner::before {
  border-top-color: #667eea;
  border-right-color: #667eea;
  filter: drop-shadow(0 0 6px rgba(102, 126, 234, 0.4));
}

/* Light mode spinner adjustments */
[data-theme="light"] .loading-spinner::before {
  border-top-color: #4f46e5;
  border-right-color: #4f46e5;
  filter: drop-shadow(0 0 3px rgba(79, 70, 229, 0.2));
}

/* Error states */
.error-state {
  padding: 1rem;
  color: var(--error-color, #e74c3c);
  font-size: 0.9rem;
  text-align: center;
  background: var(--error-bg, rgba(231, 76, 60, 0.1));
  border-radius: 8px;
  margin: 0.5rem 0;
}



/* Modern Filter Loading Overlay */
.filter-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0.95;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: 12px;
  animation: fadeInOverlay 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInOverlay {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 0.95;
    backdrop-filter: blur(8px);
  }
}

/* Dark mode overlay adjustments */
[data-theme="dark"] .filter-loading-overlay {
  background: rgba(30, 30, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Light mode overlay adjustments */
[data-theme="light"] .filter-loading-overlay {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Disabled filter controls during loading */
.filter-panel input:disabled,
.filter-panel select:disabled,
.filter-panel button:disabled {
  cursor: not-allowed;
  transition: opacity 0.2s ease;
}

/* Filter error message */
.filter-error-message {
  padding: 0.75rem 1rem;
  background: var(--cautious-color);
  opacity: 0.1;
  color: var(--cautious-color);
  border: 1px solid var(--cautious-color);
  border-radius: 8px;
  margin: 1rem 0;
  font-size: 0.9rem;
  text-align: center;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Results count display */
#results-count {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0.5rem 0;
  padding: 0.25rem 0;
}



/* Sentiment Input Styles */
.sentiment-inputs {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}

.input-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.input-label {
  font-size: 0.8em;
  color: var(--secondary-text);
  margin-bottom: 4px;
  font-weight: 500;
}

.sentiment-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--secondary-border-color);
  border-radius: 6px;
  background: var(--bg-color);
  color: var(--text-color);
  font-size: 0.9em;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.sentiment-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.sentiment-input:invalid {
  border-color: #ef4444;
}

.sentiment-input::placeholder {
  color: var(--secondary-text);
  opacity: 0.7;
}

.input-separator {
  color: var(--secondary-text);
  font-weight: 500;
  padding: 0 4px;
  margin-bottom: 8px;
  font-size: 0.9em;
}

.apply-sentiment-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85em;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  margin-bottom: 1px;
  min-width: 60px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.apply-sentiment-btn:hover {
  background: var(--strong-buy-color, #2563eb);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.apply-sentiment-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(59, 130, 246, 0.2);
}

.apply-sentiment-btn:disabled {
  background: var(--secondary-border-color);
  color: var(--secondary-text);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Mobile responsive adjustments */
@media (max-width: 480px) {
  .sentiment-inputs {
    gap: 6px;
  }
  
  .sentiment-input {
    padding: 6px 8px;
    font-size: 0.85em;
  }
  
  .apply-sentiment-btn {
    padding: 6px 10px;
    font-size: 0.8em;
    min-width: 50px;
  }
  
  .input-label {
    font-size: 0.75em;
  }
}

/* Dark mode support */
html[data-theme="dark"] .sentiment-input {
  background: var(--card-bg);
  border-color: var(--secondary-border-color);
}

html[data-theme="dark"] .sentiment-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Input number spinner styling */
.sentiment-input::-webkit-outer-spin-button,
.sentiment-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.sentiment-input[type=number] {
  -moz-appearance: textfield;
}

/* Validation styling */
.sentiment-input.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.1);
}

.sentiment-validation-message {
  font-size: 0.75em;
  color: #ef4444;
  margin-top: 4px;
  display: none;
}

.sentiment-validation-message.show {
  display: block;
}

/* Loading state for apply button */
.apply-sentiment-btn.loading {
  position: relative;
  color: transparent;
}

.apply-sentiment-btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border: 2px solid transparent;
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Success state */
.apply-sentiment-btn.success {
  background: #10b981;
}

.apply-sentiment-btn.success::after {
  content: '✓';
  color: white;
  font-weight: bold;
}

/* Improved mobile filter modal */
@media (max-width: 768px) {
  .mobile-filter-modal {
    backdrop-filter: blur(4px);
  }
  
  .mobile-filter-content {
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .filter-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
  }
}

/* Smooth transitions for filter changes */
#news-container-by-token {
  transition: opacity 0.3s ease;
}

/* Filter button states */
.filter-btn.active {
  background: var(--accent-color);
  color: white;
}

.filter-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Sort options styling */
select[id*="sort-select"] option {
  padding: 0.5rem;
}

/* Time range buttons with better feedback */
.time-btn {
  transition: all 0.2s ease;
  position: relative;
}

/* Checkbox improvements */
.checkbox-label input[type="checkbox"] {
  transition: all 0.2s ease;
}

.checkbox-label input[type="checkbox"]:checked {
  background: rgba(80,130,255,.35);
  border-color: rgba(80,130,255,.35);
}

/* Range slider improvements */
input[type="range"] {
  transition: all 0.2s ease;
}

input[type="range"]:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Responsive improvements */
@media (max-width: 480px) {
  .filter-section {
    margin-bottom: 1.5rem;
  }
}

/* Add these CSS rules to your existing styles */

/* Loading overlay for filtering */
.filter-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card-bg);
  opacity: 0.9;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.filter-loading-overlay .loading-spinner {
  font-size: 1.2rem;
  color: var(--secondary-text);
}

/* Error message styling */
.filter-error-message {
  background: var(--cautious-color);
  opacity: 0.1;
  color: var(--text-color);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  animation: slideIn 0.3s ease-out;
}

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

/* Active filter indicators */
.filter-panel.has-active-filters {
  border-color: var(--accent-color);
}

.time-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: rgba(102, 126, 234, 0.5);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Pagination loading state */
.pagination-container.pagination-loading {
  position: relative;
  pointer-events: none;
}

.pagination-container.pagination-loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card-bg);
  opacity: 0.7;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Results count indicator */
#results-count {
  font-size: 0.9rem;
  color: var(--secondary-text);
  margin-bottom: 1rem;
  font-weight: 500;
}

/* Clear filters button enhancement */
.clear-filters-btn {
  transition: all 0.2s ease;
}

.clear-filters-btn:hover {
  background: var(--cautious-color);
  color: white;
  border-color: var(--cautious-color);
}

/* Top pagination info styling */
.top-pagination-info {
  background: var(--bg-color);
  padding: 8px 16px;
  border-radius: 8px;
  margin-bottom: 1rem;
  text-align: center;
}

.current-page-indicator {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--secondary-text);
}

/* Filter panel responsive improvements */
@media (max-width: 768px) {
  .filter-panel {
      position: sticky;
      top: 60px;
      z-index: 40;
      background: var(--card-bg);
  }
}

/* Prevent layout shift during filtering */
#news-container-by-token {
  min-height: 400px;
  transition: opacity 0.2s ease;
}

/* Visual feedback for active filters */
.filter-panel:has(.time-btn.active:not([data-range="all"])),
.filter-panel:has(input[type="checkbox"]:not(:checked)) {
  border-left: 4px solid var(--accent-color);
  padding-left: calc(1rem - 4px);
}

/* Sector Filter Styles */
.sector-filter-container {
  position: relative;
}

.sector-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--secondary-border-color);
  border-radius: 6px;
  background: var(--bg-color);
  color: var(--text-color);
  font-size: 0.9em;
  outline: none;
  transition: border-color 0.2s ease;
  cursor: pointer;
}

.sector-select:focus {
  border-color: var(--accent-color);
}

.sector-search-container {
  position: relative;
  margin-top: 8px;
}

.sector-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--secondary-border-color);
  border-radius: 6px;
  background: var(--bg-color);
  color: var(--text-color);
  font-size: 0.9em;
  outline: none;
  transition: border-color 0.2s ease;
}

.sector-search-input:focus {
  border-color: var(--accent-color);
}

.sector-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--secondary-border-color);
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: none;
}

.sector-dropdown.show {
  display: block;
}

.sector-dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 0.9em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sector-dropdown-item:hover {
  background-color: var(--hover-bg);
}

.sector-dropdown-item.selected {
  background-color: var(--accent-color);
  color: white;
}

.sector-count {
  font-size: 0.8em;
  opacity: 0.7;
  margin-left: 8px;
}

.sector-dropdown-item.no-results {
  color: var(--text-muted);
  font-style: italic;
  cursor: default;
}

.sector-dropdown-item.no-results:hover {
  background-color: transparent;
}

/* Scrollbar styling for sector dropdown */
.sector-dropdown::-webkit-scrollbar {
  width: 6px;
}

.sector-dropdown::-webkit-scrollbar-track {
  background: var(--bg-color);
  border-radius: 3px;
}

.sector-dropdown::-webkit-scrollbar-thumb {
  background: var(--secondary-border-color);
  border-radius: 3px;
}

.sector-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color);
}
/* Light mode spinner fix */
html.light .apply-sentiment-btn.loading::after {
  border: 2px solid transparent;
  border-top: 2px solid #333333;
}

/* Market Selector in Filter Panel - Compact design matching AI Assessment */
.market-filters {
  display: flex;
  flex-direction: row;
  gap: 6px; /* Tighter gap to match AI Assessment */
  align-items: center;
  justify-content: flex-start;
  min-height: 32px; /* Match AI Assessment height */
}

.market-filters .checkbox-label {
  flex: 0 0 auto;
  min-width: auto;
  max-width: none;
  white-space: nowrap;
  padding: 2px 6px; /* Match AI Assessment padding exactly */
  font-size: 0.8em; /* Match AI Assessment font size exactly */
  min-height: 28px; /* Match AI Assessment height exactly */
  display: flex;
  align-items: center;
}

/* Tighter spacing for market filter checkboxes specifically */
.market-filters .checkbox-label .checkmark {
  margin-right: 5px; /* Match AI Assessment margin */
  width: 16px; /* Same size as AI Assessment checkboxes */
  height: 16px;
}

/* Add subtle visual grouping for market filters - match AI Assessment styling */
.market-filters {
  background: var(--secondary-bg, rgba(0, 0, 0, 0.02));
  border-radius: 6px;
  padding: 2px 4px; /* Match AI Assessment padding exactly */
  border: 1px solid var(--secondary-border-color, rgba(0, 0, 0, 0.1));
  transition: all 0.2s ease;
}

/* Subtle hover effect for the entire market filter container */
.market-filters:hover {
  background: var(--secondary-bg, rgba(0, 0, 0, 0.04));
  border-color: #667eea;
}

/* Focus state for market filter container */
.market-filters:focus-within {
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

/* Enhanced hover for individual market filter labels */
.market-filters .checkbox-label:hover {
  background-color: rgba(102, 126, 234, 0.1);
  border-radius: 4px;
}

/* Dark theme support */
[data-theme="dark"] .market-filters {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .market-filters:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: #667eea;
}

[data-theme="dark"] .market-filters .checkbox-label:hover {
  background-color: rgba(102, 126, 234, 0.15);
}

/* Mobile responsive - match AI Assessment design exactly */
@media (max-width: 768px) {
  .market-filters {
    gap: 6px; /* Match AI Assessment gap */
    justify-content: flex-start;
    padding: 2px 3px; /* Match AI Assessment mobile padding */
    min-height: 30px; /* Match AI Assessment mobile height */
  }
  
  .market-filters .checkbox-label {
    flex: 0 0 auto;
    padding: 2px 4px; /* Match AI Assessment mobile padding */
    font-size: 0.75em; /* Match AI Assessment mobile font size */
    min-height: 26px; /* Match AI Assessment mobile height */
  }
}

/* Very small screens - match AI Assessment design exactly */
@media (max-width: 480px) {
  .market-filters {
    gap: 6px; /* Match AI Assessment gap */
    padding: 2px 3px; /* Match AI Assessment mobile padding */
    min-height: 30px; /* Match AI Assessment mobile height */
  }
  
  .market-filters .checkbox-label {
    font-size: 0.75em; /* Match AI Assessment mobile font size */
    padding: 2px 4px; /* Match AI Assessment mobile padding */
    min-height: 26px; /* Match AI Assessment mobile height */
  }
  
  .market-filters .checkbox-label .checkmark {
    margin-right: 4px; /* Match AI Assessment mobile margin */
    width: 14px; /* Same size as AI Assessment on mobile */
    height: 14px;
  }
}
.market-selector-filter {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.market-filter-btn {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--secondary-border-color);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--text-color);
  font-weight: 600;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 6px var(--shadow-color);
}

.market-filter-btn input[type="checkbox"] {
  margin: 0;
  transform: scale(1.2);
  accent-color: #667eea;
  flex-shrink: 0;
}

.market-filter-btn i {
  font-size: 1.1rem;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.market-filter-btn span {
  flex: 1;
  text-align: left;
}

.market-filter-btn:hover {
  border-color: #667eea;
  transform: translateX(2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

.market-filter-btn:hover i {
  transform: scale(1.1);
}

.market-filter-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
}

.market-filter-btn.active i {
  animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

/* Light theme adjustments */
html.light .market-filter-btn {
  background: #ffffff;
  border-color: #e5e7eb;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

html.light .market-filter-btn:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.18);
}

html.light .market-filter-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(102, 126, 234, 0.35);
}

/* Mobile responsive */
@media (max-width: 768px) {
  .market-selector-filter {
    gap: 6px;
  }
  
  .market-filter-btn {
    padding: 10px 14px;
    font-size: 0.85em;
    border-radius: 8px;
  }
  
  .market-filter-btn i {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .market-filter-btn {
    padding: 9px 12px;
    font-size: 0.8em;
  }
  
  .market-filter-btn i {
    font-size: 0.95rem;
  }
}
/* Ensure market filter checkboxes are properly visible */
.market-filters .checkbox-label {
  display: flex !important;
  align-items: center !important;
}

.market-filters .checkbox-label .checkmark {
  display: block !important;
  flex-shrink: 0;
}

.market-filters .checkbox-label input[type="checkbox"] {
  display: none !important;
}

/* Ensure checkmark is visible when checked */
.market-filters .checkbox-label input[type="checkbox"]:checked + .checkmark {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  border-color: #667eea !important;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3) !important;
}

.market-filters .checkbox-label input[type="checkbox"]:checked + .checkmark::after {
  content: "✓" !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  color: white !important;
  font-size: 12px !important;
  font-weight: bold !important;
  line-height: 1 !important;
}


/* Market Cap Filter Styles */
.market-cap-filters {
  display: flex;
  flex-direction: row;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  background: var(--secondary-bg, rgba(0, 0, 0, 0.02));
  border-radius: 6px;
  padding: 2px 4px;
  border: 1px solid var(--secondary-border-color, rgba(0, 0, 0, 0.1));
  transition: all 0.2s ease;
  min-height: 32px;
}

.market-cap-filters:hover {
  background: var(--secondary-bg, rgba(0, 0, 0, 0.04));
  border-color: #667eea;
}

.market-cap-filters:focus-within {
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

[data-theme="dark"] .market-cap-filters {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .market-cap-filters:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: #667eea;
}

.market-cap-filters .checkbox-label {
  flex: 0 0 auto;
  font-size: 0.75em;
  padding: 2px 6px;
  min-height: 28px;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.market-cap-filters .checkmark {
  width: 14px;
  height: 14px;
  margin-right: 4px;
}

/* Mobile responsive for market cap filters */
@media (max-width: 768px) {
  .market-cap-filters {
    gap: 5px;
    padding: 2px 3px;
    min-height: 30px;
  }
  
  .market-cap-filters .checkbox-label {
    padding: 2px 4px;
    font-size: 0.7em;
  }
}

@media (max-width: 480px) {
  .market-cap-filters {
    gap: 4px;
    padding: 2px 3px;
    min-height: 28px;
  }
  
  .market-cap-filters .checkbox-label {
    font-size: 0.65em;
    padding: 2px 3px;
    min-height: 24px;
  }
  
  .market-cap-filters .checkmark {
    width: 12px;
    height: 12px;
    margin-right: 3px;
  }
}

/* Ensure market cap checkboxes are properly visible */
.market-cap-filters .checkbox-label {
  display: flex !important;
  align-items: center !important;
}

.market-cap-filters .checkbox-label .checkmark {
  display: block !important;
  flex-shrink: 0;
}

.market-cap-filters .checkbox-label input[type="checkbox"] {
  display: none !important;
}

/* Ensure checkmark is visible when checked */
.market-cap-filters .checkbox-label input[type="checkbox"]:checked + .checkmark {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  border-color: #667eea !important;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3) !important;
}

.market-cap-filters .checkbox-label input[type="checkbox"]:checked + .checkmark::after {
  content: "✓" !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  color: white !important;
  font-size: 10px !important;
  font-weight: bold !important;
  line-height: 1 !important;
}
