/**
 * WCMS Ratings Module Styles
 * 
 * Rating widgets, sliders, stats, and themes.
 * Uses shared variables from common.css
 * 
 * @package WCMS_Product_Suite
 */

/* ============================================
   RATINGS CONTAINER
   ============================================ */

.wcms-ratings-heading {
  max-width: 64rem;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 1rem;
  text-align: center;
}

/* Ensure theme `.container` rules don't override our max-width when both classes are present. */
.wcms-ratings-heading.container {
  max-width: 64rem;
}

.wcms-ratings-heading-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--wcms-gray-800);
}

.wcms-ratings-container {
  max-width: 64rem;
  margin-left: auto;
  margin-right: auto;
}

/* Ensure theme `.container` rules don't override our max-width when both classes are present. */
.wcms-ratings-container.container {
  max-width: 70rem;
}

.wcms-ratings-container .grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .wcms-ratings-container .grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
  }
}

/* ============================================
   RATING WIDGET
   ============================================ */

.wcms-rating-widget {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  opacity: 0;
  color: var(--wcms-gray-800);
  direction: rtl;
}

.wcms-rating-widget.wcms-animate-in {
  animation: wcms-fade-in-up 0.6s ease-out forwards;
}

.wcms-rating-widget.wcms-animated {
  opacity: 1;
  animation: none;
}

.wcms-rating-widget:nth-child(1) { animation-delay: 0.1s; }
.wcms-rating-widget:nth-child(2) { animation-delay: 0.2s; }
.wcms-rating-widget:nth-child(3) { animation-delay: 0.3s; }
.wcms-rating-widget:nth-child(4) { animation-delay: 0.4s; }

/* ============================================
   WIDGET HEADER
   ============================================ */

.wcms-rating-widget .header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.wcms-rating-widget .icon-wrapper {
  padding: 0.5rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--theme-bg);
  color: var(--theme-color);
}

.wcms-rating-widget .section-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  color: var(--wcms-gray-700);
  margin: 0;
}

/* ============================================
   SLIDER
   ============================================ */

.wcms-rating-widget .slider-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.wcms-rating-widget .range-container {
  position: relative;
  padding-top: 0.25rem;
}

.wcms-rating-widget input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 0.5rem;
  background: var(--wcms-gray-100);
  border-radius: 0.5rem;
  cursor: pointer;
  display: block;
  color: var(--theme-color);
}

.wcms-rating-widget input[type=range]:focus {
  outline: none;
}

.wcms-rating-widget input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 12px;
  width: 12px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid currentColor;
  cursor: pointer;
  margin-top: -3px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wcms-rating-widget input[type=range]:active::-webkit-slider-thumb {
  transform: scale(1.3);
  box-shadow: 0 0 0 4px var(--theme-bg);
}

.wcms-rating-widget input[type=range]::-moz-range-thumb {
  height: 12px;
  width: 12px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid currentColor;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.wcms-rating-widget .slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--wcms-gray-400);
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.wcms-rating-widget .slider-labels span {
  transition: color 0.2s ease, font-weight 0.2s ease, transform 0.2s ease;
  display: inline-block;
}

.wcms-rating-widget .slider-labels span.selected {
  color: var(--wcms-gray-800);
  font-weight: 700;
  transform: scale(1.15);
}

/* ============================================
   STATS
   ============================================ */

.wcms-rating-widget .stats-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.wcms-rating-widget .stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  cursor: pointer;
  padding: 0.25rem 0.75rem 0.25rem 0.25rem;
  border-radius: 0.25rem;
  transition: background-color 0.2s ease;
  position: relative;
}

