/* Dhamen Pay v2 — professional redesign with brand selection */

*, *::before, *::after {
    box-sizing: border-box;
}

body.pdv2 {
    font-family: 'Tajawal', sans-serif;
    background: #f2f5fb;
    min-height: 100vh;
    margin: 0;
    color: #1a1f36;
}

body.pdv2--hosted {
    background: #f2f5fb;
}

/* ── Page wrapper ─────────────────────────────────────── */
.pdv2__page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ───────────────────────────────────────────── */
.pdv2__header {
    background: var(--brand-primary);
    padding: 1.25rem 1.25rem;
}

.pdv2__header-inner {
    max-width: 30rem;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.pdv2__header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

.pdv2__header-logo {
    width: 2.75rem;
    height: 2.75rem;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 0.625rem;
    background: rgba(255, 255, 255, 0.18);
    padding: 0.25rem;
}

.pdv2__header-title {
    color: #fff;
    min-width: 0;
}

.pdv2__header-title h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdv2__header-title p {
    margin: 0.1rem 0 0;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.75);
}

.pdv2__header-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.pdv2__header-secure {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.75rem;
}

.pdv2__header-secure svg {
    width: 0.875rem;
    height: 0.875rem;
}

.pdv2__lang-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.92);
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 0.375rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    line-height: 1.6;
}

.pdv2__lang-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

/* ── Main content ─────────────────────────────────────── */
.pdv2__main {
    flex: 1;
    max-width: 30rem;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ── Summary card ─────────────────────────────────────── */
.pdv2__summary {
    background: #fff;
    border-radius: 1.125rem;
    box-shadow: 0 2px 12px rgba(25, 40, 100, 0.07);
    padding: 1.25rem 1.25rem 1rem;
}

.pdv2__summary-ref {
    font-size: 0.8125rem;
    color: #6b7280;
    margin: 0 0 0.6rem;
    letter-spacing: 0.01em;
}

.pdv2__summary-ref strong {
    color: #374151;
    font-weight: 600;
}

.pdv2__summary-amount-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    background: color-mix(in srgb, var(--brand-primary) 7%, #fff);
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
}

.pdv2__summary-amount-label {
    font-size: 0.875rem;
    color: var(--brand-primary);
    font-weight: 500;
}

.pdv2__summary-amount-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--brand-primary);
    white-space: nowrap;
}

/* ── Payment card ─────────────────────────────────────── */
.pdv2__card {
    background: #fff;
    border-radius: 1.125rem;
    box-shadow: 0 4px 24px rgba(25, 40, 100, 0.09);
    overflow: hidden;
}

.pdv2__card-head {
    padding: 1.125rem 1.25rem 0.875rem;
    border-bottom: 1px solid #f0f2f7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.pdv2__card-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #1a1f36;
    margin: 0;
}

