/* ===== NOTIFICATION BELL COMPONENT ===== */

/* --- Bell Icon in Navbar --- */
.nav-notification-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: #f59e0b;
    font-size: 18px;
    background: transparent;
    border: none;
    flex-shrink: 0;
}
.nav-notification-bell:hover {
    background: rgba(245, 158, 11, 0.08);
    color: #d97706;
}
.nav-notification-bell:active {
    transform: scale(0.94);
}

.nav-notification-bell.has-unread {
    /* badge handles count display */
}

/* badge - red count dot */
.notification-badge {
    position: absolute;
    top: -1px;
    right: -1px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.45);
    animation: badgePopIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

@keyframes badgePopIn {
    0%   { transform: scale(0); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* bell swing on new notification */
@keyframes bellRing {
    0%   { transform: rotate(0); }
    10%  { transform: rotate(14deg); }
    20%  { transform: rotate(-12deg); }
    30%  { transform: rotate(10deg); }
    40%  { transform: rotate(-8deg); }
    50%  { transform: rotate(6deg); }
    60%  { transform: rotate(-4deg); }
    70%  { transform: rotate(2deg); }
    80%  { transform: rotate(0); }
}
.nav-notification-bell.ring {
    animation: bellRing 1.2s ease-in-out;
}

/* ===== POPUP OVERLAY ===== */
.notification-overlay {
    position: fixed; inset: 0; z-index: 998;
    background: rgba(15, 23, 42, 0.25);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0; visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}
.notification-overlay.open {
    opacity: 1; visibility: visible;
}

/* ===== POPUP PANEL ===== */
.notification-popup {
    position: fixed;
    top: 68px;
    right: 20px;
    width: 440px;
    max-height: calc(100vh - 100px);
    z-index: 999;
    background: rgba(255, 255, 255, 0.975);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: 20px;
    box-shadow:
        0 24px 56px rgba(15, 23, 42, 0.14),
        0 4px 16px rgba(15, 23, 42, 0.06),
        0 0 0 0.5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    opacity: 0; visibility: hidden;
    transform: translateY(-10px) scale(0.96);
    transform-origin: top right;
    transition:
        opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0.28s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}
.notification-popup.open {
    opacity: 1; visibility: visible;
    transform: translateY(0) scale(1);
}

/* ===== HEADER ===== */
.notif-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}
.notif-popup-title {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}
.notif-popup-title i {
    color: #f59e0b;
    font-size: 18px;
}
.notif-mark-all-read {
    font-size: 13px;
    color: #2563eb;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.notif-mark-all-read:hover {
    background: rgba(37, 99, 235, 0.07);
    color: #1d4ed8;
}
.notif-mark-all-read:active {
    transform: scale(0.96);
}

/* ===== TABS ===== */
.notif-tabs {
    display: flex;
    gap: 4px;
    padding: 0 20px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}
.notif-tab {
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 500;
    color: #94a3b8;
    cursor: pointer;
    border: none;
    background: none;
    position: relative;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.notif-tab:hover { color: #64748b; }
.notif-tab.active {
    color: #2563eb;
    font-weight: 600;
}
.notif-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 18px;
    right: 18px;
    height: 2.5px;
    background: #2563eb;
    border-radius: 3px;
}
.notif-tab .tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    padding: 0 6px;
    background: #f1f5f9;
    color: #94a3b8;
    transition: all 0.2s ease;
}
.notif-tab .tab-badge.has-unread {
    background: #fef2f2;
    color: #ef4444;
}

/* ===== MESSAGE LIST ===== */
.notif-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 0;
}
.notif-list::-webkit-scrollbar { width: 4px; }
.notif-list::-webkit-scrollbar-track { background: transparent; }
.notif-list::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}
.notif-list::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

/* ===== MESSAGE ITEM ===== */
.notif-item {
    display: flex;
    gap: 14px;
    padding: 16px 24px;
    cursor: pointer;
    transition: background 0.18s ease;
    position: relative;
    border-left: 3px solid transparent;
    align-items: flex-start;
}
.notif-item:hover {
    background: #f8fafc;
}
.notif-item.unread {
    background: linear-gradient(90deg, rgba(239, 246, 255, 0.7) 0%, rgba(239, 246, 255, 0.2) 40%, transparent 100%);
    border-left-color: #2563eb;
}
.notif-item.unread:hover {
    background: linear-gradient(90deg, rgba(239, 246, 255, 0.85) 0%, rgba(239, 246, 255, 0.3) 40%, rgba(248, 250, 252, 0.6) 100%);
}

