/* Секція відгуків */

.reviews-section {
    padding: 60px 0;
    margin-top: 40px; /* Відступ від основного контенту */
    clear: both; /* Гарантує що секція не перекривається з sidebar */
}

.reviews-section .section-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--neutral-dark);
    margin-bottom: 40px;
    text-align: center;
}

.reviews-slider-container {
    position: relative;
    padding: 0 50px;
}

.reviews-slider {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    padding: 20px 0;
    margin: 0 -12px;
    padding: 20px 12px;
}

.reviews-slider::-webkit-scrollbar {
    display: none;
}

.review-card {
    flex: 0 0 380px;
    background: var(--white);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.review-card.expanded {
    height: auto;
}

.review-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.review-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-light);
}

.review-product-image {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--gray-light);
}

.review-author-info {
    flex: 1;
}

.review-author-name {
    font-weight: 600;
    color: var(--neutral-dark);
    font-size: 16px;
    margin-bottom: 4px;
}

.review-rating {
    display: flex;
    gap: 4px;
}

.star {
    font-size: 16px;
    color: var(--badge-top);
}

.star.empty {
    color: var(--gray-medium);
}

.review-category-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(74, 144, 217, 0.1);
    color: var(--color-cta-primary);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.review-text {
    color: var(--neutral-medium);
    line-height: 1.6;
    font-size: 14px;
    position: relative;
}

.review-text.collapsed {
    max-height: 60px;
    overflow: hidden;
}

.review-text.collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, var(--white));
}

.review-text.expanded {
    max-height: none;
    overflow: visible;
}

.review-read-more {
    background: none;
    border: none;
    color: var(--color-cta-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-align: left;
    transition: opacity 0.3s ease;
}

.review-read-more:hover {
    opacity: 0.8;
}

.review-date {
    font-size: 12px;
    color: var(--gray-medium);
    text-align: right;
}

.reviews-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--white);
    border: 2px solid var(--gray-light);
    color: var(--neutral-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 2;
}

.reviews-nav-btn:hover {
    background: var(--color-cta-primary);
    border-color: var(--color-cta-primary);
    color: var(--white);
}

.reviews-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.reviews-prev-btn {
    left: 0;
}

.reviews-next-btn {
    right: 0;
}

/* Порожній стан */

.reviews-empty-state {
    text-align: center;
    padding: 40px 20px;
}

.reviews-empty-text {
    font-size: 16px;
    color: var(--neutral-medium);
    margin-bottom: 20px;
}

.reviews-empty-cta {
    display: inline-block;
    padding: 12px 28px;
    background: var(--color-cta-primary);
    color: var(--white);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.reviews-empty-cta:hover {
    opacity: 0.85;
}

/* Планшетна версія */
@media (max-width: 1024px) {
    .reviews-section {
        padding: 50px 0;
    }

    .reviews-section .section-title {
        font-size: 28px;
        margin-bottom: 32px;
    }

    .reviews-slider-container {
        padding: 0 45px;
    }

    .review-card {
        flex: 0 0 320px;
        padding: 20px;
    }

    .reviews-slider {
        gap: 20px;
    }
}

/* Мобільна версія */
@media (max-width: 767.98px) {
    .reviews-section {
        padding: 40px 0;
    }

    .reviews-section .section-title {
        font-size: 24px;
        margin-bottom: 24px;
    }

    .reviews-slider-container {
        padding: 0 40px;
    }

    .review-card {
        flex: 0 0 calc(100vw - 100px);
        padding: 16px;
    }
    
    .review-card.expanded {
        height: auto;
    }

    .reviews-slider {
        gap: 20px;
        padding: 16px 10px;
        margin: 0 -10px;
    }

    .review-header {
        padding-bottom: 12px;
    }

    .review-product-image {
        width: 40px;
        height: 40px;
    }

    .review-author-name {
        font-size: 14px;
    }

    .review-rating .star {
        font-size: 14px;
    }

    .review-text {
        font-size: 13px;
    }
    
    .review-text.collapsed {
        max-height: 55px;
    }

    .reviews-nav-btn {
        width: 36px;
        height: 36px;
    }

    .reviews-nav-btn svg {
        width: 20px;
        height: 20px;
    }
}

/* Дуже маленькі екрани */
@media (max-width: 375px) {
    .reviews-slider-container {
        padding: 0 35px;
    }

    .review-card {
        flex: 0 0 260px;
        padding: 14px;
    }

    .reviews-nav-btn {
        width: 32px;
        height: 32px;
    }
}

/* iOS Safari оптимізації */
@supports (-webkit-touch-callout: none) {
    .reviews-slider {
        -webkit-overflow-scrolling: touch;
    }

    .review-card {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }

    .reviews-nav-btn {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .reviews-slider,
    .review-card,
    .reviews-nav-btn {
        transition: none;
    }
}

/* =========================================
   Заголовок секції відгуків + кнопка
   ========================================= */

.reviews-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 32px;
}

.reviews-section-header .section-title {
    margin-bottom: 0;
}

.reviews-write-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--color-cta-primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.reviews-write-btn:hover {
    opacity: 0.85;
}

/* =========================================
   Модальне вікно відгуків
   ========================================= */

.home-review-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.25s ease;
    -webkit-overflow-scrolling: touch;
}

