/* ═══════════════════════════════════════════════════════
   GM Reviews – Front-end Styles
   Green Meadow Memorials · Theme-aligned
   ═══════════════════════════════════════════════════════ */

/* ─── Variables (matching GM styleguide) ─── */
:root {
    --gm-green: #16b793;
    --gm-blue: #003b4d;
    --gm-muted: #495057;
    --gm-light-blue: #e5f3ef;
    --gm-gold: #e5a100;
    --gm-gray: #dee2e6;
    --gm-light-gray: #f8f9fa;
    --gm-danger: #dc3545;
    --gm-font-heading: 'quatro-slab', 'Quatro Slab', serif;
    --gm-font-body: 'open-sans', 'Open Sans', sans-serif;
}

/* ─── Section Layout ─── */
.gm-reviews {
    margin: 2rem 0;
    padding: 2rem 0;
    border-top: 1px solid #ccc;
}

.gm-reviews__heading {
    font-family: var(--gm-font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--gm-blue);
    margin-bottom: 1.5rem;
}

/* ─── Star SVG ─── */
.gm-star {
    display: inline-block;
    vertical-align: middle;
}

.gm-star--filled {
    fill: var(--gm-gold);
}

.gm-star--empty {
    fill: var(--gm-gray);
}

.gm-stars {
    display: inline-flex;
    gap: 2px;
    align-items: center;
}

.gm-stars--sm svg {
    width: 24px;
    height: 24px;
}

/* ─── Inline Rating (near product title) ─── */
.gm-rating-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 1rem;
    text-decoration: none;
    color: var(--gm-muted);
    font-size: 0.875rem;
}

.gm-rating-inline:hover {
    color: var(--gm-green);
    text-decoration: none;
}

.gm-rating-avg {
    font-family: var(--gm-font-body);
    font-weight: 600;
    color: var(--gm-dark);
}

.gm-rating-count {
    font-family: var(--gm-font-body);
    color: var(--gm-green);
}

.gm-rating-inline:hover .gm-rating-count {
    text-decoration: underline;
}

.gm-rating-inline--empty {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    margin: 0.5rem 0;
    font-size: 0.875rem;
}

.gm-rating-label {
    font-family: var(--gm-font-body);
    color: var(--gm-muted);
}

/* ─── Aggregate Summary ─── */
.gm-reviews__summary {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: var(--gm-light-gray);
    border-radius: 8px;
}

.gm-reviews__summary-score {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.gm-reviews__avg {
    font-family: var(--gm-font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--gm-blue);
    line-height: 1;
}

.gm-reviews__summary-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.gm-reviews__total {
    font-size: 0.875rem;
    color: var(--gm-muted);
}

/* Distribution bars */
.gm-reviews__distribution {
    flex: 1;
    min-width: 0;
}

.gm-reviews__dist-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.gm-reviews__dist-label {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 2rem;
    font-size: 0.875rem;
    color: var(--gm-muted);
    justify-content: flex-end;
    flex-shrink: 0;
}

.gm-reviews__dist-bar {
    flex: 1;
    height: 8px;
    background: var(--gm-gray);
    border-radius: 4px;
    overflow: hidden;
}

.gm-reviews__dist-fill {
    height: 100%;
    background: var(--gm-gold);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.gm-reviews__dist-count {
    width: 1.5rem;
    font-size: 0.875rem;
    color: var(--gm-muted);
    text-align: right;
    flex-shrink: 0;
}

.gm-reviews__empty {
    color: var(--gm-muted);
    font-style: italic;
    margin-bottom: 1.5rem;
}

/* ─── Actions ─── */
.gm-reviews__actions {
    margin-bottom: 1.5rem;
}

/* ─── Review Form ─── */
.gm-review-form {
    padding: 1.5rem;
    background: var(--gm-light-gray);
    border-radius: 8px;
    margin-bottom: 2rem;
    position: relative;
}

.gm-form-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--gm-blue);
    margin-bottom: 0.35rem;
    display: block;
}

/* Star input widget */
.gm-star-input {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 4px;
}

.gm-star-input__radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.gm-star-input__label {
    cursor: pointer;
    padding: 4px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: transform 0.1s ease;
}

.gm-star-input__label svg {
    width: 36px;
    height: 36px;
    fill: none;
    stroke: var(--gm-muted);
    stroke-width: 1.5;
    transition: fill 0.15s ease, stroke 0.15s ease;
}

.gm-star-input__label:hover svg,
.gm-star-input__label:hover ~ .gm-star-input__label svg {
    fill: var(--gm-gold);
    stroke: var(--gm-gold);
}

.gm-star-input__radio:checked ~ .gm-star-input__label svg {
    fill: var(--gm-gold);
    stroke: var(--gm-gold);
}

.gm-star-input__radio:focus + .gm-star-input__label {
    outline: 2px solid var(--gm-green);
    outline-offset: 2px;
}

