@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap');

/* ================================================================
   PC & Solar Builder Pro — Clean Light UI
   بنفسجي فاتح للحدود، أبيض للخلفية، أزرق للأزرار — مثل الصورة المرجعية
   ================================================================ */

:root {
    --pcbp-purple:    #7c3aed;
    --pcbp-purple-lt: #ede9fe;
    --pcbp-purple-md: #c4b5fd;
    --pcbp-border:    #ddd6fe;
    --pcbp-blue:      #2563eb;
    --pcbp-blue-lt:   #eff6ff;
    --pcbp-green:     #16a34a;
    --pcbp-green-lt:  #dcfce7;
    --pcbp-red:       #dc2626;
    --pcbp-amber:     #d97706;
    --pcbp-bg:        #f8fafc;
    --pcbp-white:     #ffffff;
    --pcbp-text:      #1e293b;
    --pcbp-muted:     #64748b;
    --pcbp-radius:    14px;
    --pcbp-shadow:    0 2px 12px rgba(124,58,237,.08);
}

/* ── Base — force all text to be dark, override any theme interference ── */
.pcbp-builder *, .pcbp-builder *::before, .pcbp-builder *::after { box-sizing: border-box; margin: 0; padding: 0; }
.pcbp-builder {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    color: #1e293b !important;
    background: #f8fafc;
    padding: 28px 0 60px;
    direction: rtl;
}

/* Force all text inside builder to dark unless explicitly set otherwise */
.pcbp-builder h1,.pcbp-builder h2,.pcbp-builder h3,
.pcbp-builder p,.pcbp-builder span,.pcbp-builder div,
.pcbp-builder label,.pcbp-builder td,.pcbp-builder th {
    color: inherit;
}

