/* Advanced Star Rating System - Centered Layout */

:root {
    --asr-star-size: 24px;
    --asr-star-color: #FFD700;
    --asr-empty-color: #ddd;
}

/* Centered container layout */
.asr-rating-container {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin: 10px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    width: 100%;
    max-width: 300px; /* Optional: limit width */
}

.asr-stars {
    display: inline-block;
    position: relative;
    font-size: var(--asr-star-size, 24px);
    line-height: 1;
    white-space: nowrap;
    user-select: none;
    margin-bottom: 8px; /* Space between stars and text */
}

/* Size variants */
.asr-stars.size-xs { font-size: 12px; }
.asr-stars.size-sm { font-size: 16px; }
.asr-stars.size-md { font-size: 24px; }
.asr-stars.size-lg { font-size: 32px; }
.asr-stars.size-xl { font-size: 48px; }
.asr-stars.size-xxl { font-size: 64px; }

.asr-star {
    position: relative;
    display: inline-block;
    cursor: pointer;
    width: 1.2em;
    height: 1.2em;
    margin: 0 2px;
    transition: transform 0.2s ease;
}

.asr-stars:not(.readonly) .asr-star:hover {
    transform: scale(1.1);
}

.asr-stars.readonly .asr-star {
    cursor: default;
}

.asr-star-empty,
.asr-star-filled,
.asr-star-half {
    position: absolute;
    top: 0;
    left: 0;
    transition: all 0.2s ease;
}

.asr-star-empty {
    color: var(--asr-empty-color, #ddd);
    text-shadow: 0 1px 0 #ccc;
}

.asr-star-filled,
.asr-star-half {
    color: var(--asr-star-color, #FFD700);
    text-shadow: 0 1px 0 #f5c500;
    opacity: 0;
}

.asr-star.active .asr-star-filled {
    opacity: 1;
}

.asr-star.half .asr-star-half {
    opacity: 1;
    width: 50%;
    overflow: hidden;
}

.asr-star.half .asr-star-filled {
    opacity: 0;
}

/* Hover effects */
.asr-stars:not(.readonly):hover .asr-star-empty {
    color: var(--asr-star-color, #FFD700);
    opacity: 0.3;
}

.asr-stars:not(.readonly) .asr-star:hover ~ .asr-star .asr-star-filled,
.asr-stars:not(.readonly) .asr-star:hover ~ .asr-star .asr-star-half {
    opacity: 0;
}

.asr-stars:not(.readonly) .asr-star:hover .asr-star-filled,
.asr-stars:not(.readonly) .asr-star:hover .asr-star-empty {
    opacity: 1;
}

.asr-stars:not(.readonly) .asr-star:hover .asr-star-empty {
    color: var(--asr-star-color, #FFD700);
}

/* CENTERED Rating info */
.asr-rating-info {
    display: block;
    margin: 0;
    font-size: 14px;
    color: #333;
    text-align: center;
    width: 100%;
}

.asr-average {
    font-weight: bold;
    margin-right: 5px;
    color: #999;
}

.asr-count {
    color: #999;
}

/* Messages */
.asr-message {
    margin-top: 8px;
    padding: 5px 10px;
    font-size: 14px;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.3s ease;
    text-align: center;
    width: 100%;
}

.asr-message.show {
    opacity: 1;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.asr-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Alternative inline layout with centered text below */
.asr-rating-container.inline {
    display: inline-block;
    text-align: center;
}

.asr-rating-container.inline .asr-stars {
    display: block;
    margin-bottom: 8px;
}

.asr-rating-container.inline .asr-rating-info {
    display: block;
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .asr-stars {
        font-size: 20px;
    }
    
    .asr-rating-info {
        font-size: 13px;
    }
}

/* Animation */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.asr-star.pulse {
    animation: pulse 0.5s ease;
}

/* Tooltip */
.asr-stars:not(.readonly)::before {
    content: "Click left half for ½ star";
    position: absolute;
    margin-top: 60px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: #999;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.asr-stars:not(.readonly):hover::before {
    opacity: 1;
}