/* ============================================================================
   УВЕДОМЛЕНИЯ - СТИЛИ
   ============================================================================ */

/* Кнопка колокольчика в шапке */
.notifications-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--font-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.notifications-bell:hover {
    background: var(--bg-content-secondary);
    color: var(--font-primary);
}

.notifications-bell i {
    font-size: var(--font-size-md);
    position: relative;
    z-index: 1;
}

/* Бейдж: компактная таблетка в углу, не перекрывает иконку (см. .gc-badge-counter в badges.css) */
.notifications-badge {
    position: absolute;
    top: var(--spacing-4xs);
    right: var(--spacing-4xs);
    z-index: 2;
    box-sizing: border-box;
    min-width: var(--spacing-lg);
    height: 1.25rem;
    padding: 0 var(--spacing-sm);
    border: none;
    border-radius: var(--radius-full);
    background: var(--accent-link);
    color: var(--color-on-accent);
    font-size: var(--font-size-2xs);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    box-shadow: 0 0 0 2px var(--bg-content-main);
    transform: translate(18%, -18%);
}

.notifications-badge.hidden {
    display: none;
}

/* Мобильный навбар: та же логика на 32×32 */
.gc-nav-icon .notifications-badge {
    top: 0;
    right: 0;
    transform: translate(12%, -12%);
}

/* Якорь в разметке (десктоп переносит #notificationsDropdown в навбар; узел остаётся в DOM) */
.notifications-dropdown-host {
    position: static;
}

/* Корень: класс .show — единая точка открытия (десктоп и адаптив) */
.notifications-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px; /* Отступ от кнопки на десктопе */
    z-index: var(--z-modal);
    display: none;
    pointer-events: none;
}

.notifications-dropdown.show {
    display: block;
    pointer-events: auto;
}

/* Затемнение — только на адаптиве (как ::before у gc-modal) */
.notifications-dropdown-backdrop {
    display: none;
}

/* Визуальная «карточка» под колокольчиком / нижний sheet на мобильных */
.notifications-dropdown-panel {
    width: 380px;
    max-height: 480px;
    background: var(--bg-content-main);
    border: 1px solid var(--ui-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .notifications-dropdown.show .notifications-dropdown-panel {
        animation: dropdown-fade-in 0.2s ease;
    }
}

@keyframes dropdown-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Заголовок dropdown */
.notifications-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-mdl);
    border-bottom: 1px solid var(--ui-border);
    flex-shrink: 0; /* Не сжимается */
}

.notifications-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--font-primary);
    margin: 0;
}

.notifications-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.notifications-action-btn {
    background: transparent;
    border: none;
    color: var(--font-secondary);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.notifications-action-btn:hover {
    background: var(--bg-content-secondary);
    color: var(--accent-link);
}

/* Список уведомлений */
.notifications-list {
    flex: 1; /* Занимает оставшееся место */
    min-height: 0; /* Позволяет сжаться */
    overflow-y: auto;
    max-height: 400px; /* Ограничение для десктопа; на мобильном — см. media */
}

.notifications-list::-webkit-scrollbar {
    width: 6px;
}

.notifications-list::-webkit-scrollbar-track {
    background: transparent;
}

.notifications-list::-webkit-scrollbar-thumb {
    background: var(--ui-border);
    border-radius: var(--radius-sm);
}

/* Одно уведомление */
.notification-item {
    display: flex;
    gap: var(--spacing-3sm);
    padding: var(--spacing-md) var(--spacing-mdl);
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--ui-border);
    /* Меньше задержка/двойной тап на iOS при клике по строке в скролле */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

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

.notification-item:hover {
    background: var(--bg-content-secondary);
}

/* Непрочитанные уведомления без фона - только точка */
/* .notification-item.unread - без стилей, для семантики */

/* Аватар уведомления */
.notification-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.notification-avatar-main {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--ui-surface-1);
    box-sizing: border-box;
}

/* Плейсхолдер если нет аватарки (нейтральный фон — без per-type hex из JS) */
.notification-avatar .notification-avatar-placeholder {
    display: none;
}

.notification-avatar.notification-avatar--fallback .notification-avatar-main {
    display: none !important;
}

.notification-avatar.notification-avatar--fallback .notification-avatar-placeholder {
    display: flex;
}

.notification-avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xl);
    font-weight: 600;
    line-height: 1;
    background: var(--ui-surface-1);
    border: 1px solid var(--ui-border);
    color: var(--font-secondary);
}

.notification-avatar-placeholder i {
    color: var(--font-secondary);
}

/* Маленькая аватарка пользователя в правом нижнем углу */
.notification-avatar-small {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--bg-content-main);
    object-fit: cover;
    background: var(--ui-surface-1);
    box-sizing: border-box;
}

/* Маленький плейсхолдер */
.notification-avatar-small-placeholder {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--bg-content-main);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-2xs);
    font-weight: 600;
    line-height: 1;
    color: var(--font-secondary);
    background: var(--ui-surface-1);
    box-shadow: inset 0 0 0 1px var(--ui-border);
}

/* Маленькая аватарка для иконки */
.notification-icon-user-avatar {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--bg-content-main);
    object-fit: cover;
    background: var(--bg-content-secondary);
}