.gm-star-input__label:active {
    transform: scale(1.15);
}

/* Image upload */
.gm-image-upload {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.gm-image-upload__previews {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.gm-image-upload__preview {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--gm-gray);
}

.gm-image-upload__preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gm-image-upload__remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.gm-image-upload__btn {
    width: 80px;
    height: 80px;
    border: 2px dashed var(--gm-gray);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--gm-muted);
    transition: border-color 0.2s ease, color 0.2s ease;
}

.gm-image-upload__btn:hover {
    border-color: var(--gm-green);
    color: var(--gm-green);
}

/* ─── Review List ─── */
.gm-review-list {
    margin-top: 1.5rem;
}

.gm-review {
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--gm-gray);
}

.gm-review:last-child {
    border-bottom: none;
}

.gm-review__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.gm-review__meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.gm-review__author {
    font-weight: 600;
    color: var(--gm-blue);
    font-size: 0.9rem;
}

.gm-review__date {
    color: var(--gm-muted);
    font-size: 0.875rem;
}

.gm-review__badges {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* Badges (inline bg per styleguide) */
.gm-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 6px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.4;
}

.gm-badge--verified {
    background: var(--gm-green);
    color: #fff;
}

.gm-badge--shared {
    background: var(--gm-light-blue);
    color: var(--gm-blue);
}

/* Review layout (thumbnail left, content right) */
.gm-review--has-thumb {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.gm-review__thumb {
    flex-shrink: 0;
    display: block;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--gm-gray);
    transition: border-color 0.2s ease;
}

a.gm-review__thumb:hover {
    border-color: var(--gm-green);
}

.gm-review__logo-thumb {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 150px;
}

.gm-review__logo-img {
    display: block;
    max-width: 100%;
    height: auto;
}

.gm-review__thumb-img {
    display: block;
    width: 150px;
    height: 150px;
    object-fit: contain;
}

.gm-review__body {
    flex: 1;
    min-width: 0;
}

.gm-review__product-name {
    display: block;
    font-family: var(--gm-font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--gm-blue);
    text-decoration: none;
    margin-bottom: 0.35rem;
}

.gm-review__product-name:hover {
    color: var(--gm-green);
    text-decoration: underline;
}

.gm-review__content {
    font-size: 0.9rem;
    color: var(--gm-blue);
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

/* Review images */
.gm-review__images {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.gm-review__image-link {
    display: block;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--gm-gray);
    transition: border-color 0.2s ease;
}

.gm-review__image-link:hover {
    border-color: var(--gm-green);
}

.gm-review__image {
    display: block;
    width: 80px;
    height: 80px;
    object-fit: cover;
}

/* Company response */
.gm-review__response {
    background: var(--gm-light-blue);
    padding: 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--gm-green);
    margin: 0.75rem 0;
}

.gm-review__response-author {
    font-size: 0.875rem;
    color: var(--gm-blue);
    display: block;
    margin-bottom: 0.25rem;
}

.gm-review__response-content {
    font-size: 0.875rem;
    color: var(--gm-blue);
    line-height: 1.5;
    margin: 0;
}

/* Helpful voting */
.gm-review__footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.gm-review__helpful-label {
    font-size: 0.875rem;
    color: var(--gm-muted);
}

.gm-vote-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: none;
    border: 1px solid var(--gm-gray);
    border-radius: 6px;
    padding: 0.35rem 0.65rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--gm-muted);
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.gm-vote-btn:hover {
    border-color: var(--gm-green);
    color: var(--gm-green);
}

.gm-vote-btn.voted {
    background: var(--gm-light-blue);
    border-color: var(--gm-green);
    color: var(--gm-green);
    pointer-events: none;
}

