/* Saudi Riyal symbol (new official glyph U+20C1) — never use «ر.س». */
@font-face {
    font-family: 'saudi_riyal';
    src: url('../fonts/saudi_riyal.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
.icon-saudi_riyal_new::after {
    content: "\20c1";
    font-family: 'saudi_riyal' !important;
    font-size: inherit;
    color: inherit;
    margin-inline-start: 2px;
}

/* Sulfah brand font (Cairo) — matches sulfah.com. */
@font-face {
    font-family: 'SulfahCairo';
    src: url('../fonts/cairo-var.woff2') format('woff2');
    font-weight: 200 900;
    font-display: swap;
    font-style: normal;
}

/* Apply the brand font to every Sulfah element. */
.sulfah-bnpl-method,
.sulfah-bnpl-method *,
.sulfah-promo-widget,
.sulfah-promo-widget *,
.sulfah-info,
.sulfah-info *,
.sulfah-modal__bar,
.sulfah-modal__bar * {
    font-family: 'SulfahCairo', 'Cairo', system-ui, sans-serif !important;
}

/* ==========================================================================
   Sulfah BNPL — checkout payment-method row.
   Renders: [radio]  «العنوان» + «النص الفرعي»  [شعار سلفة]
   RTL-first (Arabic), with an LTR fallback. `!important` is used only on the
   logo box so a host theme's generic `img` rules cannot blow up the badge.
   ========================================================================== */

/* --- Row label: badge on the far side from the radio ---------------------- */
.sulfah-bnpl-method .sulfah-bnpl-label {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-direction: row-reverse;     /* RTL: radio at the right, badge at the left */
    justify-content: flex-end;
    margin: 0;
    cursor: pointer;
}

/* --- Official Sulfah logo (the green «سلفة» mark) -------------------------- */
.sulfah-bnpl-method img.sulfah-bnpl-logo {
    display: block;
    height: 28px !important;         /* matches Tabby's badge height */
    max-height: 28px !important;
    width: auto !important;
    max-width: 80px !important;
    flex: 0 0 auto;
    object-fit: contain;
    vertical-align: middle;
    border: 0;
}

/* --- Text fallback badge (only if the logo asset URL is missing) ----------- */
.sulfah-bnpl-method .sulfah-bnpl-logo--text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    height: 28px;
    padding: 0 12px;
    background: #31a343;             /* Sulfah brand green */
    color: #ffffff;
    font-weight: 700;
    font-size: 15px;
    line-height: 1;
    border-radius: 8px;
    white-space: nowrap;
}

/* --- Title + subtitle stack ---------------------------------------------- */
.sulfah-bnpl-method .sulfah-bnpl-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.35;
}

.sulfah-bnpl-method .sulfah-bnpl-title {
    font-weight: 700;
    font-size: 15px;
    color: #1a1a1a;
}

.sulfah-bnpl-method .sulfah-bnpl-subtitle {
    font-weight: 400;
    font-size: 13px;
    color: #6b7280;
    margin-top: 2px;
}

/* --- LTR locales: badge on the left, radio on the right -------------------
   Only flip on an EXPLICIT ltr signal. The previous `body:not([dir="rtl"])`
   wrongly matched RTL stores whose theme sets dir on <html> (not <body>) or
   omits it, inverting the tile. RTL is the module's default, so we require an
   explicit dir="ltr" to switch. */
html[dir="ltr"] .sulfah-bnpl-method .sulfah-bnpl-label,
body[dir="ltr"] .sulfah-bnpl-method .sulfah-bnpl-label,
[dir="ltr"] .sulfah-bnpl-method .sulfah-bnpl-label {
    flex-direction: row;
    justify-content: flex-start;
}

/* ==========================================================================
   Expanded promo panel (shown when Sulfah is selected) — Tabby-style layout.
   ========================================================================== */
.sulfah-bnpl-method .sulfah-promo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 56px;
    flex-wrap: wrap;
    padding: 24px 16px 8px;
}

/* Centered: logo + headline + sub-line */
.sulfah-bnpl-method .sulfah-promo__main {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
}

.sulfah-bnpl-method .sulfah-promo__logo {
    height: 30px !important;
    max-height: 30px !important;
    width: auto !important;
    max-width: 90px !important;
    object-fit: contain;
    margin-bottom: 4px;
}

