/* =====================================================================
   جرس التنبيهات (النافذة C2) — الهيدر + اللوحة المنسدلة + /notifications + /admin/notifications.
   رموز الثيم من theme-base.css فقط (الثلاثة)، خصائص منطقية (RTL/LTR)، أيقونات SVG بقناع (بلا إيموجي).
   ===================================================================== */
:root {
    --ntf-i-bell: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9a6 6 0 0 1 12 0c0 6 2.5 7.5 2.5 7.5h-17S6 15 6 9z'/%3E%3Cpath d='M10 20a2.2 2.2 0 0 0 4 0'/%3E%3C/svg%3E");
    --ntf-i-news: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 10v4a1 1 0 0 0 1 1h2l6 4.5v-15L7 9H5a1 1 0 0 0-1 1z'/%3E%3Cpath d='M16.5 9a4 4 0 0 1 0 6M19 6.5a7.5 7.5 0 0 1 0 11'/%3E%3C/svg%3E");
    --ntf-i-service: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 3.5l1.9 5.1L18 10.5l-5.1 1.9L11 17.5l-1.9-5.1L4 10.5l5.1-1.9z'/%3E%3Cpath d='M18.5 15.5v5M16 18h5'/%3E%3C/svg%3E");
    --ntf-i-offer: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.6 13.4l-7.2 7.2a2 2 0 0 1-2.8 0L3 13V3h10l7.6 7.6a2 2 0 0 1 0 2.8z'/%3E%3Ccircle cx='7.5' cy='7.5' r='1.6'/%3E%3C/svg%3E");
    --ntf-i-system: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5.5M12 16.5h.01'/%3E%3C/svg%3E");
}

/* ---------- الزرّ (بنفس قياس زرّ المظهر) ---------- */
.ntf { position: relative; flex: none; display: flex; }
.ntf-btn {
    position: relative; display: grid; place-items: center; flex: none;
    width: 38px; height: 38px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim);
    transition: border-color .15s, color .15s, background .15s;
}
.ntf-btn:hover, .ntf.is-open .ntf-btn { border-color: var(--primary); color: var(--primary); }
.ntf.is-unread .ntf-btn { color: var(--text); }
.ntf-ico {
    display: block; width: 19px; height: 19px; background: currentColor; transform-origin: 50% 12%;
    -webkit-mask: var(--ntf-i-bell) center / contain no-repeat; mask: var(--ntf-i-bell) center / contain no-repeat;
}
/* رنّة هادئة كل بضع ثوانٍ ما دام هناك غير مقروء (تتوقّف حين تُفتح اللوحة، وتحت prefers-reduced-motion) */
.ntf.is-unread .ntf-ico { animation: ntf-ring 6s ease-in-out 1.2s infinite; }
.ntf.is-open .ntf-ico { animation: none; }
@keyframes ntf-ring {
    0%, 16%, 100% { transform: rotate(0); }
    2%  { transform: rotate(16deg); }
    4%  { transform: rotate(-14deg); }
    6%  { transform: rotate(11deg); }
    8%  { transform: rotate(-8deg); }
    10% { transform: rotate(5deg); }
    12% { transform: rotate(-3deg); }
    14% { transform: rotate(1deg); }
}
.ntf-badge {
    position: absolute; top: -6px; inset-inline-end: -6px;
    min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
    background: var(--danger); color: #fff; font-size: .68rem; font-weight: 800; line-height: 19px; text-align: center;
    box-shadow: 0 0 0 2px var(--bg-elev); font-variant-numeric: tabular-nums; direction: ltr; pointer-events: none;
}
.ntf.is-unread .ntf-badge { animation: ntf-pop .35s ease-out both; }
@keyframes ntf-pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- اللوحة المنسدلة ---------- */
.ntf-panel {
    position: absolute; top: calc(100% + 10px); inset-inline-end: -8px; z-index: 70;
    width: 370px; max-width: calc(100vw - 24px); max-height: min(72vh, 560px);
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--bg-elev); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.ntf-panel[hidden] { display: none; }
.ntf-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none;
    padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.ntf-head-t { font-size: .98rem; }
