/* =========================================
   Відгуки на сторінці товару
   ========================================= */

.product-reviews-section {
    margin-top: 56px;
    padding: 40px 0 48px;
    border-top: 1px solid var(--border-color, #e8e8e8);
}

/* --- Заголовок + середній рейтинг --- */

.product-reviews-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 32px;
}

.product-reviews-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--neutral-dark, #1a1a1a);
    margin: 0;
}

.product-reviews-summary {
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-avg-score {
    font-size: 28px;
    font-weight: 800;
    color: var(--neutral-dark, #1a1a1a);
    line-height: 1;
}

.product-avg-stars .star,
.product-review-stars .star {
    font-size: 18px;
    color: #f5a623;
    line-height: 1;
}

.product-avg-stars .star.empty,
.product-review-stars .star.empty {
    color: #d9d9d9;
}

.product-reviews-count {
    font-size: 14px;
    color: var(--text-secondary, #777);
}

/* --- Список відгуків --- */

.product-reviews-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 40px;
}

.product-review-card {
    background: var(--white, #fff);
    border: 1px solid var(--border-color, #e8e8e8);
    border-radius: 12px;
    padding: 20px 24px;
    transition: box-shadow 0.2s ease;
}

.product-review-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.product-review-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 10px;
}

.product-review-author {
    font-weight: 600;
    font-size: 15px;
    color: var(--neutral-dark, #1a1a1a);
}

.product-review-date {
    font-size: 13px;
    color: var(--text-secondary, #999);
    margin-left: auto;
}

.product-review-text {
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-primary, #333);
    margin: 0;
    white-space: pre-line;
}

.product-reviews-empty {
    font-size: 15px;
    color: var(--text-secondary, #999);
    margin-bottom: 32px;
}

/* --- Форма відгуку --- */

.product-review-form-wrap {
    background: var(--bg-light, #f8f8f8);
    border-radius: 16px;
    padding: 32px;
}

.review-form-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--neutral-dark, #1a1a1a);
    margin: 0 0 24px;
}

.product-review-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

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

.review-field input[type="text"],
.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, #fff);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

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

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

/* --- Зірки інтерактивні --- */

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

.star-pick {
    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;
}

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

.star-pick:hover {
    transform: scale(1.2);
}

/* --- Кнопка сабміт --- */

.review-submit-btn {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary, #e91e8c);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 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;
}

.review-submit-btn:hover {
    background: var(--primary-dark, #c4166e);
}

.review-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

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

/* --- Алерт --- */

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

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

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

/* --- Стан "вже відправлено" --- */

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

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

/* =========================================
   Tablet (768px–1024px)
   ========================================= */

@media (max-width: 1024px) {
    .product-reviews-section {
        margin-top: 40px;
        padding: 32px 0 40px;
    }

    .product-review-form-wrap {
        padding: 24px;
    }
}

/* =========================================
   Mobile (≤ 767px)
   ========================================= */

@media (max-width: 767px) {
    .product-reviews-section {
        margin-top: 32px;
        padding: 24px 0 32px;
    }

    .product-reviews-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 24px;
    }

    .product-reviews-title {
        font-size: 20px;
    }

    .product-review-form-wrap {
        padding: 20px 16px;
        border-radius: 12px;
    }

    .review-form-title {
        font-size: 18px;
    }

    .star-pick {
        font-size: 28px;
    }

    .review-submit-btn {
        width: 100%;
        justify-content: center;
    }

    .product-review-card {
        padding: 16px;
    }

    .product-review-date {
        margin-left: 0;
        width: 100%;
    }
}

/* =========================================
   iOS Safari — safe area & input fixes
   ========================================= */

@supports (-webkit-touch-callout: none) {
    .review-field input[type="text"],
    .review-field textarea {
        font-size: 16px; /* запобігає auto-zoom на iOS */
    }

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

    .product-reviews-section {
        padding-bottom: max(32px, env(safe-area-inset-bottom));
    }
}
