/* ===== NOTIFICATION SYSTEM — iPhone-style top-down ===== */

#notifications-container {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    pointer-events: none;
    width: 100%;
    max-width: 480px;
    padding: 0.5rem 0.75rem 0.75rem;
    align-items: stretch;
}

.notifications-stack-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem 0.15rem;
    pointer-events: auto;
}

.notifications-stack-toolbar[hidden] {
    display: none !important;
}

.notifications-stack-toolbar-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.45);
}

.notifications-clear-all-btn {
    pointer-events: auto;
    border: none;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
    background: rgba(168, 85, 247, 0.35);
    transition: background 0.2s;
}

.notifications-clear-all-btn:hover {
    background: rgba(168, 85, 247, 0.5);
}

.notification--has-link {
    cursor: pointer;
}

.notification {
    background: rgba(22, 22, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.06);
    opacity: 0;
    transform: translateY(-100%) scale(0.95);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.notification.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.notification.hiding {
    opacity: 0;
    transform: translateY(-40px) scale(0.95);
}

.notification-content {
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    gap: 0.75rem;
}

.notification-icon-circle {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
    color: #fff;
}

.notification-success .notification-icon-circle { background: #10b981; }
.notification-error .notification-icon-circle { background: #ef4444; }
.notification-warning .notification-icon-circle { background: #f59e0b; }
.notification-info .notification-icon-circle { background: #a855f7; }
.notification-dm .notification-icon-circle { background: #3b82f6; }

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

.notification-app-name {
    font-size: 0.68rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.notification-message {
    color: #e0e0e0;
    font-size: 0.88rem;
    line-height: 1.35;
    margin-top: 0.1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-time-label {
    font-size: 0.68rem;
    color: #666;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 0.1rem;
}

.notification-close {
    position: absolute;
    top: 0.4rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 1rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

.notification:hover .notification-close { opacity: 1; }
.notification-close:hover { background: rgba(255,255,255,0.08); color: #aaa; }

/* DM reply button */
.notification-reply-area {
    display: flex;
    gap: 0.4rem;
    padding: 0 1rem 0.75rem;
    padding-left: calc(32px + 0.75rem + 1rem);
}

.notification-reply-input {
    flex: 1;
    padding: 0.4rem 0.7rem;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: #fff;
    font-size: 0.8rem;
    font-family: inherit;
    outline: none;
}

.notification-reply-input:focus { border-color: rgba(168,85,247,0.4); }

.notification-reply-send {
    padding: 0.4rem 0.7rem;
    border-radius: 10px;
    background: #a855f7;
    border: none;
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
}

/* Progress bar at bottom of notification */
.notification-progress {
    height: 3px;
    background: rgba(255,255,255,0.05);
    overflow: hidden;
}

.notification-progress-bar {
    height: 100%;
    background: rgba(255,255,255,0.15);
    width: 100%;
    transform-origin: left;
    animation: notifCountdown 5s linear forwards;
}

@keyframes notifCountdown {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.notification:hover .notification-progress-bar {
    animation-play-state: paused;
}

/* ===== NOTIFICATION PANEL — шторка + затемнение ===== */
.notifications-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(6, 4, 12, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}

.notifications-backdrop.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.notifications-sheet-open {
    overflow: hidden;
}

.notifications-panel {
    z-index: 10001;
    overflow: hidden;
}

.notifications-panel--sheet {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: auto;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    max-height: min(72vh, 520px);
    background: linear-gradient(180deg, rgba(26, 24, 34, 0.98) 0%, rgba(14, 12, 22, 0.99) 100%);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border-radius: 0 0 20px 20px;
    border: 1px solid rgba(168, 85, 247, 0.28);
    border-top: none;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    display: flex;
    flex-direction: column;
    transform: translateY(-110%);
    opacity: 0;
    visibility: hidden;
    transition:
        transform 0.3s cubic-bezier(0.32, 0.72, 0, 1),
        opacity 0.22s ease,
        visibility 0s linear 0.3s;
    pointer-events: none;
}

.notifications-panel--sheet.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    transition-delay: 0s, 0s, 0s;
    pointer-events: auto;
}

.notifications-panel-header {
    padding: 0.35rem 1rem 0.85rem;
    border-bottom: 1px solid rgba(168, 85, 247, 0.12);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notifications-panel-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
}

.notifications-panel-close {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.3rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.notifications-panel-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.notifications-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.notification-item {
    padding: 0.85rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin-bottom: 0.4rem;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    display: flex;
    gap: 0.75rem;
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.notification-item.unread {
    border-left-color: #a855f7;
    background: rgba(168, 85, 247, 0.08);
}

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

.notifications-empty-hint {
    text-align: center;
    color: rgba(255, 255, 255, 0.42);
    font-size: 0.88rem;
    padding: 2rem 1rem;
    line-height: 1.45;
}

.notifications-footer {
    display: none;
    flex-direction: column;
    padding: 0.65rem 0.85rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.22);
}

.notifications-footer-actions {
    display: flex;
    gap: 0.5rem;
}

.notifications-foot-btn {
    flex: 1;
    border: none;
    border-radius: 12px;
    padding: 0.55rem 0.65rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    font-family: inherit;
}

.notifications-foot-btn:active {
    transform: scale(0.98);
}

.notifications-foot-btn--secondary {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.notifications-foot-btn--secondary:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.35);
}

.notifications-foot-btn--danger {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.5), rgba(124, 58, 237, 0.45));
    color: #fff;
    border: 1px solid rgba(168, 85, 247, 0.45);
}

.notifications-foot-btn--danger:hover {
    filter: brightness(1.06);
}

.top-notifications-btn {
    color: #c4b5fd !important;
    border: 1px solid rgba(168, 85, 247, 0.35) !important;
    background: rgba(168, 85, 247, 0.1) !important;
    border-radius: 12px !important;
}

.top-notifications-btn:hover {
    background: rgba(168, 85, 247, 0.2) !important;
    color: #e9d5ff !important;
}

.notification-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.notification-title {
    font-weight: 600;
    color: #fff;
    font-size: 0.88rem;
    margin-bottom: 0.15rem;
}

.notification-time {
    font-size: 0.72rem;
    color: #666;
}

/* Notification toast (for server push events) */
.notification-toast {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: rgba(22, 22, 30, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 1rem;
    border: 1px solid rgba(168, 85, 247, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 10002;
    min-width: 300px;
    max-width: 480px;
    width: calc(100% - 1.5rem);
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0.75rem);
}

.notification-toast-content {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.notification-toast-icon { font-size: 1.5rem; flex-shrink: 0; }

.notification-toast-text { flex: 1; }

.notification-toast-title {
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.2rem;
    font-size: 0.92rem;
}

.notification-toast-message {
    color: #aaa;
    font-size: 0.85rem;
}

.notification-toast-close {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.notification-toast-close:hover { background: rgba(255,255,255,0.08); color: #aaa; }

@media (max-width: 768px) {
    #notifications-container {
        max-width: 100%;
        padding: 0.5rem;
    }
    .notification { border-radius: 14px; }
    .notifications-panel--sheet {
        max-width: 100%;
        max-height: min(82vh, 620px);
    }
}

@media (min-width: 900px) {
    .notifications-panel--sheet {
        border-radius: 20px;
        bottom: 24px;
        max-height: min(70vh, 520px);
        box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(168, 85, 247, 0.2);
    }
    .notifications-sheet-handle {
        display: none;
    }
}
