/*
| «اطلب في ثواني» (صفحة المنتج) — الكارت + الـpopup — product/quick-order.js
| الألوان من متغيرات المتجر (app.css / brand.css) → بتمشي مع A/B البراند لوحدها
*/

/* ---------- الكارت في الصفحة ---------- */
/* مختصر (المالك 21-10-2026: «كبيرة ومزعجة»): عنوان + سطر + خانة سطرين بتكبر لما العميل يكتب + الزرار — كان ~425px بقى ~200px على الموبايل */
.qo-card {
    position: relative;
    margin-bottom: 1rem;
    padding: 12px;
    border-radius: var(--radius-card, 1rem);
    border: 1px solid color-mix(in srgb, var(--color-brand) 35%, var(--color-line));
    background: linear-gradient(180deg, var(--color-brand-soft) 0%, #fff 60%);
}
.qo-card-title { margin: 0; font-size: 15px; font-weight: 800; line-height: 1.5; color: var(--color-ink); }
.qo-card-sub { margin: 0 0 8px; font-size: 12.5px; color: var(--color-muted); line-height: 1.6; }
.qo-saved {
    margin: 2px 0 8px; padding: 5px 9px; border-radius: 9px;
    background: #ecfdf3; color: #146c43; font-size: 12.5px; font-weight: 700; line-height: 1.6;
}
.qo-text {
    display: block; width: 100%; min-height: 66px; resize: none;
    padding: 9px 12px; border-radius: var(--radius-xl, .75rem);
    border: 1.5px solid var(--color-line); background: #fff; color: var(--color-ink);
    font: inherit; font-size: 16px; line-height: 1.6; /* 16px = الآيفون مايعملش zoom */
    direction: rtl; text-align: right; /* الكلام يمين دايماً حتى لو بدأ برقم */
    transition: border-color .15s, box-shadow .15s, min-height .2s;
}
/* بتكبر لما العميل يدوس عليها أو يكون فيها كلام — وهي فاضية سطرين بس */
.qo-text:focus, .qo-text:not(:placeholder-shown) { min-height: 112px; resize: vertical; }
.qo-text::placeholder { color: color-mix(in srgb, var(--color-muted) 75%, transparent); font-size: 13.5px; }
.qo-text:focus { outline: none; border-color: var(--color-ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-brand) 25%, transparent); }
.qo-card.qo-shake .qo-text { animation: qo-shake .35s; border-color: var(--color-sale); }
@keyframes qo-shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
.qo-go { width: 100%; min-height: 46px; margin-top: 8px; padding-block: 10px; font-size: 15.5px; font-weight: 800; border-radius: var(--radius-xl, .75rem); }
.qo-go[aria-busy="true"] { pointer-events: none; opacity: .85; }
@media (prefers-reduced-motion: reduce) { .qo-text { transition: none; } }

/* إجابة سؤال / ملاحظة جوه الكارت (من غير popup) */
.qo-inline { margin-top: 10px; }
.qo-bubble {
    position: relative; padding: 10px 12px; border-radius: 14px 14px 14px 4px;
    background: #fff; border: 1px solid var(--color-line); color: var(--color-ink);
    font-size: 14px; line-height: 1.75; white-space: pre-line;
}
.qo-bubble b { display: block; margin-bottom: 2px; font-size: 12px; color: var(--color-muted); }
.qo-inline .qo-chips { margin-top: 8px; }

/* ---------- الـpopup ---------- */
html.qo-lock, html.qo-lock body { overflow: hidden !important; }
html.qo-lock .dlc-launch, html.qo-lock .dlc-nudge, html.qo-lock #dlStickyBuy { display: none !important; }

.qo-modal {
    position: fixed; left: 0; right: 0; top: 0; z-index: 1100;
    height: 100vh; height: var(--qo-vh, 100dvh);
    display: flex; align-items: flex-end; justify-content: center;
    direction: rtl; color: var(--color-ink);
}
.qo-modal[hidden] { display: none; }
.qo-backdrop { position: absolute; inset: 0; background: rgb(12 12 14 / .55); opacity: 0; transition: opacity .22s; }
.qo-modal.show .qo-backdrop { opacity: 1; }
.qo-sheet {
    position: relative; width: 100%; max-width: 560px;
    max-height: calc(var(--qo-vh, 100dvh) - 8px);
    display: flex; flex-direction: column;
    background: #fff; border-radius: 20px 20px 0 0;
    box-shadow: 0 -12px 40px rgb(0 0 0 / .25);
    transform: translateY(105%); transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}
