/**
 * DataView Rating Cell
 * Star-based rating display and editing (1-5 scale)
 * Polished with animations, hover effects, and consistent styling
 */

/* ========================================
   RATING DISPLAY (Table & Card Views)
   ======================================== */

.dv-rating {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background-color 0.15s ease;
}

.dv-rating:hover {
  background: var(--hover-bg, rgba(0, 0, 0, 0.04));
}

.dv-rating-star {
  color: #d1d5db;
  transition: all 0.15s ease;
  font-style: normal;
  text-shadow: none;
}

.dv-rating-star.filled {
  color: #f59e0b;
  text-shadow: 0 1px 2px rgba(245, 158, 11, 0.3);
}

.dv-rating-star.half {
  position: relative;
  color: #d1d5db;
}

.dv-rating-star.half::before {
  content: '★';
  position: absolute;
  left: 0;
  top: 0;
  width: 50%;
  overflow: hidden;
  color: #f59e0b;
  text-shadow: 0 1px 2px rgba(245, 158, 11, 0.3);
}

/* Numeric value display */
.dv-rating-value {
  margin-left: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--content-text-secondary, #6b7280);
  background: var(--hover-bg, #f3f4f6);
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 2rem;
  text-align: center;
}

/* Hover effect on editable ratings */
.dv-cell-editable .dv-rating:hover .dv-rating-star {
  transform: scale(1.1);
}

.dv-cell-editable .dv-rating:hover .dv-rating-star.filled {
  color: #fbbf24;
}

/* Empty state */
.dv-rating-empty {
  color: var(--content-text-tertiary, #9ca3af);
  font-size: 0.8125rem;
  font-style: italic;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.dv-cell-editable .dv-rating-empty:hover {
  background: var(--hover-bg, rgba(0, 0, 0, 0.04));
  color: var(--content-text-secondary, #6b7280);
}

/* ========================================
   INLINE RATING EDITOR
   ======================================== */

.dv-rating-editor {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  background: var(--content-bg, white);
  border: 2px solid var(--primary-color, #667eea);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
  animation: dv-rating-editor-appear 0.15s ease-out;
}

/* Rating editor within form context - less prominent styling */
.dv-rating-field .dv-rating-editor {
  border: 1px solid var(--border-color, #e5e7eb);
  box-shadow: none;
  animation: none;
  padding: 8px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dv-rating-field .dv-rating-editor:hover {
  border-color: var(--content-text-secondary, #9ca3af);
}

.dv-rating-field .dv-rating-editor:focus-within {
  border-color: var(--primary-color, #667eea);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

@keyframes dv-rating-editor-appear {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-2px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dv-rating-editor-star {
  font-size: 1.5rem;
  color: #d1d5db;
  cursor: pointer;
  transition: all 0.1s ease;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
}

.dv-rating-editor-star:hover {
  transform: scale(1.15);
  background: rgba(245, 158, 11, 0.1);
}

.dv-rating-editor-star.filled {
  color: #f59e0b;
  text-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
}

.dv-rating-editor-star.hovered {
  color: #fbbf24;
  text-shadow: 0 2px 4px rgba(251, 191, 36, 0.4);
}

/* Value indicator in editor */
.dv-rating-editor-value {
  margin-left: 4px;
  padding: 4px 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--content-text-secondary, #6b7280);
  background: var(--hover-bg, #f3f4f6);
  border-radius: 4px;
  min-width: 2.5rem;
  text-align: center;
}

/* Divider between stars and clear button */
.dv-rating-editor-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color, #e5e7eb);
  margin: 0 4px;
}

/* Clear rating button */
.dv-rating-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--content-text-secondary, #6b7280);
  background: var(--hover-bg, #f3f4f6);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 4px;
}

.dv-rating-clear:hover {
  background: #fee2e2;
  color: #dc2626;
}

.dv-rating-clear:active {
  transform: scale(0.95);
}

/* ========================================
   CARD VIEW RATING
   ======================================== */

.dv-card-rating {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dv-card-rating .dv-rating {
  font-size: 0.875rem;
  padding: 0;
}

.dv-card-rating .dv-rating:hover {
  background: transparent;
}

.dv-card-rating .dv-rating-value {
  font-size: 0.6875rem;
  padding: 1px 5px;
  margin-left: 4px;
}

.dv-card-rating .dv-rating-empty {
  font-size: 0.75rem;
  padding: 0;
}

/* ========================================
   SUMMARY/AGGREGATE RATING (Table Footer)
   ======================================== */

.dv-rating-summary {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dv-rating-summary-stars {
  display: flex;
  align-items: center;
  gap: 1px;
  font-size: 0.75rem;
}

.dv-rating-summary-stars .dv-rating-star {
  font-size: inherit;
}

.dv-rating-summary-avg {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--content-text-secondary, #6b7280);
  background: var(--hover-bg, #f3f4f6);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ========================================
   SIZE VARIANTS
   ======================================== */

/* Small variant */
.dv-rating-sm,
.dv-rating-sm .dv-rating {
  font-size: 0.75rem;
  gap: 0;
}

.dv-rating-sm .dv-rating-value {
  font-size: 0.625rem;
  padding: 1px 4px;
  margin-left: 4px;
}

/* Large variant */
.dv-rating-lg,
.dv-rating-lg .dv-rating {
  font-size: 1.25rem;
  gap: 2px;
}

.dv-rating-lg .dv-rating-value {
  font-size: 0.875rem;
  padding: 3px 8px;
}

/* ========================================
   DARK MODE
   ======================================== */

[data-theme="dark"] .dv-rating-star {
  color: #4b5563;
}

[data-theme="dark"] .dv-rating-star.filled {
  color: #f59e0b;
  text-shadow: 0 1px 3px rgba(245, 158, 11, 0.4);
}

[data-theme="dark"] .dv-rating:hover {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .dv-rating-value {
  background: rgba(255, 255, 255, 0.08);
  color: var(--content-text-secondary, #9ca3af);
}

[data-theme="dark"] .dv-rating-empty {
  color: var(--content-text-tertiary, #6b7280);
}

[data-theme="dark"] .dv-cell-editable .dv-rating-empty:hover {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .dv-rating-editor {
  background: var(--content-bg, #1f2937);
  border-color: var(--primary-color, #667eea);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .dv-rating-editor-star {
  color: #4b5563;
}

[data-theme="dark"] .dv-rating-editor-star.filled {
  color: #f59e0b;
  text-shadow: 0 2px 6px rgba(245, 158, 11, 0.5);
}

[data-theme="dark"] .dv-rating-editor-star.hovered {
  color: #fbbf24;
}

[data-theme="dark"] .dv-rating-editor-star:hover {
  background: rgba(245, 158, 11, 0.15);
}

[data-theme="dark"] .dv-rating-editor-value {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .dv-rating-editor-divider {
  background: var(--border-color, #374151);
}

[data-theme="dark"] .dv-rating-clear {
  background: rgba(255, 255, 255, 0.08);
  color: var(--content-text-secondary, #9ca3af);
}

[data-theme="dark"] .dv-rating-clear:hover {
  background: rgba(220, 38, 38, 0.2);
  color: #f87171;
}

[data-theme="dark"] .dv-rating-summary-avg {
  background: rgba(255, 255, 255, 0.08);
}

/* Dark mode for form rating field */
[data-theme="dark"] .dv-rating-field .dv-rating-editor {
  border-color: var(--border-color, #374151);
}

[data-theme="dark"] .dv-rating-field .dv-rating-editor:hover {
  border-color: var(--content-text-secondary, #6b7280);
}

[data-theme="dark"] .dv-rating-field .dv-rating-editor:focus-within {
  border-color: var(--primary-color, #667eea);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

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

/* Inline editor accessibility - keep outline for keyboard navigation */
.dv-rating-editor:focus-within {
  outline: 2px solid var(--primary-color, #667eea);
  outline-offset: 2px;
}

.dv-rating-editor:focus {
  outline: 2px solid var(--primary-color, #667eea);
  outline-offset: 2px;
}

/* Form context - remove outline since we use border instead */
.dv-rating-field .dv-rating-editor:focus-within {
  outline: none;
}

.dv-rating-field .dv-rating-editor:focus {
  outline: none;
}

.dv-rating-editor-star:focus {
  outline: none;
  background: rgba(102, 126, 234, 0.15);
  border-radius: 4px;
}

/* Screen reader text */
.dv-rating[aria-label],
.dv-rating-editor[aria-label] {
  position: relative;
}

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

@keyframes dv-star-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

.dv-rating-star.just-filled {
  animation: dv-star-pulse 0.3s ease-out;
}
