/**
 * CSS for the market stats bar
 * Path: /TB/app/static/css/public-index-market_stats.css
 */

/* Market Stats Bar - Fixed at the top of the page, always visible */
.fixed-market-stats-bar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1040; /* Higher than regular page elements */
  width: 100%;
  max-width: 100vw;
  margin: 0 auto; /* Center the bar */
  display: flex;
  justify-content: center;
  box-sizing: border-box;
  overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Specific styling for market-insights-card to vertically center content */
.market-stats-container .stat-card.market-insights-card {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Add the always-visible class to make sure it stays visible */
.fixed-market-stats-bar.always-visible {
  display: block !important;
  visibility: visible !important;
}

/* Enhanced Card Titles - applies to Market Insights and Top Performers */
.market-insights-card .stat-title,
.top-performers-card .stat-title {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 15px;
  font-size: 1.25rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.5px;
  font-family: 'Lato', -apple-system, sans-serif;
}

/* No icons for clean design */
.market-insights-card .stat-title i.fa-chart-line,
.top-performers-card .stat-title i.fa-chart-bar {
  display: none;
}

/* Market Stats Container */
.market-stats-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 10px;
}

@media (min-width: 1201px) {
  .market-stats-container {
    max-width: 100%;
    width: 100%;
    padding: 0 20px;
    justify-content: space-between;
    margin: 0 auto;
  }
  
  /* Allow stat cards to grow on large screens */
  .stat-card {
    flex: 1 1 auto;
    max-width: none;
  }
}

@media (min-width: 1600px) {
  .market-stats-container {
    padding: 0 40px;
  }
  
  /* Maintain reasonable card sizes on ultra-wide */
  .stat-card {
    max-width: 600px;
  }
}

/* Responsive breakpoints for better mobile experience */
@media (max-width: 1200px) {
  .market-stats-container {
    flex-direction: column;
    gap: 6px;
    padding: 0 15px;
  }
  
  .stat-card {
    min-width: 100%;
    flex: none;
  }
}

@media (max-width: 768px) {
  .market-stats-container {
    padding: 0 10px;
    gap: 6px;
  }
  
  .stat-card {
    padding: 8px 12px;
  }
}

@media (max-width: 480px) {
  .market-stats-container {
    padding: 0 8px;
    gap: 6px;
  }
  
  .stat-card {
    padding: 6px 10px;
  }
}

/* Hide scrollbar for Chrome, Safari and Opera */
.market-stats-container::-webkit-scrollbar {
  display: none;
}

/* Individual Stat Card */
.stat-card {
  flex: 1;
  min-width: 120px;
  text-align: center;
  padding: 10px 15px;
  margin: 0 5px
}

.stat-card:last-child {
  border-right: none;
}

/* Center content vertically in market insights card */
.market-insights-card {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Stat Title */
.indicator-title {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(to right, #00ffa3, #00e5ff);
    -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.5px;
  text-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
  margin-bottom: 8px;
  text-align: center;
  position: relative;
  padding-bottom: 5px;
}

.indicator-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 2px;
  background: linear-gradient(to right, #00ffa3, #00e5ff);
  border-radius: 1px;
}


/* Stat Value */
.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #e2e8f0;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
}

/* Change Indicators - REMOVED: Conflicted with inline stat-change styling */

.stat-change-up {
  color: #22c55e;
}

.stat-change-down {
  color: #ef4444;
}

/* Fear & Greed Meter */
.fear-greed-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* New Fear & Greed Gauge Styles */
.gauge-container {
  position: relative;
  height: 100px;
  margin: 0 auto;
  padding: 0 10px;
}

.gauge-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0px 2px 3px rgba(0,0,0,0.1));
}

.score-display {
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}


.score {
  font-size: 24px;
  font-weight: 700;
  transition: color 0.3s ease;
  color: #FFC107;
}

/* Fear & Greed gauge styles for market stats bar */
.fear-greed-container .gauge-container {
  height: 60px;
  margin: 0 auto;
  padding: 0 10px;
}

.fear-greed-container .score-display {
  bottom: -10px;
}

.fear-greed-container .score-card {
  padding: 5px 10px;
  min-width: 40px;
}

.fear-greed-container .score {
  font-size: 18px;
}

/* Fear & Greed Colors */
.extreme-fear {
  background-color: #ef4444;
}

