/**
 * Enhanced Rating System Styles
 * Features smooth animations and prevents overlapping
 */

.rating-system {
    padding: 2rem;
    background: #f8fafc;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 
                0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin: 2rem 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.rating-system:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 
                0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.rating-system h4 {
    font-size: 1.25rem;
    color: #1a202c;
    margin-bottom: 1rem;
    font-weight: 600;
}

/* Stars Container */
.stars {
    display: inline-flex;
    gap: 0.25rem;
    position: relative;
    margin-bottom: 1rem;
}

/* Individual Star */
.star {
    font-size: 2rem;
    cursor: pointer;
    color: #cbd5e0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

/* Star Hover Effect */
.star:hover,
.star:hover ~ .star {
    color: #ecc94b;
    transform: scale(1.1);
}

/* Selected Stars */
.star.selected {
    color: #ecc94b;
    animation: starPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Prevent multiple star systems from overlapping */
.rating-system .stars {
    z-index: 2;
    position: relative;
}

/* Rating Info */
.rating-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    font-size: 0.875rem;
}

.average-rating {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2d3748;
    margin-right: 0.5rem;
}

.rating-count {
    color: #718096;
}

/* Rating Distribution */
.rating-distribution {
    margin-top: 1.5rem;
}

.rating-bar {
    display: grid;
    grid-template-columns: 4rem 1fr 3rem;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.rating-label {
    font-size: 0.875rem;
    color: #718096;
    text-align: right;
}

.rating-progress {
    height: 0.5rem;
    background: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
}

.rating-progress-fill {
    height: 100%;
    background: #ecc94b;
    border-radius: 9999px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left;
    animation: progressFill 1s ease-out forwards;
}

.rating-value {
    font-size: 0.875rem;
    color: #718096;
    min-width: 2rem;
}

/* Animations */
@keyframes starPop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes progressFill {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

/* Tooltip on Hover */
.star::before {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-0.5rem);
    padding: 0.25rem 0.5rem;
    background: #2d3748;
    color: white;
    font-size: 0.75rem;
    border-radius: 0.25rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
}

.star:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-0.25rem);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .rating-system {
        background: #2d3748;
    }

    .rating-system h4 {
        color: #f7fafc;
    }

    .star {
        color: #4a5568;
    }

    .average-rating {
        color: #e2e8f0;
    }

    .rating-count,
    .rating-label,
    .rating-value {
        color: #a0aec0;
    }

    .rating-progress {
        background: #4a5568;
    }
}

/* Responsive Design */
@media (max-width: 640px) {
    .rating-system {
        padding: 1.5rem;
    }

    .stars {
        gap: 0.125rem;
    }

    .star {
        font-size: 1.75rem;
    }

    .rating-bar {
        grid-template-columns: 3.5rem 1fr 2.5rem;
        gap: 0.75rem;
    }
}

/* Smooth hover transitions for interactive elements */
.rating-system *,
.newsletter-form *,
.social-following *,
button,
.btn,
a {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Button animations */
button:not(:disabled),
.btn:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:not(:disabled):hover,
.btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

button:not(:disabled):active,
.btn:not(:disabled):active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Social media buttons animation */
.follow-btn {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.3s ease;
}

.follow-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.follow-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Newsletter form animations */
.newsletter-form input,
.popup-newsletter-form input {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.newsletter-form input:focus,
.popup-newsletter-form input:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.1);
}

/* Newsletter popup animations */
.newsletter-popup {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.newsletter-popup.show {
    opacity: 1;
    visibility: visible;
}

.newsletter-popup-content {
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.newsletter-popup.show .newsletter-popup-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Loading state animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}