.qo-modal.show .qo-sheet { transform: none; }
@media (min-width: 640px) {
    .qo-modal { align-items: center; padding: 16px; }
    .qo-sheet { border-radius: 20px; max-height: min(92vh, 880px); }
}
.qo-mh { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--color-line); }
.qo-mh b { font-size: 16px; font-weight: 800; }
.qo-x { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--color-soft); color: var(--color-ink); font-size: 16px; font-weight: 800; cursor: pointer; }
.qo-body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 12px 16px 18px; }
.qo-foot {
    flex: none; display: flex; align-items: center; gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--color-line); background: #fff;
}
@media (min-width: 640px) { .qo-foot { border-radius: 0 0 20px 20px; } }
.qo-ft { display: flex; flex-direction: column; min-width: 86px; line-height: 1.25; }
.qo-ft small { font-size: 12px; color: var(--color-muted); font-weight: 700; }
.qo-ft b { font-size: 18px; font-weight: 800; white-space: nowrap; }
.qo-ft i { font-style: normal; font-size: 11px; color: var(--color-muted); font-weight: 700; }
.qo-submit { flex: 1; min-height: 52px; border-radius: var(--radius-2xl, 1rem); font-size: 16px !important; font-weight: 800 !important; }
.qo-submit[aria-busy="true"] { pointer-events: none; opacity: .8; }

