﻿/* открыть/закрыть чат */
@supports not (height: 100dvh) {
    .chat-modal {
        height: 100vh;
        max-height: 100vh;
    }
}

.chat-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color, #F2E15F);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(242, 225, 95, 0.4);
    transition: all 0.3s ease;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

    .chat-toggle-btn:hover {
        transform: scale(1.1);
        box-shadow: 0 6px 30px rgba(242, 225, 95, 0.6);
    }

    .chat-toggle-btn.active {
        background: var(--dark-bg, #0D0D0D);
        border: 2px solid var(--primary-color, #F2E15F);
    }

.chat-icon-default {
    font-size: 28px;
    color: #0D0D0D;
}

.chat-toggle-btn.active .chat-icon-default {
    display: none;
}

.chat-toggle-btn.active .chat-icon-close {
    display: block !important;
    color: var(--primary-color, #F2E15F);
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #EF4444;
    color: white;
    font-size: 12px;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* модалка */
.chat-modal {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 140px);
    background: var(--darker-bg, #0A0A0A);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: none;
    overflow: hidden;
    animation: chatSlideIn 0.3s ease;
}

    .chat-modal.open {
        display: flex;
        flex-direction: column;
    }

.chat-modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* хеадер */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1A1A1A 0%, #0D0D0D 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-icon {
    font-size: 24px;
    color: var(--primary-color, #F2E15F);
}

.chat-header-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 18px;
    color: var(--text-light, #FFFFFF);
    letter-spacing: 1px;
}

.chat-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted, #B0B0B0);
    font-family: 'Inter', sans-serif;
}

.status-dot-online {
    width: 8px;
    height: 8px;
    background: #22C55E;
    border-radius: 50%;
    box-shadow: 0 0 8px #22C55E;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.chat-close-btn {
    background: none;
    border: none;
    color: var(--text-muted, #B0B0B0);
    cursor: pointer;
    font-size: 20px;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

    .chat-close-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        color: var(--text-light, #FFFFFF);
    }

/* сообщения */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--darker-bg, #0A0A0A);
    min-height: 0;
    max-height: calc(100% - 140px);
}

.chat-spacer {
    flex: 1;
    min-height: 20px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

    .chat-messages::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.2);
    }

.chat-welcome {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted, #B0B0B0);
    margin: auto 0;
}

    .chat-welcome i {
        font-size: 48px;
        color: var(--primary-color, #F2E15F);
        margin-bottom: 16px;
        display: block;
    }

    .chat-welcome p {
        font-family: 'Inter', sans-serif;
        font-size: 14px;
        line-height: 1.6;
        margin: 0;
    }

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-message.admin {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.chat-message.user .chat-message-bubble {
    background: var(--primary-color, #F2E15F);
    color: #0D0D0D;
    border-bottom-right-radius: 4px;
}

.chat-message.admin .chat-message-bubble {
    background: #1A1A1A;
    color: var(--text-light, #FFFFFF);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 4px;
}

.chat-message-time {
    font-size: 11px;
    color: var(--text-muted, #B0B0B0);
    margin-top: 4px;
    font-family: 'Inter', sans-serif;
}

.chat-message.admin-name {
    font-size: 11px;
    color: var(--primary-color, #F2E15F);
    margin-bottom: 4px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
}

.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #1A1A1A;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    align-self: flex-start;
}

.chat-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted, #B0B0B0);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

    .chat-typing-dot:nth-child(2) {
        animation-delay: 0.2s;
    }

    .chat-typing-dot:nth-child(3) {
        animation-delay: 0.4s;
    }

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

/* поле ввода */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 16px;
    background: #1A1A1A;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: var(--darker-bg, #0A0A0A);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 12px 16px;
    color: var(--text-light, #FFFFFF);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    overflow-y: auto;
    outline: none;
    transition: border-color 0.3s ease;
    line-height: 1.4;
    word-wrap: break-word;
}

    .chat-input::-webkit-scrollbar {
        width: 4px;
    }

    .chat-input::-webkit-scrollbar-track {
        background: transparent;
    }

    .chat-input::-webkit-scrollbar-thumb {
        background: rgba(242, 225, 95, 0.3);
        border-radius: 2px;
    }

        .chat-input::-webkit-scrollbar-thumb:hover {
            background: rgba(242, 225, 95, 0.5);
        }

    .chat-input::placeholder {
        color: var(--text-muted, #B0B0B0);
    }

    .chat-input:focus {
        border-color: var(--primary-color, #F2E15F);
    }

    .chat-input:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color, #F2E15F);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    color: #0D0D0D;
    font-size: 18px;
}

    .chat-send-btn:hover:not(:disabled) {
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(242, 225, 95, 0.5);
    }

    .chat-send-btn:disabled {
        opacity: 0.3;
        cursor: not-allowed;
    }

    .chat-send-btn i {
        transform: translateY(2px);
    }

/* заглушка при закрытии чата (завершение сессии) */
.chat-status-bar.closed {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    margin: 16px 0;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    animation: closedFadeIn 0.4s ease;
}

    .chat-status-bar.closed i {
        font-size: 32px;
        color: #EF4444;
        flex-shrink: 0;
    }

.chat-closed-content {
    flex: 1;
}

    .chat-closed-content h4 {
        font-family: 'Bebas Neue', sans-serif;
        font-size: 18px;
        color: #FCA5A5;
        margin: 0 0 4px 0;
        letter-spacing: 1px;
    }

    .chat-closed-content p {
        font-family: 'Inter', sans-serif;
        font-size: 12px;
        color: #B0B0B0;
        margin: 0;
        line-height: 1.5;
    }

@keyframes closedFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* адаптация*/
@media (max-width: 480px) {
    .chat-toggle-btn {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .chat-modal {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100svh;
        max-height: 100svh;
        border-radius: 0;
        display: none;
    }

        .chat-modal.open {
            display: flex;
            flex-direction: column;
            animation: chatSlideInMobile 0.3s ease;
        }

    .chat-modal-content {
        display: flex;
        flex-direction: column;
        height: 100%;
        width: 100%;
    }

    .chat-header {
        flex-shrink: 0;
    }

    .chat-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 20px;
        display: flex;
        flex-direction: column;
        gap: 12px;
        background: var(--darker-bg, #0A0A0A);
        min-height: 0;
        max-height: calc(100svh - 140px);
    }

    .chat-input-area {
        flex-shrink: 0;
    }

    @keyframes chatSlideInMobile {
        from {
            opacity: 0;
            transform: translateY(100%);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

@media (max-width: 350px) {
    .chat-header-status {
        font-size: 9.5px;
    }
}

@media (max-width: 480px) {
    .chat-status-bar.closed {
        flex-direction: column;
        text-align: center;
        gap: 12px;
        padding: 16px;
    }

    .chat-closed-content p {
        font-size: 14px;
    }
}

@media (max-width: 420px) {
    .chat-closed-content p {
        font-size: 12px;
    }
}

@media (max-width: 360px) {
    .chat-closed-content p {
        font-size: 10px;
    }
}
