/* ==========================================================================
   Flavor Reviews — Frontend Widget
   Google-style review cards with slider, source tabs, dark/light modes.
   ========================================================================== */

:root {
    --fr-accent: #1a73e8;
    --fr-star: #f4b400;
}

/* ---- Reset scoped to widget — override WP themes ---- */
.flavor-reviews-widget *,
.flavor-reviews-widget *::before,
.flavor-reviews-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.flavor-reviews-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.5;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 0;
    position: relative;
}

/* ---- Theme override protection ---- */
.flavor-reviews-widget a,
.flavor-reviews-widget a:visited,
.flavor-reviews-widget a:focus {
    color: inherit;
    text-decoration: none;
}

.flavor-reviews-widget button {
    font-family: inherit;
    outline: none;
}

.flavor-reviews-widget button:focus,
.flavor-reviews-widget a:focus {
    outline: none;
}

/* ============================================================
   LIGHT MODE (default)
   ============================================================ */
.flavor-reviews-widget[data-mode="light"] {
    --fr-bg: #ffffff;
    --fr-bg-card: #ffffff;
    --fr-bg-header: #f8f9fa;
    --fr-text: #202124;
    --fr-text-secondary: #5f6368;
    --fr-text-muted: #9aa0a6;
    --fr-border: #e8eaed;
    --fr-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --fr-shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
    --fr-tab-bg: #f1f3f4;
    --fr-tab-active-bg: var(--fr-accent);
    --fr-tab-active-text: #ffffff;
    --fr-tab-text: #5f6368;
    --fr-avatar-bg: #e8eaed;
    --fr-avatar-text: #5f6368;
}

/* ============================================================
   DARK MODE
   ============================================================ */
.flavor-reviews-widget[data-mode="dark"] {
    --fr-bg: #1a1a2e;
    --fr-bg-card: #16213e;
    --fr-bg-header: #0f3460;
    --fr-text: #e8e8e8;
    --fr-text-secondary: #b0b0b0;
    --fr-text-muted: #787878;
    --fr-border: #2a2a4a;
    --fr-shadow: 0 2px 8px rgba(0,0,0,0.3);
    --fr-shadow-hover: 0 6px 20px rgba(0,0,0,0.4);
    --fr-tab-bg: #2a2a4a;
    --fr-tab-active-bg: var(--fr-accent);
    --fr-tab-active-text: #ffffff;
    --fr-tab-text: #b0b0b0;
    --fr-avatar-bg: #2a2a4a;
    --fr-avatar-text: #b0b0b0;
}

/* ============================================================
   HEADER — Centered rating summary (Google Reviews style)
   ============================================================ */
.fr-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 28px 24px;
    background: var(--fr-bg-header);
    border-radius: 16px;
    margin-bottom: 20px;
    text-align: center;
}

.fr-header__rating-block {
    display: flex;
    align-items: center;
    gap: 16px;
}

.fr-header__score {
    font-size: 56px;
    font-weight: 700;
    color: var(--fr-text);
    line-height: 1;
    letter-spacing: -2px;
}

.fr-header__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.fr-header__stars {
    display: flex;
    gap: 2px;
}

.fr-header__count {
    font-size: 14px;
    color: var(--fr-text-secondary);
    font-weight: 500;
}

.fr-header__sources {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.fr-header__source-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--fr-bg-card);
    border: 1px solid var(--fr-border);
    border-radius: 20px;
    font-size: 12px;
    color: var(--fr-text-secondary) !important;
    font-weight: 500;
    text-decoration: none !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.fr-header__source-badge:hover {
    border-color: var(--fr-accent) !important;
    box-shadow: 0 0 0 1px var(--fr-accent);
    color: var(--fr-text-secondary) !important;
}

.fr-header__source-badge img {
    width: 16px;
    height: 16px;
    object-fit: contain;
    flex-shrink: 0;
}

/* ============================================================
   SOURCE TABS
   ============================================================ */
.fr-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding: 0 4px;
    flex-wrap: wrap;
}

.fr-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--fr-border) !important;
    background: var(--fr-tab-bg) !important;
    color: var(--fr-tab-text) !important;
    transition: all 0.25s ease;
    user-select: none;
    white-space: nowrap;
    text-decoration: none !important;
}

.fr-tab:hover,
.fr-tab:focus {
    border-color: var(--fr-accent) !important;
    color: var(--fr-accent) !important;
    background: var(--fr-tab-bg) !important;
}

.fr-tab--active {
    background: var(--fr-tab-active-bg) !important;
    color: var(--fr-tab-active-text) !important;
    border-color: transparent !important;
}

.fr-tab--active:hover,
.fr-tab--active:focus {
    color: var(--fr-tab-active-text) !important;
    background: var(--fr-tab-active-bg) !important;
    opacity: 0.9;
}

.fr-tab img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
    /* Logo floats outside the pill's visual line — not clipped */
    margin: -4px 0;
}

.fr-tab__count {
    background: rgba(255,255,255,0.2);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
}

.fr-tab--active .fr-tab__count {
    background: rgba(255,255,255,0.25);
}

/* ============================================================
   SLIDER CONTAINER
   ============================================================ */
.fr-slider-wrapper {
    position: relative;
    overflow: hidden;
}

.fr-slider {
    display: flex;
    gap: 16px;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.fr-slider--dragging {
    transition: none;
    cursor: grabbing;
}

/* ============================================================
   NAV ARROWS
   ============================================================ */
.fr-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--fr-bg-card) !important;
    border: 1px solid var(--fr-border) !important;
    box-shadow: var(--fr-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    transition: all 0.2s;
    color: var(--fr-text) !important;
}

