/* WTCHLST Notifications
   Feed-Style
   - Satz in einer Zeile mit normalem Umbruch bei Bedarf
   - Button „Gelesen" in eigener Fußzeile unter dem Content
   - Strenges Scoping, keine Kollision mit feed.css oder .desktop-nav-links */

div.notif-wrapper.notif-desktop {
    margin-left: var(--spacing-24);
}

.notif-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    /* isolation: isolate ist bewusst entfernt (2026-07-06):
       schuf einen Stacking-Kontext, in dem die Bell ueber Modals lag.
       Stattdessen setzt der Wrapper einen expliziten niedrigen z-index,
       damit Modals + Toasts immer drueberliegen. */
    z-index: var(--z-sticky);
    line-height: 1;
    font-family: var(--font-family);
    color: var(--text);
}

.notif-wrapper .notif-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    border-radius: 50%;
}

.notif-wrapper .notif-btn:hover {
    color: var(--primary-color);
}

.notif-wrapper .notif-btn i {
    font-size: 18px;
    line-height: 1;
}

.notif-wrapper .notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    background: var(--accent-red);
    border-radius: 50%;
    border: 2px solid var(--background);
}

/* Mobile: Bell sitzt auf dem helleren Header-Ton (Light Mode).
   Border auf --background-active angleichen, damit die weisse Kontur
   im Light Mode nicht wie ein heller Ring um den roten Dot wirkt. */
.notif-wrapper.notif-mobile .notif-dot {
    border-color: var(--background-active);
}

/* Overlay */
.notif-wrapper .notif-overlay {
    position: absolute;
    top: 44px;
    right: -56px;
    width: clamp(280px, 92vw, 360px);
    background: var(--background);
    border: 1px solid var(--primary-color);
    border-radius: var(--spacing-12);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    padding: 0;
    /* Dropdown liegt ueber normalen Overlays, aber unter Modals + Toasts.
       Wenn ein Modal offen ist, hat es Vorrang; Toasts immer ganz oben. */
    z-index: calc(var(--z-overlay) + 10);
    color: var(--text);
    overflow: hidden;
}

/* Reset im Overlay: verhindert Einflüsse aus Nav/Feed */
.notif-wrapper .notif-overlay,
.notif-wrapper .notif-overlay * {
    box-sizing: border-box;
    font-family: var(--font-family);
    letter-spacing: 0.3px;
}

.notif-wrapper .notif-overlay a {
    display: inline !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    color: var(--text-link) !important;
    text-decoration: none;
    vertical-align: baseline;
    border-bottom: var(--border-champagne);
    opacity: 1;
    font-size: inherit;
    font-weight: 300;
}

.notif-wrapper .notif-overlay a:has(> img) {
    border-bottom: none;
}

.desktop-nav-links .notif-wrapper .notif-overlay a {
    display: inline !important;
    gap: 0 !important;
}

/* Kopf */
.notif-wrapper .notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-12);
    padding: var(--spacing-12) var(--spacing-16);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text);
    min-width: 0;
    min-height: 56px;
}

.notif-wrapper .notif-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--headline);
    line-height: 1.2;
    flex: 1;
    min-width: 0;
}

.notif-wrapper .notif-mark-all {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 112px;
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--text-sub);
    border-radius: var(--radius-full);
    padding: 0 var(--spacing-12);
    height: 32px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
    white-space: nowrap;
    visibility: visible;
    opacity: 1;
}

.notif-wrapper .notif-mark-all.is-hidden {
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
}

.notif-wrapper .notif-mark-all:hover {
    background: var(--background-light);
    color: var(--text);
    border-color: var(--primary-color-hover);
}

/* Tabs */
.notif-wrapper .notif-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin: 0;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--background) 88%, var(--background-light));
}

.notif-wrapper .notif-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    padding: var(--spacing-12) 0;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: color 0.2s, background-color 0.2s;
}

