/* ============================================================
   Notification Bell + Dropdown + Center
   Dark-mode aware via existing ServiceHub CSS variables.
   ============================================================ */

:root {
    --notif-bg:        var(--surface, #ffffff);
    --notif-bg-elev:   var(--bg, #ffffff);
    --notif-text:      var(--text, #0E1116);
    --notif-muted:     var(--muted, #5B6470);
    --notif-border:    var(--border, rgba(15,25,40,.08));
    --notif-accent:    var(--accent, #00A859);
    --notif-danger:    #DC2626;
    --notif-warn:      #F59E0B;
    --notif-info:      #2563EB;
    --notif-shadow:    0 12px 40px rgba(15,25,40,.12), 0 2px 6px rgba(15,25,40,.06);
}
@media (prefers-color-scheme: dark) {
    :root {
        --notif-bg:      #161A22;
        --notif-bg-elev: #1F2530;
        --notif-text:    #ECEEF2;
        --notif-muted:   #9AA3B2;
        --notif-border:  rgba(255,255,255,.08);
        --notif-shadow:  0 12px 40px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.4);
    }
}
[data-theme="dark"] {
    --notif-bg:      #161A22;
    --notif-bg-elev: #1F2530;
    --notif-text:    #ECEEF2;
    --notif-muted:   #9AA3B2;
    --notif-border:  rgba(255,255,255,.08);
    --notif-shadow:  0 12px 40px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.4);
}

/* ---------- Bell ---------- */
[data-notif-bell] {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.notif-bell-btn {
    position: relative;
    appearance: none;
    background: transparent;
    border: 0;
    color: inherit;
    width: 40px; height: 40px;
    border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background-color .15s ease;
}
.notif-bell-btn:hover,
.notif-bell-btn:focus-visible { background: rgba(15,25,40,.06); outline: none; }
[data-theme="dark"] .notif-bell-btn:hover,
[data-theme="dark"] .notif-bell-btn:focus-visible { background: rgba(255,255,255,.06); }
.notif-bell-btn > i { font-size: 18px; }
.notif-bell-btn:focus-visible { box-shadow: 0 0 0 2px var(--notif-accent); }

.notif-bell-badge {
    position: absolute;
    top: 4px; right: 4px;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--notif-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    transform-origin: center;
    box-shadow: 0 0 0 2px var(--notif-bg-elev);
}
.notif-bell-badge-lg { min-width: 24px; }
.notif-bell-pulse { animation: notif-pulse .45s ease-out; }
@keyframes notif-pulse {
    0% { transform: scale(.6); opacity: 0; }
    60% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) { .notif-bell-pulse { animation: none; } }

/* ---------- Popover ---------- */
.notif-pop {
    position: absolute;
    top: calc(100% + 10px); right: 0;
    width: min(380px, calc(100vw - 24px));
    background: var(--notif-bg);
    color: var(--notif-text);
    border: 1px solid var(--notif-border);
    border-radius: 16px;
    box-shadow: var(--notif-shadow);
    z-index: 1000;
    overflow: hidden;
}
.notif-pop[hidden] { display: none; }
.notif-pop-arrow {
    position: absolute;
    top: -6px; right: 14px;
    width: 12px; height: 12px;
    background: var(--notif-bg);
    border-top: 1px solid var(--notif-border);
    border-left: 1px solid var(--notif-border);
    transform: rotate(45deg);
}
@media (max-width: 560px) {
    .notif-pop {
        position: fixed; right: 8px; left: 8px;
        top: auto; bottom: 8px;
        width: auto;
        max-height: 80vh;
        border-radius: 16px 16px 12px 12px;
    }
    .notif-pop-arrow { display: none; }
}

.notif-pop-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--notif-border);
}
.notif-pop-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.notif-link {
    appearance: none; background: transparent; border: 0;
    color: var(--notif-accent);
    font-weight: 600; font-size: 13px;
    cursor: pointer; padding: 6px 8px; border-radius: 8px;
}
.notif-link:hover, .notif-link:focus-visible { background: rgba(0,168,89,.08); outline: none; }
.notif-link[disabled] { opacity: .5; cursor: not-allowed; }

.notif-pop-list {
    max-height: 60vh;
    overflow: auto;
    padding: 4px 0;
}
.notif-pop-foot {
    padding: 10px 12px;
    border-top: 1px solid var(--notif-border);
    text-align: center;
}
.notif-pop-empty {
    padding: 36px 16px;
    text-align: center;
    color: var(--notif-muted);
}
.notif-pop-empty i { font-size: 28px; margin-bottom: 8px; display: block; }

/* ---------- Notification item ---------- */
.notif-item {
    position: relative;
    display: grid;
    grid-template-columns: 6px 36px 1fr auto;
    gap: 10px;
    align-items: start;
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--notif-border);
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover,
.notif-item:focus-visible { background: rgba(0,168,89,.04); outline: none; }
[data-theme="dark"] .notif-item:hover,
[data-theme="dark"] .notif-item:focus-visible { background: rgba(255,255,255,.04); }

.notif-item-dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 8px; background: transparent; }
.notif-item.is-unread .notif-item-dot { background: var(--notif-accent); }

.notif-item-icon {
    width: 36px; height: 36px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(0,168,89,.10); color: var(--notif-accent);
}
.notif-tone-danger .notif-item-icon { background: rgba(220,38,38,.10); color: var(--notif-danger); }
.notif-tone-warn   .notif-item-icon { background: rgba(245,158,11,.10); color: var(--notif-warn); }
.notif-tone-info   .notif-item-icon { background: rgba(37,99,235,.10);  color: var(--notif-info); }
.notif-tone-accent .notif-item-icon { background: rgba(124,58,237,.10); color: #7C3AED; }
.notif-tone-success .notif-item-icon { background: rgba(16,185,129,.10); color: #10B981; }

.notif-item-body { display: grid; gap: 2px; min-width: 0; }
.notif-item-title { font-weight: 600; font-size: 14px; color: var(--notif-text); }
.notif-item-text  { font-size: 13px; color: var(--notif-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-item-meta  { font-size: 11px; color: var(--notif-muted); text-transform: capitalize; display: inline-flex; gap: 4px; align-items: center; }

.notif-item-actions { display: inline-flex; gap: 4px; opacity: 0; transition: opacity .15s ease; }
.notif-item:hover .notif-item-actions,
.notif-item:focus-within .notif-item-actions { opacity: 1; }
@media (max-width: 560px) { .notif-item-actions { opacity: 1; } }

.notif-icon-btn {
    appearance: none; background: transparent; border: 0;
    width: 28px; height: 28px; border-radius: 8px;
    color: var(--notif-muted); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.notif-icon-btn:hover, .notif-icon-btn:focus-visible {
    background: rgba(15,25,40,.06); color: var(--notif-text); outline: none;
}
[data-theme="dark"] .notif-icon-btn:hover,
[data-theme="dark"] .notif-icon-btn:focus-visible { background: rgba(255,255,255,.06); }
.notif-icon-danger:hover { color: var(--notif-danger); background: rgba(220,38,38,.08); }

/* ============================================================
   Full-page Notification Center
   ============================================================ */
.notif-center {
    max-width: 880px;
    margin: 0 auto;
    padding: 20px 16px 80px;
    color: var(--notif-text);
}
.notif-center-head {
    display: flex; justify-content: space-between; align-items: end; gap: 16px;
    flex-wrap: wrap; margin-bottom: 16px;
}
.notif-center-head h1 { margin: 0; font-size: 22px; font-weight: 800; }
.notif-center-sub { color: var(--notif-muted); margin: 4px 0 0; font-size: 14px; }

.notif-center-toolbar {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    flex-wrap: wrap; margin-bottom: 12px;
}
.notif-tabs { display: inline-flex; background: var(--notif-bg-elev); border: 1px solid var(--notif-border); border-radius: 12px; padding: 4px; gap: 4px; }
.notif-tab {
    appearance: none; border: 0; background: transparent;
    padding: 8px 14px; border-radius: 8px;
    font-weight: 600; font-size: 13px; color: var(--notif-muted);
    cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.notif-tab.is-active { background: var(--notif-bg); color: var(--notif-text); box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.notif-tab-count { background: var(--notif-danger); color: #fff; font-size: 11px; min-width: 18px; padding: 1px 5px; border-radius: 999px; line-height: 16px; text-align: center; }
.notif-tab-count:empty { display: none; }

.notif-search { display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--notif-bg-elev); border: 1px solid var(--notif-border); border-radius: 10px; height: 40px; flex: 1 1 220px; max-width: 320px; }
.notif-search i { color: var(--notif-muted); }
.notif-search input { flex: 1; border: 0; background: transparent; color: inherit; outline: none; font-size: 14px; }

.notif-filters {
    display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px;
    scrollbar-width: thin; margin-bottom: 12px;
}
.notif-chip {
    appearance: none; background: var(--notif-bg-elev); border: 1px solid var(--notif-border);
    color: var(--notif-text); border-radius: 999px; padding: 6px 12px;
    font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 6px;
}
.notif-chip.is-active { background: var(--notif-accent); color: #fff; border-color: var(--notif-accent); }

.notif-bulkbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; padding: 10px 12px; background: var(--notif-bg-elev);
    border: 1px solid var(--notif-border); border-radius: 12px; margin-bottom: 8px;
}
.notif-bulk-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.notif-bulk-actions { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.btn-danger { background: var(--notif-danger); color: #fff; border: 0; padding: 8px 12px; border-radius: 10px; font-weight: 600; cursor: pointer; }
.btn-danger:hover { filter: brightness(.95); }

.notif-list { display: grid; gap: 8px; }
.notif-row {
    display: grid;
    grid-template-columns: 24px 44px 1fr auto;
    gap: 12px; align-items: start;
    padding: 14px; background: var(--notif-bg-elev);
    border: 1px solid var(--notif-border); border-radius: 14px;
}
.notif-row.is-unread { box-shadow: inset 4px 0 0 var(--notif-accent); }
.notif-row-check { display: inline-flex; align-items: center; padding-top: 4px; }
.notif-row-icon {
    appearance: none; border: 0;
    width: 44px; height: 44px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(0,168,89,.10); color: var(--notif-accent); cursor: pointer;
}
.notif-row-body { min-width: 0; display: grid; gap: 4px; cursor: pointer; }
.notif-row-body:focus-visible { outline: 2px solid var(--notif-accent); border-radius: 6px; }
.notif-row-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.notif-row-title span { font-weight: 700; font-size: 14px; }
.notif-row-title time { font-size: 12px; color: var(--notif-muted); white-space: nowrap; }
.notif-row-text { font-size: 13px; color: var(--notif-muted); }
.notif-row-meta { display: inline-flex; gap: 6px; }
.notif-row-tag {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    background: rgba(15,25,40,.06); color: var(--notif-muted);
    font-size: 11px; text-transform: capitalize;
}
[data-theme="dark"] .notif-row-tag { background: rgba(255,255,255,.06); }
.notif-row-tag.tone-high, .notif-row-tag.tone-urgent { background: rgba(245,158,11,.16); color: var(--notif-warn); }
.notif-row-tag.tone-critical { background: rgba(220,38,38,.16); color: var(--notif-danger); }

.notif-row-actions { display: inline-flex; flex-direction: column; gap: 6px; }
@media (min-width: 720px) { .notif-row-actions { flex-direction: row; align-self: center; } }

.notif-loading, .notif-empty {
    padding: 36px 12px; text-align: center; color: var(--notif-muted);
}
.notif-sentinel { height: 1px; }

.notif-center.is-refreshing::before {
    content: ""; display: block; height: 3px; margin-bottom: 8px;
    background: linear-gradient(90deg, transparent, var(--notif-accent), transparent);
    animation: notif-refresh 1s linear infinite;
}
@keyframes notif-refresh { 0% { background-position: -200px 0;} 100% { background-position: 600px 0;} }
@media (prefers-reduced-motion: reduce) { .notif-center.is-refreshing::before { animation: none; } }

/* mobile: bottom space for nav, swipe rows */
@media (max-width: 560px) {
    .notif-row { grid-template-columns: 22px 40px 1fr; }
    .notif-row-actions { grid-column: 1 / -1; justify-content: flex-end; }
    .notif-center { padding-bottom: 96px; }
}
