/* RightReviews — storefront widget styles
   All colors come from CSS variables on the block element so merchant settings flow through.
   We isolate styles with high specificity (.rightreviews-block .x) to survive aggressive theme CSS. */

/* Inherit the merchant's storefront font instead of forcing Inter — that's
   how Loox/Judge.me look "native" to whatever theme they're dropped into.
   Falls back to the system stack if the theme doesn't set a font. */
.rightreviews-block,
.rightreviews-summary {
  font-family: inherit, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--rr-text, #1A1C1E);
  box-sizing: border-box;
}

.rightreviews-block *,
.rightreviews-summary * { box-sizing: border-box; }

.rightreviews-block { margin: 40px 0; scroll-margin-top: 80px; }

/* Loading skeleton */
.rightreviews-block .rr-loading {
  color: transparent;
  font-size: 0;
  padding: 40px 0;
  position: relative;
}
.rightreviews-block .rr-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #EFEDF0 0%, #F4F3F6 50%, #EFEDF0 100%);
  background-size: 200% 100%;
  border-radius: 8px;
  animation: rr-shimmer 1.4s linear infinite;
  height: 140px;
}
@keyframes rr-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   Top header bar — Loox-style summary pill + actions
   ============================================================ */
.rightreviews-block .rr-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.rightreviews-block .rr-bar-left {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.rightreviews-block .rr-bar-left:hover .rr-bar-count { color: #000; }
.rightreviews-block .rr-bar-stars { display: inline-flex; gap: 3px; align-items: center; }
.rightreviews-block .rr-bar-stars .rr-star { width: 24px; height: 24px; }
.rightreviews-block .rr-bar-count {
  font-weight: 600;
  font-size: 18px;
  color: var(--rr-text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .15s ease;
}
.rightreviews-block .rr-bar-caret {
  width: 14px; height: 14px;
  color: var(--rr-text);
  transition: transform .2s ease;
}
.rightreviews-block .rr-bar-actions { display: inline-flex; gap: 8px; align-items: center; }

/* Mobile: filter icon stays in the bar, Write-a-review drops to a full-width row below. */
.rightreviews-block .rr-write-mobile {
  display: none;
}
@media (max-width: 540px) {
  .rightreviews-block .rr-bar { gap: 8px; }
  .rightreviews-block .rr-bar-actions .rr-write-desktop { display: none; }
  .rightreviews-block .rr-write-mobile {
    display: block;
    width: 100%;
    margin: 0 0 24px;
  }
  .rightreviews-block .rr-write-mobile .rr-action-btn {
    width: 100%;
    height: 48px;
    font-size: 15px;
    justify-content: center;
  }
  .rightreviews-block .rr-bar-stars .rr-star { width: 22px; height: 22px; }
  .rightreviews-block .rr-bar-count { font-size: 17px; }
  .rightreviews-block .rr-card-media-more { font-size: 11px; padding: 3px 7px; }
}

.rightreviews-block .rr-action-btn {
  height: 40px;
  padding: 0 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--rr-line, #E3E2E5);
  background: var(--rr-card, #FFFFFF);
  color: var(--rr-text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s ease, border-color .15s ease;
  text-decoration: none;
  line-height: 1;
}
.rightreviews-block .rr-action-btn:hover { background: #FAFAFA; border-color: #C4C6CE; }
.rightreviews-block .rr-icon-btn {
  width: 40px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ============================================================
   Summary panel (collapsed by default; opens on bar click).
   Layout matches Loox: large average + star on left, full-width
   distribution rows stacked vertically on the right.
   ============================================================ */
.rightreviews-block .rr-summary-panel {
  margin-bottom: 32px;
  padding: 24px 4px;
  display: none;
  grid-template-columns: 200px 1fr;
  align-items: center;
  gap: 32px;
  border-bottom: 1px solid var(--rr-line, #E3E2E5);
}
.rightreviews-block .rr-summary-panel.is-open { display: grid; }
@media (max-width: 720px) {
  .rightreviews-block .rr-summary-panel { grid-template-columns: 1fr; gap: 20px; }
}

.rightreviews-block .rr-summary-avg {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}
.rightreviews-block .rr-summary-avg .rr-star { width: 36px; height: 36px; }
.rightreviews-block .rr-avg-num {
  font-size: 56px;
  font-weight: 600;
  line-height: 1;
  color: var(--rr-text);
  letter-spacing: -0.02em;
}

.rightreviews-block .rr-distribution { display: flex; flex-direction: column; gap: 6px; }
.rightreviews-block .rr-dist-row {
  display: grid;
  grid-template-columns: auto 1fr 44px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--rr-muted);
}
.rightreviews-block .rr-dist-stars { display: inline-flex; gap: 2px; }
.rightreviews-block .rr-dist-stars .rr-star { width: 14px; height: 14px; }
.rightreviews-block .rr-dist-bar { height: 8px; background: #F1F2F4; border-radius: 9999px; overflow: hidden; }
.rightreviews-block .rr-dist-bar > span { display: block; height: 100%; background: var(--rr-star); transition: width .5s ease; }
.rightreviews-block .rr-dist-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--rr-text);
}

/* ============================================================
   Reviews — CSS columns gives the Loox-style staggered/masonry
   look without JS layout calculations. Cards keep natural height.
   ============================================================ */
.rightreviews-block .rr-masonry {
  column-count: 4;
  column-gap: 14px;
}
@media (max-width: 1280px) { .rightreviews-block .rr-masonry { column-count: 3; column-gap: 14px; } }
@media (max-width: 900px)  { .rightreviews-block .rr-masonry { column-count: 2; column-gap: 12px; } }
@media (max-width: 540px)  { .rightreviews-block .rr-masonry { column-count: 2; column-gap: 10px; } }
@media (max-width: 380px)  { .rightreviews-block .rr-masonry { column-count: 1; } }

.rightreviews-block .rr-card {
  background: var(--rr-card, #FFFFFF);
  border: 1px solid var(--rr-line, #E3E2E5);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0 0 14px;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
}

.rightreviews-block .rr-card-media {
  position: relative;
  background: #F4F3F6;
  cursor: zoom-in;
  overflow: hidden;
  display: block;
}
.rightreviews-block .rr-card-media img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform .4s ease;
}
.rightreviews-block .rr-card-media:hover img { transform: scale(1.03); }
.rightreviews-block .rr-card-media-more {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
}

.rightreviews-block .rr-card-body {
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rightreviews-block .rr-name-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  font-weight: 600;
  color: var(--rr-text);
  flex-wrap: nowrap;
  min-width: 0;
}
.rightreviews-block .rr-name-row > span:first-child {
  /* Truncate long names with an ellipsis so the Verified badge stays inline. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.rightreviews-block .rr-verified-icon {
  width: 14px;
  height: 14px;
  color: #008060;
  flex-shrink: 0;
}
.rightreviews-block .rr-verified-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--rr-muted);
  flex-shrink: 0;
  white-space: nowrap;
}
.rightreviews-block .rr-date {
  font-size: 12px;
  color: var(--rr-muted);
}
.rightreviews-block .rr-card-stars { display: inline-flex; gap: 2px; align-items: center; margin-top: 1px; }
.rightreviews-block .rr-card-stars .rr-star { width: 16px; height: 16px; }

.rightreviews-block .rr-body {
  color: var(--rr-text);
  font-size: 14px;
  line-height: 1.5;
  margin: 4px 0 0;
  white-space: pre-line;
}
.rightreviews-block .rr-review-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--rr-text);
  margin: 2px 0 0;
}

/* SVG star — single source of truth */
.rr-star { display: inline-block; }
.rr-star path { fill: var(--rr-empty, #E3E2E5); }
.rr-star.is-on path { fill: var(--rr-star, #EBBF20); }
.rightreviews-block .rr-stars-large .rr-star { width: 26px; height: 26px; }

/* ============================================================
   Show more / pagination
   ============================================================ */
.rightreviews-block .rr-show-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 36px;
}
.rightreviews-block .rr-show-more {
  height: 44px;
  padding: 0 28px;
  border-radius: 6px;
  background: var(--rr-card);
  border: 1px solid var(--rr-line);
  color: var(--rr-text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.rightreviews-block .rr-show-more:hover { background: #FAFAFA; border-color: #C4C6CE; }

/* ============================================================
   Empty state — branded, intentional, on-brand
   ============================================================ */
.rightreviews-block .rr-empty {
  padding: 56px 24px;
  text-align: center;
  background: var(--rr-card);
  border: 1px solid var(--rr-line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.rightreviews-block .rr-empty-stars { opacity: 0.9; }
.rightreviews-block .rr-empty-stars .rr-star { width: 28px; height: 28px; }
.rightreviews-block .rr-empty-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--rr-text);
  margin: 4px 0 0;
}
.rightreviews-block .rr-empty-body {
  font-size: 14px;
  color: var(--rr-muted);
  max-width: 360px;
  line-height: 1.55;
  margin: 0;
}
.rightreviews-block .rr-empty-cta {
  margin-top: 8px;
}

/* ============================================================
   Star summary block (compact, on PDP near price).
   We force horizontal inline-flex with !important to survive
   theme parent stylesheets that try to stack inline children.
   ============================================================ */
/* Star summary — sized via the --rr-sum-size CSS var the merchant configures
   in the theme editor. Star gap + count text both scale off that var so the
   block looks balanced at any size (Loox's bigger stars + bigger count text). */
.rightreviews-summary {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: calc(var(--rr-sum-size, 22px) * 0.4);
  text-decoration: none;
  color: var(--rr-text);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  /* Count text is proportional to star size (≈0.85x), capped on the small end */
  font-size: max(13px, calc(var(--rr-sum-size, 22px) * 0.85));
}
.rightreviews-summary.is-block { display: flex !important; }
.rightreviews-summary.is-center { justify-content: center; }
.rightreviews-summary.is-right { justify-content: flex-end; }
.rightreviews-summary .rr-sum-stars {
  display: inline-flex !important;
  flex-direction: row !important;
  gap: calc(var(--rr-sum-size, 22px) * 0.12);
  align-items: center;
}
.rightreviews-summary .rr-sum-stars .rr-star {
  width: var(--rr-sum-size, 22px);
  height: var(--rr-sum-size, 22px);
}
.rightreviews-summary .rr-sum-text {
  color: var(--rr-text);
  font-weight: 500;
}
.rightreviews-summary.is-empty { color: var(--rr-muted); }

/* ============================================================
   Write-a-review modal
   ============================================================ */
.rr-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: rr-fade .15s ease;
}
@keyframes rr-fade { from { opacity: 0 } to { opacity: 1 } }
.rr-modal {
  background: #FFFFFF;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow: auto;
  padding: 24px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1A1C1E;
}
.rr-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 8px;
}
.rr-modal-title { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.rr-modal-close {
  width: 32px; height: 32px; border-radius: 9999px;
  background: transparent; border: 0; cursor: pointer;
  color: #43474E; font-size: 22px; line-height: 1;
}
.rr-modal-close:hover { background: #F4F3F6; }
.rr-modal-body p { color: #43474E; font-size: 14px; line-height: 1.5; margin: 0 0 20px; }
.rr-modal label { display: block; font-size: 13px; font-weight: 600; color: #1A1C1E; margin: 14px 0 6px; }
.rr-modal input,
.rr-modal textarea {
  width: 100%;
  border: 1px solid #C4C6CE;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: #1A1C1E;
  background: #fff;
}
.rr-modal input:focus,
.rr-modal textarea:focus {
  outline: none; border-color: var(--rr-brand, #001E3C);
  box-shadow: 0 0 0 3px rgba(0, 30, 60, 0.15);
}
.rr-modal textarea { min-height: 120px; resize: vertical; }
.rr-modal-rating { display: inline-flex; gap: 4px; }
.rr-modal-rating button {
  background: transparent; border: 0; padding: 4px; cursor: pointer; line-height: 0;
}
.rr-modal-rating .rr-star { width: 28px; height: 28px; }
.rr-modal-actions {
  margin-top: 24px;
  display: flex; gap: 12px; justify-content: flex-end;
}
.rr-modal-btn {
  height: 40px; padding: 0 18px;
  border-radius: 6px; font-weight: 600; font-size: 14px;
  cursor: pointer; border: 1px solid #C4C6CE;
  background: #fff; color: #1A1C1E;
  font-family: inherit;
}
.rr-modal-btn-primary {
  background: var(--rr-brand, #001E3C);
  border-color: var(--rr-brand, #001E3C);
  color: #fff;
}
.rr-modal-note {
  background: #F4F3F6; padding: 12px 14px; border-radius: 6px;
  color: #43474E; font-size: 13px;
}
.rr-modal-error {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 6px;
  background: #FFE0DE;
  border-left: 3px solid #BA1A1A;
  color: #93000A;
  font-size: 13px;
  line-height: 1.4;
}

/* ============================================================
   Photo lightbox
   ============================================================ */
.rr-lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex; align-items: center; justify-content: center;
  z-index: 99999;
  cursor: zoom-out;
  padding: 24px;
}
.rr-lightbox img {
  max-width: 92vw; max-height: 92vh;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
