/* =============================================
   СИСТЕМА УВЕДОМЛЕНИЙ В РЕАЛЬНОМ ВРЕМЕНИ
   Стиль современных мессенджеров
   ============================================= */

/* Контейнер для toast-уведомлений */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: 400px;
    width: calc(100% - 40px);
}

/* Базовый toast */
.toast {
    background: white;
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    pointer-events: auto;
    cursor: pointer;
    animation: toastSlideIn 0.4s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
    border-left: 4px solid #007aff;
    transform: translateX(100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.toast.visible {
    transform: translateX(0);
    opacity: 1;
}

.toast.hiding {
    animation: toastSlideOut 0.3s ease forwards;
}

/* Анимации */
@keyframes toastSlideIn {
    from {
        transform: translateX(120%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(120%);
        opacity: 0;
    }
}

/* Иконка типа уведомления */
.toast-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-icon svg {
    width: 22px;
    height: 22px;
}

/* Типы уведомлений */
.toast.message {
    border-left-color: #007aff;
}

.toast.message .toast-icon {
    background: linear-gradient(135deg, #007aff 0%, #5856d6 100%);
    color: white;
}

.toast.order {
    border-left-color: #34c759;
}

.toast.order .toast-icon {
    background: linear-gradient(135deg, #34c759 0%, #30d158 100%);
    color: white;
}

.toast.warning {
    border-left-color: #ff9500;
}

.toast.warning .toast-icon {
    background: linear-gradient(135deg, #ff9500 0%, #ff8000 100%);
    color: white;
}

.toast.urgent {
    border-left-color: #ff3b30;
}

.toast.urgent .toast-icon {
    background: linear-gradient(135deg, #ff3b30 0%, #ff2d20 100%);
    color: white;
    animation: urgentPulse 1.5s ease-in-out infinite;
}

@keyframes urgentPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.toast.system .toast-icon {
    background: linear-gradient(135deg, #86868b 0%, #6e6e73 100%);
    color: white;
}

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

.toast-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.toast-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1d1d1f;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toast-time {
    font-size: 0.75rem;
    color: #86868b;
    flex-shrink: 0;
    margin-left: 8px;
}

.toast-message {
    font-size: 0.875rem;
    color: #6e6e73;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Кнопка закрытия */
.toast-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #86868b;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    margin: -4px -8px -4px 0;
}

.toast-close:hover {
    background: #f5f5f7;
    color: #1d1d1f;
}

.toast-close svg {
    width: 16px;
    height: 16px;
}

/* Прогресс-бар автозакрытия */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 4px;
    right: 0;
    height: 3px;
    background: rgba(0, 122, 255, 0.2);
    border-radius: 0 0 16px 12px;
    overflow: hidden;
}

.toast-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #007aff, #5856d6);
    border-radius: inherit;
    animation: progressShrink var(--toast-duration, 5s) linear forwards;
}

@keyframes progressShrink {
    from { width: 100%; }
    to { width: 0%; }
}

/* Наведение останавливает прогресс */
.toast:hover .toast-progress-bar {
    animation-play-state: paused;
}

/* Аватар отправителя (для сообщений) */
.toast-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.toast-avatar.manager {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

/* Индикатор непрочитанных в навигации */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: linear-gradient(135deg, #ff3b30, #ff2d20);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(255, 59, 48, 0.4);
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.notification-badge:empty,
.notification-badge[data-count="0"] {
    display: none;
}

/* Пульсирующая точка для индикации активности */
.notification-dot {
    width: 10px;
    height: 10px;
    background: #34c759;
    border-radius: 50%;
    position: relative;
}

.notification-dot::before {
    content: '';
    position: absolute;
    inset: -3px;
    background: rgba(52, 199, 89, 0.3);
    border-radius: 50%;
    animation: dotPulse 2s ease-out infinite;
}

@keyframes dotPulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(2); opacity: 0; }
}

/* Кнопка разрешения уведомлений браузера */
.notification-permission-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #007aff 0%, #5856d6 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(0, 122, 255, 0.25);
}

.notification-permission-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 122, 255, 0.35);
}

.notification-permission-btn svg {
    width: 18px;
    height: 18px;
}

/* Звук уведомления (невидимый элемент) */
.notification-sound {
    display: none;
}

/* Адаптивность */
@media (max-width: 480px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
    }
    
    .toast {
        padding: 14px 16px;
        border-radius: 14px;
    }
    
    .toast-icon,
    .toast-avatar {
        width: 40px;
        height: 40px;
    }
    
    .toast-icon svg {
        width: 20px;
        height: 20px;
    }
    
    .toast-title {
        font-size: 0.9rem;
    }
    
    .toast-message {
        font-size: 0.8rem;
    }
}

/* Темная тема (опционально) */
@media (prefers-color-scheme: dark) {
    .toast {
        background: rgba(44, 44, 46, 0.95);
        box-shadow: 
            0 8px 32px rgba(0, 0, 0, 0.3),
            0 2px 8px rgba(0, 0, 0, 0.2);
    }
    
    .toast-title {
        color: #ffffff;
    }
    
    .toast-message {
        color: #aeaeb2;
    }
    
    .toast-close:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #ffffff;
    }
}

/* Анимация появления бейджа при обновлении */
@keyframes badgeBounce {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(0.9); }
    75% { transform: scale(1.15); }
}

.notification-badge.updated {
    animation: badgeBounce 0.5s ease;
}

/* Стили для счетчика в меню */
.menu-badge-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: linear-gradient(135deg, #ff3b30, #ff2d20);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 9px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Стили для звукового индикатора */
.sound-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f5f5f7;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sound-toggle:hover {
    background: #e8e8ed;
}

.sound-toggle.muted {
    opacity: 0.6;
}

.sound-toggle svg {
    width: 18px;
    height: 18px;
    color: #86868b;
}

.sound-toggle.muted svg {
    color: #ff3b30;
}