.fear {
  background-color: #f97316;
}

.neutral {
  background-color: #eab308;
  color: #333 !important;
}

.greed {
  background-color: #84cc16;
}

.extreme-greed {
  background-color: #22c55e;
}

/* Last Update Time */
.stat-update-time {
  min-width: 100px;
}

/* Refresh animation */
.refresh-flash {
  animation: refresh-flash-animation 0.5s ease-in-out;
}

@keyframes refresh-flash-animation {
  0% { opacity: 0.2; }
  50% { opacity: 1; }
  100% { opacity: 0.8; }
}

/* Info tooltip styling */
.info-tooltip {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  cursor: help;
  margin-left: 3px;
  position: relative;
}

.info-tooltip:hover::after {
  content: attr(title);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 100%;
  width: 150px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  text-align: center;
  font-size: 10px;
  border-radius: 4px;
  padding: 5px;
  margin-bottom: 5px;
  z-index: 10;
  pointer-events: none;
}

/* Info icon and tooltip styles */
.info-icon {
  display: inline-block;
  margin-left: 5px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  cursor: help;
  position: relative;
}

.info-icon:hover::after {
  content: attr(data-tooltip);
  position: fixed; /* Use fixed positioning to ensure it's always visible */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%); /* Center in viewport */
  background-color: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: normal;
  white-space: normal;
  width: auto;
  max-width: 80vw; /* Responsive width */
  min-width: 200px;
  z-index: 10000; /* Very high z-index to ensure visibility */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  text-align: center;
  overflow-wrap: break-word; /* Allow word wrapping */
  word-break: normal;
  line-height: 1.5;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.info-icon:hover::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.9) transparent transparent transparent;
  z-index: 1000;
  pointer-events: none;
}

/* Add some padding to the top of the body to compensate for the fixed bar */
body {
  padding-top: 0;
}

/* Top Performers styling - matching existing design */
.top-performers-card {
  width: auto;
  min-width: 200px;
  flex: 1;
  margin: 0 5px;
}

.performers-container {
  display: flex;
  flex-direction: column;
  gap: 4px; /* Reduced gap for tighter spacing between gainers/losers */
  width: 100%;
  padding: 5px 0;
}

.performers-section {
  /* Removed flex: 1 to prevent expansion */
}

.performers-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--text-color);
  opacity: 0.9;
  padding-left: 5px;
}

.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 with !important */
  row-gap: 0 !important;
  column-gap: 0 !important;
}

.performer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 0; /* Square edges for cohesive list */
  border-bottom: 1px solid rgba(255, 255, 255, 0.08); /* Subtle separator */
  transition: all 0.2s ease;
}

.performer-item:last-child {
  border-bottom: none; /* Remove border from last item */
}

.performer-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.performer-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.performer-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: contain;
}

.performer-symbol {
  font-weight: 600;
  font-size: 0.9rem;
}

