/* =========================================================================
   Google Reviews Showcase — Frontend Styles
   BEM with .grs- prefix. RTL-ready via logical properties.
   ========================================================================= */

/* --- CSS Custom Properties (Theme Tokens) --- */
:root {
    --grs-bg: transparent;
    --grs-card-bg: #ffffff;
    --grs-text: #333333;
    --grs-text-secondary: #666666;
    --grs-star-color: #fbbc04;
    --grs-star-empty: #dadce0;
    --grs-border: #e0e0e0;
    --grs-border-radius: 8px;
    --grs-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --grs-font-family: inherit;
    --grs-reply-bg: #f8f9fa;
    --grs-avatar-bg: #e8eaed;
    --grs-avatar-text: #5f6368;
    --grs-btn-bg: #1a73e8;
    --grs-btn-text: #ffffff;
    --grs-btn-hover: #1557b0;
}

/* --- Dark Theme --- */
.grs-theme-dark {
    --grs-bg: transparent;
    --grs-card-bg: #1e1e1e;
    --grs-text: #e8eaed;
    --grs-text-secondary: #9aa0a6;
    --grs-border: #3c4043;
    --grs-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --grs-reply-bg: #2d2d2d;
    --grs-avatar-bg: #3c4043;
    --grs-avatar-text: #e8eaed;
    --grs-btn-bg: #8ab4f8;
    --grs-btn-text: #1e1e1e;
    --grs-btn-hover: #aecbfa;
}

/* --- Wrapper --- */
.grs-wrapper {
    font-family: var(--grs-font-family);
    color: var(--grs-text);
    line-height: 1.5;
    max-width: 100%;
}

/* --- Rating Header --- */
.grs-rating-header-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}
.grs-rating-header {
    display: inline-flex;
    align-items: center;
    gap: 0;
    margin-bottom: 0;
    background: var(--grs-card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    overflow: hidden;
    max-width: 100%;
}

/* Score block: big number + stars stacked */
.grs-rating-header__score-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 20px;
    gap: 4px;
    background: var(--grs-card-bg);
}

.grs-rating-header__score {
    font-size: 2.4em;
    font-weight: 800;
    color: var(--grs-text);
    line-height: 1;
}

.grs-rating-header__stars {
    display: flex;
    gap: 1px;
}

.grs-rating-header__stars .grs-star {
    font-size: 16px;
}

/* Vertical divider */
.grs-rating-header__divider {
    width: 1px;
    height: 44px;
    background: var(--grs-border);
    flex-shrink: 0;
}

/* Info block: count + platform */
.grs-rating-header__info {
    display: flex;
    flex-direction: column;
    padding: 14px 20px;
    gap: 4px;
}

.grs-rating-header__count {
    font-size: 1.05em;
    font-weight: 700;
    color: var(--grs-text);
}

