/* ============================================================
   NOTIFICATION CENTRE
   Bell icon, badge, dropdown panel, notification items.
   Colour semantics lean on the aq-badge system; this file
   handles layout, positioning, and structural styles only.
   ============================================================ */

/* ─── Bell button wrapper ─────────────────────────────────── */
.aq-notif-btn-wrap {
    position: relative;
    display: flex;
    align-items: center;
    overflow: visible;
    z-index: 1000;
}

/* ─── Bell button ─────────────────────────────────────────── */
/* Chrome + hover are the shared .aq-header-icon-btn (aquilastrap.css),
   applied alongside this class in the markup - position:relative is the
   one thing genuinely specific to this button, needed as the containing
   block for the unread badge below. */
.aq-notif-btn {
    position: relative;
}

/* ─── Unread count badge - sits in the top-right corner of the bell ── */
/* Uses aq-badge-solid aq-badge-error colour semantics but needs custom
   absolute positioning which the inline aq-badge system doesn't provide. */
.aq-notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    /* Mirror aq-badge-solid aq-badge-error */
    background-color: var(--aq-error-colour, #ff0000);
    border: 1.5px solid var(--aq-secondary-colour-dark-25, #213b5b);
    color: #fff;
    font-size: 0.575rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.175rem 0.325rem;
    border-radius: 99px;
    min-width: 1rem;
    text-align: center;
    pointer-events: none;
    display: none;
}

/* ─── Panel ───────────────────────────────────────────────── */
.aq-notif-panel {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: calc(100% + 0.625rem);
    right: 0;
    width: 390px;
    background: var(--aq-white);
    border-radius: var(--aq-radius, 0.6rem);
    box-shadow: 0 0.75rem 2.5rem rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.06);
    z-index: 9000;
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

.aq-notif-panel.aq-notif-panel-open {
    visibility: visible;
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0s;
}

/* ─── Panel header ────────────────────────────────────────── */
.aq-notif-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--aq-surface-border, #e2e8f0);
    flex-shrink: 0;
}

.aq-notif-panel-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--aq-neutral-colour-dark-25, #333740);
    letter-spacing: -0.01em;
}

.aq-notif-mark-all-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--aq-information-colour-dark-25, #0007bf);
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: var(--aq-radius-btn, 0.5rem);
    transition: background-color 0.15s;
    white-space: nowrap;
}

.aq-notif-mark-all-btn:hover {
    background-color: var(--aq-surface-page, #f8fafc);
}

/* ─── Filter bar ──────────────────────────────────────────── */
.aq-notif-filter-bar {
    display: flex;
    gap: 0.25rem;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--aq-surface-border, #e2e8f0);
    flex-shrink: 0;
}

.aq-notif-filter-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--aq-neutral-colour-light-25, #737780);
    padding: 0.25rem 0.875rem;
    border-radius: 99px;
    transition: background-color 0.15s, color 0.15s;
}