.fr-nav:hover,
.fr-nav:focus {
    box-shadow: var(--fr-shadow-hover);
    background: var(--fr-accent) !important;
    color: #fff !important;
    border-color: var(--fr-accent) !important;
}

.fr-nav--prev {
    left: -8px;
}

.fr-nav--next {
    right: -8px;
}

.fr-nav--disabled {
    opacity: 0.3;
    pointer-events: none;
}

.fr-nav svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ============================================================
   REVIEW CARD
   ============================================================ */
.fr-card {
    flex: 0 0 calc(33.333% - 11px);
    min-width: 280px;
    background: var(--fr-bg-card);
    border: 1px solid var(--fr-border);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--fr-shadow);
    transition: box-shadow 0.25s, transform 0.25s;
    position: relative;
    overflow: hidden;
}

.fr-card:hover {
    box-shadow: var(--fr-shadow-hover);
    transform: translateY(-2px);
}

/* Source icon in top-right of card */
.fr-card__source-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fr-card__source-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Card header with avatar + name */
.fr-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 32px; /* make room for source icon */
}

.fr-card__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--fr-avatar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fr-card__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.fr-card__avatar-initials {
    font-size: 16px;
    font-weight: 600;
    color: var(--fr-avatar-text);
    text-transform: uppercase;
    line-height: 1;
}

.fr-card__info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.fr-card__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--fr-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fr-card__date {
    font-size: 12px;
    color: var(--fr-text-muted);
}

/* Stars */
.fr-card__stars {
    display: flex;
    gap: 2px;
}

/* Review text */
.fr-card__text {
    font-size: 14px;
    color: var(--fr-text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.fr-card__read-more {
    font-size: 13px;
    font-weight: 500;
    color: var(--fr-accent) !important;
    cursor: pointer;
    background: none !important;
    border: none !important;
    padding: 0;
    text-align: left;
}

.fr-card__read-more:hover,
.fr-card__read-more:focus {
    color: var(--fr-accent) !important;
    text-decoration: underline;
    background: none !important;
}

/* Featured badge */
.fr-card--featured {
    border-color: var(--fr-accent);
    border-width: 2px;
}

.fr-card--featured::before {
    content: '★ Featured';
    position: absolute;
    top: 0;
    left: 0;
    background: var(--fr-accent);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 10px;
    border-radius: 0 0 8px 0;
}

/* ============================================================
   STAR SVGs
   ============================================================ */
.fr-star {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.fr-star--header {
    width: 22px;
    height: 22px;
}

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

.fr-star--half {
    color: var(--fr-star);
}

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

/* ============================================================
   PAGINATION DOTS
   ============================================================ */
.fr-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.fr-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--fr-border);
    cursor: pointer;
    transition: all 0.25s;
}

.fr-dot--active {
    background: var(--fr-accent);
    width: 24px;
    border-radius: 4px;
}

/* ============================================================
   MODAL — Read More
   ============================================================ */
.fr-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.fr-modal-overlay--open {
    opacity: 1;
    visibility: visible;
}

.fr-modal {
    background: var(--fr-bg-card);
    border-radius: 16px;
    padding: 32px;
    max-width: 520px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.fr-modal-overlay--open .fr-modal {
    transform: translateY(0);
}

.fr-modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none !important;
    background: var(--fr-tab-bg) !important;
    color: var(--fr-text) !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.fr-modal__close:hover,
.fr-modal__close:focus {
    background: var(--fr-border) !important;
    color: var(--fr-text) !important;
}

.fr-modal__header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding-right: 40px;
}

.fr-modal__avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--fr-avatar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fr-modal__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fr-modal__name {
    font-size: 16px;
    font-weight: 600;
    color: var(--fr-text);
}

.fr-modal__date {
    font-size: 13px;
    color: var(--fr-text-muted);
}

.fr-modal__stars {
    display: flex;
    gap: 2px;
    margin-bottom: 12px;
}

.fr-modal__text {
    font-size: 15px;
    color: var(--fr-text-secondary);
    line-height: 1.7;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .fr-card {
        flex: 0 0 calc(50% - 8px);
    }
}

@media (max-width: 768px) {
    .fr-header {
        padding: 20px 16px;
        gap: 10px;
    }

    .fr-header__score {
        font-size: 44px;
    }

    .fr-tabs {
        gap: 6px;
    }

    .fr-tab {
        padding: 6px 14px;
        font-size: 13px;
    }

    .fr-card {
        flex: 0 0 calc(100% - 0px);
        min-width: unset;
    }

    .fr-nav {
        width: 34px;
        height: 34px;
    }

    .fr-nav--prev { left: 4px; }
    .fr-nav--next { right: 4px; }
}

@media (max-width: 480px) {
    .flavor-reviews-widget {
        padding: 16px 0;
    }

    .fr-header {
        border-radius: 12px;
    }

    .fr-card {
        padding: 16px;
        border-radius: 12px;
    }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.fr-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--fr-text-muted);
}

.fr-empty__icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.fr-empty__text {
    font-size: 15px;
}

/* ============================================================
   ANIMATION — Fade in cards
   ============================================================ */
@keyframes fr-fade-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fr-card {
    animation: fr-fade-in 0.4s ease both;
}

.fr-card:nth-child(1) { animation-delay: 0s; }
.fr-card:nth-child(2) { animation-delay: 0.08s; }
.fr-card:nth-child(3) { animation-delay: 0.16s; }
.fr-card:nth-child(4) { animation-delay: 0.24s; }
.fr-card:nth-child(5) { animation-delay: 0.32s; }