.wcms-rating-widget .stat-item::before {
  content: '';
  position: absolute;
  top: 0.5rem;
  bottom: 0.5rem;
  right: 0;
  width: 3px;
  background-color: var(--theme-color);
  border-top-left-radius: 2px;
  border-bottom-left-radius: 2px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.wcms-rating-widget .stat-item.selected::before {
  opacity: 1;
}

.wcms-rating-widget .stat-item:hover,
.wcms-rating-widget .stat-item.selected {
  background-color: var(--wcms-gray-50);
}

.wcms-rating-widget .stat-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.75rem;
  margin-bottom: 0.125rem;
}

.wcms-rating-widget .stat-label {
  font-weight: 500;
  color: var(--wcms-gray-600);
}

.wcms-rating-widget .stat-value {
  font-size: 0.75rem;
  color: var(--wcms-gray-400);
}

.wcms-rating-widget .progress-bg {
  width: 100%;
  background-color: var(--wcms-gray-100);
  border-radius: 9999px;
  height: 0.5rem;
  overflow: hidden;
}

.wcms-rating-widget .progress-fill {
  height: 100%;
  border-radius: 9999px;
  transform-origin: right;
  animation: wcms-grow-bar 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ============================================
   WINNER STYLING
   ============================================ */

.wcms-rating-widget .stat-item.winner .stat-label {
  font-weight: 700;
  color: var(--wcms-gray-800);
}

.wcms-rating-widget .stat-item.winner .stat-value {
  font-weight: 700;
  color: var(--theme-color);
}

.wcms-rating-widget .stat-item.winner .progress-fill {
  background-color: var(--bar-color-winner);
  box-shadow: 0 0 10px var(--theme-color);
  opacity: 0.8;
}

/* ============================================
   BAR CLASSES
   ============================================ */

.wcms-rating-widget .bar-weak { background-color: var(--bar-color-weak); }
.wcms-rating-widget .bar-normal { background-color: var(--bar-color); }
.wcms-rating-widget .bar-strong { background-color: var(--bar-color-strong); }
.wcms-rating-widget .bar-winner { background-color: var(--bar-color-winner); }

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

.wcms-rating-widget.wcms-rating-loading {
  position: relative;
  pointer-events: none;
}

.wcms-rating-widget.wcms-rating-loading::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.7);
  z-index: 10;
  border-radius: inherit;
  backdrop-filter: blur(1px);
}

