/* الإشعارات الداخلية: الجرس واللوحة والنافذة وصفحة الإرسال */
.notif-wrap { position: relative; display: inline-flex; }
.notif-bell {
    position: relative;
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.notif-badge {
    position: absolute;
    top: -6px;
    inset-inline-start: -4px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: #dc2626;
    color: #fff;
    font-size: 10.5px;
    font-weight: 800;
    line-height: 17px;
    text-align: center;
}
.notif-badge.d-none { display: none; }

.notif-link-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    margin-inline-start: 6px;
    padding: 0 5px;
    border-radius: 9px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
    vertical-align: middle;
}

.notif-panel {
    position: fixed;
    z-index: 3500;
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .25);
    direction: rtl;
    overflow: hidden;
    font-size: 14px;
}
.notif-panel.d-none { display: none; }
.notif-panel-head,
.notif-panel-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8fafc;
}
.notif-panel-foot { justify-content: center; border-top: 1px solid #e5e7eb; }
.notif-panel-foot a { color: #1a3a52; font-weight: 700; text-decoration: none; }
.notif-link {
    background: transparent;
    border: 0;
    color: #1a3a52;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
}
.notif-panel-list { max-height: 60vh; overflow-y: auto; }
.notif-empty { padding: 18px; text-align: center; color: #64748b; }

.notif-item {
    display: block;
    width: 100%;
    text-align: start;
    background: #fff;
    border: 0;
    border-bottom: 1px solid #f1f5f9;
    padding: 10px 14px;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
}
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #eff6ff; border-inline-start: 3px solid #b8956a; }
.notif-item-title { display: block; font-weight: 800; color: #1a3a52; }
.notif-item-body { display: block; margin-top: 2px; color: #475569; font-size: 13px; line-height: 1.6; }
.notif-item-time { display: block; margin-top: 3px; color: #94a3b8; font-size: 11.5px; }

.notif-page-list .notif-item { border: 1px solid #e5e7eb; border-radius: 10px; margin-bottom: 8px; }

.notif-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 3600;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    direction: rtl;
}
.notif-modal {
    background: #fff;
    color: #1f2937;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.notif-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 18px;
    background: #1a3a52;
    color: #fff;
}
.notif-modal-close { background: transparent; border: 0; color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.notif-modal-body { padding: 16px 18px; overflow-y: auto; line-height: 1.9; }
.notif-modal-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    border-top: 1px solid #e5e7eb;
}

/* صفحة إرسال رسالة */
.nc-results {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-top: 4px;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
}
.nc-results.d-none { display: none; }
.nc-result {
    display: block;
    width: 100%;
    text-align: start;
    background: #fff;
    border: 0;
    border-bottom: 1px solid #f1f5f9;
    padding: 7px 12px;
    cursor: pointer;
    font-family: inherit;
}
.nc-result:hover { background: #f8fafc; }
.nc-result span { color: #64748b; font-size: 12.5px; margin-inline-start: 6px; }
.nc-empty { padding: 10px 12px; color: #64748b; }
.nc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.nc-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 16px;
    padding: 2px 10px;
    font-size: 13px;
}
.nc-chip button { background: transparent; border: 0; cursor: pointer; font-size: 16px; line-height: 1; color: #64748b; }

/* ============================================================
   الرسائل المنسَّقة: أنماط، بطاقة، مرفقات، محادثة، رفع، صفحة الإرسال
   الألوان: 0f2640 (تنويه) | c8860a (دعاية) | b42318 (هام) | 0f766e (خبر)
   ============================================================ */
.nmsg-notice { --nm-accent: #0f2640; --nm-soft: #e9eff6; --nm-grad: linear-gradient(135deg, #0f2640, #1c4670); }
.nmsg-promo { --nm-accent: #c8860a; --nm-soft: #fdf3dc; --nm-grad: linear-gradient(135deg, #c8860a, #f0a830); }
.nmsg-important { --nm-accent: #b42318; --nm-soft: #fdecea; --nm-grad: linear-gradient(135deg, #b42318, #e0574a); }
.nmsg-news { --nm-accent: #0f766e; --nm-soft: #e1f4f1; --nm-grad: linear-gradient(135deg, #0f766e, #1fa396); }

/* عناصر القائمة */
.notif-item.notif-item-notice { border-inline-start: 3px solid #0f2640; }
.notif-item.notif-item-promo { border-inline-start: 3px solid #c8860a; }
.notif-item.notif-item-important { border-inline-start: 3px solid #b42318; }
.notif-item.notif-item-news { border-inline-start: 3px solid #0f766e; }
.notif-item-clip { margin-inline-start: 6px; color: #94a3b8; font-size: 12px; }

/* النافذة */
.notif-modal.notif-modal-wide { max-width: 720px; }
.notif-modal[class*="nmsg-"] .notif-modal-head { background: var(--nm-grad); }
.notif-modal .nmsg { border: 0; box-shadow: none; border-radius: 0; margin: -16px -18px 0; }
.notif-modal .nmsg + .nthread,
.notif-modal .nmsg + .nreply-form { margin-top: 16px; }
.notif-modal .nthread { margin-top: 22px; }

/* البطاقة */
.nmsg {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 6px 22px rgba(15, 38, 64, .08);
    direction: rtl;
}
.nmsg-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 18px;
    background: var(--nm-soft);
    border-bottom: 3px solid var(--nm-accent);
}
.nmsg-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--nm-accent);
    color: #fff;
    border-radius: 999px;
    padding: 3px 14px;
    font-size: 13px;
    font-weight: 800;
}
.nmsg-head time { color: #64748b; font-size: 12px; }
.nmsg-banner img { display: block; width: 100%; max-height: 260px; object-fit: cover; }
.nmsg-content { padding: 16px 20px 18px; }
.nmsg-title { margin: 0 0 10px; font-size: 20px; font-weight: 800; color: var(--nm-accent); line-height: 1.6; }
.nmsg-body { line-height: 2; font-size: 15px; overflow-wrap: anywhere; }
.nmsg-body p { margin: 0 0 10px; }
.nmsg-body h3, .nmsg-body h4, .nmsg-body h5 { color: var(--nm-accent); font-weight: 800; margin: 16px 0 8px; }
.nmsg-body h3 { font-size: 18px; }
.nmsg-body h4 { font-size: 16.5px; }
.nmsg-body h5 { font-size: 15px; }
.nmsg-body ul, .nmsg-body ol { margin: 0 0 10px; padding-inline-start: 24px; }
.nmsg-body blockquote {
    margin: 0 0 10px;
    padding: 8px 14px;
    background: var(--nm-soft);
    border-inline-start: 4px solid var(--nm-accent);
    border-radius: 6px;
}
.nmsg-body hr { border: 0; border-top: 1px dashed #cbd5e1; margin: 14px 0; opacity: 1; }
.nmsg-body a { color: var(--nm-accent); font-weight: 700; text-decoration: underline; }

.nmsg-cta { margin-top: 14px; text-align: center; }
.nmsg-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--nm-grad);
    color: #fff;
    border-radius: 10px;
    padding: 10px 28px;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
    transition: transform .15s ease, box-shadow .15s ease;
}
.nmsg-cta-btn:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 7px 16px rgba(0, 0, 0, .22); }

/* المرفقات */
.nmsg-files { margin-top: 16px; padding-top: 12px; border-top: 1px solid #e5e7eb; }
.nmsg-files-title { font-weight: 800; color: #475569; margin-bottom: 8px; font-size: 13.5px; }
.nmsg-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-bottom: 8px; }
.nmsg-thumb { display: block; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; border: 1px solid #e5e7eb; background: #f1f5f9; }
.nmsg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s ease; }
.nmsg-thumb:hover img { transform: scale(1.06); }
.nmsg-filelist { display: flex; flex-direction: column; gap: 6px; }
.nmsg-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    color: #1f2937;
    text-decoration: none;
}
.nmsg-file:hover { background: var(--nm-soft); border-color: var(--nm-accent); }
.nmsg-file > i:first-child { color: var(--nm-accent); font-size: 18px; }
.nmsg-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.nmsg-file-size { color: #64748b; font-size: 12px; }

/* المحادثة */
.nthread { margin-top: 20px; }
.nthread-title { font-size: 15px; font-weight: 800; color: #0f2640; margin: 0 0 10px; }
.nreply {
    max-width: 88%;
    margin-bottom: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
}
.nreply-mine { margin-inline-start: auto; background: #fdf3dc; border-color: #f0d9a0; }
.nreply-other { margin-inline-end: auto; }
.nreply-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: #475569; margin-bottom: 4px; }
.nreply-meta time { color: #94a3b8; }
.nreply-body { line-height: 1.9; overflow-wrap: anywhere; }
.nreply .nmsg-files { margin-top: 8px; padding-top: 8px; }

/* نموذج الرد */
.nreply-form { margin-top: 18px; padding: 14px; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 12px; }
.nreply-label { font-weight: 800; color: #0f2640; margin-bottom: 6px; }
.nreply-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }

/* رفع الملفات المؤقت */
.nup-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nup-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px dashed #c8860a;
    border-radius: 8px;
    background: #fffaf0;
    color: #8a5a00;
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
}
.nup-btn:hover { background: #fdf3dc; }
.nup-hint { color: #64748b; font-size: 12px; }
.nup-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.nup-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13.5px;
}
.nup-item > i { color: #0f2640; font-size: 17px; }
.nup-thumb { width: 38px; height: 38px; object-fit: cover; border-radius: 6px; }
.nup-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nup-size { color: #64748b; font-size: 12px; }
.nup-remove { background: transparent; border: 0; color: #b42318; font-size: 20px; line-height: 1; cursor: pointer; }
.nup-pending { color: #64748b; }
.nup-msg:empty { display: none; }

/* صفحة الإرسال */
.nc-styles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.nc-style {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    font-weight: 800;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.nc-style input { position: absolute; opacity: 0; pointer-events: none; }
.nc-style i { font-size: 20px; }
.nc-style-notice i { color: #0f2640; }
.nc-style-promo i { color: #c8860a; }
.nc-style-important i { color: #b42318; }
.nc-style-news i { color: #0f766e; }
.nc-style:has(input:checked).nc-style-notice { border-color: #0f2640; background: #e9eff6; }
.nc-style:has(input:checked).nc-style-promo { border-color: #c8860a; background: #fdf3dc; }
.nc-style:has(input:checked).nc-style-important { border-color: #b42318; background: #fdecea; }
.nc-style:has(input:checked).nc-style-news { border-color: #0f766e; background: #e1f4f1; }
.nc-style:has(input:focus-visible) { outline: 2px solid #f0a830; outline-offset: 2px; }

.nc-toolbar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.nc-toolbar button {
    width: 34px;
    height: 32px;
    background: #fff;
    border: 1px solid #d5dbe3;
    border-radius: 7px;
    color: #0f2640;
    cursor: pointer;
}
.nc-toolbar button:hover { background: #fdf3dc; border-color: #c8860a; }
.nc-body { font-family: inherit; line-height: 1.9; }

.nc-preview-wrap { position: sticky; top: 84px; }
.nc-preview { max-height: calc(100vh - 140px); overflow-y: auto; border-radius: 14px; }
.nc-preview-empty,
.nc-preview-error {
    padding: 28px 16px;
    text-align: center;
    border: 2px dashed #d5dbe3;
    border-radius: 14px;
    color: #64748b;
}
.nc-preview-error { color: #b42318; border-color: #f3b8b2; background: #fdecea; }

/* صندوق الردود */
.nr-list { display: flex; flex-direction: column; gap: 8px; }
.nr-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    color: inherit;
    text-decoration: none;
}
.nr-row:hover { border-color: #c8860a; box-shadow: 0 4px 14px rgba(15, 38, 64, .08); color: inherit; }
.nr-row.unread { background: #fffaf0; border-inline-start: 4px solid #c8860a; }
.nr-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nr-user { color: #0f2640; }
.nr-title { color: #475569; font-size: 13px; }
.nr-last { color: #64748b; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px; }
.nr-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; font-size: 12px; color: #64748b; }
.nr-new, .nr-wait { border-radius: 999px; padding: 1px 10px; font-size: 11.5px; color: #fff; }
.nr-new { background: #dc2626; }
.nr-wait { background: #c8860a; }
.nt-who { margin-bottom: 14px; font-size: 15px; }

@media (max-width: 575.98px) {
    .nmsg-content { padding: 14px 14px 16px; }
    .nreply { max-width: 100%; }
    .nr-row { flex-direction: column; align-items: stretch; }
    .nr-row-side { flex-direction: row; align-items: center; justify-content: space-between; }
    .nr-last { max-width: 100%; }
    .nc-preview-wrap { position: static; }
}

/* ============================================================
   زر الإشعارات: مميّز وأول زر بالشريط العلوى + نافذة/صفحة الرسالة أعرض بصورة كاملة
   ============================================================ */
.user-pill.notif-pill-hl {
    padding: 0;
    background: linear-gradient(135deg, #f0b43c, #c8860a);
    border-color: rgba(255, 255, 255, .55);
    color: #1b1405;
    font-weight: 800;
    box-shadow: 0 2px 10px rgba(200, 134, 10, .35);
}
.user-pill.notif-pill-hl:hover { background: linear-gradient(135deg, #f6c35a, #d89414); }
.notif-pill-hl .notif-wrap { display: flex; }
.notif-pill-hl .notif-bell {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 14px;
    color: inherit;
    font: inherit;
}
.notif-pill-hl .notif-bell i { color: #1b1405; font-size: 1.05em; }
.notif-pill-hl .notif-badge { top: -7px; inset-inline-start: auto; inset-inline-end: -6px; border: 2px solid #fff; box-sizing: content-box; }
.notif-pill-hl:has(.notif-badge:not(.d-none)) .notif-bell i { animation: notifRing 2.4s ease-in-out infinite; transform-origin: 50% 0; }
@keyframes notifRing {
    0%, 70%, 100% { transform: rotate(0); }
    75% { transform: rotate(14deg); }
    80% { transform: rotate(-12deg); }
    85% { transform: rotate(8deg); }
    90% { transform: rotate(-6deg); }
}
@media (prefers-reduced-motion: reduce) { .notif-pill-hl:has(.notif-badge:not(.d-none)) .notif-bell i { animation: none; } }

.notif-modal-overlay { padding: 12px; }
.notif-modal { max-height: 92vh; }
.notif-modal.notif-modal-wide { max-width: min(1080px, 96vw); }
.notif-modal-body { padding: 16px 22px; }
.notif-modal .nmsg { margin: -16px -22px 0; }
.nmsg-banner { background: var(--nm-soft, #f1f5f9); }
.nmsg-banner img { width: 100%; height: auto; max-height: 75vh; object-fit: contain; }
.nmsg-content { padding: 18px 28px 22px; }
.nmsg-body { font-size: 16px; }
.nmsg-gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
#ntThread .nmsg { max-width: 1280px; margin-inline: auto; }
@media (max-width: 575.98px) {
    .nmsg-content { padding: 14px 16px 18px; }
    .notif-modal-body { padding: 12px 14px; }
    .notif-modal .nmsg { margin: -12px -14px 0; }
}
