/* Стили для раздела отзывов */
#product-reviews-section {
    background-color: #fdf8f0; /* Очень светлый персиковый, почти белый */
}

.review-card {
    background-color: white;
    border: 1px solid #f3e5d8; /* Светлее чем soft-peach */
    border-radius: 12px;
    padding: 1rem;
    transition: box-shadow 0.2s ease-in-out;
}

.reviews-preview .review-item {
    padding: 0.5rem 0.5rem; /* tighter horizontal padding */
    margin-bottom: 0.4rem;
}

/* Align reviews preview with section title width (when placed right after .pm-section-title) */
.pm-section-title + .reviews-preview,
.reviews-preview.pm-aligned {
    padding-left: 0; /* align to section title left edge */
    padding-right: 0;
    margin-left: 0;
    margin-right: 0;
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.review-compact {
    gap: 0.75rem;
}

/* Align author name to the left and verified badge to the right in the compact row.
   Prevent name+badge wrapping by truncating the name and forcing badge to not wrap. */
.review-compact > .flex-shrink-0 {
    /* ensure avatar is flush left inside its cell */
    margin-left: 0;
    margin-right: 0;
}

.review-compact .flex-1 {
    min-width: 0; /* allow children to truncate properly */
}

/* the inner row that currently contains name + badge */
.review-compact .flex-1 > .flex.items-center {
    display: flex;
    justify-content: space-between; /* name left, badge right */
    align-items: center;
    gap: 0.5rem;
}

.review-compact .review-author-name,
.review-compact .review-author {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    max-width: calc(100% - 6rem); /* leave room for badge */
}

/* Also apply to markup that uses utility classes instead of .review-author-name */
.review-compact .flex-1 > .flex.items-center > span:first-child,
.review-compact .flex-1 > .flex.items-center > .text-sm {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    max-width: calc(100% - 6rem);
}

.review-compact .verified-badge {
    white-space: nowrap;
    flex-shrink: 0; /* don't let badge shrink or wrap */
    margin-left: 0.5rem;
}

.review-author {
    font-weight: 600;
    color: var(--dark-eggplant);
}

.review-date {
    font-size: 0.75rem;
    color: #a0a0a0;
}

.review-rating .star.filled {
    color: var(--muted-gold) !important;
}

.review-rating .star {
    color: #e0e0e0;
}

/* Semantic star styling (used across product modal and reviews) */
.star {
    color: #e0e0e0; /* fallback light gray */
}
.star.filled {
    color: var(--muted-gold, #DAA520) !important; /* use theme muted gold, fallback to #DAA520 */
}

/* Ensure any remaining Tailwind utility usages for yellow stars match theme color.
   This is an override for legacy/generated CSS (tailwind.output.css) and can be removed
   if you prefer adjusting the Tailwind config instead. */
.text-yellow-400 {
    color: var(--muted-gold, #DAA520) !important;
}

/* Right-align the compact stars row in the preview so stars don't stretch across whole width */
.reviews-preview .review-item .flex.items-center.gap-1.mb-1,
.reviews-preview .review-item .review-rating-row {
    display: flex;
    justify-content: flex-end; /* push stars to the right */
    align-items: center;
    gap: 0.25rem;
}

.review-comment {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #555;
}

.review-content .pm-rich-paragraph {
    margin: 0; /* Reset paragraph margin to avoid extra spacing issues on mobile */
}

.review-helpful {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.helpful-btn {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 16px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    /* Убрана анимация hover для предотвращения подергивания */
}

.helpful-btn.liked {
    background-color: var(--terracotta);
    color: white;
    border-color: var(--terracotta);
    pointer-events: none;
}

/* Visual state for optimistic 'liked' before server confirms */
.helpful-btn.liked {
    background-color: var(--sage-green, #16a34a);
    color: white;
    border-color: transparent;
}

/* Disabled button appearance (after click or while processing) */
.helpful-btn[disabled], .helpful-btn[data-processing="1"] {
    opacity: 0.7;
    cursor: default;
}

/* Mobile-specific spacing improvements */
@media (max-width: 640px) {
    .reviews-preview {
        padding: 0.25rem 0.5rem; /* reduced breathing space on mobile */
    }

    .reviews-preview .review-item {
        padding: 0.5rem 0.25rem; /* tighter vertical/horizontal padding on mobile */
        margin-bottom: 0.35rem;
    }

    .reviews-preview .review-item .review-compact {
        align-items: flex-start;
        gap: 0.75rem;
    }

    .reviews-preview .review-item .flex-shrink-0 > div,
    .review-avatar, .my-review-product-image {
        width: 40px;
        height: 40px;
        min-width: 40px;
        border-radius: 9999px;
        font-size: 0.85rem;
    }

    .review-author, .review-author-name {
        font-size: 0.95rem;
    }

    .review-content {
        font-size: 0.95rem;
        line-height: 1.6;
        margin-top: 0.25rem;
    }

    .review-date, .review-helpful, .review-actions, .review-footer {
        font-size: 0.8rem;
    }

    /* Soften borders in preview for mobile */
    .reviews-preview .review-item {
        border-bottom: 1px solid rgba(0,0,0,0.04);
    }
}

/* Стили для формы добавления отзыва */
#review-star-rating .star {
    /* Убрана анимация hover для предотвращения подергивания */
}

#review-star-rating .star.selected {
    color: var(--muted-gold);
}

/* === ГИБРИДНЫЙ БЛОК ОТЗЫВОВ === */

/* Основной контейнер гибридного блока отзывов */
.hybrid-reviews-card {
    position: relative;
    background: linear-gradient(135deg, #fefefe 0%, #fdf9f5 100%);
    border: 1px solid #f0e6d8;
    border-radius: 16px;
    overflow: hidden;
    /* Убрана анимация hover для предотвращения подергивания */
}

/* Превью отзывов */
.reviews-preview {
    max-height: 200px;
    /* enable internal scrolling when there are many reviews */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS */
    position: relative;
}

.reviews-preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, rgba(254, 254, 254, 0.9), transparent);
    pointer-events: none;
}

/* Элементы отзывов */
.review-item {
    /* Убрана анимация hover для предотвращения подергивания */
}

/* NOTE: compact sizing moved to .review-compact to avoid affecting full reviews modal */


/* Utility class to apply compact sizing to arbitrary containers (used in product modal preview) */
.review-compact {
    min-height: 70px;
}

/* show-all-reviews-btn styles removed (button deprecated) */

/* Значки проверенной покупки */
.verified-badge {
    animation: verifiedPulse 2s ease-in-out infinite;
}

/* Fallback: ensure a star inside verified badge appears gold even if 'filled' class
   wasn't generated (covers cached/legacy templates or load-order issues). */
.verified-badge .star {
    color: var(--muted-gold, #DAA520) !important;
    font-size: 0.875rem; /* match .text-sm */
    line-height: 1;
}

/* Метка для гостевых отзывов (не верифицированные пользователи) */
.guest-label {
    font-size: 0.85rem;
    color: #374151; /* gray-700 */
    background: #f3f4f6; /* gray-100 */
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    display: inline-block;
}

@keyframes verifiedPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* Модальное окно отзывов */
#hybrid-reviews-modal {
    backdrop-filter: blur(4px);
    z-index: 90; /* Выше чем у confirmation-modal (z-[80]) и product-detail-modal (z-[70]) */
}

#hybrid-reviews-modal > div {
    animation: modalSlideIn 0.3s ease-out;
    /* Use unified modal sizing: max-w-md, responsive width, modal max height variable */
    box-shadow: 0 8px 32px rgba(138, 154, 91, 0.18);
    max-width: 28rem; /* Tailwind max-w-md */
    width: 100%;
    height: var(--modal-max-height);
    min-height: 300px;
    max-height: var(--modal-max-height);
    overflow: hidden;
    background: var(--off-white, #FDF8F0);
    border-radius: .75rem; /* rounded-xl */
    border: 1px solid rgba(138, 154, 91, 0.2);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Адаптивность */
@media (max-width: 640px) {
    .hybrid-reviews-card {
        border-radius: 12px;
    }

    /* На мобильных уменьшаем высоту превью отзывов до 70px */
    .reviews-preview {
        max-height: 70px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* show-all-reviews-btn styles removed (button deprecated) */

    #hybrid-reviews-modal > div {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
    }
}

/* Ensure when the modal is open and the page behind should not scroll, the modal body itself
   manages overflow. This keeps the header/actions visible while allowing users to scroll reviews. */
#hybrid-reviews-modal .modal-content {
    display: flex;
    flex-direction: column;
}

#hybrid-reviews-modal-body {
    /* allow the body to scroll independently, with a sensible max-height */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(var(--modal-max-height, 80vh) - 140px);
}

/* Ensure hybrid reviews modal shows full content and body scrolls internally */
#hybrid-reviews-modal .modal-content {
    max-height: 90vh;
    width: 100%;
}

#hybrid-reviews-modal-body {
    max-height: calc(90vh - 120px);
    overflow-y: auto;
}

/* Темная тема (если понадобится) */
@media (prefers-color-scheme: dark) {
    .hybrid-reviews-card {
        background: linear-gradient(135deg, #2d2d2d 0%, #252525 100%);
        border-color: #404040;
    }

    /* Убрана анимация hover для предотвращения подергивания */
}