.wcms-rating-widget.wcms-rating-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin-top: -16px;
  margin-left: -16px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--theme-color, #4f46e5);
  border-radius: 50%;
  animation: wcms-spin 0.8s linear infinite;
  z-index: 11;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes wcms-grow-bar {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes wcms-fade-in-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* ============================================
   ICON METER STRIP STYLE
   ============================================ */

.wcms-rating-strip-wrap {
  max-width: 68.75rem;
  margin-left: auto;
  margin-right: auto;
  border: 1px solid var(--wcms-gray-200);
  border-radius: 1rem;
  background: #fff;
  padding: clamp(10px, 2.4vw, 16px);
  --strip-gap: clamp(14px, 2.2vw, 18px);
  --group-gap: clamp(10px, 1.6vw, 14px);
  --item-width: clamp(64px, 6.2vw, 72px);
  --icon-size: clamp(32px, 3.4vw, 38px);
  --bar-height: clamp(5px, 0.8vw, 6px);
  --divider-height: clamp(44px, 6vw, 54px);
}

/* Ensure theme `.container` rules don't override our max-width when both classes are present. */
.wcms-rating-strip-wrap.container {
  max-width: 68.75rem;
}

.wcms-rating-strip {
  display: flex;
  align-items: flex-start;
  gap: var(--strip-gap);
  padding: clamp(10px, 2.2vw, 16px) clamp(6px, 1.8vw, 10px);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  justify-content: center;
  scroll-snap-type: x proximity;
  scroll-padding: 10px;
  direction: rtl;
}

.wcms-rating-strip::-webkit-scrollbar { height: 0; }
.wcms-rating-strip { scrollbar-width: none; }

.wcms-rating-strip-divider {
  width: 1px;
  height: var(--divider-height);
  background: var(--wcms-gray-200);
  flex: 0 0 auto;
  margin-top: 6px;
}

.wcms-rating-style-icon-strip {
  display: flex;
  gap: var(--group-gap);
  flex-direction: row;
  align-items: flex-start;
  flex: 0 0 auto;
  direction: rtl;
}

.wcms-rating-style-icon-strip .wcms-strip-item {
  width: var(--item-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--wcms-gray-500);
  user-select: none;
  scroll-snap-align: start;
  padding: 6px 6px 8px;
  border-radius: 12px;
  transition: background var(--wcms-transition-fast), transform var(--wcms-transition-fast);
}

.wcms-rating-style-icon-strip .wcms-strip-item:hover {
  background: var(--wcms-gray-50);
}

.wcms-rating-style-icon-strip .wcms-strip-item:active {
  transform: scale(0.98);
}

.wcms-rating-style-icon-strip .wcms-strip-item::before {
  content: none;
}

.wcms-rating-style-icon-strip .wcms-strip-item.selected {
  background: var(--wcms-gray-50);
}

.wcms-rating-style-icon-strip .wcms-strip-icon {
  width: var(--icon-size);
  height: var(--icon-size);
  display: grid;
  place-items: center;
  color: var(--icon-color, var(--wcms-gray-400));
  transition: color var(--wcms-transition-fast);
}

.wcms-rating-style-icon-strip .wcms-strip-icon svg {
  width: var(--icon-size);
  height: var(--icon-size);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wcms-rating-style-icon-strip .wcms-strip-label {
  font-size: clamp(12px, 1.35vw, 14px);
  line-height: 1;
  color: var(--wcms-gray-700);
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color var(--wcms-transition-fast);
}

.wcms-rating-style-icon-strip .wcms-strip-label-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.wcms-rating-style-icon-strip .wcms-strip-count {
  font-size: clamp(11px, 1.2vw, 12px);
  line-height: 1;
  color: var(--wcms-gray-500);
  white-space: nowrap;
}

.wcms-rating-style-icon-strip .wcms-strip-bar {
  width: 100%;
  height: var(--bar-height);
  background: var(--wcms-gray-100);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}

.wcms-rating-style-icon-strip .wcms-strip-bar-fill {
  position: absolute;
  inset: 0;
  width: var(--value, 0%);
  background: var(--bar-color, #6366f1);
  border-radius: 999px;
}

.wcms-rating-style-icon-strip .stat-value {
  display: none;
}

.wcms-rating-style-icon-strip .stat-item.winner .wcms-strip-label,
.wcms-rating-style-icon-strip .stat-item.winner .wcms-strip-icon {
  color: inherit;
}

.wcms-rating-style-icon-strip .stat-item.winner .progress-fill {
  background-color: var(--bar-color, #6366f1);
  box-shadow: none;
  opacity: 1;
}

@media (max-width: 980px) {
  .wcms-rating-strip {
    flex-wrap: wrap;
    overflow-x: visible;
    justify-content: stretch;
    scroll-snap-type: none;
  }

  .wcms-rating-strip-divider {
    display: none;
  }

  .wcms-rating-style-icon-strip {
    flex: 1 1 320px;
    width: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 12px 10px;
  }

  .wcms-rating-style-icon-strip .wcms-strip-item {
    width: auto;
  }
}

@media (max-width: 560px) {
  .wcms-rating-strip {
    flex-wrap: wrap;
    overflow-x: visible;
    justify-content: stretch;
    scroll-snap-type: none;
    gap: 14px;
  }

  .wcms-rating-strip-divider {
    display: none;
  }

  .wcms-rating-style-icon-strip {
    width: 100%;
    grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
    gap: 12px 10px;
  }

  .wcms-rating-style-icon-strip .wcms-strip-item {
    width: auto;
  }
}

@media (min-width: 1200px) {
  .wcms-rating-strip { justify-content: space-between; }
}
