/**
 * الجزائر برس — مخرجات محرر تصميم صورة المقال + أقسام صفحة المقال المطورة (v2.8.0)
 * الغلاف يُبنى ببنية واحدة للموقع والمعاينة الحية (نفس الكلاسات والمتغيرات).
 * الأيقونة تظهر لمن يملك صلاحية التعديل فقط — الزائر لا يرى أي أداة تحرير.
 */

/* ============================================================
 * 1) الغلاف (Hero) — الأساس المشترك
 * ============================================================ */
.apd-hero {
    position: relative;
    margin: 0 0 20px;
    border-radius: 10px;
    overflow: hidden;
    background: #0b1e33;
    isolation: isolate;
    direction: rtl;
}
.apd-media { position: absolute; inset: 0; }
.apd-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: var(--apd-img-x, 50%) var(--apd-img-y, 50%);
    transform: scale(var(--apd-zoom, 1));
    filter: var(--apd-filter, none);
    display: block;
}
.apd-dim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, var(--apd-dim, 0));
    pointer-events: none;
    z-index: 1;
}
.apd-grad {
    position: absolute;
    inset: 0;
    background: linear-gradient(var(--apd-gdir, to top), transparent 35%, rgba(var(--apd-gcolor, 11,30,51), var(--apd-gstrength, .45)));
    pointer-events: none;
    z-index: 1;
}

/* منطقة النص — الموضع والمحاذاة */
.apd-text {
    position: absolute;
    inset-inline: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: var(--apd-t-pad, 26px);
    z-index: 2;
    pointer-events: none;
}
.apd-badge { order: 1; }
.apd-title { order: 2; }
.apd-info  { order: 3; }
.apd-pos-bottom .apd-text { bottom: 0; top: auto; justify-content: flex-end; }
.apd-pos-top    .apd-text { top: 0; bottom: auto; justify-content: flex-start; }
.apd-pos-middle .apd-text { top: 50%; bottom: auto; transform: translateY(-50%); justify-content: center; }
.apd-al-start  .apd-text { align-items: flex-start; }
.apd-al-center .apd-text { align-items: center; }
.apd-al-end    .apd-text { align-items: flex-end; }
.apd-pos-middle .apd-title { text-align: inherit; }