.sulfah-bnpl-method .sulfah-promo__headline {
    margin: 0;
    font-weight: 800;
    font-size: 20px;
    color: #1a1a1a;
}

.sulfah-bnpl-method .sulfah-promo__sub {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}

/* Benefits list with green icon chips */
.sulfah-bnpl-method .sulfah-benefits {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sulfah-bnpl-method .sulfah-benefit {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 14px;
    color: #1a1a1a;
}

.sulfah-bnpl-method .sulfah-benefit__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #eaf6ec;             /* light Sulfah green chip */
}

/* Official Sulfah icon (already brand-green #12a754) */
.sulfah-bnpl-method .sulfah-benefit__img {
    display: block;
    width: 20px !important;
    height: 20px !important;
    object-fit: contain;
}

/* Place-order button as a soft pill, like «عرض الخيارات» */
.sulfah-bnpl-method .actions-toolbar {
    text-align: center;
    margin-top: 8px;
}

.sulfah-bnpl-method .actions-toolbar .action.primary.checkout {
    border-radius: 24px;
    padding: 10px 28px;
    font-weight: 700;
}

@media (max-width: 600px) {
    .sulfah-bnpl-method .sulfah-promo {
        gap: 24px;
    }
}

/* ==========================================================================
   On-site promo widget (cart + product pages) — clean bordered card.
   `min-height` reserves space so async price/total updates cause no layout
   shift (CLS-safe).
   ========================================================================== */
.sulfah-promo-widget {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 0;
    padding: 14px 16px;
    min-height: 64px;
    border: 1px solid #d8e6dc;
    border-radius: 14px;
    background: #fbfefc;
    box-shadow: 0 1px 2px rgba(20, 40, 28, 0.04);
}

.sulfah-promo-widget__logo {
    height: 26px !important;
    max-height: 26px !important;
    width: auto !important;
    max-width: 76px !important;
    flex: 0 0 auto;
    object-fit: contain;
}

.sulfah-promo-widget__body {
    flex: 1 1 auto;
    min-width: 0;
}

.sulfah-promo-widget__lead {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.55;
    color: #1a1a1a;
}

.sulfah-promo-widget__lead .sulfah-amt {
    color: #1f7a31;
    font-weight: 800;
    white-space: nowrap;
}

.sulfah-promo-widget__meta {
    margin: 3px 0 0;
    font-size: 12px;
    line-height: 1.4;
    color: #6b7280;
}

/* "القيمة تقريبية وتُحتسب عند الدفع" — sets expectation that the live figure is
   representative; the exact rate is finalised at checkout. */
.sulfah-promo-widget__note {
    margin: 2px 0 0;
    font-size: 11px;
    line-height: 1.4;
    color: #9aa3af;
}

.sulfah-promo-widget__more {
    flex: 0 0 auto;
    align-self: center;
    border: 0;
    background: transparent;
    padding: 6px 4px;
    font-weight: 700;
    font-size: 13px;
    color: #1f7a31;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    white-space: nowrap;
}
.sulfah-promo-widget__more:hover { color: #166026; }
.sulfah-promo-widget__more:focus-visible {
    outline: 2px solid #31a343;
    outline-offset: 2px;
    border-radius: 6px;
    text-decoration: none;
}

/* Stack the «عرض خطة الدفعات» action under the text on narrow viewports. */
@media (max-width: 480px) {
    .sulfah-promo-widget {
        flex-wrap: wrap;
        row-gap: 6px;
    }
    .sulfah-promo-widget__more {
        flex-basis: 100%;
        text-align: start;
        align-self: flex-start;
        padding-inline: 0;
    }
}

/* --------------------------------------------------------------------------
   COMPACT SIDEBAR VARIANT — cart-summary column only, desktop only.
   The cart-summary sidebar (~280–320px) is too narrow for the horizontal
   logo|text|link row: the body gets squeezed to one word per line and the
   badge collides with the link. Scope the fix to `.cart-summary` (the cart
   sidebar context) AND gate it to >=768px so the FULL-WIDTH mobile cart and
   the PDP card (which lives under product.info.main, not .cart-summary) are
   left untouched. Stacks the card vertically so nothing squeezes.
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
    .cart-summary .sulfah-promo-widget {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 14px;
        min-height: 0;
    }
    .cart-summary .sulfah-promo-widget__logo {
        align-self: flex-start;
    }
    .cart-summary .sulfah-promo-widget__body {
        width: 100%;
    }
    .cart-summary .sulfah-promo-widget__lead {
        font-size: 13px;
        line-height: 1.5;
        /* Normal wrapping — never one-word-per-line. */
        word-break: normal;
        overflow-wrap: anywhere;
    }
    .cart-summary .sulfah-promo-widget__meta {
        font-size: 11.5px;
    }
    .cart-summary .sulfah-promo-widget__more {
        align-self: flex-start;
        flex: 0 0 auto;
        padding-inline: 0;
        white-space: normal;   /* link may wrap rather than collide */
    }
}

