/* ============================================
   Header Notification Bell & Dropdown
   Community Phase 3: Notifications UI
   ============================================ */

/* Bell button */
.header-notif-dropdown {
    position: relative;
}

.header-notif-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    color: var(--text-secondary, #94a3b8);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.header-notif-btn:hover {
    background: var(--bg-secondary, rgba(255,255,255,0.04));
    color: var(--text-primary, #e2e8f0);
    border-color: rgba(99, 102, 241, 0.3);
}

/* Unread badge */
.header-notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
    animation: notif-badge-pop 0.3s ease;
}

@keyframes notif-badge-pop {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Dropdown Menu */
.header-notif-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 360px;
    max-height: 440px;
    background: var(--bg-primary, #1a1a2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header-notif-dropdown.active .header-notif-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Menu Header */
.header-notif-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
    flex-shrink: 0;
}

.header-notif-menu-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
}

.header-notif-mark-all {
    background: none;
    border: none;
    font-size: 0.75rem;
    color: #818cf8;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.header-notif-mark-all:hover {
    background: rgba(99, 102, 241, 0.1);
}

/* Notification List */
.header-notif-list {
    overflow-y: auto;
    max-height: 360px;
    flex: 1;
}

/* Individual Notification Item */
.header-notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.04));
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
    color: inherit;
}

.header-notif-item:hover {
    background: var(--bg-secondary, rgba(255,255,255,0.03));
}

.header-notif-item.unread {
    background: rgba(99, 102, 241, 0.05);
}

.header-notif-item.unread::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6366f1;
}

.header-notif-item {
    position: relative;
}

[dir="rtl"] .header-notif-item.unread::before {
    left: auto;
    right: 6px;
}

/* Notification avatar */
.header-notif-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.header-notif-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    background: none;
}

/* Notification content */
.header-notif-content {
    flex: 1;
    min-width: 0;
}

.header-notif-text {
    font-size: 0.8rem;
    color: var(--text-primary, #e2e8f0);
    line-height: 1.4;
    margin-bottom: 2px;
}

.header-notif-text strong {
    font-weight: 600;
    color: var(--text-primary, #f1f5f9);
}

.header-notif-text em {
    font-style: normal;
    color: #818cf8;
    font-weight: 500;
}

.header-notif-snippet {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted, #64748b);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-notif-time {
    font-size: 0.7rem;
    color: var(--text-muted, #64748b);
}

/* Notification type icon */
.header-notif-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Empty state */
.header-notif-empty {
    padding: 40px 20px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted, #64748b);
}

/* Loading state */
.header-notif-loading {
    padding: 24px;
    text-align: center;
}

.header-notif-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color, rgba(255,255,255,0.1));
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

/* Light theme overrides */
[data-theme="light"] .header-notif-btn {
    border-color: var(--border-color, #e5e7eb);
    color: var(--text-secondary, #6b7280);
}

[data-theme="light"] .header-notif-btn:hover {
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-primary, #111827);
}

[data-theme="light"] .header-notif-menu {
    background: var(--bg-primary, #ffffff);
    border-color: var(--border-color, #e5e7eb);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .header-notif-item.unread {
    background: rgba(99, 102, 241, 0.04);
}

[data-theme="light"] .header-notif-item:hover {
    background: var(--bg-secondary, #f9fafb);
}

/* Responsive */
@media (max-width: 600px) {
    .header-notif-menu {
        position: fixed;
        top: 60px;
        right: 8px;
        left: 8px;
        width: auto;
        max-height: 70vh;
    }
}

/* The header bar is forced LTR (.nav-container { direction: ltr }), so the bell
   stays on the right even on Arabic/RTL pages. Anchor the menu to the right so
   it opens inward (leftward) instead of overflowing off the right edge. */
[dir="rtl"] .header-notif-menu {
    right: 0;
    left: auto;
}

@media (max-width: 600px) {
    [dir="rtl"] .header-notif-menu {
        right: 8px;
        left: 8px;
    }
}