.gm-vote-count {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Load more */
.gm-reviews__load-more {
    text-align: center;
    padding: 1.5rem 0;
}

/* ─── Homepage Reviews (inside .gm-testimonials) ─── */
.gm-home-reviews__actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.gm-testimonials .gm-review-form {
    background: #fff;
    margin-top: 1rem;
}

.gm-testimonials .gm-reviews__empty {
    color: var(--gm-muted);
    font-style: italic;
    margin-bottom: 0;
}

/* ─── Reviews Page Hero Banner ─── */
.gm-reviews-hero {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: var(--gm-light-gray);
    padding: 3rem 3.5rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
}

.gm-reviews-hero__title {
    font-family: var(--gm-font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--gm-blue);
    margin: 0;
    flex-shrink: 0;
    line-height: 1.1;
}

.gm-reviews-hero__divider {
    width: 2px;
    align-self: stretch;
    background: var(--gm-gray);
    flex-shrink: 0;
}

.gm-reviews-hero__text {
    font-family: var(--gm-font-body);
    font-size: 1.05rem;
    color: var(--gm-muted);
    line-height: 1.65;
    margin: 0;
    max-width: 42rem;
}

.gm-reviews-hero__cta {
    text-align: center;
    margin-bottom: 1.5rem;
}

@media (max-width: 767px) {
    .gm-reviews-hero {
        flex-direction: column;
        gap: 1rem;
        padding: 2rem 1.5rem;
        text-align: center;
    }

    .gm-reviews-hero__title {
        font-size: 2rem;
    }

    .gm-reviews-hero__divider {
        width: 60px;
        height: 2px;
        align-self: center;
    }
}

/* ─── Public Reviews Page ─── */
.gm-reviews--page {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

/* Clean up theme wrapper styles on the reviews page */
.page-wrapper:has(.gm-reviews--page) {
    border: none;
    box-shadow: none;
}

.page-wrapper:has(.gm-reviews--page) .page-content {
    padding: 0;
}

.page-wrapper:has(.gm-reviews--page) .page-header {
    display: none;
}

.gm-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--gm-light-gray);
    border-radius: 8px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.gm-page-header__count {
    font-family: var(--gm-font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gm-blue);
}

.gm-reviews__filter-tabs {
    display: flex;
    width: fit-content;
    margin: 0 auto 1.5rem;
    background: var(--gm-light-gray);
    border-radius: 8px;
    padding: 4px;
    gap: 2px;
}

.gm-filter-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.5rem 1.35rem;
    font-family: var(--gm-font-body);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gm-muted);
    text-decoration: none;
    border-radius: 6px;
    background: transparent;
    transition: color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
    white-space: nowrap;
}

.gm-filter-tab:hover {
    color: var(--gm-blue);
    text-decoration: none;
}

.gm-filter-tab--active {
    background: #fff;
    color: var(--gm-blue);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 59, 77, 0.1), 0 1px 2px rgba(0, 59, 77, 0.06);
}

/* ─── Product List Rating (category/search pages) ─── */
.gm-list-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.gm-list-rating__avg {
    font-family: var(--gm-font-body);
    font-weight: 600;
    font-size: 0.875rem;
    color: #9f9f9f;
}

.gm-list-rating__stars {
    display: inline-flex;
    gap: 1px;
    align-items: center;
}

.gm-list-rating__count {
    font-size: 0.8rem;
    color: #9f9f9f;
    font-family: var(--gm-font-body);
}

/* ─── Product Card Rating (homepage top sellers) ─── */
.gm-product-card__rating .gm-list-rating {
    justify-content: flex-start;
    gap: 0.35rem;
    margin-top: 0;
    margin-bottom: 0.3rem;
}

.gm-product-card__rating .gm-list-rating__avg {
    display: none;
}

.gm-product-card__rating .gm-list-rating__stars {
    gap: 0;
}

.gm-product-card__rating .gm-list-rating__stars svg {
    width: 0.65rem;
    height: 0.65rem;
}

.gm-product-card__rating .gm-list-rating__count {
    font-size: 0.7rem;
    color: #9f9f9f;
}

/* ─── Pagination ─── */
.gm-pagination {
    margin-top: 2rem;
    padding-top: 1rem;
}

.gm-pagination__list {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}

.gm-pagination__link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gm-gray);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: var(--gm-font-body);
    color: var(--gm-blue);
    text-decoration: none;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.gm-pagination__link:hover {
    border-color: var(--gm-green);
    color: var(--gm-green);
    text-decoration: none;
}

.gm-pagination__link--current {
    background: var(--gm-green);
    border-color: var(--gm-green);
    color: #fff;
    font-weight: 600;
    cursor: default;
}

.gm-pagination__link--current:hover {
    background: var(--gm-green);
    color: #fff;
}

.gm-pagination__ellipsis {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    color: var(--gm-muted);
    font-size: 0.875rem;
    cursor: default;
}

/* ─── Mobile Responsive ─── */
@media (max-width: 575px) {
    .gm-review--has-thumb {
        flex-direction: row;
        gap: 0.75rem;
    }

    .gm-review__thumb-img {
        width: 80px;
        height: 80px;
    }

    .gm-review__logo-thumb {
        width: 80px;
    }

    .gm-review__product-name {
        font-size: 0.95rem;
    }

    .gm-reviews__summary {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .gm-reviews__summary-score {
        justify-content: center;
        width: 100%;
    }

    .gm-reviews__distribution {
        width: 100%;
    }

    .gm-page-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        padding: 1rem;
    }

    .gm-page-header .btn {
        width: 100%;
    }

    .gm-review__header {
        flex-direction: column;
    }

    .gm-review__image {
        width: 60px;
        height: 60px;
    }

    .gm-image-upload__btn,
    .gm-image-upload__preview {
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 767px) {
    .gm-reviews__avg {
        font-size: 2rem;
    }
}