/* ==========================================================================
   Installment schedule («خطة الدفعات») — vertical timeline of rows.
   ========================================================================== */
.sulfah-plan {
    list-style: none;
    margin: 0;
    padding: 0;
}
.sulfah-plan__row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f3f2;
}
.sulfah-plan__row:last-child { border-bottom: 0; }

/* Connecting timeline line behind the dots. */
.sulfah-plan__dot {
    position: relative;
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #c7d7cc;
}
.sulfah-plan__row:not(:last-child) .sulfah-plan__dot::after {
    content: "";
    position: absolute;
    inset-inline-start: 50%;
    top: 14px;
    transform: translateX(-50%);
    width: 2px;
    height: 34px;
    background: #e4ece7;
}
.sulfah-plan__row.is-today .sulfah-plan__dot {
    background: #31a343;
    border-color: #31a343;
    box-shadow: 0 0 0 4px rgba(49, 163, 67, 0.15);
}

.sulfah-plan__when {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    min-width: 0;
}
.sulfah-plan__label { font-size: 14px; font-weight: 700; color: #1a1a1a; }
.sulfah-plan__sub { font-size: 12px; color: #6b7280; margin-top: 1px; }
.sulfah-plan__row.is-today .sulfah-plan__label { color: #1f7a31; }

.sulfah-plan__amt {
    flex: 0 0 auto;
    font-size: 14px;
    font-weight: 800;
    color: #1a1a1a;
    white-space: nowrap;
}
.sulfah-plan__row.is-more { opacity: 0.72; }
.sulfah-plan__row.is-more .sulfah-plan__label { font-weight: 600; }

/* Neutral, factual eligibility note in the sheet. */
.sulfah-info__note {
    margin: 4px 0 14px;
    font-size: 12px;
    line-height: 1.6;
    color: #6b7280;
    text-align: center;
}

/* ==========================================================================
   Checkout panel: live per-installment preview at the point of decision.
   ========================================================================== */
.sulfah-bnpl-method .sulfah-promo__preview {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    margin: 2px 0 2px;
    padding: 6px 14px;
    border-radius: 999px;
    background: #eaf6ec;
}
.sulfah-bnpl-method .sulfah-promo__preview-amt {
    font-size: 18px;
    font-weight: 800;
    color: #1f7a31;
    white-space: nowrap;
}
.sulfah-bnpl-method .sulfah-promo__preview-prefix {
    font-size: 12px;
    color: #4b6b54;
}
.sulfah-bnpl-method .sulfah-promo__preview-unit {
    font-size: 12px;
    color: #4b6b54;
}
/* Approximate-rate note under the live checkout preview. */
.sulfah-bnpl-method .sulfah-promo__approx {
    margin: 2px 0 0;
    font-size: 11px;
    line-height: 1.4;
    color: #9aa3af;
}

/* ==========================================================================
   In-page modal hosting the Sulfah hosted checkout (iframe).
   ========================================================================== */
body.sulfah-modal-open { overflow: hidden; }

.sulfah-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sulfah-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 28, 24, 0.55);
}

.sulfah-modal__dialog {
    position: relative;
    z-index: 1;
    width: 460px;
    max-width: calc(100% - 24px);
    height: 760px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.sulfah-modal__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid #eef1ef;
    flex: 0 0 auto;
}

.sulfah-modal__title {
    font-weight: 700;
    font-size: 14px;
    color: #1a1a1a;
}

.sulfah-modal__close {
    border: 0;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0 6px;
}

.sulfah-modal__frame {
    border: 0;
    width: 100%;
    flex: 1 1 auto;
}

/* Full-screen on phones. */
@media (max-width: 600px) {
    .sulfah-modal__dialog {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
}

/* ==========================================================================
   «كيف يعمل» info sheet (Tabby «عرض الخيارات»-style).
   ========================================================================== */
.sulfah-promo__more {
    margin-top: 8px;
    font-weight: 700;
    font-size: 13px;
    color: #31a343;
    text-decoration: underline;
    cursor: pointer;
}

.sulfah-info {
    position: fixed;
    inset: 0;
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* The promo-widget sheet uses [hidden] + .is-open (KO sheet uses visible+display).
   Keep it hidden until opened so it never flashes during page load. */
.sulfah-info[hidden] { display: none; }

.sulfah-info__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 28, 24, 0.55);
}

/* Subtle entrance: backdrop fades, dialog rises. */
.sulfah-info.is-open .sulfah-info__dialog {
    animation: sulfah-dialog-in 0.18s ease-out both;
}
@keyframes sulfah-dialog-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .sulfah-info.is-open .sulfah-info__dialog { animation: none; }
}