/* icon circle */
.notif-item-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}
.notif-item-icon.reply {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(59, 130, 246, 0.06));
    color: #2563eb;
}
.notif-item-icon.system {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(251, 191, 36, 0.06));
    color: #f59e0b;
}

/* body */
.notif-item-body {
    flex: 1;
    min-width: 0;
}
.notif-item-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}
.notif-item-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
}
.notif-item .unread-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2563eb;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(37, 99, 235, 0.5);
}
.notif-item-preview {
    font-size: 13px;
    color: #64748b;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}
.notif-item-meta {
    font-size: 12px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* action row */
.notif-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.notif-item .mark-read-btn {
    font-size: 12px;
    color: #2563eb;
    background: rgba(37, 99, 235, 0.07);
    border: none;
    cursor: pointer;
    padding: 5px 12px;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.2s ease;
}
.notif-item .mark-read-btn:hover {
    background: rgba(37, 99, 235, 0.14);
    color: #1d4ed8;
}

/* ===== EXPANDED REPLY BLOCK (CHAT LAYOUT) ===== */
.notif-item-expanded {
    padding: 8px 24px 16px;
    margin-top: -4px;
}
/* Chat thread container */
.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 0;
}
/* Date divider */
.chat-date-divider {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    padding: 6px 0;
    font-weight: 500;
}
.chat-date-divider span {
    background: #f8fafc;
    padding: 3px 12px;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
}

/* Base bubble */
.chat-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.65;
    position: relative;
    word-break: break-word;
}
.chat-bubble .chat-bubble-text {
    margin-bottom: 4px;
}
.chat-bubble .chat-bubble-meta {
    font-size: 11px;
    display: flex; align-items: center; gap: 4px;
}

/* User message - right aligned, blue */
.chat-bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-bottom-right-radius: 6px;
    color: #1e40af;
}
.chat-bubble.user .chat-bubble-meta {
    color: #60a5fa;
    justify-content: flex-end;
}

/* Admin reply - left aligned, neutral */
.chat-bubble.admin {
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
    color: #334155;
}
.chat-bubble.admin .chat-bubble-sender {
    font-size: 11px;
    font-weight: 700;
    color: #2563eb;
    margin-bottom: 4px;
    display: flex; align-items: center; gap: 4px;
}
.chat-bubble.admin .chat-bubble-meta {
    color: #94a3b8;
}

/* ===== REPLY BOX IN EXPANDED FEEDBACK ===== */
.notif-reply-box {
    display: flex; gap: 8px; align-items: flex-end;
    padding: 12px 0 4px;
    margin-top: 8px;
    border-top: 1px solid #f1f5f9;
}
.notif-reply-input {
    flex: 1; padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #fff;
    font-size: 13px; color: #334155;
    resize: none; min-height: 38px; max-height: 80px;
    font-family: inherit; outline: none;
    transition: border-color 0.2s;
}
.notif-reply-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}
.notif-reply-send {
    padding: 10px 14px; border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #fff; font-size: 14px; cursor: pointer;
    transition: all 0.2s; flex-shrink: 0;
}
.notif-reply-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.notif-reply-send:disabled {
    opacity: 0.5; cursor: not-allowed; transform: none;
}

/* ===== EMPTY STATE ===== */
.notif-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 52px 28px;
    text-align: center;
}
.notif-empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 22px;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #cbd5e1;
    margin-bottom: 16px;
}
.notif-empty h4 {
    font-size: 15px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}
.notif-empty p {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.5;
    max-width: 280px;
}

/* ===== LOADING ===== */
.notif-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}
.notif-spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid #e2e8f0;
    border-top-color: #94a3b8;
    border-radius: 50%;
    animation: notifSpin 0.7s linear infinite;
}
@keyframes notifSpin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 520px) {
    .notification-popup {
        width: calc(100vw - 24px);
        right: 12px;
        top: 62px;
        border-radius: 16px;
    }
}
