/* =========================================
   RATING UI STYLES
   COSTA Industries - ML Recommendation System
   ========================================= */

/* ===== RATING CONTAINER ===== */

.article-rating-container {
  display: flex;
  align-items: center;
  gap: 8px; /* Reduced gap to save space */
  margin-top: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  transition: all 0.3s ease;
  flex-wrap: wrap; /* Allow wrapping if needed */
}

.article-rating-container:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Rating submitted animation */
.article-rating-container.rating-submitted {
  animation: pulseGreen 0.6s ease;
}

@keyframes pulseGreen {
  0%,
  100% {
    background: rgba(255, 255, 255, 0.05);
    transform: scale(1);
  }
  50% {
    background: rgba(76, 175, 80, 0.2);
    transform: scale(1.02);
  }
}

/* ===== ML SCORE BADGE ===== */

.article-score-badge,
.ml-score-badge {
  display: flex;
  align-items: center;
  gap: 4px; /* Reduced gap */
  padding: 4px 10px; /* Reduced padding */
  border-radius: 20px;
  font-size: 0.8125rem; /* Slightly smaller */
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.3s ease;
  cursor: help;
  flex-shrink: 0; /* Don't compress badge */
}

.article-score-badge .score-icon,
.ml-score-badge .badge-icon {
  font-size: 0.9rem; /* Slightly smaller icon */
}

.article-score-badge .score-value,
.ml-score-badge .badge-score {
  font-family: 'Courier New', monospace;
  letter-spacing: 0.5px;
}

/* Badge color variants */
.score-excellent,
.ml-score-badge.score-excellent {
  background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.score-good,
.ml-score-badge.score-good {
  background: linear-gradient(135deg, #2196f3 0%, #42a5f5 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.score-neutral,
.ml-score-badge.score-neutral {
  background: linear-gradient(135deg, #ff9800 0%, #ffa726 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.score-low,
.ml-score-badge.score-low {
  background: linear-gradient(135deg, #9e9e9e 0%, #bdbdbd 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(158, 158, 158, 0.3);
}

.article-score-badge:hover,
.ml-score-badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ===== STAR RATING ===== */

.star-rating {
  display: flex;
  gap: 2px; /* Reduced gap between stars */
  align-items: center;
  flex-shrink: 0; /* Don't compress stars */
}

.star {
  font-size: 1.4rem; /* Slightly smaller stars */
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  opacity: 0.7;
}

.star:hover {
  transform: scale(1.2);
  opacity: 1;
}

.star.filled {
  opacity: 1;
  animation: starPop 0.3s ease;
}

@keyframes starPop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

/* Keyboard focus */
.star:focus {
  outline: 2px solid #2196f3;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===== RATING LABEL ===== */

.rating-label {
  font-size: 0.8125rem; /* Slightly smaller to fit text */
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  min-width: 90px; /* Reduced to fit in available space */
  flex-shrink: 0; /* Don't shrink */
  flex-grow: 0; /* Don't grow */
  text-align: left; /* Align left for better readability */
  white-space: nowrap; /* Keep text on one line */
  transition: color 0.2s ease;
}

.article-rating-container:hover .rating-label {
  color: rgba(255, 255, 255, 0.9);
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  .article-rating-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .article-score-badge,
  .ml-score-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
  }

  .star {
    font-size: 1.25rem;
  }

  .rating-label {
    font-size: 0.75rem;
    min-width: 90px;
  }
}

/* ===== INTEGRATION WITH EXISTING ARTICLE CARDS ===== */

/* If using with feed-ai.html article cards */
.article-card .article-rating-container {
  margin-top: auto; /* Push to bottom of card */
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
}

/* ===== LOADING STATE ===== */

.article-rating-container.loading {
  opacity: 0.5;
  pointer-events: none;
}

.article-rating-container.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #2196f3;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== TOOLTIP (Optional enhancement) ===== */

.article-score-badge::before,
.ml-score-badge::before {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 0.75rem;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.article-score-badge:hover::before,
.ml-score-badge:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(-12px);
}

/* ===== DARK/LIGHT MODE SUPPORT ===== */

@media (prefers-color-scheme: light) {
  .article-rating-container {
    background: rgba(0, 0, 0, 0.05);
  }

  .article-rating-container:hover {
    background: rgba(0, 0, 0, 0.08);
  }

  .rating-label {
    color: rgba(0, 0, 0, 0.7);
  }

  .article-rating-container:hover .rating-label {
    color: rgba(0, 0, 0, 0.9);
  }
}

/* ===== ACCESSIBILITY ===== */

.star:focus-visible {
  outline: 2px solid #2196f3;
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .star,
  .article-score-badge,
  .ml-score-badge,
  .article-rating-container {
    transition: none;
    animation: none;
  }

  .star:hover {
    transform: none;
  }

  .article-score-badge:hover,
  .ml-score-badge:hover {
    transform: none;
  }
}
