/* ============================================================
   مكوّن المشاركة الاجتماعي — مشترك بين كل صفحات البوابة
   ------------------------------------------------------------
   مصمَّم على نمط بوابة أمانة منطقة القصيم (أزرار منسدلة + صف أزرار ملوّنة).
   يُحمَّل مرة واحدة في include/new_header.php (CSS) و include/new_footer.php (JS)،
   فلا يحتاج أي صفحة أن تكرّر الوسم أو منطق JavaScript.

   ---------- البنية ----------
   زر المشاركة (يفتح قائمة واحدة مشتركة في الصفحة كلها):
     <button class="hs-btn" data-share-toggle
             data-share-title="عنوان العنصر"      ← اختياري، وإلا عنوان الصفحة
             data-share-url="https://…"           ← اختياري، وإلا رابط الصفحة
             aria-label="مشاركة">
       <svg …></svg>
     </button>

   صف أزرار ملوّنة (تُملأ روابطها تلقائياً عند التحميل):
     <div class="hs-bar">
       <a class="hs-pill hs-pill--x" data-share="x">إكس</a>
       <button class="hs-pill hs-pill--copy" data-share="copy">نسخ الرابط</button>
     </div>

   ---------- ما يملأه share.js ----------
   - روابط كل [data-share] الثابتة في الصفحة.
   - القائمة المنسدلة المشتركة: تُبنى مرة واحدة وتُموضع بجوار الزر عند الفتح،
     فلا تتأثر بـ overflow:hidden على البطاقات ولا يحتاج تكرار 8 عناصر في كل بطاقة.
   - نسخ الرابط (Clipboard API مع بديل execCommand) + رسالة تأكيد.
   - الطباعة.
   - الإغلاق بالنقر خارجها أو بمفتاح Escape، مع إدارة aria.

   بادئة الكلاسات: hs- (hail share) — لا تتعارض مع أي مكوّن آخر في style.css.
   ============================================================ */

/* ---------- 1. زر المشاركة ---------- */
.hs-btn {
    all: unset;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    padding: 0;
    background: #ffffff;
    border: 1px solid #e2e5e9;
    border-radius: 8px;
    color: #161616;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.hs-btn:hover,
.hs-btn:focus-visible {
    background: #1b8354;
    border-color: #1b8354;
    color: #ffffff;
}

.hs-btn svg {
    width: 19px;
    height: 19px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

/* نسخة داكنة تُستعمل فوق الصور (مكتبة الوسائط) لتبقى مقروءة */
.hs-btn--onmedia {
    background: rgba(255, 255, 255, 0.94);
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}

.hs-btn--onmedia:hover,
.hs-btn--onmedia:focus-visible {
    background: #1b8354;
    border-color: #1b8354;
}

/* ---------- 2. القائمة المنسدلة المشتركة ---------- */
/* fixed لأنها قد تُفتح داخل بطاقة عليها overflow:hidden فتفتصّ */
.hs-pop {
    position: fixed;
    z-index: 9999;
    min-width: 200px;
    padding: 8px;
    margin: 0;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
    text-align: right;
}

.hs-pop[hidden] {
    display: none;
}

.hs-menu {
    margin: 0;
    padding: 0;
    list-style: none;
}

.hs-menu li {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Bootstrap يضبط padding-inline-start للقوائم — نلغيه */
.hs-menu li::before,
.hs-menu li::marker {
    content: none;
}

.hs-item {
    all: unset;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 9px 11px;
    border-radius: 7px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.6;
    color: #161616;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}

.hs-item:hover,
.hs-item:focus-visible {
    background: #f4f7f5;
    color: #1b8354;
}

/* ---------- 3. أيقونات المنصات ---------- */
.hs-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    color: #ffffff;
}

.hs-ico svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    stroke: none;
}

/* المبدّل يطابق اسم المنصة في share.js (قيمة data-share) حرفياً،
   فلو اختلف الاسمان اختفى لون الأيقونة دون خطأ ظاهر. */
.hs-ico--x         { background: #000000; }
.hs-ico--facebook  { background: #1877f2; }
.hs-ico--linkedin  { background: #0a66c2; }
.hs-ico--whatsapp  { background: #25d366; }
.hs-ico--telegram  { background: #229ed9; }
.hs-ico--email     { background: #6b7280; }
.hs-ico--copy      { background: #1b8354; }
.hs-ico--print     { background: #475569; }

/* أيقونات مرسومة بخط (رسالة/نسخ/طباعة) لا بملء */
.hs-ico--stroke svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hs-sep {
    height: 1px;
    margin: 6px 8px;
    background: #ececec;
}

/* ---------- 4. رسالة "تم نسخ الرابط" ---------- */
.hs-toast {
    position: fixed;
    z-index: 10000;
    margin: 0;
    padding: 7px 13px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    color: #ffffff;
    background: #161616;
    border-radius: 7px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    pointer-events: none;
}

.hs-toast.is-show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ---------- 5. صف الأزرار الملوّنة ---------- */
.hs-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.hs-pill {
    all: unset;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px;
    border-radius: 9px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1;
    color: #ffffff;
    text-decoration: none;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.hs-pill:hover,
.hs-pill:focus-visible {
    filter: brightness(0.93);
    transform: translateY(-1px);
}

.hs-pill svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    stroke: none;
    pointer-events: none;
}

.hs-pill--x         { background: #000000; }
.hs-pill--facebook  { background: #1877f2; }
.hs-pill--linkedin  { background: #0a66c2; }
.hs-pill--whatsapp  { background: #25d366; }
.hs-pill--telegram  { background: #229ed9; }
.hs-pill--email     { background: #6b7280; }
.hs-pill--copy      { background: #1b8354; }

.hs-pill--stroke svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------- 6. الاستجابة ---------- */
@media (max-width: 480px) {
    .hs-pill span {
        display: none;
    }
    .hs-pill {
        padding: 9px 11px;
    }
    .hs-pop {
        min-width: 178px;
    }
}

@media print {
    .hs-btn,
    .hs-pop,
    .hs-toast,
    .hs-bar {
        display: none !important;
    }
}