.notif-wrapper .notif-tab:hover {
    color: var(--primary-color);
}

.notif-wrapper .notif-tab.active {
    color: var(--primary-color);
}

.notif-wrapper .notif-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--primary-color);
    border-radius: var(--radius-full);
}

/* Liste */
.notif-wrapper .notif-list {
    max-height: 60vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Item-Layout:
   Row 1: avatar | content | dismiss-x
   Row 2: avatar | actions (colspan 2, nur wenn vorhanden) */
.notif-wrapper .notif-item {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    grid-template-areas:
        "avatar content dismiss"
        "avatar actions  actions";
    column-gap: var(--spacing-12);
    row-gap: var(--spacing-8);
    padding: var(--spacing-16) var(--spacing-24);
    align-items: start;
    border-bottom: var(--border-subtle);
    position: relative;
    transition: background-color 0.15s ease;
}

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

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

/* Ungelesen: dezenter primary-Akzent links + zarter Background */
.notif-wrapper .notif-item.unread {
    background: var(--background-hover);
}

.notif-wrapper .notif-item.unread::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
}

.notif-wrapper .notif-item .notif-avatar-link {
    grid-area: avatar;
    align-self: start;
}

.notif-wrapper .notif-item .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--background-light);
    border: 1px solid var(--background-dark);
    display: block;
}

.notif-wrapper .notif-item .notif-poster-avatar {
    grid-area: avatar;
    display: block;
    width: 32px;
    height: 48px;
    border-radius: var(--spacing-4);
    overflow: hidden;
    background: var(--background-light);
    border: 1px solid var(--background-dark);
    flex-shrink: 0;
    align-self: start;
}

.notif-wrapper .notif-item .notif-poster-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.notif-wrapper .notif-item .content {
    grid-area: content;
    min-width: 0;
    display: block;
}

.notif-wrapper .notif-item .content > * + * {
    margin-top: var(--spacing-8);
}

.notif-wrapper .notif-item .content .sentence {
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    word-break: break-word;
    white-space: normal;
}

/* Timestamp außerhalb des Blocks */
.notif-wrapper .notif-item .content .meta {
    color: var(--text-sub);
    font-size: 14px;
    margin-top: var(--spacing-8);
    opacity: 0.95;
}

/* Dismiss-X oben rechts */
.notif-wrapper .notif-item .notif-dismiss {
    grid-area: dismiss;
    background: transparent;
    border: none;
    color: var(--text-sub);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.2s, background-color 0.2s;
    align-self: start;
    flex-shrink: 0;
}

.notif-wrapper .notif-item .notif-dismiss:hover {
    color: var(--text);
    background: var(--background-light);
}

.notif-wrapper .notif-item .notif-dismiss i {
    font-size: 13px;
    line-height: 1;
}

/* Actions-Fußzeile (nur für Annehmen/Ablehnen und Watchlog-Übernahme) */
.notif-wrapper .notif-item .actions {
    grid-area: actions;
    display: flex;
    align-items: center;
    gap: var(--spacing-8);
    flex-wrap: wrap;
}

/* Empty State */
.notif-wrapper .notif-list .empty {
    padding: var(--spacing-16);
    color: var(--text-sub);
    text-align: center;
    font-size: 14px;
}

/* Fokus für A11y */
.notif-wrapper .notif-btn:focus-visible,
.notif-wrapper .notif-mark-all:focus-visible,
.notif-wrapper .notif-tab:focus-visible,
.notif-wrapper .notif-item .notif-dismiss:focus-visible,
.notif-wrapper .notif-overlay a:focus-visible,
.notif-detail-close:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: var(--radius-full);
}