.pdv2__card-brands {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.pdv2__brand-badge {
    height: 1.375rem;
    width: auto;
    display: block;
    opacity: 0.85;
}

/* ── Widget container ─────────────────────────────────── */
.pdv2__widget-body {
    padding: 1.25rem;
}

.pdv2__loading {
    text-align: center;
    color: #9ca3af;
    font-size: 0.875rem;
    padding: 2rem 1rem;
}

.pdv2__loading[hidden] { display: none !important; }

/* wpwl overrides — zero-specificity trick avoids !important everywhere */
body.pdv2 .wpwl-form-card {
    background: transparent;
    border-radius: 0;
    padding: 0;
    max-width: 100%;
    margin: 0;
    border: none;
    box-shadow: none;
}

body.pdv2 .wpwl-label,
body.pdv2 .wpwl-control-brand {
    display: none !important;
}

body.pdv2 .wpwl-form-card input[type="text"],
body.pdv2 .wpwl-form-card input[type="tel"],
body.pdv2 .wpwl-form-card select {
    background: #f8f9fc;
    border: 1.5px solid #e4e7ef;
    border-radius: 0.75rem;
    color: #1a1f36;
    font-size: 16px;
    min-height: 52px;
    padding: 14px 16px;
    width: 100%;
    max-width: 100%;
    font-family: 'Tajawal', sans-serif;
    transition: border-color 0.15s;
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: plaintext;
}

body.pdv2 .wpwl-form-card input:focus {
    border-color: var(--brand-primary);
    outline: none;
    background: #fff;
}

body.pdv2 .wpwl-form-card iframe,
body.pdv2 .wpwl-control iframe,
body.pdv2 .wpwl-wrapper iframe {
    width: 100% !important;
    max-width: 100% !important;
    height: 52px !important;
    min-height: 52px !important;
    border: 1.5px solid #e4e7ef !important;
    border-radius: 0.75rem !important;
    background: #f8f9fc !important;
    display: block !important;
}

body.pdv2 .wpwl-wrapper,
body.pdv2 .wpwl-control {
    width: 100% !important;
    max-width: 100% !important;
    direction: ltr !important;
    text-align: left !important;
}

body.pdv2 .wpwl-group,
body.pdv2 .wpwl-form-card {
    direction: ltr !important;
}

body.pdv2 .wpwl-button-pay,
body.pdv2 [class*="wpwl-button"] {
    background: var(--brand-primary) !important;
    border: none !important;
    border-radius: 0.875rem !important;
    padding: 1rem !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    color: #fff !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    cursor: pointer !important;
    font-family: 'Tajawal', sans-serif !important;
    letter-spacing: 0.01em;
    margin-top: 0.5rem !important;
}

body.pdv2 .wpwl-button-pay:hover {
    opacity: 0.92 !important;
}

body.pdv2 apple-pay-button,
body.pdv2 .wpwl-button-apple,
body.pdv2 [class*="apple-pay"] {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    margin-top: 0.75rem;
}

body.pdv2 .p-message-info,
body.pdv2 .message-info {
    display: none !important;
}

body.pdv2 .wpwl-form-card img,
body.pdv2 .wpwl-brand,
body.pdv2 .wpwl-brand-card {
    max-height: 26px !important;
    max-width: 52px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
}

/* ── Hosted iframe mode ───────────────────────────────── */
.pdv2__hosted-stage {
    padding: 0;
}

.pdv2__frame-wrap {
    width: 100%;
    position: relative;
    background: #fff;
    --dhamen-crop-top: 60px;
    --dhamen-crop-bottom: 64px;
    --dhamen-iframe-width-percent: 100;
    --dhamen-iframe-fit-scale: 1;
    height: clamp(460px, 85vh, 880px);
    overflow: hidden;
    border-radius: 0 0 1.125rem 1.125rem;
    isolation: isolate;
}

.pdv2__frame-wrap::before,
.pdv2__frame-wrap::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    z-index: 3;
    pointer-events: none;
    background: #fff;
}

.pdv2__frame-wrap::before {
    top: 0;
    height: var(--dhamen-crop-top, 60px);
}

.pdv2__frame-wrap::after {
    bottom: 0;
    height: var(--dhamen-crop-bottom, 64px);
}

.pdv2__frame {
    position: absolute;
    z-index: 1;
    top: calc(-1 * var(--dhamen-crop-top));
    left: 50%;
    width: 100%;
    max-width: none;
    height: calc(
        (100% + var(--dhamen-crop-top) + var(--dhamen-crop-bottom)) / var(--dhamen-iframe-fit-scale, 1)
    );
    min-height: 0;
    border: 0;
    display: block;
    transform: translateX(-50%) scale(var(--dhamen-iframe-fit-scale, 1));
    transform-origin: center top;
}

@media (min-width: 640px) {
    .pdv2__frame {
        width: calc(var(--dhamen-iframe-width-percent, 100) * 1%);
    }
}

/* ── Trust footer ─────────────────────────────────────── */
.pdv2__trust {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid #f0f2f7;
    font-size: 0.75rem;
    color: #9ca3af;
}

.pdv2__trust-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.pdv2__trust-item svg {
    width: 0.875rem;
    height: 0.875rem;
    flex-shrink: 0;
    color: #6b7280;
}

/* ── Back link ────────────────────────────────────────── */
.pdv2__back {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: #6b7280;
    font-size: 0.8125rem;
    text-decoration: none;
    margin-bottom: 0.25rem;
}

.pdv2__back:hover { color: var(--brand-primary); }

/* ── Page footer ──────────────────────────────────────── */
.pdv2__footer {
    text-align: center;
    color: #c0c8d5;
    font-size: 0.75rem;
    padding-bottom: 1.5rem;
}

/* ── Saudi riyal symbol ───────────────────────────────── */
.icon-saudi_riyal {
    font-family: 'SaudiRiyalSymbol', sans-serif !important;
    font-weight: bold;
    display: inline;
    font-size: 1em;
    line-height: 1;
    margin-inline-start: 0.15em;
}

/* ── Brand selection grid ─────────────────────────────── */
.pdv2__brand-grid {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    padding: 1rem 1.125rem 0.5rem;
}

/* ── Brand card (button) ──────────────────────────────── */
.pdv2__bc {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: 1.5px solid #e8ecf3;
    border-radius: 0.875rem;
    cursor: pointer;
    text-align: start;
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
    font-family: 'Tajawal', sans-serif;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
    overflow: hidden;
}