/* ── Platform Selector ── */
.pcbp-platform-wrap { text-align: center; margin-bottom: 28px; }
.pcbp-platform-label { font-size: 15px; font-weight: 700; color: #1e293b; margin-bottom: 12px; }
.pcbp-platform-btns {
    display: inline-flex; gap: 12px;
    background: #ffffff; border: 1px solid #ddd6fe;
    border-radius: 999px; padding: 6px;
}
.pcbp-plat-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 32px; border-radius: 999px;
    border: 1.5px solid transparent; background: transparent;
    font-size: 15px; font-weight: 700; cursor: pointer;
    transition: all 0.2s ease; color: #64748b;
}
.pcbp-plat-btn.active {
    background: #ffffff; border-color: #ddd6fe;
    color: #1e293b; box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.pcbp-plat-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.pcbp-plat-dot--intel { background: #2563eb; }
.pcbp-plat-dot--amd   { background: #dc2626; }

/* ── Layout ── */
.pcbp-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}
@media (max-width: 900px) {
    .pcbp-layout { grid-template-columns: 1fr; }
    /* الملخص تحت القائمة على الموبايل */
    .pcbp-summary-col { order: 2; position: static; }
    .pcbp-slots-col   { order: 1; }
}

/* ── Slot ── */
.pcbp-slot {
    display: flex; align-items: center; gap: 14px;
    background: #ffffff; border: 1.5px solid #ddd6fe;
    border-radius: 14px; padding: 16px 18px; margin-bottom: 10px;
    transition: border-color .2s, box-shadow .2s;
}
.pcbp-slot:hover       { border-color: #c4b5fd; box-shadow: 0 2px 12px rgba(124,58,237,.08); }
.pcbp-slot.is-selected { border-color: #a78bfa; background: #f5f3ff; }
.pcbp-slot.is-hidden   { display: none !important; }

.pcbp-slot-num {
    min-width: 32px; height: 32px; border-radius: 8px;
    background: #ede9fe; color: #7c3aed;
    font-size: 13px; font-weight: 800;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.pcbp-slot.is-selected .pcbp-slot-num { background: #7c3aed; color: #ffffff; }

.pcbp-slot-info { flex: 1; min-width: 0; }
.pcbp-slot-labels { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.pcbp-slot-label-ar { font-size: 14px; font-weight: 700; color: #1e293b; }
.pcbp-slot-label-en { font-size: 12px; color: #64748b; direction: ltr; display: inline-block; }
.pcbp-req { color: #dc2626; }

.pcbp-slot-selected-preview {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: #7c3aed; margin-top: 2px;
}
.pcbp-slot-selected-preview img { width: 24px; height: 24px; object-fit: contain; border-radius: 4px; }
.pcbp-slot-selected-preview .sel-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; color: #1e293b; }
.pcbp-slot-selected-preview .sel-price { color: #7c3aed; font-weight: 700; white-space: nowrap; }

.pcbp-slot-trigger {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 20px; border: 1.5px dashed #c4b5fd;
    border-radius: 999px; background: #ede9fe; color: #7c3aed;
    font-size: 13px; font-weight: 600; cursor: pointer;
    white-space: nowrap; transition: all .15s ease; flex-shrink: 0;
}
.pcbp-slot-trigger:hover { background: #7c3aed; color: #ffffff; border-color: #7c3aed; }
.pcbp-slot.is-selected .pcbp-slot-trigger { border-style: solid; }
.pcbp-trigger-icon { font-size: 16px; font-weight: 400; }

/* ── Summary Card ── */
.pcbp-summary-col { position: sticky; top: 80px; }
.pcbp-summary-card {
    background: #ffffff; border: 1.5px solid #ddd6fe;
    border-radius: 14px; overflow: hidden;
    box-shadow: 0 2px 12px rgba(124,58,237,.08);
}
.pcbp-summary-header {
    padding: 14px 18px;
    border-bottom: 1px solid #ddd6fe;
    background: #ede9fe;
}
.pcbp-summary-title { font-size: 15px; font-weight: 800; color: #7c3aed; }

.pcbp-summary-items { padding: 10px 0; min-height: 60px; }
.pcbp-sum-empty { padding: 16px 18px; color: #94a3b8; font-size: 13px; text-align: center; }

.pcbp-sum-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 7px 18px; border-bottom: 1px solid #f1f5f9; font-size: 12px;
}
.pcbp-sum-item:last-child { border-bottom: none; }
.pcbp-sum-arrow  { color: #7c3aed; flex-shrink: 0; font-size: 10px; margin-top: 2px; }
.pcbp-sum-item-info  { flex: 1; min-width: 0; }
.pcbp-sum-item-name  { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #1e293b; }
.pcbp-sum-item-sku   { color: #94a3b8; font-size: 11px; }
.pcbp-sum-item-price { font-weight: 700; color: #2563eb; white-space: nowrap; }

.pcbp-sum-totals  { padding: 12px 18px; border-top: 1.5px solid #ddd6fe; background: #fafbff; }
.pcbp-sum-row     { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 4px 0; color: #64748b; }
.pcbp-sum-final   { font-size: 15px; font-weight: 800; color: #1e293b; padding-top: 8px; border-top: 1px solid #e2e8f0; margin-top: 6px; }
.pcbp-price-before   { text-decoration: line-through; color: #94a3b8; }
.pcbp-price-after    { color: #2563eb; font-weight: 800; font-size: 16px; }
.pcbp-price-discount { color: #16a34a; font-weight: 700; }
.pcbp-zone-shipping-val { color: #7c3aed; font-weight: 700; }
.pcbp-discount-promo { font-size: 11px; color: #64748b; background: #eff6ff; border-radius: 8px; padding: 7px 10px; margin-top: 8px; line-height: 1.5; }
.pcbp-discount-promo--hidden { display: none; }

/* ── Zone inside card ── */
.pcbp-zone-sep  { height: 1px; background: #ddd6fe; margin: 0 0 14px; }
.pcbp-zone-inner { padding: 0 18px 14px; }
.pcbp-zone-inner-label { font-size: 13px; font-weight: 700; color: #1e293b; margin-bottom: 8px; }
.pcbp-zone-select {
    width: 100%; padding: 10px 12px;
    border: 1.5px solid #ddd6fe; border-radius: 8px;
    font-size: 14px; color: #1e293b; background: #f8fafc; cursor: pointer;
}
.pcbp-zone-select:focus { outline: none; border-color: #7c3aed; }

/* ── Button group inside card ── */
.pcbp-btn-group {
    padding: 14px 18px;
    border-top: 1px solid #ddd6fe;
    display: flex; flex-direction: column; gap: 8px;
    background: #fafbff;
}
.pcbp-btn {
    display: block; width: 100%;
    padding: 11px; border-radius: 8px;
    border: none; font-size: 13px; font-weight: 700;
    cursor: pointer; text-align: center;
    transition: opacity .15s, transform .12s;
    font-family: inherit;
    letter-spacing: 0.2px;
}
.pcbp-btn:hover:not(:disabled) { opacity: .88; transform: translateY(-1px); }
.pcbp-btn:disabled { opacity: .38; cursor: not-allowed; transform: none; }
.pcbp-btn--copy    { background: #1e293b; color: #ffffff; }
.pcbp-btn--invoice { background: #eff6ff; color: #2563eb; border: 1.5px solid #bfdbfe; }
.pcbp-wa-btns { display: flex; flex-direction: column; gap: 8px; }
.pcbp-wa-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 14px; border-radius: 8px;
    background: #16a34a; color: #ffffff;
    border: none; cursor: pointer; font-size: 14px; font-weight: 700;
    width: 100%; transition: opacity .15s; font-family: inherit;
}
.pcbp-wa-btn:hover:not(:disabled) { opacity: .88; }
.pcbp-wa-btn:disabled { opacity: .35; cursor: not-allowed; }
.pcbp-wa-btn-hint { font-size: 11px; color: #94a3b8; text-align: center; margin: 2px 0 0; }

/* Buttons */
.pcbp-btn {
    display: block; width: calc(100% - 36px); margin: 8px 18px;
    padding: 11px;
    border-radius: 10px;
    border: none;
    font-size: 13px; font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: opacity .15s, transform .15s;
}
.pcbp-btn:hover:not(:disabled) { opacity: .88; transform: translateY(-1px); }
.pcbp-btn:disabled { opacity: .4; cursor: not-allowed; }

.pcbp-btn--copy    { background: #1e293b; color: #fff; }
.pcbp-btn--invoice { background: var(--pcbp-blue-lt); color: var(--pcbp-blue); border: 1.5px solid var(--pcbp-blue); }
.pcbp-btn--cart    { background: var(--pcbp-blue); color: #fff; margin-top: 4px; }
.pcbp-btn--primary { background: var(--pcbp-blue); color: #fff; }
.pcbp-btn--wa      { background: #25d366; color: #fff; font-size: 13px; }

.pcbp-wa-btns { padding: 0 18px; display: flex; flex-direction: column; gap: 8px; margin: 4px 0; }
.pcbp-wa-btn  {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 14px; border-radius: 10px;
    background: #25d366; color: #fff;
    border: none; cursor: pointer;
    font-size: 13px; font-weight: 700;
    transition: opacity .15s;
    text-decoration: none;
}
.pcbp-wa-btn:hover { opacity: .88; }

.pcbp-power-value  { font-size: 22px; font-weight: 800; color: var(--pcbp-purple); }
.pcbp-power-note   { font-size: 11px; color: var(--pcbp-muted); margin-top: 4px; }

/* ── Product Modal ── */
.pcbp-modal {
    position: fixed; inset: 0; z-index: 100000;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 20px 16px;
    overflow-y: auto;
}
.pcbp-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.55);
    cursor: pointer;
    z-index: 0;
}
.pcbp-modal-dialog {
    position: relative; z-index: 1;
    background: #fff;
    border-radius: 14px;
    width: min(880px, 96vw);
    /* المفتاح: ارتفاع ثابت كافٍ مع flex column حتى يشتغل overflow الداخلي */
    height: calc(100vh - 80px);
    max-height: 860px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    margin: auto;
}

/* Header: لا يتمدد */
.pcbp-modal-head {
    flex-shrink: 0;
    padding: 14px 20px;
    border-bottom: 1px solid #ddd6fe;
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    background: #fafbff;
}
.pcbp-modal-title {
    font-size: 15px; font-weight: 800; margin-bottom: 4px;
    color: #1e293b; /* نص داكن ليظهر على الخلفية الفاتحة */
}
.pcbp-modal-meta {
    font-size: 12px; color: #475569;
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.pcbp-modal-meta select {
    font-size: 12px; padding: 2px 6px;
    border: 1px solid #ddd6fe; border-radius: 6px;
    color: #1e293b; background: #fff;
}
.pcbp-modal-meta label { color: #475569; }
.pcbp-modal-meta input[type="checkbox"] { accent-color: #7c3aed; }
.pcbp-modal-actions { display: flex; gap: 8px; flex-shrink: 0; }
.pcbp-modal-refresh, .pcbp-modal-close, .pcbp-modal-reset {
    padding: 6px 14px; border-radius: 8px; border: 1px solid #ddd6fe;
    background: #fff; font-size: 12px; cursor: pointer; white-space: nowrap;
    color: #1e293b;
}
.pcbp-modal-close  { background: #fee2e2; color: #dc2626; border-color: #fecaca; }
.pcbp-modal-reset  { color: #7c3aed; }

/* Search: لا يتمدد */
.pcbp-modal-search-bar {
    flex-shrink: 0;
    padding: 10px 16px;
    border-bottom: 1px solid #ddd6fe;
    background: #fff;
}
.pcbp-search {
    width: 100%; padding: 10px 14px;
    border: 1.5px solid #ddd6fe; border-radius: 10px;
    font-size: 14px; color: #1e293b;
    background: #fff;
    transition: border-color .2s;
}
.pcbp-search::placeholder { color: #94a3b8; }
.pcbp-search:focus { outline: none; border-color: #7c3aed; }

/* Grid: يتمدد ويأخذ كل المساحة المتبقية مع scroll داخلي */
.pcbp-modal-grid {
    flex: 1;              /* يأخذ كل المساحة المتبقية بعد الـ header والـ search */
    overflow-y: auto;     /* scroll داخلي هنا فقط */
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    align-content: start; /* البطاقات تبدأ من الأعلى ولا تتمدد لتملأ كل الارتفاع */
    -webkit-overflow-scrolling: touch;
}

/* ── بطاقة المنتج ── */
.pcbp-loading {
    grid-column: 1/-1; text-align: center;
    padding: 40px; color: #94a3b8; font-size: 14px;
}
.pcbp-no-products {
    grid-column: 1/-1; text-align: center;
    padding: 40px; color: #94a3b8; font-size: 14px;
}

.pcbp-prod-card {
    border: 1.5px solid #ddd6fe;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    background: #fff;
    transition: border-color .15s, box-shadow .15s, transform .15s;
    display: flex;
    flex-direction: column;
}
.pcbp-prod-card:hover {
    border-color: #c4b5fd;
    box-shadow: 0 4px 16px rgba(124,58,237,.12);
    transform: translateY(-2px);
}
.pcbp-prod-card.is-selected { border-color: #7c3aed; background: #ede9fe; }

.pcbp-prod-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    padding: 12px;
    background: #f8fafc;
    flex-shrink: 0;
}
.pcbp-prod-body {
    padding: 10px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.pcbp-prod-name {
    font-size: 12px; font-weight: 700;
    line-height: 1.4; color: #1e293b;
    word-break: break-word;
}
.pcbp-prod-sku   { font-size: 11px; color: #64748b; }
.pcbp-prod-status { font-size: 11px; font-weight: 600; color: #16a34a; }
.pcbp-prod-price  {
    font-size: 14px; font-weight: 800;
    color: #1d4ed8; margin-top: auto;
    padding-top: 6px;
}

.pcbp-prod-select-btn {
    display: block; width: 100%; padding: 10px;
    background: #2563eb; color: #fff;
    border: none; font-size: 13px; font-weight: 700;
    cursor: pointer; transition: background .15s;
    flex-shrink: 0;
    letter-spacing: 0.3px;
}
.pcbp-prod-select-btn:hover { background: #1d4ed8; }

/* ── Invoice Modal ── */
.pcbp-invoice-modal {
    position: fixed; inset: 0; z-index: 100001;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 20px 16px;
    overflow-y: auto;
    background: rgba(15,23,42,0.6);
}
.pcbp-invoice-dialog {
    position: relative; z-index: 1;
    background: #ffffff;
    border-radius: 14px;
    width: min(720px, 96vw);
    /* لا max-height هنا — الفاتورة تتمدد بكل محتواها ويكون الـ scroll على الـ modal overlay */
    margin: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    flex-shrink: 0;
}
.pcbp-inv-step { padding: 28px; }
.pcbp-inv-step h3 { font-size: 18px; font-weight: 800; margin-bottom: 20px; color: #1e293b; }
.pcbp-inv-field { margin-bottom: 16px; }
.pcbp-inv-field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: #1e293b; }
.pcbp-inv-field input {
    width: 100%; padding: 11px 14px;
    border: 1.5px solid #ddd6fe; border-radius: 10px;
    font-size: 14px; color: #1e293b; background: #fff;
}
.pcbp-inv-field input:focus { outline: none; border-color: #7c3aed; }
.pcbp-inv-btns { display: flex; gap: 10px; }
.pcbp-inv-toolbar {
    padding: 14px 20px;
    border-bottom: 1px solid #ddd6fe;
    display: flex; gap: 10px; flex-wrap: wrap;
    background: #f8fafc;
    border-radius: 14px 14px 0 0;
}
.pcbp-inv-toolbar .pcbp-btn { width: auto; margin: 0; }
.pcbp-btn--print  { background: #1e293b; color: #fff; }
.pcbp-btn--pdf    { background: #dc2626; color: #fff; }
.pcbp-btn--wa-pdf { background: #25d366; color: #fff; }

/* ── Invoice Body ── */
.pcbp-invoice-body { padding: 30px; background: #ffffff; }
.pcbp-inv-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.pcbp-inv-logo img { max-width: 120px; max-height: 60px; object-fit: contain; }
.pcbp-inv-company-name { font-size: 16px; font-weight: 800; }
.pcbp-inv-company-sub  { font-size: 12px; color: var(--pcbp-muted); }
.pcbp-inv-meta { text-align: start; }
.pcbp-inv-quote-title { font-size: 18px; font-weight: 800; color: var(--pcbp-blue); margin-bottom: 4px; }
.pcbp-inv-meta-row { font-size: 12px; color: var(--pcbp-muted); }

.pcbp-inv-platform-badge {
    display: inline-block; padding: 4px 12px; border-radius: 999px;
    font-size: 12px; font-weight: 700; margin-bottom: 14px;
    background: var(--pcbp-blue-lt); color: var(--pcbp-blue);
    border: 1px solid #bfdbfe;
}
.pcbp-inv-client-section {
    display: flex; gap: 24px; margin-bottom: 16px;
    background: #f8fafc; padding: 12px 16px; border-radius: 10px;
}
.pcbp-inv-client-item { font-size: 13px; }
.pcbp-inv-client-item strong { font-weight: 700; }

.pcbp-inv-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 13px; }
.pcbp-inv-table th {
    background: var(--pcbp-blue); color: #fff;
    padding: 10px 12px; text-align: right;
    font-weight: 700;
}
.pcbp-inv-table td { padding: 9px 12px; border-bottom: 1px solid #f1f5f9; }
.pcbp-inv-table tr:hover td { background: #f8fafc; }
.pcbp-inv-table td.comp-ar { font-weight: 700; color: var(--pcbp-text); }
.pcbp-inv-table td.comp-en { font-size: 11px; color: var(--pcbp-muted); }
.pcbp-inv-table td.sku     { font-family: monospace; color: var(--pcbp-blue); font-size: 12px; text-decoration: underline; cursor: pointer; }
.pcbp-inv-table td.price   { font-weight: 700; white-space: nowrap; }

.pcbp-inv-totals { background: #f8fafc; border-radius: 10px; padding: 14px 18px; }
.pcbp-inv-tot-row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; color: var(--pcbp-muted); }
.pcbp-inv-tot-final {
    display: flex; justify-content: space-between;
    font-size: 18px; font-weight: 800;
    background: var(--pcbp-blue); color: #fff;
    padding: 12px 18px; border-radius: 10px; margin-top: 10px;
}
.pcbp-inv-count-badge {
    display: flex; justify-content: flex-end;
    font-size: 12px; color: var(--pcbp-muted);
    margin-top: 8px;
}
.pcbp-inv-discount-note { font-size: 12px; color: var(--pcbp-green); margin-top: 4px; }

.pcbp-inv-footer {
    margin-top: 20px; padding-top: 14px;
    border-top: 1px solid var(--pcbp-border);
    font-size: 11px; color: var(--pcbp-muted);
    text-align: center;
}

.pcbp-toast {
    position: fixed; bottom: 24px; left: 24px; z-index: 999999;
    padding: 12px 20px; border-radius: 12px;
    font-size: 14px; font-weight: 600;
    background: var(--pcbp-white);
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
    border: 1.5px solid var(--pcbp-border);
    animation: pcbp-slide 0.3s ease;
}
.pcbp-toast-ok  { border-color: var(--pcbp-green); color: var(--pcbp-green); }
.pcbp-toast-err { border-color: var(--pcbp-red);   color: var(--pcbp-red);   }
@keyframes pcbp-slide { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Print styles ── */

/* ── Desktop/Mobile preview toggle ── */
/* ── Desktop/Mobile preview toggle ── */
.pcbp-preview-desktop { display: flex !important; }
.pcbp-preview-mobile  { display: none !important; }

@media (max-width: 860px) {

    /* الـ slot: عرض ثابت لا يتمدد أبداً */
    .pcbp-slot {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        flex-wrap: nowrap;
    }

    /* الرقم: مربع صغير بجانب العنوان — لا يأخذ عرضاً كاملاً */
    .pcbp-slot-num {
        min-width: 28px !important;
        width: 28px !important;
        height: 28px !important;
        font-size: 11px !important;
        border-radius: 7px !important;
        flex-shrink: 0 !important;
        align-self: flex-start !important;
    }

    /* الـ slot-info لا يتمدد */
    .pcbp-slot-info {
        flex: 1 !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }

    /* الـ labels: قطع النص الطويل */
    .pcbp-slot-label-ar {
        font-size: 13px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        max-width: 100% !important;
    }
    .pcbp-slot-label-en {
        font-size: 10px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    /* الحقل المختار: بطاقة عمودية */
    .pcbp-slot.is-selected {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 6px !important;
    }
    /* الرقم بجانب العنوان — نعيد السطر الأول أفقياً */
    .pcbp-slot.is-selected > .pcbp-slot-num {
        display: none !important; /* نخفيه من الجسم ونُظهره بجانب العنوان */
    }
    .pcbp-slot.is-selected .pcbp-slot-info { width: 100% !important; }
    .pcbp-slot.is-selected .pcbp-slot-trigger { display: none !important; }

    /* preview mobile */
    .pcbp-preview-desktop { display: none !important; }
    .pcbp-preview-mobile  {
        display: flex !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        gap: 10px !important;
        align-items: flex-start !important;
    }
    .pcbp-preview-mobile > img {
        width: 56px !important;
        height: 56px !important;
        flex-shrink: 0 !important;
        object-fit: contain !important;
        border-radius: 8px !important;
        background: #f8fafc !important;
    }
    .pcbp-preview-mobile > div {
        flex: 1 !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }
    /* اسم المنتج: بحد أقصى سطرين */
    .pcbp-preview-mobile .sel-name-text {
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        word-break: break-word !important;
        max-width: 100% !important;
        font-size: 12px !important;
        line-height: 1.4 !important;
        white-space: normal !important;
    }
    .pcbp-preview-mobile .sel-price-text {
        white-space: nowrap !important;
        font-size: 13px !important;
        font-weight: 800 !important;
        color: #7c3aed !important;
    }
    .pcbp-preview-mobile .sel-sku-text {
        font-size: 10px !important;
        color: #94a3b8 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    .pcbp-preview-mobile .sel-actions {
        display: flex !important;
        gap: 7px !important;
        margin-top: 6px !important;
        width: 100% !important;
    }
    .pcbp-preview-mobile .sel-btn-change,
    .pcbp-preview-mobile .sel-btn-clear {
        flex: 1 !important;
        padding: 7px !important;
        border-radius: 7px !important;
        font-size: 12px !important;
        font-weight: 700 !important;
        cursor: pointer !important;
        border: none !important;
        font-family: inherit !important;
    }
    .pcbp-preview-mobile .sel-btn-change { background: #2563eb !important; color: #fff !important; }
    .pcbp-preview-mobile .sel-btn-clear  { background: #fee2e2 !important; color: #dc2626 !important; border: 1.5px solid #fecaca !important; }
}


/* ── Invoice responsive ── */
@media (max-width: 680px) {
    .pcbp-invoice-modal {
        padding: 6px !important;
        align-items: flex-start !important;
        overflow-y: auto !important;
    }
    .pcbp-invoice-dialog {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 10px !important;
        margin: 0 auto !important;
    }
    .pcbp-invoice-body {
        padding: 10px 8px !important;
        font-size: 11px !important;
        overflow-x: hidden !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    /* الجدول على الموبايل */
    .pcbp-invoice-body table {
        font-size: 10px !important;
    }
    .pcbp-invoice-body td,
    .pcbp-invoice-body th {
        padding: 6px 5px !important;
        font-size: 10px !important;
    }
    /* Header الفاتورة: عمودي على الموبايل */
    .pcbp-invoice-body > div:first-of-type {
        flex-direction: column !important;
        gap: 8px !important;
    }
    .pcbp-inv-toolbar {
        padding: 8px 10px !important;
        gap: 5px !important;
        flex-wrap: wrap !important;
    }
    .pcbp-inv-toolbar .pcbp-btn {
        padding: 7px 10px !important;
        font-size: 11px !important;
    }
}

/* ── Cairo font — كل عناصر البلغن والنوافذ ── */
.pcbp-builder,
.pcbp-builder *,
.pcbp-invoice-modal,
.pcbp-invoice-modal *,
.pcbp-invoice-body,
.pcbp-invoice-body *,
#pcbp-body-modal,
#pcbp-body-modal *,
#pcbp-inv-body-pc,
#pcbp-inv-body-pc *,
#pcbp-inv-body-solar,
#pcbp-inv-body-solar * {
    font-family: Cairo, 'Segoe UI', Tahoma, Arial, sans-serif !important;
}

@media print {
    body > *:not(.pcbp-invoice-body) { display: none !important; }
    .pcbp-inv-toolbar { display: none !important; }
    .pcbp-invoice-body { padding: 0; }
}
@media (max-width: 600px) {
    .pcbp-modal-grid { grid-template-columns: repeat(2, 1fr); }
    .pcbp-modal-head { flex-direction: column; }
    .pcbp-modal-meta { font-size: 11px; }
}

/* ── Power Card ── */
.pcbp-power-card {
    background: #ffffff; border: 1.5px solid #ddd6fe;
    border-radius: 14px; padding: 16px 18px; margin-top: 14px;
    box-shadow: 0 2px 12px rgba(124,58,237,.08);
}
.pcbp-power-header {
    font-size: 13px; font-weight: 800; color: #1e293b;
    margin-bottom: 14px; display: flex; align-items: center; gap: 6px;
    font-family: Cairo, 'Segoe UI', Tahoma, Arial, sans-serif;
}
.pcbp-power-card { font-family: Cairo, 'Segoe UI', Tahoma, Arial, sans-serif; }
.pcbp-power-icon { font-size: 16px; }

/* ── Gauge ── */
.pcbp-power-gauge-wrap {
    position: relative; text-align: center; margin-bottom: 16px;
    width: 150px; height: 150px; margin-left: auto; margin-right: auto;
}
.pcbp-power-gauge {
    width: 150px; height: 150px; display: block; margin: 0 auto;
}
.pcbp-gauge-center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center; pointer-events: none;
}
.pcbp-gauge-watts {
    font-size: 32px; font-weight: 900; color: #1e293b; line-height: 1;
    font-family: Cairo, 'Segoe UI', sans-serif;
}
.pcbp-gauge-unit { font-size: 11px; color: #94a3b8; margin-top: 3px; font-family: Cairo, 'Segoe UI', sans-serif; }

/* ── PSU Suggestion ── */
.pcbp-psu-suggest {
    display: flex; justify-content: space-between; align-items: center;
    background: #fafbff; border-radius: 10px; padding: 10px 14px;
    margin-bottom: 12px; border: 1px solid #ddd6fe;
    font-family: Cairo, 'Segoe UI', sans-serif;
}
.pcbp-psu-label { font-size: 11px; color: #64748b; font-weight: 600; }
.pcbp-psu-value { font-size: 20px; font-weight: 800; color: #1e293b; display: flex; align-items: center; gap: 6px; }
.pcbp-psu-badge {
    display: inline-flex; align-items: center;
    font-size: 10px; font-weight: 700;
    padding: 3px 9px; border-radius: 999px;
    background: #fef9c3; color: #854d0e;
    border: 1px solid #fde68a;
}

/* ── Load Bar ── */
.pcbp-power-load { margin-bottom: 14px; }
.pcbp-power-load-label {
    display: flex; justify-content: space-between;
    font-size: 12px; color: #64748b; margin-bottom: 6px;
}
.pcbp-power-load-pct { font-weight: 700; color: #1e293b; }
.pcbp-power-load-bar {
    height: 8px; background: #f1f5f9; border-radius: 999px; overflow: hidden;
}
.pcbp-power-load-fill {
    height: 100%; border-radius: 999px; width: 0%;
    transition: width .5s ease, background .5s ease;
    background: #22c55e;
}
.pcbp-power-load-status {
    font-size: 11px; margin-top: 5px; font-weight: 600;
    color: #16a34a;
}

/* ── Breakdown ── */
.pcbp-power-breakdown { margin-bottom: 10px; }
.pcbp-power-breakdown-title {
    font-size: 12px; font-weight: 700; color: #1e293b;
    margin-bottom: 8px; padding-bottom: 4px;
    border-bottom: 1px solid #f1f5f9;
}
.pcbp-power-row {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 0; font-size: 12px;
    font-family: Cairo, 'Segoe UI', sans-serif;
}
.pcbp-power-row-label { width: 80px; flex-shrink: 0; color: #64748b; font-size: 11px; text-align: right; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pcbp-power-row-bar   { flex: 1; height: 6px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.pcbp-power-row-fill  { height: 100%; border-radius: 999px; min-width: 4px; transition: width .4s ease; }
.pcbp-power-row-watts { font-size: 11px; font-weight: 700; color: #1e293b; white-space: nowrap; text-align: left; min-width: 55px; }

.pcbp-power-note { font-size: 10px; color: #94a3b8; margin-top: 6px; }
/* ── Summary Total Only (إجمالي بدون قائمة) ── */
.pcbp-sum-total-only {
    padding: 16px 18px 4px;
}
.pcbp-sum-total-label {
    font-size: 12px; color: #94a3b8; margin-bottom: 6px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.pcbp-sum-total-row {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 6px;
}
.pcbp-sum-total-main {
    display: flex; align-items: baseline; gap: 4px;
}
.pcbp-sum-total-main .pcbp-price-after {
    font-size: 28px; font-weight: 900; color: #1e293b; line-height: 1;
}
.pcbp-sum-currency {
    font-size: 14px; font-weight: 700; color: #64748b;
}
.pcbp-sum-total-sub {
    display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap;
}
.pcbp-price-before-small {
    font-size: 12px; color: #94a3b8; text-decoration: line-through;
}
.pcbp-price-discount-badge {
    font-size: 11px; font-weight: 700; padding: 2px 8px;
    background: #dcfce7; color: #16a34a; border-radius: 999px;
}
.pcbp-sum-count-badge {
    display: flex; flex-direction: column; align-items: center;
    background: #ede9fe; border-radius: 10px; padding: 6px 12px;
    min-width: 52px;
}
.pcbp-sum-count-num { font-size: 20px; font-weight: 900; color: #7c3aed; line-height: 1; }
.pcbp-sum-count-lbl { font-size: 10px; color: #7c3aed; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════
   عرض السعر — إصلاح الهاتف + الطباعة/حفظ PDF
   يغطّي باني الحاسبات وباني الطاقة الشمسية (كلاهما يستخدم .pcbp-doc)
   ═══════════════════════════════════════════════════════════════ */

/* سطر الـ SKU تحت اسم الموديل — مخفي على الشاشات الواسعة وفي الطباعة */
.pcbp-doc .pcbp-sku-inline {
    display: none;
    font-size: 9px;
    color: #475569;
    font-weight: 400;
    direction: ltr;
    text-align: right;
    margin-top: 2px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* ── الهاتف: إعادة توزيع أعمدة الجدول ──
   السبب الأصلي للمشكلة: table-layout:fixed مع عروض ثابتة
   (26 + 104 + 84 + 96 = 310 بكسل) لا يترك لعمود «الموديل»
   سوى بضعة بكسلات على شاشة الهاتف، فينكسر النص حرفاً بحرف. */
@media screen and (max-width: 680px) {

    .pcbp-doc table.pcbp-items {
        table-layout: auto !important;
        font-size: 10.5px !important;
    }

    .pcbp-doc table.pcbp-items th,
    .pcbp-doc table.pcbp-items td {
        padding: 5px 4px !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
    }

    /* # */
    .pcbp-doc table.pcbp-items th:nth-child(1),
    .pcbp-doc table.pcbp-items td:nth-child(1) {
        width: 20px !important;
        min-width: 20px !important;
        padding: 5px 2px !important;
    }

    /* المكوّن */
    .pcbp-doc table.pcbp-items th:nth-child(2),
    .pcbp-doc table.pcbp-items td:nth-child(2) {
        width: 66px !important;
    }

    /* الموديل — يأخذ كل المساحة المتبقّية */
    .pcbp-doc table.pcbp-items th:nth-child(3),
    .pcbp-doc table.pcbp-items td:nth-child(3) {
        width: auto !important;
        text-align: right !important;
    }

    /* SKU — يُخفى كعمود ويظهر سطراً صغيراً تحت الموديل */
    .pcbp-doc table.pcbp-items th:nth-child(4),
    .pcbp-doc table.pcbp-items td:nth-child(4) {
        display: none !important;
    }
    .pcbp-doc .pcbp-sku-inline { display: block !important; }

    /* السعر */
    .pcbp-doc table.pcbp-items th:nth-child(5),
    .pcbp-doc table.pcbp-items td:nth-child(5) {
        width: 74px !important;
        white-space: nowrap !important;
    }

    /* ترويسة الفاتورة: عمود واحد بدل ثلاثة */
    .pcbp-doc .pcbp-head {
        grid-template-columns: 1fr !important;
        gap: 2px 0 !important;
        margin-bottom: 7px !important;
    }
    .pcbp-doc .pcbp-col   { font-size: 10.5px !important; line-height: 1.6 !important; }
    .pcbp-doc .pcbp-store { font-size: 12.5px !important; }
    .pcbp-doc .pcbp-sub   { font-size: 10px !important; }
    .pcbp-doc .pcbp-en    { font-size: 8.5px !important; line-height: 1.3 !important; }
    .pcbp-doc .pcbp-chip  { font-size: 9px !important; padding: 1px 8px !important; }

    .pcbp-doc .pcbp-tr    { font-size: 10.5px !important; }
    .pcbp-doc .pcbp-final { font-size: 13px !important; padding: 7px 9px !important; }
    .pcbp-doc .pcbp-note  { font-size: 8.5px !important; }

    .pcbp-doc .pcbp-banner img { max-height: 110px !important; }
    .pcbp-doc .pcbp-padt,
    .pcbp-doc .pcbp-padb { height: 4mm !important; }
}

/* ── الطباعة / حفظ PDF من الصفحة نفسها ──
   يعمل على الهاتف والحاسوب بلا نافذة منبثقة (النوافذ المنبثقة
   تُحجب على متصفّحات الهاتف، وهذا سبب تعطّل زرّ «حفظ PDF»). */
#pcbp-print-root { display: none; }

@media print {
    body.pcbp-printing > *:not(#pcbp-print-root) { display: none !important; }

    body.pcbp-printing #pcbp-print-root {
        display: block !important;
        position: static !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    body.pcbp-printing {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* الجدول يرجع لتوزيع A4 الكامل حتى لو كانت الطباعة من الهاتف */
    body.pcbp-printing #pcbp-print-root table.pcbp-items { table-layout: fixed !important; }
    body.pcbp-printing #pcbp-print-root .pcbp-sku-inline { display: none !important; }
    body.pcbp-printing #pcbp-print-root table.pcbp-items th:nth-child(4),
    body.pcbp-printing #pcbp-print-root table.pcbp-items td:nth-child(4) { display: table-cell !important; }

    body.pcbp-printing #pcbp-print-root * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    @page { size: A4; margin: 10mm; }
}

/* ═══════════════════════════════════════════════════════════════
   إصلاح الخروج عن حدود الشاشة على الهواتف
   ───────────────────────────────────────────────────────────────
   السبب: في CSS Grid الوحدة 1fr تعني minmax(auto, 1fr)، و auto
   هنا = min-content. فإذا احتوى العمود على زرّ أو نصّ لا ينكسر،
   يرفض العمود النزول تحت عرض محتواه ويتمدّد خارج الشاشة.
   على شاشة 360 بكسل كان العمود 415 بكسل ويبدأ عند -81،
   فتُقَصّ أزرار «اختر المعالج» عند الحافة (ولا يمكن التمرير
   إليها لأن overflow-x مخفي في القالب).
   الحل: minmax(0,1fr) مع min-width:0 على الأعمدة.
   ═══════════════════════════════════════════════════════════════ */

.pcbp-layout { min-width: 0; }
.pcbp-slots-col,
.pcbp-summary-col { min-width: 0; }

@media (max-width: 900px) {
    .pcbp-layout      { grid-template-columns: minmax(0, 1fr) !important; }
    .pcbp-slots-col,
    .pcbp-summary-col { min-width: 0 !important; max-width: 100% !important; }
}

/* حزام أمان: لا شيء داخل الباني يتجاوز عرض الحاوية */
@media (max-width: 900px) {
    .pcbp-builder { overflow-x: clip; }
    .pcbp-builder .pcbp-slot,
    .pcbp-builder .pcbp-summary,
    .pcbp-builder .pcbp-zone-card { max-width: 100% !important; box-sizing: border-box !important; }
}