/* Zusatz: Buttons für Interaktionen */
.notif-wrapper .actions .btn,
.btn {
    height: 32px;
    padding: 0 var(--spacing-12);
    border-radius: var(--radius-full);
    cursor: pointer;
    border: 1px solid var(--primary-color);
    color: var(--text-sub);
    background: transparent;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.notif-wrapper .actions .btn-accept,
.btn-accept {
    background: var(--primary-color);
    color: var(--text-darker);
    border-color: var(--primary-color);
}

.notif-wrapper .actions .btn-accept:hover,
.btn-accept:hover {
    background: var(--primary-color-hover);
    border-color: var(--primary-color-hover);
}

.notif-wrapper .actions .btn-decline:hover,
.btn-decline:hover {
    background: var(--background-light);
    color: var(--text);
    border-color: var(--primary-color-hover);
}

/* Companion-tagged hint */
.notif-companion-hint {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
}

/* Home-spezifischer Anker für die Glocke */
.home-mobile-bell {
    position: absolute;
    top: var(--spacing-12);
    right: var(--spacing-12);
    /* War 2100 — kollidierte mit Toast (var(--z-toast) = 1200 alt / 100000000 neu).
       Sticky reicht: die Bell liegt ueber normalen Inhalten, aber
       Modals + Toasts bleiben drueber. */
    z-index: var(--z-sticky);
}

/* Breakpoints */
.notif-desktop {
    display: none;
}

.notif-mobile {
    display: none;
}

@media (max-width: 768px) {
    .notif-mobile {
        display: inline-flex;
        /* War 99999999 — lag ueber Modals + Toasts. Auf sticky-Level
           runter, damit Modals (--z-modal) und Toasts (--z-toast)
           immer drueberliegen. */
        z-index: var(--z-sticky);
    }

    .notif-desktop {
        display: none;
    }

    .notif-wrapper .notif-overlay {
        right: -12px;
        width: min(360px, 92vw);
    }
}

@media (min-width: 769px) {
    .notif-desktop {
        display: inline-flex;
    }

    .notif-mobile {
        display: none;
    }
}

/* Notification-Icon hinter Modalen verstecken */
.body-no-scroll .notif-mobile,
.body-no-scroll .home-mobile-bell {
    z-index: 1;
}

/* Kommentar/Reaction-Block */
.notif-wrapper .notif-comment-block {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-12);
    padding: var(--spacing-8) var(--spacing-12);
    background: var(--background-light);
    border: 1px solid var(--background-hover);
    border-radius: var(--spacing-8);
}

.notif-wrapper .notif-comment-block .notif-poster {
    width: 45px;
    height: 67px;
    object-fit: cover;
    border-radius: var(--spacing-4);
    flex-shrink: 0;
}

/* Review-Poster: gleiche Größe wie andere Notification-Poster */
.notif-wrapper .notif-comment-block .notif-comment-block-poster {
    width: 45px;
    height: 67px;
    object-fit: cover;
    border-radius: var(--spacing-4);
    flex-shrink: 0;
}

.notif-wrapper .notif-comment-block-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    flex: 1;
}

.notif-wrapper .notif-comment-block-text .comment-link {
    display: block !important;
    font-size: 16px;
    line-height: 1.5;
    border-bottom: none !important;
    opacity: 0.95;
    word-break: break-word;
    color: var(--text) !important;
}

.notif-wrapper .notif-comment-block-text .meta {
    color: var(--text-sub);
    font-size: 14px;
    opacity: 0.95;
    margin-top: var(--spacing-4);
}

.notif-poster {
    width: 40px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--spacing-4);
    flex-shrink: 0;
}

.notif-wrapper .notif-item .link {
    font-weight: 300;
}

/* Detail Modal */
.notif-detail-modal {
    position: fixed;
    inset: 0;
    z-index: 100000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-16);
}

.notif-detail-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.notif-detail-content {
    position: relative;
    background: var(--background);
    border: var(--border-light);
    border-radius: var(--spacing-16);
    width: min(520px, 100%);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    animation: notifModalIn 0.25s ease-out;
}

/* Light: Modal-Body leicht abgesetzt, damit das Feed-Item innen sichtbar abhebt. */
:root[data-theme="light"] .notif-detail-content{
    background: var(--background-active);
}