/* Visible focus ring on the dialog + its controls (a11y). */
.sulfah-info__dialog:focus { outline: none; }
.sulfah-info__close:focus-visible,
.sulfah-info__continue:focus-visible {
    outline: 2px solid #31a343;
    outline-offset: 2px;
    border-radius: 8px;
}

.sulfah-info__dialog {
    position: relative;
    z-index: 1;
    width: 420px;
    max-width: calc(100% - 24px);
    max-height: calc(100vh - 48px);
    background: #f4f6f5;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
}

.sulfah-info__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #fff;
    flex: 0 0 auto;
}

.sulfah-info__logo { height: 26px; width: auto; }

.sulfah-info__close {
    border: 0;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
}

.sulfah-info__body {
    padding: 16px;
    overflow-y: auto;
}

.sulfah-info__hero {
    background: linear-gradient(160deg, #31a343, #1f7a31);
    color: #fff;
    border-radius: 14px;
    padding: 28px 20px;
    text-align: center;
    margin-bottom: 16px;
}

.sulfah-info__hero h3 { margin: 0 0 6px; font-size: 22px; font-weight: 800; }
.sulfah-info__hero p { margin: 0; font-size: 14px; opacity: 0.95; }

.sulfah-info__section,
.sulfah-info__card {
    background: #fff;
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 12px;
}

.sulfah-info__section h4 { margin: 0 0 14px; font-size: 16px; font-weight: 800; color: #1a1a1a; }

.sulfah-steps { list-style: none; margin: 0; padding: 0; }
.sulfah-steps li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    font-size: 14px;
    color: #374151;
    border-bottom: 1px solid #f1f3f2;
}
.sulfah-steps li:last-child { border-bottom: 0; }
.sulfah-steps__n {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #eaf6ec;
    color: #31a343;
    font-weight: 800;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sulfah-info__card {
    display: flex;
    align-items: center;
    gap: 12px;
}
.sulfah-info__card-icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #eaf6ec;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sulfah-info__card-icon img { width: 24px; height: 24px; }
.sulfah-info__card strong { display: block; font-size: 14px; color: #1a1a1a; }
.sulfah-info__card p { margin: 2px 0 0; font-size: 13px; color: #6b7280; }

.sulfah-info__continue {
    width: 100%;
    border: 0;
    border-radius: 28px;
    background: #16231b;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    padding: 14px;
    cursor: pointer;
    margin-top: 4px;
}
.sulfah-info__continue:hover { background: #0e1712; }

/* Scroll-lock the page while the info sheet is open. */
body.sulfah-info-open { overflow: hidden; }

/* Mobile: present the info sheet as a bottom sheet (Tabby/Tamara pattern). */
@media (max-width: 600px) {
    .sulfah-info { align-items: flex-end; }
    .sulfah-info__dialog {
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        border-radius: 18px 18px 0 0;
    }
    .sulfah-info.is-open .sulfah-info__dialog,
    .sulfah-info[data-bind] .sulfah-info__dialog {
        animation: sulfah-sheet-up 0.22s ease-out both;
    }
}
@keyframes sulfah-sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .sulfah-info.is-open .sulfah-info__dialog { animation: none; }
}