/* Fallback иконка (если нет аватарок) */
.notification-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    background: var(--bg-content-secondary);
    position: relative;
}

.notification-icon i {
    color: var(--font-secondary);
}

/* Контент уведомления */
.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-message {
    font-size: 14px;
    color: var(--font-primary);
    line-height: 1.4;
    margin: 0 0 4px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-time {
    font-size: var(--font-size-sm);
    color: var(--font-secondary);
}

/* Индикатор непрочитанного */
.notification-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-link);
    flex-shrink: 0;
    margin-top: 6px;
}

/* Кнопка удаления уведомления */
.notification-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--font-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
    font-size: 12px;
}

.notification-item {
    position: relative;
}

.notification-item:hover .notification-delete-btn {
    opacity: 1;
}

.notification-delete-btn:hover {
    background: var(--ui-danger-soft);
    color: var(--danger-color);
}

/* Скрываем точку непрочитанного когда есть кнопка удаления */
.notification-item:hover .notification-unread-dot {
    opacity: 0;
}

/* Пустое состояние */
.notifications-empty {
    padding: 60px 20px;
    text-align: center;
}

.notifications-empty-icon {
    font-size: 48px;
    color: var(--font-secondary);
    opacity: 0.3;
    margin-bottom: 16px;
}

.notifications-empty-text {
    font-size: 14px;
    color: var(--font-secondary);
    margin: 0;
}

/* Футер с кнопкой "показать все" */
.notifications-footer {
    padding: var(--spacing-3sm) var(--spacing-mdl);
    border-top: 1px solid var(--ui-border);
    text-align: center;
}

.notifications-show-all {
    font-size: 14px;
    color: var(--accent-link);
    text-decoration: none;
    font-weight: 600;
}

.notifications-show-all:hover {
    text-decoration: underline;
}

/* Скелетон загрузки (список уведомлений) */
.notifications-skeleton {
    display: flex;
    flex-direction: column;
}

.notifications-skeleton-row {
    display: flex;
    gap: var(--spacing-3sm);
    align-items: flex-start;
    padding: var(--spacing-md) var(--spacing-mdl);
    border-bottom: 1px solid var(--ui-border);
}

.notifications-skeleton-row:last-child {
    border-bottom: none;
}

.notifications-skeleton-row__content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    padding-top: 2px;
}

/* ============================================================================
   АДАПТИВНОСТЬ — тот же узел .notifications-dropdown.show, оверлей как gc-modal
   ============================================================================ */

@media (max-width: 767.98px) {
    /* Как .gc-modal: верхний inset (modal.css — .modal-dialog padding-top) + нижний sheet */
    .notifications-dropdown {
        position: fixed !important;
        top: calc(0px - env(safe-area-inset-top, 0px)) !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: calc(100dvh + env(safe-area-inset-top, 0px)) !important;
        min-height: calc(100dvh + env(safe-area-inset-top, 0px)) !important;
        margin-top: 0 !important;
        max-height: none !important;
        z-index: var(--z-notification);
        overflow: hidden !important;
        box-sizing: border-box;
        padding-top: calc(env(safe-area-inset-top, 0px) + var(--spacing-md));
    }

    .notifications-dropdown.show {
        display: flex !important;
        flex-direction: column;
        background-color: rgba(0, 0, 0, 0.5);
    }

    [data-theme='light'] .notifications-dropdown.show {
        background-color: rgba(0, 0, 0, 0.4);
    }

    .notifications-dropdown-backdrop {
        display: block;
        position: relative;
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        border: none;
        border-radius: 0;
        cursor: pointer;
        -webkit-appearance: none;
        appearance: none;
        background-color: transparent;
        z-index: 0;
        pointer-events: auto;
    }

    .notifications-dropdown-panel {
        position: relative;
        flex: 0 0 auto;
        z-index: 1;
        width: 100%;
        max-width: 100%;
        max-height: calc(
            100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - var(--spacing-md)
        );
        min-height: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        border: none;
        border-top: 1px solid var(--ui-border);
        box-shadow: var(--shadow-xl);
        animation: notifications-mobile-sheet-in var(--transition-base) ease-out;
    }

    .notifications-header {
        padding: var(--spacing-md);
        flex-shrink: 0;
    }

    .notifications-list {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        max-height: none;
        -webkit-overflow-scrolling: touch;
    }

    .notification-item {
        padding: var(--spacing-md) var(--spacing-md);
    }

    /* Кнопка закрытия на мобильном */
    .notifications-close-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        background: var(--bg-content-secondary);
        border: none;
        border-radius: 50%;
        color: var(--font-primary);
        cursor: pointer;
    }
}

@keyframes notifications-mobile-sheet-in {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@media (min-width: 768px) {
    .notifications-close-mobile {
        display: none;
    }
}

/* ============================================================================
   СТРАНИЦА ВСЕХ УВЕДОМЛЕНИЙ
   ============================================================================ */

.notifications-page {
    max-width: 640px;
    margin: 0 auto;
}

.notifications-page .notification-item {
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    border: 1px solid var(--ui-border);
}

.notifications-page .notification-item:last-child {
    border-bottom: 1px solid var(--ui-border);
}

/* Группы по дате */
.notifications-date-group {
    margin-bottom: 24px;
}

.notifications-date-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--font-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-left: 4px;
}