/* الشارة */
.apd-badge {
    display: inline-block;
    background: var(--apd-b-bg, #d93025);
    color: var(--apd-b-color, #fff);
    font-size: var(--apd-b-size, 13px);
    font-weight: 800;
    line-height: 1;
    padding: calc(var(--apd-b-pad, 8px) / 1.7) var(--apd-b-pad, 8px);
    border-radius: var(--apd-b-radius, 6px);
    text-shadow: none;
    letter-spacing: 0;
}
.apd-bp-corner .apd-badge {
    position: absolute;
    top: var(--apd-t-pad, 26px);
    inset-inline-start: var(--apd-t-pad, 26px);
    z-index: 3;
}
.apd-bp-below .apd-badge { order: 3; }
.apd-bp-below .apd-info  { order: 4; }
.apd-ip-above .apd-info  { order: 1; }
.apd-bp-corner.apd-pos-top .apd-text { padding-top: calc(var(--apd-t-pad, 26px) + 30px); }

/* العنوان — H1 حقيقي على الموقع (سيو سليم بلا تكرار) */
.apd-title {
    margin: 0;
    font-size: calc(var(--apd-t-size, 34px) * var(--apd-fit, 1));
    font-weight: var(--apd-t-weight, 700);
    color: var(--apd-t-color, #fff);
    line-height: var(--apd-t-lh, 1.3);
    max-width: var(--apd-t-w, 100%);
    font-family: var(--apd-t-font, inherit);
    text-shadow: var(--apd-shadow, none);
    background: var(--apd-t-bg, transparent);
    border-radius: 10px;
    padding: 0.4em 0.7em;
    overflow-wrap: break-word;
    word-break: break-word;
}
.apd-title[style] { hyphens: none; }
.apd-al-start .apd-title { text-align: start; }
.apd-al-center .apd-title { text-align: center; }
.apd-al-end .apd-title { text-align: end; }

/* شريط المعلومات */
.apd-info {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    align-items: center;
    color: var(--apd-i-color, #e2e8f0);
    font-size: var(--apd-i-size, 13px);
    font-weight: var(--apd-i-weight, 600);
    text-shadow: var(--apd-shadow, none);
    max-width: var(--apd-t-w, 100%);
}
.apd-i { white-space: nowrap; }
.apd-i-breaking {
    background: #d93025;
    color: #fff;
    padding: 2px 12px;
    border-radius: 20px;
    font-weight: 800;
    text-shadow: none;
    font-size: 0.92em;
}
.apd-ip-corner .apd-info {
    position: absolute;
    bottom: var(--apd-t-pad, 26px);
    inset-inline-end: var(--apd-t-pad, 26px);
    z-index: 3;
    max-width: 60%;
    justify-content: flex-end;
}

/* الشعار */
.apd-logo {
    position: absolute;
    top: var(--apd-l-margin, 18px);
    height: var(--apd-l-size, 56px);
    width: auto;
    opacity: var(--apd-l-opacity, .9);
    z-index: 3;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,.5));
    pointer-events: none;
}
.apd-lp-start .apd-logo { inset-inline-start: var(--apd-l-margin, 18px); }
.apd-lp-end   .apd-logo { inset-inline-end: var(--apd-l-margin, 18px); }

/* فروق القوالب البنيوية (القيم الموصى بها تضبطها القوالب في المحرر) */
.apd-t-classic   .apd-grad { background: linear-gradient(var(--apd-gdir, to top), transparent 25%, rgba(var(--apd-gcolor, 11,30,51), var(--apd-gstrength, .45))); }
.apd-t-modern    .apd-grad { background: linear-gradient(var(--apd-gdir, to top), transparent 42%, rgba(var(--apd-gcolor, 11,30,51), var(--apd-gstrength, .45))); }
.apd-t-prominent .apd-title { max-width: 100%; }
.apd-t-prominent .apd-grad { background: linear-gradient(var(--apd-gdir, to top), transparent 18%, rgba(var(--apd-gcolor, 11,30,51), var(--apd-gstrength, .45))); }
.apd-t-minimal   .apd-hero-title-plate { }

/* تكبير الصورة حي داخل المعاينة */
.apd-zoomed { cursor: grab; }
.apd-media.is-dragging { cursor: grabbing; }

/* ============================================================
 * 2) أيقونة تحرير التصميم — الجهة اليسرى من الصورة (للمصرح لهم فقط)
 * ============================================================ */
.dz-article-featured { position: relative; }
.apd-edit-btn {
    position: absolute;
    top: 14px;
    inset-inline-end: 14px; /* يسار الصورة في صفحة RTL */
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(11, 30, 51, .85);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 9px;
    padding: 7px 13px;
    font-size: 12.5px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    opacity: .92;
    transition: background .18s ease, transform .18s ease, opacity .18s ease;
    backdrop-filter: blur(3px);
}
.apd-edit-btn:hover {
    background: #d9822b;
    border-color: #d9822b;
    opacity: 1;
    transform: translateY(-1px);
}
.apd-edit-btn:focus-visible { outline: 2px solid #d9822b; outline-offset: 2px; }
.apd-edit-btn svg { flex-shrink: 0; }

/* ============================================================
 * 2-م) شريط دخول محرر التصميم — زر بارز تحت الصورة البارزة (v2.9.0)
 *      يظهر لمن يملك صلاحية التعديل فقط — الزائر لا يرى شيئاً
 * ============================================================ */
.apd-entry-bar {
    display: flex;
    justify-content: flex-start;
    margin: -6px 0 20px;
}
.apd-entry-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: #0b1e33;
    color: #fff;
    border: 1px solid #0b1e33;
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.apd-entry-btn:hover {
    background: #d93025;
    border-color: #d93025;
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(217, 48, 37, .25);
}
.apd-entry-btn:focus-visible { outline: 2px solid #d93025; outline-offset: 2px; }
.apd-entry-btn svg { flex-shrink: 0; }
.apd-entry-btn em {
    font-style: normal;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, .72);
    border-inline-start: 1px solid rgba(255, 255, 255, .28);
    padding-inline-start: 9px;
}
@media (max-width: 640px) {
    .apd-entry-btn em { display: none; }
}

/* ============================================================
 * 3) الوسوم والتصنيفات أسفل المقال
 * ============================================================ */
.apd-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 24px 0 8px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}
.apd-tag {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: none;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}
.apd-tag:hover { background: #e2e8f0; color: #0b1e33; transform: translateY(-1px); }
.apd-tag-cat {
    background: #15406b;
    color: #fff;
    border-color: #15406b;
}
.apd-tag-cat:hover { background: #0b1e33; color: #fff; }

/* ============================================================
 * 4) المقال السابق والتالي
 * ============================================================ */
.apd-pn {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 26px 0;
}
.apd-pn-card {
    display: flex;
    gap: 12px;
    align-items: center;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    min-width: 0;
}
.apd-pn-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(11, 30, 51, .12);
    border-color: #d9822b;
}
.apd-pn-thumb {
    width: 92px;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: #eef1f5;
}
.apd-pn-body { min-width: 0; flex: 1; }
.apd-pn-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 800;
    color: #d9822b;
    margin-bottom: 4px;
}
.apd-pn-title {
    display: block;
    color: #1e293b;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.55;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.apd-pn-next { text-align: left; flex-direction: row-reverse; }
.apd-pn-next .apd-pn-label { justify-content: flex-end; }
@media (max-width: 640px) {
    .apd-pn { grid-template-columns: 1fr; }
    .apd-pn-next { flex-direction: row; }
    .apd-pn-next .apd-pn-label { justify-content: flex-start; }
}

/* ============================================================
 * 5) صندوق الكاتب المطور
 * ============================================================ */
.ajp-author-box {
    display: flex;
    gap: 16px;
    align-items: center;
    margin: 28px 0;
    padding: 18px 20px;
    border: 1px solid #e2e8f0;
    border-inline-start: 4px solid #d9822b;
    border-radius: 12px;
    background: #fbfcfe;
}
.ajp-author-box .apd-author-avatar img { border-radius: 50%; }
.ajp-author-box strong a { font-size: 16px; color: #0b1e33; }
.ajp-author-box .apd-author-role {
    display: block;
    font-size: 12px;
    color: #d9822b;
    font-weight: 700;
    margin-top: 2px;
}
.ajp-author-box .apd-author-more {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #15406b;
    text-decoration: none;
}
.ajp-author-box .apd-author-more:hover { color: #d9822b; }

/* ============================================================
 * 6) شريط المشاركة — إضافة نسخ الرابط والطباعة
 * ============================================================ */
.apd-share-extra {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-radius: 6px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 700;
    color: #15406b !important;
    background: #eef4fd;
    border: 1px solid #d3e3f8;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s ease;
}
.apd-share-extra:hover { background: #ddeaf9; }
.apd-copy-done { color: #2ecc71 !important; background: #eefaf2 !important; border-color: #bfe8cc !important; }

/* ============================================================
 * 7) بطاقات ذات صلة — صور موحدة وتصنيف
 * ============================================================ */
.dz-related-card img {
    aspect-ratio: 16 / 9;
    height: auto;
    object-fit: cover;
}
.dz-related-card .dz-rel-cat {
    display: block;
    padding: 8px 10px 0;
    color: #d9822b;
    font-size: 11.5px;
    font-weight: 800;
}

/* ============================================================
 * 8) لايت بوكس — تكبير الصور داخل المقال عند الضغط
 * ============================================================ */
.apd-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(4, 10, 18, .93);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 26px;
    cursor: zoom-out;
    animation: apdFade .18s ease;
}
.apd-lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
    cursor: default;
}
.apd-lightbox button {
    position: absolute;
    top: 16px;
    inset-inline-end: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .35);
    background: rgba(11, 30, 51, .8);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}
@keyframes apdFade { from { opacity: 0; } to { opacity: 1; } }
.dz-article-content img.apd-zoomable { cursor: zoom-in; }

/* ============================================================
 * 9) طباعة محسّنة للمقال
 * ============================================================ */
@media print {
    .apd-edit-btn, .apd-entry-bar, #apd-editor, .apd-toast,
    .dz-article-share, .apd-pn, .apd-lightbox,
    .dz-article-related, header, footer, nav { display: none !important; }
    .apd-hero { break-inside: avoid; }
}

/* ============================================================
 * 10) التجاوب
 * ============================================================ */
@media (max-width: 782px) {
    .apd-text { padding: calc(var(--apd-t-pad, 26px) * .7); }
    .apd-title { padding: .35em .6em; }
    .apd-ip-corner .apd-info { max-width: 80%; }
    .apd-edit-btn span { display: none; }
    .apd-edit-btn { padding: 8px; border-radius: 10px; }
}
@media (prefers-reduced-motion: reduce) {
    .apd-edit-btn, .apd-pn-card, .apd-tag, .apd-lightbox { transition: none; animation: none; }
}