.ntf-all { font-size: .82rem; font-weight: 700; color: var(--primary); white-space: nowrap; }
.ntf-all:hover { text-decoration: underline; }
.ntf-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.ntf-msg {
    margin: 0; padding: 24px 16px; display: flex; gap: 8px; align-items: center; justify-content: center;
    text-align: center; color: var(--text-dim); font-size: .88rem;
}
.ntf-spin {
    flex: none; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid var(--border-strong); border-top-color: var(--primary); animation: ntf-spin .8s linear infinite;
}
@keyframes ntf-spin { to { transform: rotate(360deg); } }

/* ---------- البنود ---------- */
.ntf-list { list-style: none; margin: 0; padding: 6px; display: grid; gap: 2px; }
.ntf-row {
    position: relative; display: flex; align-items: flex-start; gap: 11px;
    padding: 10px; border-radius: var(--radius); color: var(--text); text-decoration: none;
    transition: background .15s;
}
a.ntf-row:hover { background: var(--surface-2); }
.ntf-item.is-unread .ntf-row { background: color-mix(in srgb, var(--primary-soft) 60%, transparent); }
.ntf-item.is-unread a.ntf-row:hover { background: var(--primary-soft); }
.ntf-t-news    { --ntf-c: var(--primary); --ntf-m: var(--ntf-i-news); }
.ntf-t-service { --ntf-c: var(--ok);      --ntf-m: var(--ntf-i-service); }
.ntf-t-offer   { --ntf-c: var(--accent);  --ntf-m: var(--ntf-i-offer); }
.ntf-t-system  { --ntf-c: var(--danger);  --ntf-m: var(--ntf-i-system); }
.ntf-tico {
    position: relative; flex: none; width: 36px; height: 36px; border-radius: 11px;
    background: color-mix(in srgb, var(--ntf-c) 15%, transparent);
}
.ntf-tico::before {
    content: ''; position: absolute; inset: 9px; background: var(--ntf-c);
    -webkit-mask: var(--ntf-m) center / contain no-repeat; mask: var(--ntf-m) center / contain no-repeat;
}
.ntf-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ntf-kind { font-size: .7rem; font-weight: 800; color: var(--ntf-c); line-height: 1.3; }
.ntf-ttl { font-size: .9rem; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.ntf-sum {
    font-size: .82rem; color: var(--text-dim); line-height: 1.55; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ntf-sum--full { display: block; -webkit-line-clamp: unset; overflow: visible; }
.ntf-ago { font-size: .74rem; color: var(--text-dim); margin-top: 1px; }
.ntf-dot {
    flex: none; width: 9px; height: 9px; margin-top: 7px; border-radius: 50%; background: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
.ntf-sr {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ntf-empty { padding: 26px 16px; text-align: center; color: var(--text-dim); }
.ntf-empty-ico { position: relative; display: block; width: 46px; height: 46px; margin: 0 auto 10px; border-radius: 14px; background: var(--surface-2); }
.ntf-empty-ico::before {
    content: ''; position: absolute; inset: 12px; background: var(--text-dim);
    -webkit-mask: var(--ntf-i-bell) center / contain no-repeat; mask: var(--ntf-i-bell) center / contain no-repeat;
}
.ntf-empty p { margin: 0; font-size: .88rem; }

/* ---------- /notifications ---------- */
.ntf-page { max-width: 760px; padding: 28px 0 56px; }
.ntf-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.ntf-page-head h1 { margin: 0 0 4px; font-size: 1.55rem; }
.ntf-page-head p { margin: 0; }
.ntf-markall { margin: 0; }
.ntf-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.ntf-card .ntf-list { padding: 8px; gap: 4px; }
.ntf-card .ntf-row { padding: 14px 12px; }
.ntf-card .ntf-ttl { font-size: .98rem; }
.ntf-card .ntf-sum { font-size: .88rem; }

/* ---------- اللوحة: /admin/notifications ---------- */
.ntf-chip { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.ntf-chip .ntf-tico { width: 26px; height: 26px; border-radius: 8px; }
.ntf-chip .ntf-tico::before { inset: 6px; }
.ntf-adm-link { overflow-wrap: anywhere; }
/* الجدول يُمرَّر أفقياً داخل .adm-table-wrap على الهاتف بدل أن يُكسَر العنوان كلمةً كلمة */
.ntf-adm-table td:nth-child(2) { min-width: 200px; }
.ntf-adm-table td:nth-child(5) .mono { white-space: nowrap; }
.ntf-adm-table td:nth-child(4) { min-width: 120px; }
.ntf-adm-settings { display: grid; gap: 12px; max-width: 680px; }
.ntf-adm-settings input[type="number"] { max-width: 120px; }
.ntf-adm-auto-list { margin: 0 0 10px; padding-inline-start: 18px; display: grid; gap: 8px; font-size: .88rem; }
.ntf-adm-auto-list small { display: block; }
.ntf-adm-form .ntf-adm-lang { margin-top: 14px; }

/* ---------- الهاتف (نفس عتبة الهيدر 720px) ----------
   الجرس أيقونة فقط بقياس أزرار الهاتف (36px). اللوحة بعرض الشاشة تحت الهيدر: .ntf بلا موضع ⇒ مرجعها الهيدر
   (sticky) — مثل قائمة الهاتف. جرس الزائر يُخفى هنا: مكانه لاسم الموقع وزرّي الدخول/التسجيل (يبقى /notifications). */
@media (max-width: 720px) {
    .ntf { position: static; }
    .ntf-btn { width: 36px; height: 36px; }
    .ntf-ico { width: 18px; height: 18px; }
    .ntf-badge { top: -5px; inset-inline-end: -5px; min-width: 17px; height: 17px; line-height: 17px; font-size: .64rem; padding: 0 4px; }
    .ntf-panel {
        top: calc(100% + 6px); inset-inline: 8px; width: auto; max-width: none;
        max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px);
    }
    .ntf--guest { display: none; }
    .ntf-page { padding-top: 20px; }
    .ntf-page-head { align-items: flex-start; }
    .ntf-page-head h1 { font-size: 1.3rem; }
}
/* الهواتف (≤460px): أيقونة مجرّدة بلا إطار (28px) تأكل نصف الفاصلين (-3px) — قيس 360–460px:
   اسم الموقع لا يُقصّ أكثر من قبل الجرس إلا في حالة واحدة موثّقة (HANDOFF_C2 §2). */
@media (max-width: 460px) {
    .ntf { margin-inline: -3px; }
    .ntf-btn { width: 28px; height: 36px; border-color: transparent; background: transparent; }
    .ntf-btn:hover, .ntf.is-open .ntf-btn { border-color: transparent; background: var(--surface-2); }
    .ntf-badge { inset-inline-end: -7px; }
}

/* هاتف ضيّق جداً (notify.js يضيف ntf-tight فقط إن كان الجرس سيقصّ اسم الموقع والاسم يتّسع بدونه):
   الجرس يخرج من الهيدر إلى قائمة الهاتف برابط وعدد. خلاف ذلك الرابط مخفيّ دائماً. */
html:not(.ntf-tight) .ntf-mlink { display: none !important; }
html.ntf-tight .site-header .ntf { display: none; }
.ntf-mbadge {
    display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; margin-inline-start: 6px;
    border-radius: 10px; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 800; line-height: 1; direction: ltr;
}

@media (prefers-reduced-motion: reduce) {
    .ntf.is-unread .ntf-ico, .ntf.is-unread .ntf-badge, .ntf-spin { animation: none !important; }
    .ntf-btn, .ntf-row { transition: none !important; }
}