.performer-change {
  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 {
  height: 32px;
  overflow: hidden;
  position: relative;
}

.performer-skeleton-content {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Skeleton loading animations */
.skeleton-loading {
  position: relative;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.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;
}

.performer-item.empty {
  justify-content: center;
  padding: 10px;
  color: var(--text-muted, #6c757d);
  font-style: italic;
}

/* Responsive adjustments */
/* Large Desktop (1200px and up) - Single row layout */
@media (min-width: 1200px) {
  .market-stats-container {
    flex-wrap: nowrap !important;
    justify-content: space-between;
  }
  
  .stat-card {
    flex: 1;
    min-width: 0;
  }
  
  .market-insights-card,
  .top-performers-card {
    flex: 2;
    min-width: 250px;
  }
}

/* Medium Desktop (900px to 1199px) - 2 rows layout */
@media (min-width: 900px) and (max-width: 1199px) {
  .market-stats-container {
    flex-wrap: wrap;
    justify-content: space-between;
  }
  
  .stat-card {
    flex: 1 1 calc(25% - 12px);
    min-width: 150px;
  }
  
  .market-insights-card,
  .top-performers-card {
    flex: 1 1 calc(50% - 8px);
    width: calc(50% - 8px);
    min-width: 300px;
  }
}

/* Ensure proper flex behavior for market insights and top performers */
.market-insights-card .combined-indicators-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 10px;
}

.market-insights-card .indicator-box {
  width: 100%;
  margin-bottom: 8px;
}

#grid-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.indicators-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

/* Remove this section as it's covered by other media queries */

/* Remove this section as it's covered by other media queries */

/* Medium Desktop (700px to 1199px) - Optimized gaps */
@media (min-width: 700px) and (max-width: 1199px) {
  .performers-container {
    gap: 6px; /* Reduced gap for better spacing */
  }
}

/* Tablet (700px to 899px) - 3 rows layout */
@media (min-width: 700px) and (max-width: 899px) {
  .market-stats-container {
    flex-wrap: wrap;
    justify-content: space-between;
  }
  
  .stat-card {
    flex: 1 1 calc(33.33% - 10px);
    min-width: calc(33.33% - 10px);
    margin-bottom: 12px;
  }
  
  .market-insights-card,
  .top-performers-card {
    flex: 1 1 100%;
    width: 100%;
    min-width: 100%;
    order: 1;
  }
  
  .stat-title {
    font-size: 0.9rem;
  }
  
  .stat-value {
    font-size: 1.1rem;
  }
}

/* Remove this section as it's covered by other media queries */

/* Mobile (below 700px) - Single column layout */
@media (max-width: 699px) {
  .market-stats-container {
    flex-direction: column;
    gap: 10px;
  }
  
  .stat-card {
    flex: 1 1 100%;
    width: 100%;
    min-width: 100%;
    margin-bottom: 0;
  }
  
  .market-insights-card,
  .top-performers-card {
    flex: 1 1 100%;
    width: 100%;
    min-width: 100%;
    order: 0;
    padding: 12px;
  }
  
  .performers-container {
    width: 100%;
    padding: 8px;
  }
  
  .performer-item {
    margin-bottom: 6px;
    width: 100%;
    box-sizing: border-box;
  }
  
  .performer-symbol {
    font-size: 0.9rem;
  }
  
  .performer-change {
    font-size: 0.9rem;
    padding: 2px 6px;
  }
  
  .performer-icon {
    width: 18px;
    height: 18px;
  }
  
  .stat-title {
    font-size: 0.85rem;
  }
  
  .stat-value {
    font-size: 1rem;
  }
}

/* Small Mobile (below 480px) */
@media (max-width: 479px) {
  .market-stats-container {
    padding: 0 8px;
    gap: 8px;
  }
  
  .stat-card {
    padding: 10px;
  }
  
  .stat-title {
    font-size: 0.75rem;
    margin-bottom: 6px;
  }
  
  .stat-value {
    font-size: 0.85rem;
  }
  
  /* Adjust gauge size for mobile */
  .fear-greed-container .gauge-container {
    height: 50px;
  }
  
  .fear-greed-container .score {
    font-size: 16px;
  }
  
  /* Adjust for mobile performers list */
  .performers-container {
    padding: 3px 0;
  }
  
  .performers-list {
    gap: 0; /* Keep consistent zero gap on mobile too */
  }
  
  .performer-item {
    padding: 4px 6px;
  }
  
  .performer-symbol {
    font-size: 0.75rem;
  }
  
  .performer-change {
    font-size: 0.75rem;
    padding: 1px 3px;
  }
}

/* Very small screens specific adjustments */
@media (max-width: 350px) {
  .stat-card {
    padding: 8px;
  }
  
  .stat-title {
    font-size: 0.7rem;
    margin-bottom: 5px;
  }
  
  .stat-value {
    font-size: 0.8rem;
  }
  
  .performer-item {
    padding: 3px 5px;
  }
  
  .performer-symbol {
    font-size: 0.7rem;
  }
  
  .performer-change {
    font-size: 0.7rem;
    padding: 1px 2px;
  }
  
  /* Make trading bot controls stack on very small screens */
  .control-row {
    flex-direction: column;
    gap: 5px;
    margin-bottom: 5px;
  }
  
  .mini-bot-controller {
    padding: 0.3rem;
  }
}

/* Skeleton loading animations */
.skeleton-loading {
  position: relative;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.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;
}
/* Market insights full width override for problematic screen sizes */
.fullwidth-override.market-insights-card,
.market-insights-card.fullwidth-override {
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  flex: 1 0 100% !important;
  margin: 5px 0 !important;
  box-sizing: border-box !important;
  order: -1 !important;
}
