/*
 * RB contrast fix.
 *
 * Journal3 paints buttons from a colour scheme whose button background and
 * button foreground are BOTH near-black in the cart panels (#171717 on
 * #1C2021 -> 1.09:1), so "احسب الشحن", the coupon apply and the voucher apply
 * buttons render as unreadable dark-on-dark blocks. The theme sets those with
 * !important, which is why the existing custom cart rule - which already tries
 * to make the panel fields white - never wins.
 *
 * Everything here is scoped to the specific controls that were measured as
 * failing, and every rule sits BELOW the theme's specificity ceiling on
 * purpose: where the theme legitimately wants a light icon on a dark surface
 * (the mobile header search button), its more specific rule still wins.
 */

/* ── Palette, matching the gold the cart's own continue button already uses ── */
:root {
  --rb-fix-gold: #f5a400;
  --rb-fix-gold-ink: #1a1208;
  --rb-fix-ink: #171717;
  --rb-fix-muted: #6b7280;
  --rb-fix-border: #e4e8f0;
}

/* ── Cart & checkout panels: fields ─────────────────────────────────────────
   White field on a white card, dark text. The theme's `input.form-control`
   rule is !important, so this has to be too. */
html.route-checkout-cart .cart-panels .panel-body .form-control,
html.route-checkout-cart .cart-panels .panel-body input.form-control,
html.route-checkout-cart .cart-panels .panel-body select,
html.route-checkout-cart .cart-panels .panel-body select.form-control,
html.route-checkout-cart .cart-panels .panel-body textarea,
html.route-checkout-cart .cart-panels .input-group .form-control,
html.route-checkout-checkout .form-control,
html.route-checkout-checkout select,
html.route-checkout-checkout textarea {
  background: #fff !important;
  background-color: #fff !important;
  color: var(--rb-fix-ink) !important;
  border: 1px solid var(--rb-fix-border) !important;
}

html.route-checkout-cart .cart-panels .panel-body .form-control::placeholder,
html.route-checkout-checkout .form-control::placeholder {
  color: #8b93a3 !important;
  opacity: 1;
}

/* Dropdown options inherit the control's colours in several browsers. */
html.route-checkout-cart .cart-panels .panel-body select option,
html.route-checkout-checkout select option {
  background: #fff !important;
  color: var(--rb-fix-ink) !important;
}

/* ── Cart & checkout panels: buttons ────────────────────────────────────────
 * The whole defect in one line. The store's own mobile rule already says what
 * these buttons should look like:
 *
 *   @media (max-width:991px){
 *     html.route-checkout-cart .cart-panels .panel-body .btn { background:#171717; color:#fff }
 *   }
 *
 * The dark background lands, but `color:#fff` is not !important and Journal3
 * ships `.btn, .btn:visited { color: <scheme button-foreground> !important }`.
 * In this scheme that foreground is #1C2021, so the label is repainted almost
 * exactly the colour of its own background - 1.09:1, invisible.
 *
 * So the fix is not a redesign: keep the store's dark button, and win the
 * argument over the text colour. Background is restated only to guarantee the
 * pairing holds even if the scheme changes underneath it.
 */
#button-coupon,
#button-quote,
#button-voucher,
#button-reward,
html.route-checkout-cart .cart-panels .panel-body .btn,
html.route-checkout-cart .cart-panels .panel-body input[type="button"],
html.route-checkout-cart .cart-panels .input-group-btn .btn,
html.route-checkout-checkout .panel-body .btn-primary {
  background: var(--rb-fix-ink) !important;
  background-color: var(--rb-fix-ink) !important;
  border-color: var(--rb-fix-ink) !important;
  color: #fff !important;
  text-shadow: none !important;
}

#button-coupon:hover,
#button-quote:hover,
#button-voucher:hover,
#button-reward:hover,
html.route-checkout-cart .cart-panels .panel-body .btn:hover,
html.route-checkout-cart .cart-panels .input-group-btn .btn:hover {
  background: #2b2b2b !important;
  background-color: #2b2b2b !important;
  border-color: #2b2b2b !important;
  color: #fff !important;
}

/* The cart's own primary action stays gold - unchanged, just protected from
   the same scheme override. */
html.route-checkout-cart .cart-page .buttons .btn-primary {
  background: var(--rb-fix-gold) !important;
  background-color: var(--rb-fix-gold) !important;
  border-color: var(--rb-fix-gold) !important;
  color: var(--rb-fix-gold-ink) !important;
}

/* The secondary "متابعة التسوق" button.
   It measured 2.01:1 as pale grey on white at mobile widths, but on desktop it
   sits on a DARK strip - so simply darkening the text made it worse (1.20:1).
   Giving it its own light surface settles it at both widths instead of
   depending on whatever is behind it. */
html.route-checkout-cart .cart-page .buttons .btn:not(.btn-primary),
html.route-checkout-cart .buttons a.btn:not(.btn-primary) {
  background: #fff !important;
  background-color: #fff !important;
  color: var(--rb-fix-ink) !important;
  border: 1px solid #cfd4de !important;
}

/* ── Icon-only controls that were effectively invisible ─────────────────────
   These need deliberately heavy selectors. Journal3 paints the wishlist heart
   through `.main-products-style.product-list .product-thumb .btn-wishlist.btn`
   with !important, which outranks anything shorter; the site's own
   `.floating-wishlist-btn { color:#e74c3c !important }` was already trying to
   make it red and losing. This restores that intent, which also fixes the
   contrast (a grey-on-white heart measured 2.01:1). */
