/* Notification panel (pages/partials/notification-panel.php) and the toast (toast() in the shared JS). */

.notif-panel {
    position: absolute;
    top: calc(var(--topbar-h) - 4px);
    right: 24px;                          /* the bar's own padding, so it sits under the bell */
    width: 340px;
    max-width: calc(100vw - 32px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .12);
    z-index: 500;
    display: none;
}

.notif-panel.open {
    display: block;
}

.notif-head {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: var(--fs-sm);
    font-weight: 700;
}

.notif-item {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    cursor: pointer;
}

.notif-item:hover {
    background: var(--surface-2);
}

.notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    margin-top: 4px;
}

.notif-text {
    font-size: var(--fs-xs);
    color: var(--text);
    line-height: 1.5;
}

.notif-time {
    font-size: var(--fs-2xs);
    color: var(--muted);
    margin-top: 2px;
}

/* ── Notifications (common/api.js toast) ──────────────────────────────────
   The app's own dark style — the same colour, font and corners as its tooltips — so a
   notification reads as part of the app. Top right under the top bar; it fits its text, an
   icon in a tinted circle says what kind it is, and a thin line along the foot shows the time
   left. The stack lets clicks through: only the cards themselves catch the pointer. */
.pat-notes {
    position: fixed;
    top: 68px;
    right: 18px;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    max-width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}

.pat-note {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 240px;
    max-width: 100%;
    padding: 10px 10px 11px 12px;
    overflow: hidden;
    border-radius: 10px;
    background: #1D2939;
    box-shadow: 0 12px 28px -8px rgba(16, 24, 40, .45), 0 3px 8px -3px rgba(16, 24, 40, .25);
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium, 500);
    line-height: 1.4;
    color: #fff;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-6px) scale(.98);
    transition: opacity .18s ease, transform .18s ease;
}

.pat-note.is-on {
    opacity: 1;
    transform: none;
}

.pat-note.is-ok   { --note-c: #32D583; }
.pat-note.is-info { --note-c: #53B1FD; }
.pat-note.is-warn { --note-c: #FDB022; }
.pat-note.is-err  { --note-c: #F97066; }

.pat-note__ic {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--note-c) 18%, transparent);
    font-size: 14px;
    color: var(--note-c);
}

.pat-note__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow-wrap: anywhere;
}

.pat-note__t {
    font-weight: 700;
    color: #fff;
}

.pat-note__t + .pat-note__m {
    color: #D0D5DD;
    font-size: var(--fs-xs);
}

.pat-note__x {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: #98A2B3;
    font-size: 12px;
    cursor: pointer;
}

.pat-note__x:hover {
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

.pat-note__x:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 1px;
}

.pat-note__bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--note-c);
    opacity: .8;
    transform-origin: left;
}

@media (max-width: 640px) {
    .pat-notes {
        top: 62px;
        right: 16px;
        left: 16px;
        max-width: none;
        align-items: stretch;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pat-note { transition: none; }
}

.notif-head .notif-unread {
    color: var(--accent);
}
/* ── the bell, in the topbar beside the signed-in name ──────── */
.notif-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-right: 6px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--ink-3);
    cursor: pointer;
    transition: background-color .12s, color .12s, border-color .12s;
}

.notif-bell:hover {
    border-color: var(--line);
    background: var(--surface-2);
    color: var(--primary);
}

.notif-bell:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.notif-bell[aria-expanded="true"] {
    border-color: var(--line);
    background: var(--surface-2);
    color: var(--primary);
}

/* The unread count. Hidden at zero rather than showing a "0". */
.notif-count {
    position: absolute;
    top: 1px;
    right: 1px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border: 2px solid var(--surface);
    border-radius: var(--r-pill);
    background: var(--danger);
    color: #fff;
    font-size: var(--fs-2xs);
    font-weight: 700;
    line-height: 13px;
    text-align: center;
}

.notif-count[hidden] {
    display: none;
}

/* ── the panel ──────────────────────────────────────────────── */
.notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.notif-head__title {
    font-weight: 700;
}

.notif-readall {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-size: var(--fs-2xs);
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
}

.notif-readall:hover {
    text-decoration: underline;
}

.notif-readall[hidden] {
    display: none;
}

/* A long list scrolls inside the panel rather than off the screen. */
.notif-list {
    max-height: 60vh;
    overflow-y: auto;
}

/* Each row is a button now, so it is reachable by keyboard. */
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    padding: 11px 16px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: none;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.notif-item:last-child {
    border-bottom: 0;
}

.notif-item.is-unread {
    background: var(--primary-soft);
}

.notif-item:hover {
    background: var(--surface-2);
}

.notif-item.is-unread:hover {
    background: var(--primary-soft-2);
}

.notif-av {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    color: #fff;
    font-size: var(--fs-2xs);
    font-weight: 700;
}

.notif-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.notif-item .notif-text {
    font-size: var(--fs-xs);
    color: var(--ink);
    line-height: 1.45;
}

.notif-item.is-unread .notif-text {
    font-weight: 600;
}

.notif-item .notif-dot {
    margin-top: 9px;
}

.notif-empty {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 28px 20px;
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--ink-3);
}

.notif-empty span {
    font-size: var(--fs-2xs);
    color: var(--muted-ink);
    line-height: 1.5;
}

/* One width for every card, so a stack lines up. */
.pat-notes {
    width: min(380px, calc(100vw - 32px));
    align-items: stretch;
}

.pat-note {
    min-width: 0;
    width: 100%;
}

/* The round icon in its kind's colour, solid, with a white symbol:
   green ✓ success · red ✕ error · orange ! warning · blue i information. */
.pat-note.is-ok   { --note-c: #12B76A; }
.pat-note.is-err  { --note-c: #F04438; }
.pat-note.is-warn { --note-c: #F79009; }
.pat-note.is-info { --note-c: #2E90FA; }

.pat-note__ic {
    background: var(--note-c);
    color: #fff;
    font-size: 15px;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--note-c) 22%, transparent);
}

.pat-note__ic::before {
    font-weight: 700 !important;
}

.pat-note__bar {
    height: 3px;
    opacity: 1;
}
