/* ==========================================================================
   OstuGrupp — Product reviews enrichment (inc/reviews.php)
   Rating summary block · verified badge · premium review cards · review photos
   · photo-upload field. Uses the design tokens from main.css; Estonian UI.
   ========================================================================== */

/* ---- Rating summary block (top of the reviews tab) ---- */
.ostu-rev-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
  margin: 0 0 26px;
}
@media (min-width: 640px) {
  .ostu-rev-summary { grid-template-columns: minmax(150px, 200px) 1fr; gap: 30px; }
}

.ostu-rev-summary__score {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
}
@media (min-width: 640px) {
  .ostu-rev-summary__score {
    align-items: center;
    text-align: center;
    border-right: 1px solid var(--border);
    padding-right: 30px;
  }
}
.ostu-rev-summary__avg {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 52px;
  line-height: 1;
  color: var(--slate-dark);
  font-variant-numeric: tabular-nums;
}
.ostu-rev-summary__score .star-rating {
  font-size: 16px;
  margin: 2px 0;
}
.ostu-rev-summary__count {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-500);
}

/* Distribution bars */
.ostu-rev-summary__bars {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 0;
  padding: 0;
}
.ostu-rev-summary__row {
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  align-items: center;
  gap: 12px;
}
.ostu-rev-summary__star-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--slate);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ostu-rev-summary__track {
  position: relative;
  height: 9px;
  border-radius: 999px;
  background: var(--muted);
  overflow: hidden;
}
.ostu-rev-summary__fill {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green) 0%, var(--green-dark) 100%);
  transition: width .4s ease;
}
.ostu-rev-summary__num {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-500);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---- Premium review cards ---- */
.woocommerce #reviews #comments ol.commentlist { margin: 0; padding: 0; }
.ostu-rev-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.ostu-rev-card:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(5, 150, 105, .3);
}
.woocommerce #reviews #comments ol.commentlist li {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
  background: transparent;
}
/* Neutralize WooCommerce's default avatar float/box so the card controls layout */
.woocommerce #reviews #comments ol.commentlist li .comment_container {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: transparent;
  border: 0;
  padding: 0;
}
.woocommerce #reviews #comments ol.commentlist li img.avatar {
  position: static;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--muted);
  padding: 0;
  margin: 0;
  float: none;
}
.woocommerce #reviews #comments ol.commentlist li .comment-text {
  margin: 0;
  border: 0;
  padding: 0;
  flex: 1;
}
.woocommerce #reviews #comments ol.commentlist li .meta {
  font-size: 13px;
  color: var(--slate-500);
  margin-bottom: 8px;
}
.woocommerce #reviews #comments ol.commentlist li .meta strong {
  color: var(--slate-dark);
  font-weight: 700;
  font-size: 14.5px;
}
.woocommerce #reviews #comments ol.commentlist li .star-rating { font-size: 14px; margin-bottom: 6px; }
.woocommerce #reviews #comments ol.commentlist li .description p { color: var(--slate-600); line-height: 1.7; }

/* ---- Verified-buyer badge ---- */
.ostu-rev-verified {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(5, 150, 105, .1);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .01em;
  vertical-align: middle;
}
.ostu-rev-verified__icon {
  flex: none;
  display: block;
}

/* ---- Review photo thumbnails ---- */
.ostu-rev-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.ostu-rev-photos__item {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--muted);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.ostu-rev-photos__item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(5, 150, 105, .4);
}
.ostu-rev-photos__img,
.ostu-rev-photos__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---- Photo-upload field on the review form ---- */
.ostu-rev-upload {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 14px;
}
.ostu-rev-upload__label {
  font-weight: 600;
  color: var(--slate);
}
.ostu-rev-upload__hint {
  font-size: 12px;
  color: var(--slate-500);
}
.ostu-rev-upload__control {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ostu-rev-upload__input {
  font: inherit;
  color: var(--slate);
  padding: 12px 14px;
  border: 1px dashed var(--slate-300);
  border-radius: var(--radius);
  background: var(--muted);
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.ostu-rev-upload__input:hover { border-color: rgba(5, 150, 105, .5); }
.ostu-rev-upload__input:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.ostu-rev-upload__input::file-selector-button {
  font: inherit;
  font-weight: 600;
  margin-right: 12px;
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--slate-dark);
  color: #fff;
  cursor: pointer;
  transition: background .2s ease;
}
.ostu-rev-upload__input::file-selector-button:hover { background: #0f172a; }

/* JS-built preview thumbnails */
.ostu-rev-upload__preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ostu-rev-upload__preview:empty { display: none; }
.ostu-rev-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--muted);
}
.ostu-rev-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ostu-rev-thumb__remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, .72);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease;
}
.ostu-rev-thumb__remove:hover { background: var(--danger); }
.ostu-rev-upload__error {
  color: var(--danger-dark);
  font-size: 13px;
  font-weight: 600;
}
.ostu-rev-upload__error:empty { display: none; }

/* ==========================================================================
   Two confirmations for one fact
   Every review carried BOTH WooCommerce's "(toote omanik)" and the theme's own
   "Ostu kinnitatud" chip — measured live: 5 and 5 on a 5-review product.
   Safe to hide core's: ostugrupp_reviews_verified_badge() is gated on exactly the
   same wc_review_is_from_verified_owner() check core uses, so whenever core would
   have shown its label, the theme's chip is already there.
   ========================================================================== */
.woocommerce-review__verified { display: none; }

/* Rating stars in the review FORM — 24px targets on the one control a shopper has
   to hit precisely. Widened to 44px with the glyph re-centred, rather than the
   invisible-::after trick used elsewhere: the stars sit ~1em apart, so overlapping
   hit areas would let a tap for "3" register as "4", which is worse than a small
   target. Scoped to #review_form so the read-only stars on existing reviews and
   the loop rating keep their compact size. */
#review_form p.stars a {
  width: 44px;
  height: 44px;
  line-height: 44px;
}
#review_form p.stars a::before {
  left: 50%;
  transform: translateX(-50%);
  line-height: 44px;
}