/*
 * The repeated class names below are deliberate, not a typo.
 *
 * Journal3 colours these through long !important selectors such as
 * `.main-products-style.product-list .product-thumb .btn-wishlist.btn`
 * (five classes). A normal override loses on specificity no matter how it is
 * written, short of editing theme files we do not own. Repeating a class is
 * the standard, spec-sanctioned way to raise specificity without inventing
 * fake ancestors or `#id` hooks that the markup may not always provide.
 */

/* Grey-on-white heart measured 2.01:1. The store's own
   `.floating-wishlist-btn { color:#e74c3c !important }` already wanted it red
   and was being outranked; this restores that intent at a readable red. */
.floating-wishlist-btn.floating-wishlist-btn.floating-wishlist-btn.floating-wishlist-btn.floating-wishlist-btn.floating-wishlist-btn {
  color: #d92d20 !important;
}

/* White on #e8e8e8 - the grid/list toggle was not visible at all. The
   background is set too: the unselected toggle sits on a mid-grey strip, so
   colour alone still left it at 2.27:1. */
.view-btn.view-btn.view-btn.view-btn.view-btn {
  color: #4b5563 !important;
  background-color: #fff !important;
}

.view-btn.view-btn.view-btn.view-btn.view-btn.active {
  color: #fff !important;
  background-color: #4b5563 !important;
}

.rb-row-arrow.rb-row-arrow.rb-row-arrow.rb-row-arrow.rb-row-arrow,
.rb-cart-x.rb-cart-x.rb-cart-x.rb-cart-x.rb-cart-x {
  color: #4b5563 !important;
}

.rb-row-cart.rb-row-cart.rb-row-cart.rb-row-cart.rb-row-cart {
  color: #171717 !important;
}

/* Wins on desktop too, where a longer theme selector was repainting it. */
.search-button.search-button.search-button.search-button.search-button {
  color: #4b5563 !important;
}

/* ── Labels that were painted the same colour as what is behind them ────── */

/* "ترتيب حسب" - white text on a #e8e8e8 strip, 1.23:1. Six repeats because
   the desktop rule that paints it white is itself deeply nested. */
.input-group-addon.input-group-addon.input-group-addon.input-group-addon.input-group-addon.input-group-addon,
.input-group-addon.input-group-addon.input-group-addon.input-group-addon.input-group-addon.input-group-addon * {
  color: var(--rb-fix-ink) !important;
}

/* "البحث في الأقسام الفرعية" - pale grey on #e8e8e8, 1.64:1. */
.checkbox-inline.checkbox-inline.checkbox-inline.checkbox-inline,
.checkbox.checkbox.checkbox.checkbox label {
  color: var(--rb-fix-ink) !important;
}

/* "هل لديك حساب بالفعل؟" - #d9e2e3 on white, 1.32:1. */
.text-separator.text-separator.text-separator.text-separator.text-separator.text-separator,
.text-separator.text-separator.text-separator.text-separator.text-separator.text-separator * {
  color: var(--rb-fix-muted) !important;
}

/* Collection carousel arrows: grey glyph on a white pill. */
.ilm-coll-btn.ilm-coll-btn.ilm-coll-btn.ilm-coll-btn,
.ilm-coll-btn.ilm-coll-btn.ilm-coll-btn.ilm-coll-btn > span {
  color: #4b5563 !important;
  border-color: #9aa1ad !important;
}

.ilm-coll-btn.is-disabled.is-disabled.is-disabled.is-disabled {
  opacity: .55;
}

/* Checkboxes stay native, but their checked state now uses the brand gold so
   it reads on both the light panels and the dark filter sidebar. */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--rb-fix-gold);
}

/* ── Product page tags ──────────────────────────────────────────────────────
   Journal3 paints `.tags a` from --j-color-scheme-background-primary and takes
   the label colour from the same dark scheme, so on the product page each tag
   renders as near-black text on a near-black pill - the row reads as a strip of
   blank dark lozenges.

   A fix for exactly this already exists in
   catalog/view/theme/journal3/stylesheet/rb-mobile-product.css (~line 614), but
   that whole file sits inside `@media (max-width: 991px)`, so it only ever
   reached phones and tablets while every desktop visitor kept the unreadable
   version. This carries the same intent to all widths.

   Deliberately one step more specific than the mobile rule
   (`html.route-product-product #content .tags *`, which is `> a` short of this)
   so the two never disagree at the widths where both apply - a tag looks the
   same on a phone and on a desktop. */
html.route-product-product #content .tags > a,
html.route-product-product #content .product-tags > a {
  background: #f3f4f6 !important;
  background-color: #f3f4f6 !important;
  color: var(--rb-fix-ink) !important;
  border: 1px solid var(--rb-fix-border) !important;
}

/* The theme also colours the text node inside the anchor, so clearing the
   anchor alone leaves the label dark-on-dark. */
html.route-product-product #content .tags > a *,
html.route-product-product #content .product-tags > a * {
  color: var(--rb-fix-ink) !important;
  background: transparent !important;
}

html.route-product-product #content .tags > a:hover,
html.route-product-product #content .tags > a:focus,
html.route-product-product #content .product-tags > a:hover,
html.route-product-product #content .product-tags > a:focus {
  background: #fff7e6 !important;
  background-color: #fff7e6 !important;
  border-color: var(--rb-fix-gold) !important;
  color: var(--rb-fix-gold-ink) !important;
}

/* "Tags:" is a plain label, not a pill. */
html.route-product-product #content .tags .tags-title {
  color: var(--rb-fix-muted) !important;
  background: transparent !important;
}
