/* === БАЗОВЫЙ СБРОС === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* === КОНТЕЙНЕР === */
#notifications-container {
    position: fixed;
    top: 60px;
    right: 20px;
    width: 260px;
    max-height: calc(100dvh - 80px);
    overflow: auto auto; /* исправлено: было auto hidden */
    z-index: 9999;
    padding: 0 5px;
    background: #fff;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    -webkit-overflow-scrolling: touch;
    transition: opacity 0.3s, transform 0.2s;
    /* скрыт по умолчанию */
    opacity: 0;
    pointer-events: none;
    transform: translateY(-5px);
}

    /* Показываем, если есть хотя бы 1 уведомление */
    #notifications-container:not(:empty) {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

    /* fallback (если :empty не срабатывает из-за \n или пробелов) */
    #notifications-container.has-notifications {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

/* === ПУСТОЕ УВЕДОМЛЕНИЕ === */
.notification-empty {
    padding: 10px;
    color: #888;
    text-align: center;
    font-style: italic;
}

/* === УВЕДОМЛЕНИЕ === */
.notification {
    position: relative;
    padding: 8px 36px 8px 8px; /* ↓ ещё компактнее */
    margin: 6px 0; /* ↓ меньше отступ */
    border: 1px solid #ccc;
    border-radius: 5px;
    background: #fff;
    color: #333;
    cursor: pointer;
    user-select: none;
    word-break: break-word;
    transition: background-color 0.2s, border-color 0.2s;
}

    .notification:hover {
        background-color: #f5f5f5;
        border-color: #aaa;
    }

/* === КНОПКА ЗАКРЫТИЯ === */
.notif-close {
    position: absolute;
    top: 5px;
    right: 8px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    user-select: none;
    background: var(--btn-bg);
    color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    transition: background-color 0.2s, color 0.2s;
    outline: none;
}

    .notif-close:hover,
    .notif-close:focus {
        background-color: var(--border-color);
        color: var(--btn-color-hover);
    }

/* === ЗАГОЛОВОК === */
.notif-header {
    font: 700 0.9em/1.3 sans-serif; /* ↓ чуть меньше */
    margin-bottom: 3px;
    padding-right: 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #000;
}

.sender-name {
    font-weight: 700;
    flex-shrink: 0;
}

.message-count {
    font-weight: 400;
    margin-left: 5px;
    color: var(--border-color);
    font-size: 0.88em;
}

/* === ТЕЛО === */
.notif-body {
    font: italic 0.83em sans-serif; /* ↓ компактнее */
    color: var(--border-color);
    opacity: 0.9;
    padding-left: 5px; /* ↓ меньше отступ */
    border-left: 2px solid #ddd;
    margin-bottom: 5px;
    white-space: pre-wrap;
    max-height: 5.5em;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === ОТВЕТ ФОРМОЙ === */
.notification form {
    display: flex;
    gap: 3px; /* ↓ меньше промежуток */
    margin-top: 5px; /* ↓ меньше отступ */
    min-width: 0;
}

.notification input {
    flex: 1;
    padding: 3px 6px; /* ↓ компактнее */
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    color: #333;
    font-size: 0.87em;
}

    .notification input:focus {
        border-color: var(--btn-color-hover);
        outline: none;
    }

.notification button {
    padding: 3px 10px; /* ↓ компактнее */
    border: none;
    border-radius: 3px;
    background: var(--btn-bg);
    color: #fff;
    font-size: 0.87em;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.3s;
}

    .notification button:hover,
    .notification button:focus {
        background-color: var(--btn-color-hover);
        box-shadow: 0 0 6px rgba(0, 86, 179, 0.4);
        outline: none;
    }

/* === АДАПТИВ === */
@media (max-width: 768px) {
    #notifications-container {
        top: 80px; /* ← ещё ниже! (было 60px → теперь 80px) */
        right: 10px; /* чуть ближе к краю */
        width: 200px; /* ↓ ещё компактнее */
        max-height: 45vh; /* чуть меньше */
        padding: 4px 5px; /* ↓ меньше padding */
        z-index: 9999; /* исправлено: было auto */
    }

    .notification {
        padding: 7px 32px 7px 7px; /* ↓ ещё компактнее */
        margin: 4px 0;
        font-size: 0.88em;
    }

    .notif-close {
        top: 4px;
        right: 6px;
        width: 16px;
        height: 16px;
        font-size: 12px;
    }

    .notif-header {
        font-size: 0.86em;
        padding-right: 26px;
        margin-bottom: 2px;
    }

    .notif-body {
        font-size: 0.8em;
        padding-left: 4px;
        margin-bottom: 4px;
        max-height: 5em;
    }

    .notification form {
        gap: 2px;
        margin-top: 4px;
    }

    .notification input,
    .notification button {
        font-size: 0.80em;
        padding: 2px 5px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    #notifications-container {
        top: 55px;
        right: 16px;
        width: 230px;
        max-height: 55vh;
    }

    .notification {
        padding: 8px 38px 8px 8px;
    }
}
