/* App notifications — toasts, flashes, nav dropdown, detail modal (theme-aware) */

:root {
    --app-notify-surface: var(--ds-bg-1, oklch(var(--b1)));
    --app-notify-surface-2: var(--ds-bg-2, oklch(var(--b2)));
    --app-notify-border: var(--ds-border, color-mix(in oklch, oklch(var(--bc)) 14%, oklch(var(--b1))));
    --app-notify-text: var(--ds-text-0, oklch(var(--bc)));
    --app-notify-text-muted: var(--ds-text-3, oklch(var(--bc) / 0.6));
    --app-notify-radius: var(--ds-radius-md, var(--rounded-box, 0.5rem));
    --app-notify-shadow: var(--ds-shadow-md, 0 12px 32px oklch(var(--bc) / 0.12));
}

/* ----- Flash messages (server-rendered) ----- */
.app-notify-flash-stack {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-width: 56rem;
    margin: 0 auto;
}

.app-notify-flash {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.7rem 0.95rem;
    border: 1px solid var(--app-notify-border);
    border-left-width: 3px;
    border-radius: var(--app-notify-radius);
    background: var(--app-notify-surface);
    color: var(--app-notify-text);
    font-size: 0.875rem;
    line-height: 1.45;
    box-shadow: 0 1px 0 oklch(var(--bc) / 0.04);
}

.app-notify-flash--success {
    border-left-color: var(--ds-success, oklch(var(--su)));
    background: color-mix(in srgb, var(--ds-success, oklch(var(--su))) 8%, var(--app-notify-surface));
}

.app-notify-flash--error {
    border-left-color: var(--ds-danger, oklch(var(--er)));
    background: color-mix(in srgb, var(--ds-danger, oklch(var(--er))) 8%, var(--app-notify-surface));
}

.app-notify-flash--warning {
    border-left-color: var(--ds-warning, oklch(var(--wa)));
    background: color-mix(in srgb, var(--ds-warning, oklch(var(--wa))) 8%, var(--app-notify-surface));
}

.app-notify-flash--info {
    border-left-color: var(--ds-info, oklch(var(--in)));
    background: color-mix(in srgb, var(--ds-info, oklch(var(--in))) 8%, var(--app-notify-surface));
}

/* ----- Toast stack ----- */
#app-notify-toast-container {
    position: fixed;
    top: max(1rem, env(safe-area-inset-top));
    right: max(1rem, env(safe-area-inset-right));
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    width: min(24rem, calc(100vw - 2rem));
    pointer-events: none;
}

.app-notify-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.7rem 0.85rem 0.7rem 0.95rem;
    border: 1px solid var(--app-notify-border);
    border-left-width: 3px;
    border-radius: var(--app-notify-radius);
    background: var(--app-notify-surface);
    color: var(--app-notify-text);
    box-shadow: var(--app-notify-shadow);
    font-size: 0.875rem;
    line-height: 1.45;
    opacity: 0;
    transform: translateX(12px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.app-notify-toast.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.app-notify-toast--success { border-left-color: var(--ds-success, oklch(var(--su))); }
.app-notify-toast--error { border-left-color: var(--ds-danger, oklch(var(--er))); }
.app-notify-toast--warning { border-left-color: var(--ds-warning, oklch(var(--wa))); }
.app-notify-toast--info { border-left-color: var(--ds-info, oklch(var(--in))); }

.app-notify-toast__message {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.app-notify-toast__close {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--app-notify-text-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.1rem 0.25rem;
    border-radius: 0.25rem;
}

.app-notify-toast__close:hover {
    color: var(--app-notify-text);
    background: oklch(var(--bc) / 0.06);
}

/* ----- Navbar bell dropdown ----- */
.app-notify-panel {
    border: 1px solid var(--app-notify-border) !important;
    border-radius: var(--app-notify-radius) !important;
    background: var(--app-notify-surface) !important;
    box-shadow: var(--app-notify-shadow) !important;
    overflow: hidden;
    padding: 0 !important;
}

.app-notify-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--app-notify-border);
    background: var(--app-notify-surface);
}

