/* ============================================
   Стили для блока отзывов (Интеграция с темой)
   ============================================ */

.review-widget {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: var(--space-xl);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all var(--transition-base);
    margin: var(--space-xl) auto;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.review-widget .section-title {
    margin-top: 0;
    margin-bottom: var(--space-xl);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--space-sm);
}

/* Декоративное свечение на фоне карточки */
.review-widget::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, hsla(var(--accent-h), var(--accent-s), var(--accent-l), 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.rating-interactive-step {
    text-align: center;
    margin-bottom: var(--space-md);
    position: relative;
    z-index: 1;
}

.rating-label {
    font-size: var(--text-base);
    margin-bottom: var(--space-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

/* 
  Волнообразная анимация звезд (Staggered Hover)
*/
.stars-input {
    display: inline-flex;
    justify-content: center;
    gap: var(--space-sm);
    cursor: pointer;
    /* Позволяет управлять всеми дочерними элементами при наведении на контейнер */
}

.star-item {
    font-size: var(--text-4xl);
    color: var(--border-hover);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        color 0.3s ease,
        text-shadow 0.3s ease;
    user-select: none;
    line-height: 1;
    position: relative;
    /* Устанавливаем задержку для плавного возврата */
    transition-delay: calc(var(--star-idx) * 0.03s);
}

/* Каскадные индексы для волнообразного эффекта */
.star-item:nth-child(1) {
    --star-idx: 0;
}

.star-item:nth-child(2) {
    --star-idx: 1;
}

.star-item:nth-child(3) {
    --star-idx: 2;
}

.star-item:nth-child(4) {
    --star-idx: 3;
}

.star-item:nth-child(5) {
    --star-idx: 4;
}

/* Активное состояние (после клика или ховера из JS) */
.star-item.active,
.star-item.hover {
    color: var(--star-yellow);
    transform: scale(1.15) translateY(-2px);
    text-shadow: 0 0 15px var(--star-glow);
    /* При активации задержка убирается для мгновенного отклика */
    transition-delay: 0s;
}

/* Эффект при наведении мышью на конкретную звезду:
   Подсвечиваем её чуть сильнее */
.star-item:hover {
    transform: scale(1.25) translateY(-4px);
    text-shadow: 0 0 20px var(--star-glow-hover);
}


/* Область раскрытия */
.review-expand-area {
    margin-top: var(--space-lg);
    animation: slideDownReview 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
    z-index: 1;
}

.hidden {
    display: none !important;
}

@keyframes slideDownReview {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.comment-section label {
    display: block;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

textarea.review-area {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: var(--space-md);
    font-family: inherit;
    resize: none;
    box-sizing: border-box;
    outline: none;
    margin-bottom: var(--space-md);
    transition: all var(--transition-base);
}

textarea.review-area:hover {
    background: var(--bg-input-focus);
}

textarea.review-area:focus {
    background: var(--bg-glass);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-submit-review {
    width: 100%;
    background: var(--accent-gradient);
    color: var(--accent-contrast);
    border: none;
    padding: var(--space-md);
    border-radius: var(--radius-full);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.btn-submit-review::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn-submit-review:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-submit-review:hover::after {
    opacity: 1;
}

/* Футер и список отзывов */
.review-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-lg) 0;
}

.review-actions-footer {
    text-align: center;
    position: relative;
    z-index: 1;
}

.btn-text-action {
    background: none;
    border: none;
    color: var(--text-accent);
    text-underline-offset: 4px;
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: color var(--transition-fast);
}

.btn-text-action:hover {
    color: var(--accent-primary-hover);
}

.reviews-list-container {
    margin-top: var(--space-lg);
    animation: fadeIn 0.3s ease forwards;
}

.short-stats {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.avg-val {
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--text-primary);
}

.avg-stars {
    color: var(--star-yellow);
    letter-spacing: 2px;
}

.reviews-count {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.reviews-items {
    max-height: 400px;
    overflow-y: auto;
    padding-right: var(--space-sm);
}

/* Индивидуальный отзыв */
.review-item {
    margin-bottom: var(--space-md);
    padding: var(--space-lg) !important;
    position: relative;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    transition: all 0.3s ease;
    border-radius: var(--radius-lg);
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-sm);
    gap: var(--space-sm);
}

.review-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.review-author {
    font-weight: 700;
    color: var(--text-primary);
    font-size: var(--text-base);
}

.review-date {
    font-size: var(--text-xs);
    color: var(--text-muted);
    opacity: 0.7;
}

.review-rating {
    color: var(--star-yellow);
    font-size: var(--text-sm);
    letter-spacing: 1px;
    white-space: nowrap;
}

.review-text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.review-body {
    margin-top: var(--space-xs);
}

/* Compatibility classes handled by multiple selectors above */

.review-error-msg {
    color: var(--danger);
    font-size: var(--text-xs);
    margin-top: calc(var(--space-md) * -1 + 4px);
    margin-bottom: var(--space-md);
    display: none;
}

/* ============================================
   Адаптивность для мобильных устройств
   ============================================ */

@media (max-width: 768px) {
    .review-widget {
        padding: var(--space-lg);
        margin: var(--space-md) auto;
        border-radius: var(--radius-lg);
    }

    .star-item {
        font-size: var(--text-3xl);
    }

    .avg-val {
        font-size: var(--text-xl);
    }

    .short-stats {
        flex-wrap: wrap;
        margin-bottom: var(--space-md);
    }

    .review-user-info {
        gap: 0;
    }

    .review-author {
        font-size: var(--text-sm);
    }

    .review-date {
        font-size: 10px;
    }

    .review-rating {
        font-size: 10px;
    }

    textarea.review-area {
        font-size: var(--text-sm);
        padding: var(--space-sm);
    }

    .btn-submit-review {
        padding: var(--space-sm) var(--space-md);
        font-size: var(--text-sm);
    }

    .review-divider {
        margin: var(--space-md) 0;
    }

    .reviews-items {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .review-widget {
        padding: var(--space-md);
        border-radius: var(--radius-md);
    }

    .star-item {
        font-size: var(--text-2xl);
        gap: var(--space-xs);
    }

    .stars-input {
        gap: var(--space-xs);
    }

    .comment-section label {
        font-size: var(--text-xs);
    }
}

/* Особенный стиль для отзывов текущего пользователя */
.my-review-item {
    border-color: var(--success) !important;
    background: rgba(16, 185, 129, 0.04) !important;
}

.review-status-tag {
    display: inline-block;
    margin-top: var(--space-sm);
    font-size: 10px;
    padding: 4px 10px;
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border-radius: 4px;
    font-weight: 600;
}

.review-status-tag.rejected {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.review-status-tag small {
    display: block;
    margin-top: 2px;
    font-weight: 400;
    opacity: 0.9;
    font-style: italic;
}