/* ═══════════════════════════════════════════════════════
   AI Чат-агент «Сильвер» — Стили виджета
   Silver Hotel — silverhotellaz.ru
   ═══════════════════════════════════════════════════════ */

/* --- Кнопка чата --- */
.silver-chat-btn {
    position: fixed;
    bottom: 84px;
    right: 32px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #14b8a6);
    color: white;
    border: none;
    cursor: pointer;
    z-index: 900;
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.silver-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.5);
}

.silver-chat-btn:active {
    transform: scale(0.95);
}

.silver-chat-btn svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: white;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Badge уведомления */
.silver-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid white;
    display: none;
    animation: silver-chat-pulse 2s infinite;
}

.silver-chat-badge.show {
    display: block;
}

@keyframes silver-chat-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Иконка закрытия когда чат открыт */
.silver-chat-btn .icon-close {
    display: none;
}

.silver-chat-btn.active .icon-chat {
    display: none;
}

.silver-chat-btn.active .icon-close {
    display: block;
}

/* --- Окно чата --- */
.silver-chat-window {
    position: fixed;
    bottom: 140px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 900;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.silver-chat-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* --- Шапка чата --- */
.silver-chat-header {
    background: linear-gradient(135deg, #0d9488, #0f766e);
    color: white;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.silver-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.silver-chat-header-info {
    flex: 1;
    min-width: 0;
}

.silver-chat-header-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}

.silver-chat-header-subtitle {
    font-size: 12px;
    opacity: 0.85;
    line-height: 1.2;
}

.silver-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.silver-chat-close:hover {
    opacity: 1;
}

/* --- Область сообщений --- */
.silver-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 320px;
    scroll-behavior: smooth;
}

/* Скроллбар */
.silver-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.silver-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.silver-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

/* --- Сообщения --- */
.silver-chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: silver-chat-fadeIn 0.3s ease;
}

@keyframes silver-chat-fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.silver-chat-msg.assistant {
    align-self: flex-start;
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.silver-chat-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.silver-chat-typing {
    align-self: flex-start;
    background: #f3f4f6;
    padding: 12px 18px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: none;
}

.silver-chat-typing.show {
    display: flex;
    gap: 4px;
    align-items: center;
}

.silver-chat-typing span {
    width: 7px;
    height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: silver-chat-dot 1.4s infinite ease-in-out;
}

.silver-chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.silver-chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes silver-chat-dot {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- Быстрые действия --- */
.silver-chat-quick-actions {
    padding: 8px 16px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
}

.silver-chat-quick-btn {
    background: #f0fdfa;
    color: #0d9488;
    border: 1px solid #99f6e4;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}

.silver-chat-quick-btn:hover {
    background: #ccfbf1;
    border-color: #5eead4;
}


/* --- Панель 'Написать менеджеру' (всегда видна) --- */
.silver-chat-human-bar {
    padding: 6px 16px;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
    text-align: center;
}
.silver-chat-human-btn {
    background: #faf5ff;
    border: 1px solid #c084fc;
    color: #7c3aed;
    border-radius: 20px;
    padding: 7px 18px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    width: 100%;
    font-weight: 500;
}
.silver-chat-human-btn:hover {
    background: #ede9fe;
    border-color: #a78bfa;
}

/* --- Ожидание менеджера (dots animation) --- */
.silver-chat-waiting .silver-chat-dots span {
    animation: silverDots 1.4s infinite;
    font-size: 20px;
    font-weight: bold;
}
.silver-chat-waiting .silver-chat-dots span:nth-child(2) { animation-delay: 0.2s; }
.silver-chat-waiting .silver-chat-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes silverDots {
    0%, 80%, 100% { opacity: 0; }
    40% { opacity: 1; }
}

/* --- Поле ввода --- */
.silver-chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    background: white;
}

.silver-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    max-height: 80px;
    min-height: 20px;
    line-height: 1.4;
    font-family: inherit;
    background: #f9fafb;
}

.silver-chat-input:focus {
    border-color: #14b8a6;
    background: white;
}

.silver-chat-input::placeholder {
    color: #9ca3af;
}

.silver-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.silver-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.4);
}

.silver-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.silver-chat-send svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: white;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Мобильная адаптация --- */
@media (max-width: 768px) {
    .silver-chat-btn {
        bottom: 70px !important;
        right: 30px !important;
        width: 42px;
        height: 42px;
    }

    .silver-chat-btn svg {
        width: 20px;
        height: 20px;
    }

    .silver-chat-window {
        width: calc(100vw - 16px);
        right: 8px;
        left: auto;
        bottom: 8px;
        max-height: calc(100vh - 80px);
        max-height: calc(100dvh - 80px);
        border-radius: 12px;
    }

    .silver-chat-messages {
        max-height: none;
        flex: 1;
    }

    .silver-chat-header {
        padding: 12px 14px;
    }

    .silver-chat-quick-btn {
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* --- Скрытие scrollToTop при открытом чате (кнопка чата теперь справа) --- */
body.silver-chat-open #scrollToTop {
    opacity: 0 !important;
    pointer-events: none !important;
}
