/* Trader Search Autocomplete Styles */

.trader-autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: #1e293b; /* Solid color instead of var for better opacity */
  border: 1px solid #475569;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  z-index: 9999; /* Increased to ensure it's above everything */
  max-height: 300px;
  overflow-y: auto;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.trader-autocomplete-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  border-bottom: 1px solid rgba(71, 85, 105, 0.5);
  background-color: rgba(30, 41, 59, 0.95); /* Semi-transparent background */
}

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

.trader-autocomplete-item:hover,
.trader-autocomplete-item.selected {
  background-color: rgba(51, 65, 85, 0.95); /* Semi-transparent hover state */
}

.trader-username {
  font-weight: 500;
  color: #e2e8f0; /* Solid color for better readability */
  font-size: 14px;
}

.trader-wallet {
  font-size: 12px;
  color: #94a3b8; /* Solid color for better readability */
  font-family: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

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

.trader-autocomplete::-webkit-scrollbar-track {
  background: var(--slate-700);
  border-radius: 3px;
}

.trader-autocomplete::-webkit-scrollbar-thumb {
  background: var(--slate-600);
  border-radius: 3px;
}

.trader-autocomplete::-webkit-scrollbar-thumb:hover {
  background: var(--slate-500);
}

/* Loading state for autocomplete */
.trader-autocomplete.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  min-height: 60px;
}

.trader-autocomplete.loading::after {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--slate-600);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Error message styling */
.trader-search-error {
  animation: slideIn 0.2s ease-out;
}

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

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

/* Update the search input placeholder */
#walletInput::placeholder {
  color: var(--slate-500);
}

/* Add a subtle indicator when typing a username vs wallet */
#walletInput:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 1px var(--blue-500);
}

/* Ensure dropdown is fully opaque and above other elements */
.search-input-wrapper {
  position: relative;
  z-index: 1000;
}

/* Mobile specific styles for dropdown */
@media (max-width: 768px) {
  .trader-autocomplete {
    position: fixed; /* Fixed positioning on mobile */
    top: auto;
    left: 1rem;
    right: 1rem;
    bottom: auto;
    max-height: 60vh;
    margin-top: 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
  }
  
  /* Calculate position based on input element */
  .search-input-wrapper:has(.wallet-input:focus) .trader-autocomplete {
    top: calc(var(--input-top, 120px) + var(--input-height, 50px) + 10px);
  }
  
  /* Add overlay background on mobile when dropdown is open */
  .trader-autocomplete::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
    pointer-events: none;
  }
}

/* Desktop specific improvements */
@media (min-width: 769px) {
  .trader-autocomplete {
    min-width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 10px 20px rgba(0, 0, 0, 0.1);
  }
}

/* Ensure proper layering */
.trader-autocomplete-item {
  position: relative;
  z-index: 1;
}

/* Additional isolation for the dropdown container */
.trader-autocomplete {
  isolation: isolate;
}

/* Body overlay state for mobile */
@media (max-width: 768px) {
  body.trader-search-active {
    overflow: hidden;
  }
  
  body.trader-search-active::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    animation: fadeIn 0.2s ease-out;
    pointer-events: none; /* Cruciaal – overlay mag geen clicks blokkeren */
  }
}

/* Fade in animation for overlay */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Ensure autocomplete is clickable above overlay */
.trader-search-active .trader-autocomplete {
  z-index: 10000;
}

/* Ensure dropdown items are fully clickable */
.trader-autocomplete-item {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Prevent text selection on mobile */
.trader-autocomplete-item * {
  pointer-events: none;
}

/* Fix for mobile touch events */
@media (max-width: 768px) {
  .trader-autocomplete-item {
    min-height: 48px; /* Better touch target size */
    position: relative;
  }
  
  /* Remove the overlay from dropdown items to prevent blocking */
  .trader-autocomplete::before {
    display: none;
  }
}

/* Better visual separation */
.trader-autocomplete {
  border: 2px solid rgba(51, 65, 85, 0.8);
}

/* Add subtle animation to dropdown appearance */
.trader-autocomplete {
  animation: slideDown 0.2s ease-out;
}

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