/* payment/logic/static/css/chat.css */
#chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    top: auto !important;       /* Запрещаем смещение сверху */
    left: auto !important;      /* Запрещаем смещение слева */
    width: 350px;
    height: 500px;
    max-height: 80vh;
    max-width: 90vw;
    background: var(--color-surface);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.3s ease, transform 0.3s ease, width 0.1s linear; /* width без задержки для плавного ресайза */
}

#chat-container.minimized {
    height: 50px;
    transform: translateY(450px);
    transform-origin: bottom right;
}

.chat-header {
    background: var(--color-chat-accent);
    color: white;
    padding: 12px 15px 12px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.chat-title {
    font-weight: 600;
    font-size: 14.5px;
}

.chat-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

.chat-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--color-surface-alt);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chat-message.user {
    align-self: flex-start;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-bottom-left-radius: 4px;
}

.chat-message.system {
    align-self: center;
    background: var(--color-border);
    font-style: italic;
    font-size: 12px;
    max-width: 90%;
    box-shadow: none;
}

.chat-message.admin {
    align-self: flex-end;
    background: var(--color-chat-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message.admin .message-meta {
    color: rgba(255, 255, 255, 0.75);
}

.message-content {
    margin-bottom: 4px;
    font-size: 13px;
    line-height: 1.45;
    word-wrap: break-word;
}

.message-meta {
    font-size: 10.5px;
    color: var(--color-text-soft);
    text-align: right;
}

.chat-input-area {
    padding: 12px 15px;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-input-area textarea {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    resize: none;
    font-family: inherit;
    font-size: 13px;
    height: 40px;
    max-height: 100px;
    background: var(--color-surface-alt);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: var(--color-chat-accent);
    background: var(--color-surface);
}

.chat-send-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--color-chat-accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
}

.chat-send-btn svg {
    width: 17px;
    height: 17px;
}

.chat-send-btn:hover {
    background: var(--color-chat-accent-hover);
    transform: scale(1.06);
}

/* Скроллбар для чата */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--color-surface-alt);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-soft);
}

/* Кнопка открытия чата (для свернутого состояния) */
#chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--color-chat-accent);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 10001;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    animation: chat-pulse 2.5s ease-in-out infinite;
}

#chat-toggle-btn svg {
    width: 24px;
    height: 24px;
}

#chat-toggle-btn:hover {
    background: var(--color-chat-accent-hover);
    transform: scale(1.05);
    animation-play-state: paused;
}

#chat-toggle-btn.show {
    display: flex;
}

#chat-toggle-btn.hide {
    display: none;
}

@keyframes chat-pulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(224, 122, 89, 0.35);
    }
    50% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 9px rgba(224, 122, 89, 0);
    }
}

/* Всплывающая подсказка рядом с кнопкой чата */
.chat-greeting-bubble {
    position: fixed;
    bottom: 82px;
    right: 20px;
    max-width: 220px;
    background: var(--color-surface);
    color: var(--color-text);
    padding: 0.75rem 1.5rem 0.75rem 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-size: 0.85rem;
    line-height: 1.4;
    z-index: 10001;
    cursor: pointer;
    animation: chat-bubble-in 0.25s ease;
}

.chat-greeting-bubble p {
    margin: 0;
}

.chat-greeting-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 22px;
    width: 12px;
    height: 12px;
    background: var(--color-surface);
    transform: rotate(45deg);
}

.chat-greeting-close {
    position: absolute;
    top: 2px;
    right: 6px;
    background: none;
    border: none;
    color: var(--color-text-soft);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
}

.chat-greeting-close:hover {
    color: var(--color-text);
}

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

/* Адаптивность для мобильных */
@media (max-width: 480px) {
    #chat-container {
        width: 90%;
        right: 5%;
        bottom: 10px;
    }

    #chat-toggle-btn {
        bottom: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
    }

    .chat-message {
        max-width: 90%;
    }

    .chat-greeting-bubble {
        right: 15px;
        max-width: 180px;
    }
}

/* Уголок для изменения размера чата (в левом верхнем углу, не наезжает на заголовок) */
.chat-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    background: linear-gradient(315deg, transparent 50%, rgba(255, 255, 255, 0.5) 50%);
    z-index: 10;
    opacity: 0.6;
    transition: opacity 0.2s;
    border-top-left-radius: 12px;
}

.chat-resize-handle:hover {
    opacity: 1;
    background: linear-gradient(315deg, transparent 50%, rgba(255, 255, 255, 0.8) 50%);
}

/* Скрываем уголок при сворачивании */
#chat-container.minimized .chat-resize-handle {
    display: none;
}

/* Убираем фиксированную высоту при изменении размера */
#chat-container.resizing {
    transition: none;
}
