/* ============================================================
   product-modal.css — نافذة تفاصيل المنتج الاحترافية (AJAX)
   + Lightbox + مشاركة — بادئة .pdx- معزولة تماماً
   ============================================================ */

.pdx-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13, 20, 26, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

.pdx-overlay.open { opacity: 1; pointer-events: auto; }

/* ✅ إصلاح: المودال يستخدم flex مع أعمدة ثابتة */
.pdx-modal {
    background: #fff;
    border-radius: 22px;
    width: 100%;
    max-width: 980px;
    height: 92vh;
    max-height: 92vh;
    overflow: hidden;

    display: grid;
    grid-template-columns: 440px minmax(0, 1fr);

    direction: rtl;
    position: relative;

    box-shadow: 0 30px 80px rgba(0,0,0,0.35);

    transform: translateY(24px) scale(0.97);
    transition: transform 0.35s cubic-bezier(0.16,1,0.3,1);

    box-sizing: border-box;
}

.pdx-overlay.open .pdx-modal { transform: translateY(0) scale(1); }

/* ── زر الإغلاق ── */
.pdx-close {
    position: absolute;
    top: 14px; left: 14px;
    z-index: 20;
    width: 38px; height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.92);
    box-shadow: 0 3px 12px rgba(0,0,0,0.18);
    font-size: 17px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    color: #16232b;
}
.pdx-close:hover { background: #e05252; color: #fff; transform: rotate(90deg); }

/* ── المعرض ── */
.pdx-gallery {
    background: linear-gradient(160deg, #f4f8fb, #e9f0f5);
    padding: 26px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    height: 100%; /* ✅ ملء الارتفاع بالكامل */
}

.pdx-main-img {
    position: relative;
    flex: 1;
    min-height: 300px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #e4ebf0;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    font-size: 90px;
    cursor: zoom-in;
}

.pdx-main-img img {
    max-width: 88%; max-height: 88%;
    object-fit: contain;
    transition: transform 0.35s ease;
    pointer-events: none;
}
.pdx-main-img:hover img { transform: scale(1.05); }

/* أيقونة التكبير */
.pdx-zoom-hint {
    position: absolute;
    bottom: 10px; left: 10px;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(22,35,43,0.65);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.pdx-main-img:hover .pdx-zoom-hint { opacity: 1; }

.pdx-badge {
    position: absolute;
    top: 12px; right: 12px;
    background: #e05252; color: #fff;
    font-size: 12px; font-weight: 800;
    padding: 5px 13px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(224,82,82,0.35);
    z-index: 5;
}

.pdx-thumbs { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; flex-shrink: 0; }

.pdx-thumb {
    width: 68px; height: 68px;
    flex-shrink: 0;
    border-radius: 12px;
    background: #fff;
    border: 2px solid #e4ebf0;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px;
    overflow: hidden;
    transition: all 0.2s;
    padding: 0;
}
.pdx-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pdx-thumb:hover { border-color: #a9c6dc; transform: translateY(-2px); }
.pdx-thumb.active { border-color: #5c89ad; box-shadow: 0 0 0 3px rgba(92,137,173,0.22); }

/* ── عمود المعلومات ── */
/* ✅ إصلاح: عمود المعلومات يستخدم flex مع اتجاه عمودي وoverflow */
.pdx-info {
    padding: 30px 28px 24px;

    display: flex;
    flex-direction: column;

    min-width: 0;
    min-height: 0;

    height: auto;
    overflow: hidden;

    box-sizing: border-box;
}

/* ✅ منطقة المحتوى القابلة للتمرير - تنمو وتملأ المساحة المتاحة */
.pdx-info-scroll {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;

    overflow-y: auto;

    padding-right: 4px;
    margin-right: -4px;
}

/* ✅ تنسيق التمرير */
.pdx-info-scroll::-webkit-scrollbar {
    width: 4px;
}
.pdx-info-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}
.pdx-info-scroll::-webkit-scrollbar-thumb {
    background: #c9a84c;
    border-radius: 10px;
}
.pdx-info-scroll::-webkit-scrollbar-thumb:hover {
    background: #b8923a;
}

.pdx-cat {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(92,137,173,0.1);
    color: #35566f;
    border: 1px solid rgba(92,137,173,0.28);
    padding: 4px 13px;
    border-radius: 50px;
    font-size: 12px; font-weight: 700;
    width: fit-content;
    margin-bottom: 12px;
}

.pdx-title { font-size: 23px; font-weight: 900; color: #16232b; line-height: 1.4; margin: 0 0 10px; }

.pdx-rating { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; font-size: 15px; color: #f0a020; }
.pdx-rating .pdx-rev { color: #5c7a8c; font-size: 12.5px; }

.pdx-price-box {
    background: linear-gradient(135deg, #f7fafc, #eef4f8);
    border: 1px solid #e0eaf1;
    border-radius: 14px;
    padding: 14px 18px;
    display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
    margin-bottom: 14px;
}
.pdx-price { font-size: 30px; font-weight: 900; color: #16232b; }
.pdx-price small { font-size: 14px; font-weight: 600; color: #5c7a8c; }
.pdx-old { font-size: 15px; color: #98a8b3; text-decoration: line-through; }
.pdx-save {
    background: rgba(76,175,127,0.12); color: #2e8b5e;
    border: 1px solid rgba(76,175,127,0.3);
    font-size: 12px; font-weight: 800;
    padding: 3px 11px; border-radius: 50px;
}

/* ── أزرار المشاركة ── */
.pdx-share-row {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 16px;
}
.pdx-share-label { font-size: 12.5px; font-weight: 700; color: #5c7a8c; }

.pdx-share-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    color: #fff;
}
.pdx-share-btn svg { width: 17px; height: 17px; fill: currentColor; }
.pdx-share-btn:hover { transform: translateY(-3px) scale(1.08); }

.pdx-share-btn.pdx-wa { background: #25d366; box-shadow: 0 4px 12px rgba(37,211,102,0.35); }
.pdx-share-btn.pdx-fb { background: #1877f2; box-shadow: 0 4px 12px rgba(24,119,242,0.35); }
.pdx-share-btn.pdx-copy {
    background: #f1f6f9; color: #35566f;
    border: 1px solid #dde7ee;
    font-size: 15px;
}
.pdx-share-btn.pdx-copy:hover { background: #35566f; color: #fff; }

/* ── مناسب لـ ── */
.pdx-targets { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.pdx-target {
    background: rgba(59,130,246,0.07);
    border: 1px solid rgba(59,130,246,0.2);
    color: #2b6cb0;
    font-size: 12px; font-weight: 700;
    padding: 5px 12px; border-radius: 50px;
}

/* ── التبويبات ── */
.pdx-tabs { display: flex; border-bottom: 2px solid #edf2f6; margin-bottom: 14px; flex-shrink: 0; }
.pdx-tab {
    padding: 10px 18px;
    border: none; background: none;
    font-family: 'Cairo', sans-serif;
    font-size: 13.5px; font-weight: 700;
    color: #5c7a8c;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.pdx-tab:hover { color: #35566f; }
.pdx-tab.active { color: #35566f; border-bottom-color: #5c89ad; }

/* ✅ إصلاح عرض النصوص - الحفاظ على فواصل الأسطر */
.pdx-pane {
    display: none;
    font-size: 14px;
    color: #4a6472;
    line-height: 1.9;
    animation: pdxFade 0.25s ease;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Cairo', sans-serif;
    padding: 4px 0;
}

.pdx-pane.active {
    display: block;
}

@keyframes pdxFade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.pdx-spec {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 9px 2px;
    border-bottom: 1px dashed #e4ebf0;
    font-size: 13.5px;
}
.pdx-spec:last-child { border-bottom: none; }
.pdx-spec b { color: #5c7a8c; font-weight: 600; }
.pdx-spec span { color: #16232b; font-weight: 700; text-align: left; }

/* ── منطقة الشراء (الأزرار) ── */
/* ✅ الأزرار ثابتة في الأسفل ولا تختفي */
.pdx-buy {
    flex: 0 0 auto;
    min-height: 46px;

    padding-top: 16px;
    margin-top: 16px;

    border-top: 1px solid #edf2f6;

    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;

    background: #fff;

    box-sizing: border-box;
}

.pdx-qty { display: flex; align-items: center; background: #f1f6f9; border: 1px solid #dde7ee; border-radius: 12px; overflow: hidden; flex-shrink: 0; }
.pdx-qty button { width: 38px; height: 44px; border: none; background: none; font-size: 18px; cursor: pointer; color: #35566f; transition: background 0.15s; }
.pdx-qty button:hover { background: rgba(92,137,173,0.15); }
.pdx-qty span { min-width: 36px; text-align: center; font-size: 16px; font-weight: 800; color: #16232b; }

.pdx-add {
    flex: 1; min-width: 150px; height: 46px;
    border: none; border-radius: 12px;
    background: linear-gradient(135deg, #5c89ad, #35566f);
    color: #fff;
    font-family: 'Cairo', sans-serif;
    font-size: 15px; font-weight: 800;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all 0.25s;
    box-shadow: 0 5px 16px rgba(92,137,173,0.35);
}
.pdx-add:hover { transform: translateY(-2px); box-shadow: 0 9px 24px rgba(92,137,173,0.45); }

.pdx-order {
    height: 46px; padding: 0 22px;
    border-radius: 12px;
    border: 2px solid #16232b;
    background: #16232b; color: #fff;
    font-family: 'Cairo', sans-serif;
    font-size: 14px; font-weight: 800;
    cursor: pointer;
    transition: all 0.25s;
    flex-shrink: 0;
}
.pdx-order:hover { background: #21384a; border-color: #21384a; }

/* ── Skeleton ── */
.pdx-skel { grid-column: 1 / -1; display: grid; grid-template-columns: 440px 1fr; width: 100%; height: 100%; }
.pdx-skel-box {
    margin: 26px;
    border-radius: 16px;
    background: linear-gradient(90deg, #eef2f5 25%, #f8fafc 50%, #eef2f5 75%);
    background-size: 200% 100%;
    animation: pdxShimmer 1.3s infinite;
}
.pdx-skel-img { min-height: 380px; }
.pdx-skel-line { height: 20px; margin: 18px 26px; }
.pdx-skel-line.w60 { width: 60%; }
.pdx-skel-line.w40 { width: 40%; }
@keyframes pdxShimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.pdx-error { grid-column: 1 / -1; text-align: center; padding: 70px 30px; color: #b3402e; font-size: 16px; font-weight: 700; }

/* ============================================================
   🔍 LIGHTBOX — تكبير الصورة بملء الشاشة
   ============================================================ */
.pdx-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 16, 0.94);
    z-index: 13000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    direction: rtl;
}
.pdx-lightbox.open { opacity: 1; pointer-events: auto; }

.pdx-lb-stage {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-in;
    overflow: hidden;
    padding: 30px;
}

.pdx-lb-stage img {
    max-width: 92%; max-height: 88vh;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 20px 70px rgba(0,0,0,0.5);
    transition: transform 0.3s ease;
    transform: scale(1);
    user-select: none;
    -webkit-user-drag: none;
}

.pdx-lb-stage.zoomed { cursor: zoom-out; }
.pdx-lb-stage.zoomed img { transform: scale(2.2); }

.pdx-lb-emoji { font-size: 160px; }

.pdx-lb-close {
    position: absolute;
    top: 18px; left: 18px;
    width: 44px; height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 19px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    z-index: 5;
}
.pdx-lb-close:hover { background: #e05252; transform: rotate(90deg); }

.pdx-lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px; height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    z-index: 5;
}
.pdx-lb-nav:hover { background: rgba(92,137,173,0.85); }
.pdx-lb-prev { right: 18px; }
.pdx-lb-next { left: 18px; }

.pdx-lb-counter {
    position: absolute;
    bottom: 20px; right: 50%;
    transform: translateX(50%);
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 13px; font-weight: 700;
    padding: 6px 16px;
    border-radius: 50px;
    z-index: 5;
}

/* ── الجوال ── */
@media (max-width: 860px) {

    .pdx-modal,
    .pdx-skel {
        grid-template-columns: 1fr;

        height: auto;
        max-height: 96vh;

        overflow-y: auto;
        overflow-x: hidden;

        border-radius: 18px;
    }

    .pdx-overlay {
        padding: 10px;
        align-items: flex-end;
    }

    .pdx-modal {
        border-radius: 18px 18px 0 0;
    }

    .pdx-main-img {
        min-height: 240px;
        max-height: 280px;
    }

    .pdx-gallery {
        padding: 16px;
        height: auto;
        box-sizing: border-box;
    }

    .pdx-info {
        padding: 20px 18px;
        height: auto;
        min-height: 0;
        overflow: visible;
        box-sizing: border-box;
    }

    .pdx-info-scroll {
        overflow: visible;
        min-height: 0;
    }

    .pdx-skel-img {
        min-height: 260px;
    }

    .pdx-buy {
        position: sticky;
        bottom: 0;
        z-index: 10;

        background: #fff;

        padding: 12px 0 4px;
        margin-top: 8px;

        border-top: 1px solid #edf2f6;
    }

    .pdx-order {
        flex: 1;
    }
}

@media (max-width: 420px) {
    .pdx-title { font-size: 19px; }
    .pdx-price { font-size: 25px; }
    .pdx-thumb { width: 56px; height: 56px; }
    .pdx-add, .pdx-order { width: 100%; flex: none; }
    .pdx-info { padding: 16px 14px; }
}