/**
 * Star Rating Component Styles
 * Reusable star rating component with accessibility support
 */

.star-rating {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    user-select: none;
}

.star-rating__star {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    color: #d1d5db; /* gray-300 */
    position: relative;
    outline: none;
}

.star-rating__star:focus {
    outline: 2px solid #3b82f6; /* blue-500 */
    outline-offset: 2px;
}

.star-rating__star:hover:not(:disabled) {
    color: #fbbf24; /* yellow-400 */
    transform: scale(1.1);
}

.star-rating__star.active {
    color: #fbbf24; /* yellow-400 */
}

.star-rating__star.hovered {
    color: #f59e0b; /* yellow-500 */
    transform: scale(1.1);
}

.star-rating__icon {
    display: block;
    transition: inherit;
}

/* Size variants */
.star-rating--small .star-rating__icon {
    width: 16px;
    height: 16px;
}

.star-rating--medium .star-rating__icon {
    width: 20px;
    height: 20px;
}

.star-rating--large .star-rating__icon {
    width: 24px;
    height: 24px;
}

/* Readonly state */
.star-rating.readonly .star-rating__star {
    cursor: default;
    pointer-events: none;
}

.star-rating.readonly .star-rating__star:hover {
    transform: none;
}

/* Interactive state */
.star-rating.interactive .star-rating__star:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Animation for rating changes */
.star-rating__star.active .star-rating__icon {
    animation: starPulse 0.3s ease;
}

@keyframes starPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* Hover effect for better UX */
.star-rating.interactive:hover .star-rating__star:not(.hovered):not(.active) {
    color: #e5e7eb; /* gray-200 */
}

/* Focus visible for better accessibility */
.star-rating__star:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 4px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .star-rating__star {
        color: #000;
    }
    
    .star-rating__star.active,
    .star-rating__star.hovered {
        color: #ff6600;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .star-rating__star,
    .star-rating__icon {
        transition: none;
    }
    
    .star-rating__star:hover {
        transform: none;
    }
    
    .star-rating__star.active .star-rating__icon {
        animation: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .star-rating__star {
        color: #4b5563; /* gray-600 */
    }
    
    .star-rating__star.active,
    .star-rating__star.hovered {
        color: #fbbf24; /* yellow-400 */
    }
    
    .star-rating.interactive:hover .star-rating__star:not(.hovered):not(.active) {
        color: #6b7280; /* gray-500 */
    }
}

/* Tooltip styles (optional) */
.star-rating__star[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937; /* gray-800 */
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 4px;
}

.star-rating__star[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #1f2937; /* gray-800 */
    z-index: 1000;
}

/* RTL support */
[dir="rtl"] .star-rating {
    direction: rtl;
}

/* Print styles */
@media print {
    .star-rating__star:not(.active) {
        display: none;
    }
    
    .star-rating__star.active {
        color: #000 !important;
    }
}