.aq-notif-filter-btn:hover {
    background-color: var(--aq-surface-page, #f8fafc);
    color: var(--aq-neutral-colour-dark-25, #333740);
}

.aq-notif-filter-btn.active {
    background-color: var(--aq-secondary-colour-light-90, #eaeef2);
    color: var(--aq-secondary-colour, #2c4f7a);
}

/* ─── Notification list ───────────────────────────────────── */
.aq-notif-list {
    overflow-y: auto;
    max-height: 62vh;
    scrollbar-width: thin;
    scrollbar-color: var(--aq-surface-border, #e2e8f0) transparent;
}

.aq-notif-list::-webkit-scrollbar { width: 4px; }
.aq-notif-list::-webkit-scrollbar-track { background: transparent; }
.aq-notif-list::-webkit-scrollbar-thumb {
    background: var(--aq-surface-border, #e2e8f0);
    border-radius: 99px;
}

/* ─── Empty state ─────────────────────────────────────────── */
.aq-notif-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    padding: 3rem 1.5rem;
    color: var(--aq-neutral-colour-light-50, #a1a3a9);
}

.aq-notif-empty i {
    font-size: 1.875rem;
}

.aq-notif-empty span {
    font-size: 0.875rem;
    font-weight: 500;
}

/* ─── Type colour tokens ──────────────────────────────────── */
/* Mirrors the aq-stat-* pattern - each type declares four custom
   properties; all item colour rules consume them exclusively.    */

.aq-notif-type-error {
    --aq-notif-border:    var(--aq-error-colour-dark-25, #bf0000);
    --aq-notif-bg-read:   var(--aq-error-colour-light-90, #ffe6e6);
    --aq-notif-bg-unread: var(--aq-error-colour-light-75, #ffbfbf);
    --aq-notif-icon:      var(--aq-error-colour, #ff0000);
}

.aq-notif-type-warning {
    --aq-notif-border:    var(--aq-warning-colour-dark-25, #bfac00);
    --aq-notif-bg-read:   var(--aq-warning-colour-light-90, #fffde6);
    --aq-notif-bg-unread: var(--aq-warning-colour-light-75, #fff8bf);
    --aq-notif-icon:      var(--aq-warning-colour-dark-25, #bfac00);
}

.aq-notif-type-success {
    --aq-notif-border:    var(--aq-success-colour-dark-25, #0a7c00);
    --aq-notif-bg-read:   var(--aq-success-colour-light-90, #e7f6e6);
    --aq-notif-bg-unread: var(--aq-success-colour-light-75, #c2e8bf);
    --aq-notif-icon:      var(--aq-success-colour, #0da500);
}

.aq-notif-type-action {
    --aq-notif-border:    var(--aq-attention-colour-dark-25, #bf5000);
    --aq-notif-bg-read:   var(--aq-attention-colour-light-90, #fff1e6);
    --aq-notif-bg-unread: var(--aq-attention-colour-light-75, #ffdabf);
    --aq-notif-icon:      var(--aq-attention-colour, #ff6b00);
}

.aq-notif-type-info {
    --aq-notif-border:    var(--aq-information-colour-dark-25, #0007bf);
    --aq-notif-bg-read:   var(--aq-information-colour-light-90, #e6e7ff);
    --aq-notif-bg-unread: var(--aq-information-colour-light-75, #bfc1ff);
    --aq-notif-icon:      var(--aq-information-colour, #000aff);
}

/* ─── Notification item ───────────────────────────────────── */
/*
 * Gradient transitions are not interpolatable in CSS, so we split
 * the two animated properties apart:
 *   • border-color       → transitions all border colours together;
 *                          top/right/bottom start transparent so the
 *                          2px space is always in the layout (no shift
 *                          when the error unread border colour appears)
 *   • gradient overlay   → lives on ::before at opacity 0/1;
 *                          opacity *is* transitionable, giving the
 *                          smooth fade-in / fade-out on the gradient
 *   • background-color   → the solid base fades between white and
 *                          main-colour-light-90 on read/unread change
 */
.aq-notif-item {
    padding: 0.875rem 1.25rem 0.875rem 1rem;
    border-top: 1px solid transparent;
    border-right: 1px solid transparent;
    border-bottom: 1px solid var(--aq-surface-border, #e2e8f0);
    border-left: 4px solid var(--aq-main-colour-light-90, #edf9f7);
    background-color: var(--aq-white);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: background-color 0.35s ease, border-color 0.35s ease;
}

/* Gradient overlay - present for all items, opacity toggled by unread class */
.aq-notif-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--aq-notif-bg-unread, transparent) 0%, transparent 65%);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.aq-notif-item:last-child {
    border-bottom-color: transparent;
}

.aq-notif-item:hover {
    background-color: var(--aq-surface-page, #f8fafc);
}

/* Unread - type-coloured border + gradient fades in */
.aq-notif-item.aq-notif-unread {
    border-left-color: var(--aq-notif-border);
}

.aq-notif-item.aq-notif-unread::before {
    opacity: 1;
}

/* ─── Error - extra emphasis for unread critical items ────── */
/* The base item always reserves 2px on top/right/bottom (transparent).
   Setting border-color here colours those three sides without changing
   any width - border-left stays 4px as declared on .aq-notif-item.
   Pulse breathes the gradient overlay so the whole card draws the eye.
   Both effects transition away cleanly when marked read. */

@keyframes aq-notif-error-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}

.aq-notif-type-error.aq-notif-unread {
    border-color: var(--aq-notif-border, var(--aq-error-colour, #ff0000));
}

.aq-notif-type-error.aq-notif-unread::before {
    animation: aq-notif-error-pulse 2.4s ease-in-out infinite;
}

/* ─── Read/unread envelope toggle ────────────────────────── */
.aq-notif-read-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.3rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--aq-radius-btn, 0.375rem);
    transition: background-color 0.15s;
}

.aq-notif-read-toggle:hover {
    background-color: var(--aq-surface-page, #f8fafc);
}

/* Envelope icon - closed (fas fa-envelope) unread, open (far fa-envelope-open) read */
.aq-notif-envelope-icon {
    font-size: 0.875rem;
    transition: color 0.15s, opacity 0.15s;
    display: block;
}

/* Unread - full type icon colour */
.aq-notif-unread .aq-notif-envelope-icon {
    color: var(--aq-notif-icon, var(--aq-secondary-colour, #2c4f7a));
}

/* Read - border colour at half opacity */
.aq-notif-item:not(.aq-notif-unread) .aq-notif-envelope-icon {
    color: var(--aq-notif-border, var(--aq-neutral-colour-light-50, #a1a3a9));
    opacity: 0.5;
}

/* ─── Item body ───────────────────────────────────────────── */
/* position: relative + z-index: 1 lifts the content above the
   ::before gradient overlay so text and buttons are never obscured */
.aq-notif-item-body {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
}

.aq-notif-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.aq-notif-item-title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--aq-neutral-colour, #444955);
    line-height: 1.4;
    flex: 1;
    min-width: 0;
}

/* Unread title - coloured to match the type border, same as aq-stat headings */
.aq-notif-item.aq-notif-unread .aq-notif-item-title {
    font-weight: 600;
    color: var(--aq-notif-border, var(--aq-neutral-colour-dark-25, #333740));
}

/* Dismiss button - shown on hover */
.aq-notif-item-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.125rem;
    color: var(--aq-neutral-colour-light-50, #a1a3a9);
    opacity: 0;
    transition: color 0.15s, opacity 0.15s, background-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
    border-radius: 0.25rem;
}

.aq-notif-item:hover .aq-notif-item-dismiss {
    opacity: 1;
}

.aq-notif-item-dismiss:hover {
    color: var(--aq-error-colour-dark-25, #bf0000);
    background-color: var(--aq-error-colour-light-90, #ffe6e6);
}

.aq-notif-item-dismiss i {
    font-size: 0.6875rem;
}

/* Body text - allow up to 6 lines; pre-line so \n in multi-field descriptions renders */
.aq-notif-item-text {
    font-size: 0.75rem;
    color: var(--aq-neutral-colour-light-25, #737780);
    line-height: 1.45;
    margin: 0 0 0.4rem;
    white-space: pre-line;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Meta row - aq-badge + time */
.aq-notif-item-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.aq-notif-item-time {
    font-size: 0.6875rem;
    color: var(--aq-neutral-colour-light-50, #a1a3a9);
    margin-left: auto;
    white-space: nowrap;
}

/* ─── Header actions (sound btn + mark-all) ──────────────── */
.aq-notif-header-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.aq-notif-sound-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3rem 0.45rem;
    border-radius: var(--aq-radius-btn, 0.5rem);
    color: var(--aq-neutral-colour-light-25, #737780);
    font-size: 0.8rem;
    line-height: 1;
    transition: background-color 0.15s, color 0.15s;
}

.aq-notif-sound-btn:hover {
    background-color: var(--aq-surface-page, #f8fafc);
    color: var(--aq-neutral-colour-dark-25, #333740);
}

/* ─── Sound settings collapsible area ────────────────────── */
.aq-notif-sound-settings {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.2s ease;
    border-bottom: 1px solid transparent;
    background: var(--aq-surface-page, #f8fafc);
}

.aq-notif-sound-settings.aq-notif-sound-settings-open {
    grid-template-rows: 1fr;
    border-bottom-color: var(--aq-surface-border, #e2e8f0);
}

.aq-notif-sound-settings-inner {
    overflow: hidden;
    padding: 0 1rem;
}

.aq-notif-sound-settings.aq-notif-sound-settings-open .aq-notif-sound-settings-inner {
    padding: 0.625rem 1rem;
}

.aq-notif-sound-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--aq-neutral-colour-light-25, #737780);
    margin-bottom: 0.5rem;
}

.aq-notif-sound-opts {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
}

.aq-notif-sound-opt {
    background: none;
    border: 1px solid var(--aq-surface-border, #e2e8f0);
    border-radius: 99px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.2rem 0.75rem;
    color: var(--aq-neutral-colour-light-25, #737780);
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.aq-notif-sound-opt:hover {
    background-color: var(--aq-surface-border, #e2e8f0);
    color: var(--aq-neutral-colour-dark-25, #333740);
}

.aq-notif-sound-opt.active {
    background-color: var(--aq-main-colour, #1a1fb5);
    border-color: var(--aq-main-colour, #1a1fb5);
    color: #fff;
}

.aq-notif-sound-file-wrap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.7rem;
    color: var(--aq-information-colour-dark-25, #0007bf);
    padding: 0.25rem 0;
    margin-top: 0.125rem;
}

.aq-notif-sound-file-wrap:hover {
    text-decoration: underline;
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
    .aq-notif-panel {
        width: calc(100vw - 1rem);
        right: -0.5rem;
    }
}
