/**
 * CSS styles for top performers section
 * Path: /TB/app/static/css/top-performers.css
 */

/* Top Performers styling - matching existing design */
.performers-container {
  display: flex;
  flex-direction: column;
  gap: 4px; /* Reduced gap for tighter spacing between gainers/losers sections */
  width: 100%;
  padding: 5px 0;
  overflow: visible; /* Changed from hidden to visible */
  box-sizing: border-box;
  position: relative;
  /* CRITICAL: Force exact content sizing */
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
  flex: none !important; /* Prevent flex expansion */
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
  align-self: flex-start !important; /* Don't stretch to fill parent */
}

.performers-section {
  /* CRITICAL: Prevent sections from expanding to fill space */
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
  flex: none !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
  overflow: visible !important;
}

.performers-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.8rem; /* Reduced from 0.9rem */
  margin-bottom: 4px; /* Reduced from 8px */
  color: var(--text-color, #ffffff);
  opacity: 0.95;
  padding-left: 5px;
  letter-spacing: 0.3px;
  line-height: 1.2; /* Added for tighter line height */
}

.gainers .performers-header {
  color: var(--success-color, #00c853);
}

.losers .performers-header {
  color: var(--danger-color, #ff3547);
}

.performers-header i {
  font-size: 0.8rem;
}

.performers-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important; /* Force zero gap */
  row-gap: 0 !important;
  column-gap: 0 !important;
  /* CRITICAL: Prevent list expansion */
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
  overflow: visible !important; /* Changed from overflow-y: auto */
  flex: none !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
}

/* Even more specific selectors to override any other styles */
#top-gainers-list,
#top-losers-list {
  gap: 0 !important;
  row-gap: 0 !important;
  column-gap: 0 !important;
}

.performer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  margin-bottom: 1px; /* Tiny gap to slightly distinguish items */
}

/* Apply border radius only to first and last items in each section */
.performers-list .performer-item:first-child {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.performers-list .performer-item:last-child {
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  margin-bottom: 0; /* Remove bottom margin from last item */
}

.performer-item:hover {
  background-color: var(--primary-background);
}

.performer-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.performer-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
  padding: 2px;
}

.performer-icon.fallback-icon-0,
.performer-icon.fallback-icon-1,
.performer-icon.fallback-icon-2,
.performer-icon.fallback-icon-3,
.performer-icon.fallback-icon-4 {
  padding: 1px;
}