.app-notify-panel__title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--app-notify-text);
}

.app-notify-panel__link {
    font-size: 0.75rem;
    color: oklch(var(--p));
    text-decoration: none;
    min-height: 2rem;
    display: inline-flex;
    align-items: center;
}

.app-notify-panel__link:hover {
    text-decoration: underline;
}

.app-notify-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 18rem;
    overflow-y: auto;
}

.app-notify-item {
    border-bottom: 1px solid var(--app-notify-border);
}

.app-notify-item:last-child {
    border-bottom: none;
}

.app-notify-item__button {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    color: inherit;
    transition: background 0.15s ease;
}

.app-notify-item__button:hover,
.app-notify-item__button:focus-visible {
    background: var(--app-notify-surface-2);
    outline: none;
}

.app-notify-item__button:focus-visible {
    box-shadow: inset 0 0 0 2px oklch(var(--p) / 0.35);
}

.app-notify-item--unread .app-notify-item__button {
    background: color-mix(in srgb, oklch(var(--p)) 6%, var(--app-notify-surface));
}

.app-notify-item--unread .app-notify-item__title::before {
    content: "";
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    background: oklch(var(--p));
    margin-right: 0.45rem;
    vertical-align: middle;
    transform: translateY(-1px);
}

.app-notify-item__title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--app-notify-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-notify-item__meta {
    font-size: 0.72rem;
    color: var(--app-notify-text-muted);
}

.app-notify-empty {
    padding: 1.25rem 1rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--app-notify-text-muted);
}

#notification-count {
    min-width: 1.1rem;
    min-height: 1.1rem;
    font-size: 0.65rem;
    padding: 0 0.3rem;
    border: 1px solid var(--app-notify-surface);
}

/* ----- Detail modal (dropdown quick view) ----- */
.app-notify-modal::backdrop {
    background: oklch(var(--bc) / 0.35);
}

.app-notify-modal {
    border: none;
    padding: 0;
    background: transparent;
    max-width: min(92vw, 28rem);
    width: 100%;
}

.app-notify-modal__box {
    border: 1px solid var(--app-notify-border);
    border-radius: var(--app-notify-radius);
    background: var(--app-notify-surface);
    color: var(--app-notify-text);
    box-shadow: var(--app-notify-shadow);
    overflow: hidden;
}

.app-notify-modal__header {
    padding: 1rem 1.1rem 0.5rem;
    border-bottom: 1px solid var(--app-notify-border);
}

.app-notify-modal__header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.app-notify-modal__date {
    margin: 0.35rem 0 0;
    font-size: 0.75rem;
    color: var(--app-notify-text-muted);
}

.app-notify-modal__body {
    padding: 0.9rem 1.1rem 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 50vh;
    overflow-y: auto;
}

.app-notify-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.1rem;
    border-top: 1px solid var(--app-notify-border);
    background: var(--app-notify-surface-2);
}

.app-notify-modal__btn {
    font-size: 0.8125rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--app-notify-radius);
    border: 1px solid var(--app-notify-border);
    background: var(--app-notify-surface);
    color: var(--app-notify-text);
    cursor: pointer;
}

.app-notify-modal__btn:hover {
    background: var(--app-notify-surface-2);
}

.app-notify-modal__btn--primary {
    background: oklch(var(--p));
    border-color: oklch(var(--p));
    color: oklch(var(--pc, var(--b1)));
}

.app-notify-modal__btn--primary:hover {
    filter: brightness(1.05);
}

@media (max-width: 767px) {
    #app-notify-toast-container {
        left: max(1rem, env(safe-area-inset-left));
        right: max(1rem, env(safe-area-inset-right));
        width: auto;
    }

    #notification-bell-container .app-notify-panel {
        position: fixed !important;
        left: 1rem !important;
        right: 1rem !important;
        top: 4.5rem !important;
        width: calc(100vw - 2rem) !important;
        max-width: none !important;
        max-height: 70vh !important;
        margin: 0 !important;
        transform: none !important;
    }

    .app-notify-list {
        max-height: 60vh;
    }

    .app-notify-item__button {
        min-height: 2.75rem;
    }
}