:root[data-theme="light"] .notif-detail-body .feed-item{
    background: var(--background-light);
    border: var(--border-light);
    border-radius: var(--radius-md);
}

@keyframes notifModalIn {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.notif-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-12);
    padding: var(--spacing-16) var(--spacing-16);
    border-bottom: var(--border-light);
    flex-shrink: 0;
}

.notif-detail-title {
    margin: 0;
    font-weight: 600;
    font-size: 16px;
    color: var(--headline);
    line-height: 1.3;
}

.notif-detail-close {
    background: transparent;
    border: none;
    color: var(--text-sub);
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    flex-shrink: 0;
}

.notif-detail-close:hover {
    color: var(--text);
}

.notif-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-16) var(--spacing-16) var(--spacing-24);
}

/* Feed item inside modal – inherits feed.css / feed-comments.css / feed-reactions.css styles.
   Only minor overrides needed to fit inside the scrollable modal body. */

.notif-detail-body .feed-item {
    margin: 0;
    background: transparent;
}

.notif-detail-body .feed-footer {
    padding-top: var(--spacing-8);
}

/* Comments section is visible by default in modal */
.notif-detail-body .comments-section.show {
    border-top: 1px solid var(--background-hover);
    padding-top: var(--spacing-12);
    margin-top: var(--spacing-12);
}

.notif-detail-body .loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-24) 0;
}

/* --- Mobile: Review im Modal — Poster ausblenden für mehr Textbreite --- */
@media (max-width: 600px) {
    .notif-detail-body .feed-item:has(.feed-review-block) .feed-poster-link {
        display: none;
    }
}
/* --- System-Announcement Notifications --- */
.notif-wrapper .notif-item.notif-item-announcement .notif-announcement-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--background-light);
    border: 1px solid var(--background-dark);
    flex-shrink: 0;
    align-self: start;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notif-wrapper .notif-item.notif-item-announcement .notif-announcement-icon img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.notif-wrapper .notif-item.notif-item-announcement .notif-announcement-title {
    display: block;
    font-weight: 600;
    color: var(--text);
}

.notif-wrapper .notif-item.notif-item-announcement .notif-announcement-body {
    font-size: 0.9em;
    line-height: 1.7;
    color: var(--text-secondary, var(--text));
    opacity: 0.85;
    white-space: pre-wrap;
    word-break: break-word;
    margin-top: var(--spacing-4, 4px);
}

.notif-wrapper .notif-item.notif-item-announcement .notif-announcement-body--clamped {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
}

/* Announcement Detail Modal */
.notif-announcement-modal-body {
    padding: var(--spacing-20, 20px) var(--spacing-16);
    flex: 1;
    overflow-y: auto;
}

.notif-announcement-modal-text {
    font-size: 1rem;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    opacity: 0.9;
}

/* Footer: Absender */
.notif-announcement-modal-footer {
    display: flex;
    align-items: center;
    gap: var(--spacing-10, 10px);
    padding: var(--spacing-12, 12px) var(--spacing-16);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.notif-announcement-modal-footer-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.notif-announcement-modal-footer-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.notif-announcement-modal-footer-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

.notif-announcement-modal-footer-time {
    font-size: 0.78rem;
    color: var(--text-sub);
    line-height: 1.2;
}

/* Community-Notifications: Name als Inline-Link (Theme-aware). */
.notif-wrapper .notif-item .notif-community-link {
    color: var(--text-link);
    text-decoration: none;
}
.notif-wrapper .notif-item .notif-community-link:hover,
.notif-wrapper .notif-item .notif-community-link:focus-visible {
    color: var(--text-link-hover);
    text-decoration: underline;
}
.notif-wrapper .notif-item .notif-community-body {
    font-size: 0.85rem;
    color: var(--text-sub);
    margin-top: 2px;
}