.grs-rating-header__platform {
    font-size: 0.82em;
    color: var(--grs-text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- Stars --- */
.grs-star {
    font-size: 18px;
    line-height: 1;
}

.grs-star--filled {
    color: var(--grs-star-color);
}

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

.grs-star--half {
    color: var(--grs-star-color);
    position: relative;
}

/* --- Card (shared by all layouts) --- */
.grs-card {
    background: var(--grs-card-bg);
    border: 1px solid var(--grs-border);
    border-radius: var(--grs-border-radius);
    padding: 20px;
    box-shadow: var(--grs-shadow);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.grs-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.grs-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.grs-card__avatar {
    flex-shrink: 0;
}

.grs-card__avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.grs-card__avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--grs-avatar-bg);
    color: var(--grs-avatar-text);
    font-size: 18px;
    font-weight: 600;
    text-transform: uppercase;
}

.grs-card__meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.grs-card__author {
    font-weight: 600;
    font-size: 0.95em;
    color: var(--grs-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grs-card__date {
    font-size: 0.8em;
    color: var(--grs-text-secondary);
}

.grs-card__google-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    margin-inline-start: auto;
}

.grs-card__rating {
    display: flex;
    gap: 1px;
    margin-bottom: 10px;
}

.grs-card__text {
    font-size: 0.93em;
    color: var(--grs-text);
    word-break: break-word;
}

.grs-read-more {
    background: none;
    border: none;
    color: var(--grs-btn-bg);
    cursor: pointer;
    padding: 0;
    font-size: 0.9em;
    font-weight: 500;
    margin-inline-start: 4px;
}

.grs-read-more:hover {
    text-decoration: underline;
}

.grs-card__reply {
    margin-top: 12px;
    padding: 12px;
    background: var(--grs-reply-bg);
    border-radius: 6px;
    border-inline-start: 3px solid var(--grs-border);
}

.grs-card__reply-label {
    font-weight: 600;
    font-size: 0.85em;
    color: var(--grs-text-secondary);
    display: block;
    margin-bottom: 4px;
}

.grs-card__reply-text {
    margin: 0;
    font-size: 0.88em;
    color: var(--grs-text-secondary);
}

/* --- Masonry Layout --- */
.grs-masonry {
    column-gap: 20px;
}

.grs-masonry .grs-card {
    break-inside: avoid;
    margin-bottom: 20px;
    display: inline-block;
    width: 100%;
}

/* Fade-in animation for cards */
.grs-masonry .grs-card {
    animation: grsFadeInUp 0.4s ease both;
}

@keyframes grsFadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation for new cards (load more) */
.grs-card--new {
    animation-delay: calc(var(--grs-card-index, 0) * 0.05s);
}

/* =========================================================================
   Grid Layout — equal-height styled cards
   ========================================================================= */

.grs-grid {
    display: grid;
    gap: 20px;
}

/* Legacy fallback — shared review-card inside grid */
.grs-grid .grs-card {
    display: flex;
    flex-direction: column;
}
.grs-grid .grs-card__text {
    flex: 1;
}

/* --- Styled grid card --- */
.grs-grid--styled {
    gap: 20px;
}

.grs-grid-card {
    background: var(--grs-card-bg);
    border-radius: 12px;
    padding: 20px 20px 18px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.grs-grid-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

/* Header row: avatar + meta + G icon */
.grs-grid-card__header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.grs-grid-card__avatar-wrap {
    flex-shrink: 0;
}

.grs-grid-card__avatar-img,
.grs-grid-card__avatar-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    flex-shrink: 0;
}

.grs-grid-card__avatar-placeholder {
    font-size: 19px;
    font-weight: 700;
    color: #fff;
}

.grs-grid-card__meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.grs-grid-card__author {
    font-weight: 700;
    font-size: 0.92em;
    color: var(--grs-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grs-grid-card__date {
    font-size: 0.76em;
    color: var(--grs-text-secondary);
    margin-top: 1px;
}

.grs-grid-card__g-icon {
    flex-shrink: 0;
    margin-inline-start: auto;
    display: flex;
    align-items: center;
}

/* Stars row */
.grs-grid-card__stars {
    display: flex;
    gap: 1px;
}

.grs-grid-card__stars .grs-star {
    font-size: 16px;
}

/* Text body */
.grs-grid-card__text {
    font-size: 0.88em;
    color: var(--grs-text-secondary);
    line-height: 1.6;
    word-break: break-word;
    flex: 1;
}

.grs-grid-card__text-content {
    display: block;
}

/* Responsive */
@media (max-width: 1024px) {
    .grs-grid--styled {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 640px) {
    .grs-grid--styled {
        grid-template-columns: 1fr !important;
    }
}

/* =========================================================================
   Slider Layout — 3-up card carousel
   ========================================================================= */

.grs-slider--cards {
    width: 100%;
    box-sizing: border-box;
}

/* Flex row: [prev] [viewport] [next] */
.grs-slider__row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.grs-slider__viewport {
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.grs-slider--cards .grs-slider__track {
    display: flex;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.grs-slider--cards .grs-slider__slide {
    flex-shrink: 0;
    padding: 0 10px;
    box-sizing: border-box;
}

/* --- Slider Card (centered avatar style) --- */
.grs-slider-card {
    background: var(--grs-card-bg);
    border-radius: 12px;
    padding: 24px 20px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 220px;
    transition: box-shadow 0.2s ease;
}

.grs-slider-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.13);
}

.grs-slider-card__avatar-wrap {
    position: relative;
    margin-bottom: 12px;
    display: inline-block;
}

.grs-slider-card__avatar-img,
.grs-slider-card__avatar-placeholder {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
}

.grs-slider-card__avatar-placeholder {
    font-size: 26px;
    font-weight: 700;
    color: #fff;
}

/* Small Google badge overlaid on avatar bottom-right */
.grs-slider-card__g-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    background: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.grs-slider-card__name {
    font-weight: 700;
    font-size: 0.95em;
    color: var(--grs-text);
    margin-bottom: 6px;
    text-align: center;
}

.grs-slider-card__stars {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    margin-bottom: 10px;
}

.grs-slider-card__date {
    font-size: 0.78em;
    color: var(--grs-text-secondary);
    margin-inline-start: 6px;
}

.grs-slider-card__text {
    font-size: 0.88em;
    color: var(--grs-text-secondary);
    text-align: start;
    line-height: 1.55;
    word-break: break-word;
    flex: 1;
    width: 100%;
}

.grs-slider-card__text-content {
    display: block;
}

/* --- Slider Nav Buttons — flex siblings, NOT absolute --- */
.grs-slider__prev,
.grs-slider__next {
    flex-shrink: 0;
    background: var(--grs-card-bg);
    border: 1.5px solid var(--grs-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--grs-text-secondary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    transition: background 0.2s, color 0.2s;
    line-height: 1;
    padding: 0;
    align-self: center;
}

.grs-slider__prev:hover,
.grs-slider__next:hover {
    background: var(--grs-reply-bg);
    color: var(--grs-text);
}

/* --- Dots --- */
.grs-slider__dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 18px 0 4px;
}

.grs-slider__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: none;
    background: var(--grs-star-empty);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s, transform 0.2s;
}

.grs-slider__dot--active {
    background: var(--grs-btn-bg);
    transform: scale(1.25);
}

/* RTL slider: g-badge flips side */
[dir="rtl"] .grs-slider-card__g-badge {
    right: auto;
    left: 0;
}

/* =========================================================================
   Inline Layout — full-width single quote card
   ========================================================================= */

.grs-inline {
    position: relative;
    width: 100%;
}

.grs-inline__track {
    position: relative;
}

.grs-inline__slide {
    display: none;
}

.grs-inline__slide--active {
    display: block;
}

.grs-inline__card {
    position: relative;
    background: var(--grs-card-bg);
    border-radius: 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
    padding: 36px 72px 28px;
    box-sizing: border-box;
    min-height: 140px;
}

/* Decorative large quote marks */
.grs-inline__quote-open,
.grs-inline__quote-close {
    position: absolute;
    font-size: 72px;
    font-weight: 900;
    line-height: 1;
    color: #e8971a;
    pointer-events: none;
    user-select: none;
    font-family: Georgia, serif;
}

.grs-inline__quote-open {
    top: 10px;
    left: 20px;
}

.grs-inline__quote-close {
    bottom: 0;
    right: 20px;
}

/* Nav arrows inside the card — bare chevrons */
.grs-inline__prev,
.grs-inline__next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    color: var(--grs-text-secondary);
    padding: 0 8px;
    z-index: 2;
    transition: color 0.2s;
}

.grs-inline__prev:hover,
.grs-inline__next:hover {
    color: var(--grs-text);
}

.grs-inline__prev {
    left: 10px;
}

.grs-inline__next {
    right: 10px;
}

.grs-inline__body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.grs-inline__text {
    margin: 0;
    font-size: 1em;
    font-style: italic;
    color: var(--grs-text);
    text-align: center;
    line-height: 1.65;
    max-width: 680px;
}

.grs-inline__text--empty {
    color: var(--grs-star-color);
    font-style: normal;
    letter-spacing: 2px;
}

.grs-inline__byline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.grs-inline__author-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.grs-inline__author-name {
    font-weight: 700;
    font-size: 0.95em;
    color: var(--grs-text);
}

.grs-inline__view-link {
    font-size: 0.78em;
    color: var(--grs-text-secondary);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 3px;
}

.grs-inline__avatar-img,
.grs-inline__avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.grs-inline__avatar-placeholder {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

/* RTL inline */
[dir="rtl"] .grs-inline__quote-open {
    left: auto;
    right: 20px;
}
[dir="rtl"] .grs-inline__quote-close {
    right: auto;
    left: 20px;
}
[dir="rtl"] .grs-inline__prev {
    left: auto;
    right: 10px;
}
[dir="rtl"] .grs-inline__next {
    right: auto;
    left: 10px;
}

/* Inline responsive */
@media (max-width: 767px) {
    .grs-inline__card {
        padding: 32px 48px 24px;
    }
    .grs-inline__quote-open,
    .grs-inline__quote-close {
        font-size: 52px;
    }
    .grs-inline__prev {
        left: 4px;
    }
    .grs-inline__next {
        right: 4px;
    }
}

/* --- List Layout --- */
.grs-list .grs-list__item {
    margin-bottom: 16px;
}

.grs-list .grs-card {
    max-width: 100%;
}

/* --- Badge Layout (new widget style) --- */
.grs-badge-widget {
    display: inline-flex;
    align-items: center;
    gap: 0;
    background: var(--grs-card-bg);
    border: 1px solid var(--grs-border);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    overflow: hidden;
    text-decoration: none;
    color: var(--grs-text);
    transition: box-shadow 0.2s;
}

a.grs-badge-widget:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
}

.grs-badge-widget__score-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 18px;
    gap: 4px;
}

.grs-badge-widget__score {
    font-size: 2em;
    font-weight: 800;
    color: var(--grs-text);
    line-height: 1;
}

.grs-badge-widget__stars {
    display: flex;
    gap: 1px;
}

.grs-badge-widget__stars .grs-star {
    font-size: 14px;
}

.grs-badge-widget__divider {
    width: 1px;
    height: 40px;
    background: var(--grs-border);
    flex-shrink: 0;
}

.grs-badge-widget__info {
    display: flex;
    flex-direction: column;
    padding: 12px 18px;
    gap: 3px;
}

.grs-badge-widget__count {
    font-size: 0.95em;
    font-weight: 700;
    color: var(--grs-text);
}

.grs-badge-widget__platform {
    font-size: 0.78em;
    color: var(--grs-text-secondary);
    display: flex;
    align-items: center;
    gap: 3px;
}

/* Legacy badge (kept for backward compat) */
.grs-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--grs-card-bg);
    border: 1px solid var(--grs-border);
    border-radius: 24px;
    padding: 8px 16px;
    box-shadow: var(--grs-shadow);
    font-size: 15px;
    text-decoration: none;
    color: var(--grs-text);
}
.grs-badge__star { color: var(--grs-star-color); font-size: 18px; }
.grs-badge__rating { font-weight: 700; }
.grs-badge__count { color: var(--grs-text-secondary); font-size: 0.9em; }

