/* 修复星星错位问题 - 完整CSS */
.ratingplus-main {
    margin: 40px 0;
    padding: 0;
    text-align: center;
    background: transparent;
    border: none;
    box-shadow: none;
}

.rating-section {
    margin-bottom: 15px;
}

.like-box {
    display: inline-block;
}

.rating-box {
    display: inline-flex;
    align-items: center;
    gap: 15px;
    padding: 15px 25px;
    border-radius: 50px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
}

.like-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.25);
    position: relative;
    overflow: hidden;
}

.like-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s;
}

.like-btn:hover:not(:disabled)::before {
    left: 100%;
}

.like-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.35);
}

.like-btn:active:not(:disabled) {
    transform: translateY(0);
}

.like-btn.liked {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.25);
}

.like-btn.liked:hover:not(:disabled) {
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.35);
}

.like-btn:disabled {
    cursor: not-allowed;
    opacity: 0.8;
    transform: none !important;
}

.like-icon {
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}

.heart-icon {
    transition: all 0.3s ease;
}

.heart-filled {
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s ease;
}

.like-btn.liked .heart-outline {
    opacity: 0;
    transform: scale(0);
}

.like-btn.liked .heart-filled {
    opacity: 1;
    transform: scale(1);
}

.like-btn:hover .like-icon {
    transform: scale(1.1);
}

.like-text {
    font-weight: 600;
    letter-spacing: 0.3px;
}

.like-count {
    background: rgba(255, 255, 255, 0.25);
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 14px;
    font-weight: 600;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 20px;
    transition: all 0.3s ease;
}

.like-btn:hover .like-count {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.05);
}

/* 星星容器 - 重点修复部分 */
.stars-container {
    position: relative;
    display: inline-block;
    font-size: 28px;
    line-height: 1;
    height: 28px;
    width: 140px; /* 5个星星 * 28px = 140px */
    vertical-align: top;
}

.stars-background, .stars-foreground {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 28px;
    line-height: 28px;
    white-space: nowrap;
    letter-spacing: 0;
}

.stars-background {
    color: #e9ecef;
    z-index: 1;
}

.stars-foreground {
    color: #ffc107;
    overflow: hidden;
    text-shadow: 0 1px 3px rgba(255, 193, 7, 0.3);
    z-index: 2;
    width: 0; /* 初始宽度为0，通过JS动态设置 */
    transition: width 0.3s ease;
}

/* 交互层使用flex布局确保星星均匀分布 */
.stars-interactive {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    display: flex;
    justify-content: space-between;
    width: 100%;
    height: 28px;
}

.star {
    font-size: 28px;
    color: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    width: 28px;
    height: 28px;
    text-align: center;
    user-select: none;
    flex: 0 0 28px;
    line-height: 28px;
    padding: 0;
    margin: 0;
}

.star:hover:not(.disabled) {
    transform: scale(1.2);
    color: #ffd54f !important;
}

.star.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.rating-info {
    text-align: left;
}

.rating-show {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.rating-score {
    font-size: 20px;
    font-weight: 700;
    color: #495057;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.rating-count {
    color: #6c757d;
    font-size: 13px;
    font-weight: 500;
}

.rating-no {
    color: #868e96;
    font-style: italic;
    font-size: 13px;
    font-weight: 500;
}

.rating-tip {
    color: #28a745;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    background: rgba(40, 167, 69, 0.1);
    border-radius: 12px;
    display: inline-block;
}

.ratingplus-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: rgba(248, 249, 250, 0.9);
    border-radius: 8px;
    margin-top: 15px;
    color: #495057;
    font-weight: 600;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 动画效果 */
@keyframes heartBeat {
    0% { transform: scale(1); }
    25% { transform: scale(1.2); }
    50% { transform: scale(0.95); }
    75% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes starBounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0,0,0);
    }
    40%, 43% {
        transform: translate3d(0,-5px,0);
    }
    70% {
        transform: translate3d(0,-2px,0);
    }
    90% {
        transform: translate3d(0,-1px,0);
    }
}

.like-btn:active:not(:disabled) .like-icon {
    animation: heartBeat 0.5s ease;
}

.star:active:not(.disabled) {
    animation: starBounce 0.4s ease;
}

.divider {
    width: 1px;
    height: 40px;
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1), transparent);
    margin: 0 10px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .ratingplus-main {
        margin: 25px 0;
        padding: 0 10px;
    }
    
    .rating-box {
        flex-direction: column;
        gap: 16px;
        padding: 18px 20px;
        border-radius: 20px;
        width: 100%;
        max-width: 320px;
        margin: 0 auto;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    }
    
    .divider {
        width: 80%;
        height: 1px;
        background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.1), transparent);
        margin: 5px 0;
    }
    
    .rating-info {
        text-align: center;
        width: 100%;
        order: 1;
    }
    
    .stars-container {
        font-size: 26px;
        height: 26px;
        width: 130px;
        order: 2;
        margin: 8px 0;
    }
    
    .stars-background, .stars-foreground {
        font-size: 26px;
        height: 26px;
        line-height: 26px;
    }
    
    .stars-interactive {
        height: 26px;
    }
    
    .star {
        font-size: 26px;
        width: 26px;
        height: 26px;
        line-height: 26px;
        flex: 0 0 26px;
        padding: 4px 0;
    }
    
    .like-box {
        order: 3;
        width: 100%;
        margin-top: 8px;
    }
    
    .like-btn {
        padding: 14px 32px;
        font-size: 16px;
        width: auto;
        min-width: 180px;
        justify-content: center;
    }
    
    .rating-show {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 10px;
        margin-bottom: 6px;
    }
    
    .rating-score {
        font-size: 22px;
    }
    
    .rating-count {
        font-size: 14px;
    }
    
    .rating-tip {
        font-size: 13px;
        padding: 6px 12px;
        margin-top: 4px;
        display: inline-block;
    }
    
    /* 触摸优化 */
    .star {
        padding: 8px 2px;
        margin: 0 -2px;
    }
    
    .like-btn {
        padding: 16px 36px;
        margin: 8px 0;
    }
    
    /* 移动端悬停效果改为点击效果 */
    .star:active:not(.disabled) {
        transform: scale(1.3);
    }
    
    .like-btn:active:not(:disabled) {
        transform: scale(0.98);
    }
}

@media (max-width: 480px) {
    .rating-box {
        padding: 16px 18px;
        border-radius: 18px;
        max-width: 300px;
        gap: 14px;
    }
    
    .stars-container {
        font-size: 24px;
        height: 24px;
        width: 120px;
    }
    
    .stars-background, .stars-foreground {
        font-size: 24px;
        height: 24px;
        line-height: 24px;
    }
    
    .stars-interactive {
        height: 24px;
    }
    
    .star {
        font-size: 24px;
        width: 24px;
        height: 24px;
        line-height: 24px;
        flex: 0 0 24px;
        padding: 6px 1px;
    }
    
    .like-btn {
        padding: 15px 30px;
        font-size: 15px;
        min-width: 160px;
    }
    
    .rating-score {
        font-size: 20px;
    }
    
    .rating-count {
        font-size: 13px;
    }
    
    .rating-tip {
        font-size: 12px;
        padding: 5px 10px;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .rating-box {
        flex-direction: row;
        max-width: 500px;
        gap: 20px;
    }
    
    .rating-info {
        order: initial;
        text-align: left;
        flex: 1;
    }
    
    .stars-container {
        order: initial;
        margin: 0;
    }
    
    .like-box {
        order: initial;
        margin-top: 0;
    }
    
    .divider {
        width: 1px;
        height: 40px;
        background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1), transparent);
        margin: 0;
    }
}