/* Notification bell, dropdown panel, preferences modal, and the staff-only
   Moderation nav link. Tokens come from app.css so light and dark themes and
   reduced motion carry over without redefining anything. */

/* ---------- Staff-only nav link ---------- */

/* Hidden by default; notifications.js reveals it with .is-visible only for
   staff. This is a UX affordance, not a security control - the backend still
   enforces IsAdminUser on every moderation endpoint. */
.nav-mod {
    display: none;
}

.nav-mod.is-visible {
    display: inline-block;
}

/* ---------- Nav placement ---------- */

/* Keep the links group pinned to the right of the logo so the bell can sit
   just after it. The bell lives outside .app-nav-links on purpose: that list
   is an overflow-x scroll container and would clip an open dropdown. */
.app-nav-inner > .app-nav-links {
    margin-left: auto;
}

.notif {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    flex-shrink: 0;
}

/* ---------- Bell button and badge ---------- */

.notif-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.notif-bell:hover {
    color: var(--heading);
    border-color: var(--heading);
}

.notif-bell svg {
    width: 20px;
    height: 20px;
}

.notif-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    border: 2px solid var(--nav-bg);
}

/* ---------- Dropdown panel ---------- */

.notif-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 360px;
    max-width: calc(100vw - 32px);
    max-height: min(70vh, 520px);
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px var(--shadow-strong);
    z-index: 150;
    overflow: hidden;
    animation: slideIn 0.18s ease;
}

.notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.notif-head-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--heading);
}

.notif-head-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.notif-textbtn {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.notif-textbtn:hover:not(:disabled) {
    color: var(--heading);
    background: var(--card-hover);
}

.notif-textbtn:disabled {
    opacity: 0.5;
    cursor: default;
}

.notif-iconbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    color: var(--muted);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.notif-iconbtn:hover {
    color: var(--heading);
    background: var(--card-hover);
}

.notif-iconbtn svg {
    width: 18px;
    height: 18px;
}

.notif-list {
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.notif-state {
    padding: 28px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

/* ---------- Notification rows ---------- */

.notif-row {
    display: flex;
    gap: 12px;
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-light);
    color: inherit;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.notif-row:last-child {
    border-bottom: none;
}

.notif-row:hover {
    background: var(--card-hover);
}

.notif-row.unread {
    box-shadow: inset 3px 0 0 var(--danger);
}

.notif-body {
    flex: 1;
    min-width: 0;
}

.notif-msg {
    font-size: 14px;
    color: var(--text);
    line-height: 1.4;
}

.notif-row.unread .notif-msg {
    font-weight: 600;
    color: var(--heading);
}

.notif-time {
    font-size: 12px;
    color: var(--faint);
    margin-top: 2px;
}

.notif-foot {
    border-top: 1px solid var(--border);
    padding: 8px;
    flex-shrink: 0;
}

.notif-foot .notif-textbtn {
    width: 100%;
    padding: 8px;
    text-align: center;
}

/* ---------- Preferences modal ---------- */

.pref-group-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--faint);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 18px 0 6px;
}

.pref-group-title:first-child {
    margin-top: 0;
}

.pref-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.pref-row:last-child {
    border-bottom: none;
}

.pref-label {
    font-size: 14px;
    color: var(--text);
}

.pref-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--heading);
    cursor: pointer;
    flex-shrink: 0;
}

.pref-status {
    font-size: 14px;
    color: var(--muted);
    padding: 8px 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
    /* The bell shares a right-aligned cluster (.app-nav-end) with the menu
       toggle, so it keeps its natural size instead of spanning the row. The
       panel keeps its base right-anchored width (max-width: 100vw - 32px), so
       it stays on screen without stretching to a full-width bar. */
    .notif {
        margin-left: 0;
    }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .notif-panel {
        animation: none;
    }
}