.pdv2__bc:hover {
    border-color: color-mix(in srgb, var(--brand-primary) 45%, #e8ecf3);
    box-shadow: 0 3px 14px rgba(25, 40, 100, 0.09);
}

.pdv2__bc:active {
    transform: scale(0.99);
    background: color-mix(in srgb, var(--brand-primary) 3%, #fff);
}

/* Selected state */
.pdv2__bc--selected {
    border-color: var(--brand-primary) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 15%, transparent),
                0 3px 14px rgba(25, 40, 100, 0.09) !important;
    background: color-mix(in srgb, var(--brand-primary) 4%, #fff) !important;
    transform: none !important;
}

/* ── Brand logo box ───────────────────────────────────── */
.pdv2__bc-logo {
    width: 2.2rem;
    height: 2.2rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    background: transparent;
    border-radius: 0.625rem;
    margin-inline-start: auto;
}

.pdv2__bc-logo img {
    height: 1.05rem;
    width: auto;
    max-width: 2.5rem;
    object-fit: contain;
    display: block;
}

/* Visa + Mastercard side-by-side — each logo smaller */
.pdv2__bc--visamc .pdv2__bc-logo img {
    height: 0.88rem;
    max-width: 1.625rem;
}

/* ── Brand text block ─────────────────────────────────── */
.pdv2__bc-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

/* ── Brand card text ──────────────────────────────────── */
.pdv2__bc-name {
    font-size: 0.875rem;
    font-weight: 700;
    color: #1a1f36;
    line-height: 1.2;
    text-align: start;
}

.pdv2__bc-desc {
    font-size: 0.75rem;
    color: #9ca3af;
    line-height: 1.3;
    text-align: start;
}

/* ── Radio circle check ───────────────────────────────── */
.pdv2__bc-check {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.18s, background 0.18s;
}

.pdv2__bc-check svg {
    width: 0.62rem;
    height: 0.62rem;
    color: #fff;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.18s, transform 0.18s;
}

.pdv2__bc--selected .pdv2__bc-check {
    border-color: var(--brand-primary);
    background: var(--brand-primary);
}

.pdv2__bc--selected .pdv2__bc-check svg {
    opacity: 1;
    transform: scale(1);
}

/* Apple Pay logo is wider (card shape) */
.pdv2__bc--apple .pdv2__bc-logo img {
    height: 0.95rem;
    max-width: 2.75rem;
}

/* Visa/MC dual logos */
.pdv2__brand-img--visa {
    height: 0.78rem !important;
    max-width: 1.5rem !important;
}

.pdv2__brand-img--mc {
    height: 0.92rem !important;
    max-width: 1.5rem !important;
}

.pdv2__brand-img--tamara {
    height: 0.92rem !important;
    max-width: 3rem !important;
}

/* ── Form section (payment) ───────────────────────────── */
.pdv2__form-card {
    overflow: hidden;
}

.pdv2__form-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #1a1f36;
    margin: 0;
    flex: 1;
}

.pdv2__change-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--brand-primary);
    background: color-mix(in srgb, var(--brand-primary) 8%, transparent);
    border: none;
    border-radius: 6px;
    padding: 0.35rem 0.625rem;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}

.pdv2__change-btn:hover {
    background: color-mix(in srgb, var(--brand-primary) 14%, transparent);
}

/* ── Section transition animations ───────────────────── */
@keyframes pdv2-enter {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pdv2-exit {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-8px); }
}

.pdv2__card--enter {
    animation: pdv2-enter 0.3s cubic-bezier(.22,.68,0,1.2) forwards;
}

.pdv2__card--exit {
    animation: pdv2-exit 0.2s ease-in forwards;
    pointer-events: none;
}

/* ── Mobile adjustments ───────────────────────────────── */
@media (max-width: 480px) {
    .pdv2__main { padding: 1rem 0.75rem 1.5rem; }
    .pdv2__summary-amount-value { font-size: 1.25rem; }
    .pdv2__brand-grid { gap: 0.4rem; padding: 0.75rem 0.75rem 0.375rem; }
    .pdv2__bc { padding: 0.45rem 0.625rem; gap: 0.5rem; }
    .pdv2__bc-logo { width: 2rem; height: 2rem; }
}

/* ── Hosted URL mode: single card with text right, logos left ─ */
.pdv2__bc--hosted-single .pdv2__bc-logo--multi {
    margin-inline-start: auto;
}

/* ── Hosted URL mode: multi-logo brand slot ───────────── */
.pdv2__bc-logo--multi {
    width: auto;
    min-width: 2.5rem;
    height: 2.5rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    flex-shrink: 0;
}

.pdv2__bc-logo--multi img {
    height: 1.375rem;
    width: auto;
    object-fit: contain;
    display: block;
    border-radius: 3px;
}
