/* ========================================
   Chat Widget Styles - VNPAY
   ======================================== */

/* Chat Button (Floating) */
.chat-widget-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #005BAA 0%, #004a8f 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 91, 170, 0.4);
    transition: all 0.3s ease;
    z-index: 9999;
    border: none;
}

.chat-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(0, 91, 170, 0.5);
}

.chat-widget-btn svg {
    width: 30px;
    height: 30px;
    fill: #ffffff;
    transition: all 0.3s ease;
}

.chat-widget-btn .chat-icon-close {
    display: none;
}

/* Active state - show close icon */
.chat-widget-btn.active .chat-icon-open {
    display: none;
}

.chat-widget-btn.active .chat-icon-close {
    display: block;
}

/* Chat Container */
.chat-widget {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 380px;
    max-width: calc(100vw - 60px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.3s ease;
}

.chat-widget.open {
    display: flex;
}

@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #005BAA 0%, #004a8f 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.chat-header-avatar {
    width: 42px;
    height: 42px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background-image: url('https://stcd02206177151.cloud.edgevnpay.vn/assets/images/logo-icon/logo-primary.svg');
    background-size: 28px;
    background-repeat: no-repeat;
    background-position: center;
    overflow: hidden;
}

.chat-header-avatar img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.chat-header-info {
    flex: 1;
}

.chat-header-title {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 2px;
}

.chat-header-status {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-header-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chat-header-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-header-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-header-close svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8fafc;
}

.chat-message {
    display: flex;
    gap: 10px;
    animation: messageFadeIn 0.3s ease;
}

@keyframes messageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.bot {
    align-self: flex-start;
}

.chat-message.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-message.bot .chat-message-avatar {
    background: linear-gradient(135deg, #005BAA 0%, #004a8f 100%);
}

.chat-message.user .chat-message-avatar {
    background: #f5a623;
}

.chat-message-avatar svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

.chat-message-content {
    max-width: 75%;
}

.chat-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.9375rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.bot .chat-message-bubble {
    background: #ffffff;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-message.user .chat-message-bubble {
    background: linear-gradient(135deg, #005BAA 0%, #004a8f 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.chat-message-time {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-top: 4px;
}

.chat-message.user .chat-message-time {
    text-align: right;
}

/* Quick Reply Buttons */
.chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.chat-quick-reply {
    padding: 8px 14px;
    background: #f0f9f4;
    border: 1px solid #d1fae5;
    border-radius: 20px;
    font-size: 0.8125rem;
    color: #065f46;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-quick-reply:hover {
    background: #d1fae5;
    transform: translateY(-1px);
}

/* Chat Input */
.chat-input-area {
    padding: 16px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #f3f4f6;
    border-radius: 24px;
    padding: 8px 16px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.chat-input-wrapper:focus-within {
    border-color: #005BAA;
    background: #ffffff;
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.9375rem;
    color: #1f2937;
    padding: 8px 0;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
}

.chat-input:focus {
    outline: none;
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #005BAA 0%, #004a8f 100%);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.1);
    background: linear-gradient(135deg, #004a8f 0%, #003d73 100%);
}

.chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

/* Typing Indicator */
.chat-typing {
    display: none;
    align-self: flex-start;
    gap: 10px;
    animation: messageFadeIn 0.3s ease;
}

.chat-typing.show {
    display: flex;
}

.chat-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.chat-typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.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);
    }
}

/* Notification Badge */
.chat-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 22px;
    height: 22px;
    background: #e74c3c;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
}

.chat-notification.show {
    display: flex;
}

/* Mobile Responsive - Tablet */
@media (max-width: 768px) {
    .chat-widget-btn {
        bottom: 24px;
        right: 24px;
        width: 58px;
        height: 58px;
    }

    .chat-widget {
        bottom: 100px;
        right: 24px;
        left: 24px;
        width: auto;
        max-width: 400px;
        margin: 0 auto;
        height: calc(100vh - 140px);
    }
}

/* Mobile Responsive - Phone */
@media (max-width: 480px) {
    .chat-widget-btn {
        bottom: calc(20px + env(safe-area-inset-bottom, 0));
        right: calc(16px + env(safe-area-inset-right, 0));
        width: 56px;
        height: 56px;
    }

    .chat-widget-btn svg {
        width: 26px;
        height: 26px;
    }

    .chat-widget {
        bottom: calc(88px + env(safe-area-inset-bottom, 0));
        right: 16px;
        left: 16px;
        width: calc(100vw - 32px);
        max-width: none;
        height: calc(100vh - 120px);
        border-radius: 16px;
    }

    .chat-header {
        padding: 14px 16px;
    }

    .chat-header-avatar {
        width: 38px;
        height: 38px;
        background-size: 24px;
    }

    .chat-header-avatar img {
        width: 24px;
        height: 24px;
    }

    .chat-header-title {
        font-size: 0.9375rem;
    }

    .chat-messages {
        padding: 16px;
        gap: 12px;
    }

    .chat-message-content {
        max-width: 85%;
    }

    .chat-message-bubble {
        padding: 12px 14px;
        font-size: 0.9375rem;
    }

    .chat-input-area {
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
    }

    .chat-input-wrapper {
        padding: 10px 14px;
    }

    .chat-send-btn {
        width: 40px;
        height: 40px;
    }

    .chat-quick-reply {
        padding: 10px 16px;
        min-height: 44px;
    }
}

/* Màn hình rất nhỏ */
@media (max-width: 375px) {
    .chat-widget-btn {
        right: 12px;
    }

    .chat-widget {
        left: 12px;
        right: 12px;
        width: calc(100vw - 24px);
    }
}