.qo-msg { margin-bottom: 10px; padding: 10px 12px; border-radius: 12px; font-size: 14px; font-weight: 700; line-height: 1.7; }
.qo-msg.ok { background: #ecfdf3; color: #146c43; }
.qo-msg.warn { background: #fff7e6; color: #8a4b05; }
.qo-modal .qo-bubble { margin-bottom: 10px; background: var(--color-soft); border-color: transparent; }

.qo-prob { margin-bottom: 10px; padding: 10px 12px; border-radius: 12px; background: var(--color-sale-soft); border: 1px solid color-mix(in srgb, var(--color-sale) 20%, transparent); }
.qo-prob p { margin: 0; font-size: 14px; font-weight: 700; color: #9b1c1c; line-height: 1.7; }
.qo-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.qo-chip {
    min-height: 38px; padding: 6px 14px; border-radius: 999px; cursor: pointer;
    border: 1.5px solid var(--color-ink); background: #fff; color: var(--color-ink);
    font: inherit; font-size: 14px; font-weight: 800;
}
.qo-chip:hover { background: var(--color-ink); color: #fff; }
.qo-chip[disabled] { border-color: var(--color-line); color: var(--color-muted); text-decoration: line-through; cursor: not-allowed; background: var(--color-soft); }
.qo-chip.on { background: var(--color-ink); color: #fff; }

.qo-sec { margin-top: 14px; }
.qo-sec h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 14px; font-weight: 800; color: var(--color-ink); }
.qo-item { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--color-line); }
.qo-item:last-child { border-bottom: 0; }
.qo-item img, .qo-item .qo-img { width: 58px; height: 58px; border-radius: 12px; object-fit: cover; background: var(--color-soft); }
.qo-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.qo-info b { font-size: 14px; font-weight: 800; line-height: 1.45; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.qo-info span { color: var(--color-muted); font-weight: 700; }
.qo-info em { font-style: normal; color: var(--color-brand-text, var(--color-brand-d)); }
.qo-info .qo-price { color: var(--color-ink); font-weight: 800; }
.qo-info .qo-warnline { color: var(--color-sale); }
.qo-sizebtn { align-self: flex-start; padding: 0; border: 0; background: none; color: var(--color-brand-text, var(--color-brand-d)); font: inherit; font-size: 12px; font-weight: 800; text-decoration: underline; cursor: pointer; }
.qo-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.qo-qty { display: inline-flex; align-items: center; border: 1px solid var(--color-line); border-radius: 999px; overflow: hidden; }
.qo-qty button { width: 32px; height: 32px; border: 0; background: #fff; color: var(--color-ink); font-size: 18px; font-weight: 800; cursor: pointer; }
.qo-qty button[disabled] { color: var(--color-line); cursor: not-allowed; }
.qo-qty span { min-width: 22px; text-align: center; font-weight: 800; }
.qo-rm { border: 0; background: none; padding: 2px 4px; color: var(--color-muted); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.qo-rm:hover { color: var(--color-sale); }
.qo-item-sizes { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.qo-empty { margin: 0; padding: 12px; border-radius: 12px; background: var(--color-soft); font-size: 14px; font-weight: 700; color: var(--color-muted); text-align: center; }
.qo-more { width: 100%; margin-top: 8px; min-height: 42px; border: 1.5px dashed var(--color-line); border-radius: 12px; background: #fff; color: var(--color-ink); font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; }
.qo-picker { margin-top: 8px; padding: 10px; border-radius: 12px; background: var(--color-soft); }
.qo-picker p { margin: 0 0 6px; font-size: 13px; font-weight: 800; }
.qo-picker .qo-chips + p { margin-top: 10px; }

.qo-f { margin-bottom: 10px; }
.qo-f label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 800; color: var(--color-ink); }
.qo-f label span { font-weight: 600; color: var(--color-muted); }
.qo-f input, .qo-f select, .qo-f textarea {
    display: block; width: 100%; min-height: 46px; padding: 10px 12px;
    border-radius: var(--radius-xl, .75rem); border: 1.5px solid var(--color-line);
    background: #fff; color: var(--color-ink); font: inherit; font-size: 16px; line-height: 1.5;
}
.qo-f textarea { min-height: 64px; resize: vertical; }
.qo-f input:not([type="tel"]), .qo-f textarea, .qo-f select { direction: rtl; text-align: right; }
.qo-f input:focus, .qo-f select:focus, .qo-f textarea:focus { outline: none; border-color: var(--color-ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-brand) 22%, transparent); }
.qo-f.qo-miss input, .qo-f.qo-miss select, .qo-f.qo-miss textarea { border-color: var(--color-sale); background: #fffafa; }
.qo-err { display: none; margin-top: 4px; font-size: 12px; font-weight: 800; color: var(--color-sale); }
.qo-f.qo-miss .qo-err { display: block; }
.qo-tip { display: block; margin-top: 4px; font-size: 12px; font-weight: 700; color: #b45309; }
.qo-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .qo-row { grid-template-columns: 1fr; gap: 0; } }

.qo-sum { padding: 12px; border-radius: 14px; background: var(--color-soft); }
.qo-line { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 14px; font-weight: 700; }
.qo-line.qo-disc { color: #146c43; }
.qo-line.qo-tot { margin-top: 4px; padding-top: 8px; border-top: 1px dashed var(--color-line); font-size: 16px; font-weight: 800; }
.qo-free { color: #146c43; font-weight: 800; }
.qo-muted { color: var(--color-muted); font-weight: 700; }
.qo-hint { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--color-brand-soft); font-size: 13px; font-weight: 800; color: var(--color-brand-text, var(--color-brand-d)); }
.qo-trust { margin: 12px 0 0; text-align: center; font-size: 12px; font-weight: 700; color: var(--color-muted); line-height: 1.8; }

/* SweetAlert فوق الـpopup */
.qo-swal { z-index: 2000 !important; }

@media (prefers-reduced-motion: reduce) {
    .qo-sheet, .qo-backdrop { transition: none; }
    .qo-card.qo-shake .qo-text { animation: none; }
}

/* عنوان مخفي لقارئ الشاشة */
.qo-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* «ضيف قطعة كمان» بضغطة (لون تاني بنفس المقاس) */
.qo-upsell { margin-top: 8px; }
.qo-upsell .qo-chip { border-color: var(--color-brand); }

/* الاقتراح تحت المنتج نفسه في الـpopup */
.qo-item-upsell { padding: 2px 0 12px; border-bottom: 1px solid var(--color-line); }
.qo-item-upsell .qo-hint { margin-top: 0; }
#qoItems .qo-item:has(+ .qo-item-upsell) { border-bottom: 0; }

/* اقتراح اللون + صورة مصغّرة للمنتج تحته */
.qo-chip.has-img { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; min-width: 72px; padding: 5px 6px 7px; border-radius: 14px; font-size: 12.5px; }
.qo-chip.has-img img { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; background: var(--color-soft); }
/* موديلات شبهه (الموديل مالوش لون تاني بالمقاس): 3 كروت جنب بعض — الصورة + الاسم + اللون والسعر */
.qo-upsell.is-sim { display: grid; grid-template-columns: repeat(3, minmax(0, 150px)); }
.qo-chip.qo-sim { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; min-height: 0; padding: 6px 4px 7px; border-radius: 14px; border-color: var(--color-brand); text-align: center; }
.qo-chip.qo-sim:hover { background: #fff; color: var(--color-ink); border-color: var(--color-ink); }
.qo-chip.qo-sim img { width: 64px; height: 64px; margin-bottom: 2px; border-radius: 10px; object-fit: cover; background: var(--color-soft); }
.qo-chip.qo-sim b { font-size: 12px; font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; }
.qo-chip.qo-sim span { font-size: 11.5px; font-weight: 700; color: var(--color-muted); line-height: 1.35; }
.qo-chip.qo-sim i { margin-top: 3px; padding: 1px 10px; border-radius: 999px; background: var(--color-brand); color: #fff; font-size: 11.5px; font-style: normal; font-weight: 800; }
.qo-chip.qo-sim[disabled] { opacity: .55; text-decoration: none; background: #fff; color: var(--color-ink); cursor: wait; }

/* ---------- رقم الموبايل بارز (المالك 2026-10-17: عميلين نسيوه — واحد منهم مكمّلش) ---------- */
.qo-need li.qo-need-key { border-color: color-mix(in srgb, var(--color-sale) 45%, transparent); background: var(--color-sale-soft); color: #9b1c1c; }
.qo-need li.qo-need-key b { margin-inline-start: 2px; padding: 0 6px; border-radius: 999px; background: var(--color-sale); color: #fff; font-size: 11px; font-weight: 800; }
/* تحت الخانة وهو بيكتب */
.qo-phone-hint { margin-top: 8px; padding: 8px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 700; line-height: 1.6; }
.qo-phone-hint.warn { background: var(--color-sale-soft); color: #9b1c1c; border: 1px solid color-mix(in srgb, var(--color-sale) 30%, transparent); }
.qo-phone-hint.ok { background: #ecfdf3; color: #146c43; }
.qo-phone-hint b { font-weight: 800; }
/* الـpopup: نسي الموبايل → كارت فوق خالص فيه الخانة */
.qo-req { margin-inline-start: 4px; padding: 0 6px; border-radius: 999px; background: var(--color-sale-soft); color: #9b1c1c; font-size: 11px; font-weight: 800; }
.qo-phone-call { margin-bottom: 12px; padding: 12px; border-radius: 14px; border: 2px solid var(--color-sale); background: var(--color-sale-soft); animation: qo-pulse 1.4s ease-in-out 3; }
.qo-phone-call > b { display: block; font-size: 16px; font-weight: 800; color: #9b1c1c; line-height: 1.5; }
.qo-phone-call > span { display: block; margin: 2px 0 10px; font-size: 13px; font-weight: 700; color: var(--color-ink-2, var(--color-ink)); }
.qo-phone-call .qo-f { margin-bottom: 0; }
.qo-phone-call #qoPhone { min-height: 52px; border-color: var(--color-sale); font-size: 18px; font-weight: 800; letter-spacing: .5px; }
.qo-phone-call.done { border-color: #198754; background: #ecfdf3; animation: none; }
.qo-phone-call.done > b { color: #146c43; }
.qo-phone-call.done #qoPhone { border-color: #198754; }
@keyframes qo-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgb(220 38 38 / 0); } 50% { box-shadow: 0 0 0 6px rgb(220 38 38 / .18); } }
@media (prefers-reduced-motion: reduce) { .qo-phone-call { animation: none; } }