/* --- Load More Button --- */
.grs-load-more-wrap {
    text-align: center;
    padding: 24px 0 8px;
}

.grs-load-more {
    display: inline-block;
    background: var(--grs-btn-bg);
    color: var(--grs-btn-text);
    border: none;
    border-radius: var(--grs-border-radius);
    padding: 12px 32px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.grs-load-more:hover {
    background: var(--grs-btn-hover);
}

.grs-load-more:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- No Reviews Message --- */
.grs-no-reviews {
    text-align: center;
    color: var(--grs-text-secondary);
    padding: 40px 20px;
    font-style: italic;
}

/* =========================================================================
   RTL Support
   Uses logical properties throughout (inline-start/end, margin-inline, etc.)
   but add explicit RTL overrides for older browser compat.
   ========================================================================= */
[dir="rtl"] .grs-wrapper,
.grs-wrapper[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .grs-card__header {
    flex-direction: row;
}

[dir="rtl"] .grs-rating-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .grs-slider__prev {
    right: auto;
    left: auto;
}

[dir="rtl"] .grs-slider__next {
    left: auto;
    right: auto;
}

[dir="rtl"] .grs-card__reply {
    border-right: 3px solid var(--grs-border);
    border-left: none;
}

/* =========================================================================
   Responsive
   ========================================================================= */

/* Tablet */
@media (max-width: 1024px) {
    .grs-masonry {
        column-count: 2 !important;
    }

    .grs-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .grs-masonry {
        column-count: 1 !important;
    }

    .grs-grid {
        grid-template-columns: 1fr !important;
    }

    .grs-card {
        padding: 16px;
    }


    .grs-slider__prev,
    .grs-slider__next {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .grs-badge {
        font-size: 13px;
        padding: 6px 12px;
    }
}

/* RTL mobile fix */
@media (max-width: 767px) {
    .grs-rating-header {
        display: flex;
        width: 100%;
    }
}