.performer-symbol {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.performer-change {
  font-family: 'Inter', sans-serif !important;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.performer-change.positive {
  background-color: rgba(0, 200, 83, 0.15);
  color: var(--success-color, #00c853);
}

.performer-change.negative {
  background-color: rgba(255, 53, 71, 0.15);
  color: var(--danger-color, #ff3547);
}

.performer-item.skeleton,
.skeleton-loading {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
}

.performer-item.skeleton::before,
.skeleton-loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
              rgba(255, 255, 255, 0.05) 0%, 
              rgba(255, 255, 255, 0.1) 50%, 
              rgba(255, 255, 255, 0.05) 100%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite linear;
}

.skeleton-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.1);
}

.skeleton-text {
  height: 14px;
  width: 50px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.performer-item.empty {
  justify-content: center;
  padding: 10px;
  color: var(--text-muted, #6c757d);
  font-style: italic;
}

/* Scrollbar styling */
.performers-list::-webkit-scrollbar {
  width: 6px;
}

.performers-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.performers-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.performers-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* GLOBAL FIX: Prevent top-performers-card from expanding beyond content */
.top-performers-card {
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
  flex: none !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
  align-self: flex-start !important;
  overflow: visible !important;
  display: flex !important;
  flex-direction: column !important;
}

/* AGGRESSIVE FIX: Override any external styling that causes expansion */
.stat-card.top-performers-card,
.market-stats-container .top-performers-card,
.top-performers-card {
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
  flex: none !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
  flex-basis: auto !important;
  align-self: flex-start !important;
  justify-self: flex-start !important;
  overflow: visible !important;
}

/* Ensure children don't cause parent expansion */
.top-performers-card > * {
  flex: none !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
}

/* NUCLEAR OPTION: Force all performers elements to exact content size */
.performers-container,
.performers-section,
.performers-list,
#top-gainers-list,
#top-losers-list {
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
  flex: none !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
  overflow: visible !important;
}

/* Responsive adjustments */
/* Above 1200px - maintain flexbox layout */
@media (min-width: 1201px) {
  .performers-container {
    gap: 4px; /* Consistent gap across all screen sizes */
  }
}

/* Between 700px and 1200px - maintain flexbox layout */
@media (max-width: 1200px) and (min-width: 701px) {
  .performers-container {
    gap: 4px; /* Consistent gap across all screen sizes */
  }
}

/* Below 900px - add spacing to prevent price table overlap */
@media (max-width: 900px) {
  .top-performers-card {
    margin-bottom: 20px !important; /* Add space between top performers and price table */
  }
  
  .performers-container {
    margin-bottom: 15px !important; /* Additional bottom margin */
  }
}

/* Below 700px - optimize for mobile to show all 7 performers */
@media (max-width: 700px) {
  .performers-container {
    gap: 2px; /* Tighter gap for mobile */
    padding: 8px 0; /* Reduced padding */
    margin-bottom: 20px !important; /* Ensure spacing is maintained */
  }
  
  .performers-section {
    margin-bottom: 6px; /* Compact spacing between sections */
  }
  
  .performers-list {
    max-height: none !important; /* Remove height limits */
    overflow-y: visible !important; /* Show all items */
  }
  
  .performer-item {
    margin-bottom: 1px;
    padding: 5px 8px; /* Compact padding */
    min-height: 28px; /* Adequate touch target */
  }
  
  .performer-symbol {
    font-size: 0.75rem; /* Slightly smaller for mobile */
  }
  
  .performer-change {
    font-family: 'Inter', sans-serif !important;
    font-size: 0.75rem;
    padding: 2px 4px;
  }
  
  .performer-icon {
    width: 18px; /* Slightly larger than before for better visibility */
    height: 18px;
  }
}

/* New media query for even smaller screens - FORCE 7 ITEMS DISPLAY */
@media (max-width: 735px) {
  .top-performers-card {
    width: 100% !important;
    min-height: auto !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    /* CRITICAL: Remove any flex constraints that limit height */
    flex: none !important;
    align-self: stretch !important;
    margin-bottom: 25px !important; /* Extra spacing for small screens */
  }
  
  .performers-container {
    width: 100% !important;
    min-height: auto !important;
    max-height: none !important;
    height: auto !important;
    gap: 2px; /* Tighter gap for mobile */
    overflow: visible !important;
    /* CRITICAL: Remove flex constraints */
    flex: none !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
  }
  
  .performers-section {
    min-height: auto !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    /* CRITICAL: Remove flex constraints */
    flex: none !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
  }
  
  .performers-list {
    max-height: none !important; /* Ensure all 7 items show */
    overflow-y: visible !important;
    overflow: visible !important;
    height: auto !important;
    min-height: auto !important;
    /* CRITICAL: Remove any display constraints */
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* FORCE: All 7 items must be visible */
  .performer-item {
    margin-bottom: 1px;
    padding: 4px 6px; /* More compact padding for mobile */
    min-height: 24px; /* Reduced height for mobile */
    max-height: none !important;
    height: auto !important;
    /* CRITICAL: Force visibility */
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
  }
  
  /* Explicit visibility for first 7 items */
  .performer-item:nth-child(1),
  .performer-item:nth-child(2),
  .performer-item:nth-child(3),
  .performer-item:nth-child(4),
  .performer-item:nth-child(5),
  .performer-item:nth-child(6),
  .performer-item:nth-child(7) {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    min-height: 24px !important;
  }
  
  .performer-symbol {
    font-size: 0.8rem; /* Smaller font for mobile */
  }
  
  .performer-change {
    font-family: 'Inter', sans-serif !important;
    font-size: 0.8rem;
    padding: 2px 4px;
  }
  
  .performer-icon {
    width: 16px;
    height: 16px;
  }
  
  /* NUCLEAR OPTION: Override any external height restrictions */
  .stat-card.top-performers-card {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
}

/* Icon container and performer icon styling - replaces inline styles */
.icon-container {
  position: relative;
  width: 24px;
  height: 24px;
  display: inline-block;
  margin-right: 8px;
}

.performer-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: contain;
  background-color: var(--primary-background, #0f1219);
  cursor: pointer;
}

.performer-icon-primary {
  display: none;
}

.performer-icon-secondary {
  display: none;
}

.performer-icon-tertiary {
  display: none;
}

/* Show icons when they successfully load */
.performer-icon.loaded {
  display: inline-block !important;
}

.letter-fallback-icon {
  color: #fff;
  font-weight: bold;
  font-size: 14px;
  text-align: center;
  width: 24px;
  height: 24px;
  line-height: 24px;
  display: none;
  border-radius: 50%;
  position: absolute;
  top: 0;
  left: 0;
  cursor: pointer;
}

.letter-fallback-icon.loaded {
  display: inline-block !important;
}

/* Dynamic background colors for letter icons based on data attributes */
.letter-fallback-icon[data-color] {
  background-color: var(--fallback-color);
}

.performer-item {
  cursor: pointer;
}

.performer-name {
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}