.home-review-overlay.is-open {
    display: flex;
    opacity: 1;
}

.home-review-modal {
    position: relative;
    background: var(--white);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.25s ease;
    -webkit-overflow-scrolling: touch;
}

.home-review-overlay.is-open .home-review-modal {
    transform: translateY(0);
}

.home-review-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: var(--neutral-medium);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.home-review-close:hover {
    background: var(--gray-light);
    color: var(--neutral-dark);
}

.home-review-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--neutral-dark);
    margin: 0 0 24px;
    padding-right: 32px;
}

/* --- Форма --- */

.home-review-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.home-review-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.home-review-field label {
    font-size: 14px;
    font-weight: 600;
    color: var(--neutral-dark);
}

.home-review-field input[type="text"],
.home-review-field textarea {
    width: 100%;
    border: 1.5px solid var(--border-color, #ddd);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary, #333);
    background: var(--white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

.home-review-field input[type="text"]:focus,
.home-review-field textarea:focus {
    outline: none;
    border-color: var(--color-cta-primary);
    box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.1);
}

.home-review-field textarea {
    resize: vertical;
    min-height: 96px;
}

/* --- Product search --- */

.home-product-search-wrap {
    position: relative;
}

.home-product-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--white);
    border: 1.5px solid var(--border-color, #ddd);
    border-radius: 8px;
    list-style: none;
    margin: 0;
    padding: 4px 0;
    z-index: 10;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.home-product-result-item {
    padding: 10px 14px;
    font-size: 14px;
    color: var(--neutral-dark);
    cursor: pointer;
    transition: background 0.15s ease;
}

.home-product-result-item:hover {
    background: var(--gray-light, #f5f5f5);
}

.home-product-result-empty {
    color: var(--neutral-medium);
    cursor: default;
}

.home-review-hint {
    font-size: 12px;
    color: var(--neutral-medium);
}

.home-review-hint.hint-ok {
    color: #2e7d32;
}

/* --- Зірки --- */

.home-star-picker {
    display: flex;
    gap: 4px;
}

.home-star-btn {
    background: none;
    border: none;
    padding: 4px 2px;
    font-size: 32px;
    color: #d9d9d9;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.home-star-btn.active,
.home-star-btn.hovered {
    color: #f5a623;
}

.home-star-btn:hover {
    transform: scale(1.15);
}

/* --- Alert --- */

.home-review-alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}

.home-review-alert.alert-error {
    background: #fce4ec;
    color: #c62828;
    border: 1px solid #f48fb1;
}

.home-review-alert.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

/* --- Submit button --- */

.home-review-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--color-cta-primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    padding: 13px 28px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s ease, opacity 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.home-review-submit:hover {
    opacity: 0.88;
}

.home-review-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.home-review-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: hrSpin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes hrSpin {
    to { transform: rotate(360deg); }
}

/* --- Success state --- */

.home-review-done {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 16px 0 8px;
    text-align: center;
}

.home-review-done p {
    font-size: 16px;
    font-weight: 600;
    color: #2e7d32;
    margin: 0;
}

.home-review-done-close {
    background: none;
    border: 1.5px solid var(--border-color, #ddd);
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    color: var(--neutral-dark);
    transition: background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.home-review-done-close:hover {
    background: var(--gray-light, #f5f5f5);
}

/* =========================================
   Адаптив — планшет (≤ 1024px)
   ========================================= */

@media (max-width: 1024px) {
    .home-review-modal {
        padding: 24px;
    }
}

/* =========================================
   Адаптив — мобільний (≤ 767px)
   ========================================= */

@media (max-width: 767px) {
    .reviews-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 24px;
    }

    .reviews-write-btn {
        width: 100%;
        justify-content: center;
    }

    .home-review-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .home-review-modal {
        border-radius: 20px 20px 0 0;
        max-height: 92vh;
        padding: 24px 20px;
    }

    .home-review-title {
        font-size: 19px;
    }

    .home-star-btn {
        font-size: 28px;
    }

    .home-review-submit {
        width: 100%;
    }
}

/* =========================================
   iOS Safari — safe area, input zoom fix
   ========================================= */

@supports (-webkit-touch-callout: none) {
    .home-review-field input[type="text"],
    .home-review-field textarea {
        font-size: 16px;
    }

    .home-review-overlay {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .home-review-modal {
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }

    .home-review-submit {
        padding-bottom: max(13px, env(safe-area-inset-bottom));
    }
}

/* =========================================
   Reduced motion
   ========================================= */

@media (prefers-reduced-motion: reduce) {
    .home-review-overlay,
    .home-review-modal {
        transition: none;
    }

    .home-review-spinner {
        animation: none;
    }
}
