/* ==========================================================================
   AI CHAT WIDGET STYLESHEET - KHUNG TƯ VẤN VIÊN AI TỰ ĐỘNG FPT TELECOM
   ==========================================================================
   MỤC LỤC / TABLE OF CONTENTS:
   01. FLOATING CHAT BUTTON    - Nút tròn nổi ở góc màn hình & nhãn gợi mở trên PC
   02. CHAT WINDOW & HEADER    - Khung hội thoại rộng rãi (460px trên PC), gradient cam
   03. MESSAGE BODY & BUBBLES  - Bong bóng tin nhắn AI và người dùng, nút CTA
   04. QUICK SUGGESTIONS       - Gợi ý câu hỏi nhanh dạng chip bấm tiện lợi
   05. INPUT BAR & CONTROLS    - Thanh nhập câu hỏi bo tròn & nút gửi tin nhắn
   06. RESPONSIVE BREAKPOINTS  - Tablet & mobile tự động co giãn vừa vặn
   ========================================================================== */

/* 01. FLOATING CHAT LAUNCHER BUTTON */
.ai-chat-button {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #f37021 0%, #ff7a18 50%, #ff953f 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(243, 112, 33, 0.42);
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: chatPulse 2.4s infinite;
}

.ai-chat-button:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 14px 36px rgba(243, 112, 33, 0.58);
}

.ai-chat-button svg {
    width: 28px;
    height: 28px;
    stroke: #ffffff;
    transition: transform 0.2s ease;
}

.ai-chat-button:hover svg {
    transform: scale(1.05);
}

@keyframes chatPulse {
    0%, 100% {
        box-shadow: 0 10px 28px rgba(243, 112, 33, 0.42), 0 0 0 0 rgba(243, 112, 33, 0.65);
    }
    50% {
        box-shadow: 0 10px 28px rgba(243, 112, 33, 0.42), 0 0 0 14px rgba(243, 112, 33, 0);
    }
}

/* 02. CHAT WINDOW CONTAINER (RỘNG RÃI & SANG TRỌNG TRÊN PC) */
.ai-chat-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 460px;
    max-width: calc(100vw - 40px);
    height: 630px;
    max-height: calc(100vh - 120px);
    min-height: 480px;
    background: #ffffff;
    border-radius: 22px;
    box-shadow: 0 24px 70px -10px rgba(15, 23, 42, 0.28), 0 10px 28px -4px rgba(243, 112, 33, 0.16);
    border: 1px solid rgba(243, 112, 33, 0.18);
    display: none;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    animation: chatSlideIn 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

.ai-chat-window.active {
    display: flex;
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(22px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 03. CHAT HEADER */
.ai-chat-header {
    background: linear-gradient(135deg, #f37021 0%, #fa711f 52%, #ff8c42 100%);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 4px 16px rgba(243, 112, 33, 0.22);
}

.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ai-chat-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.22);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ai-chat-avatar svg {
    width: 22px;
    height: 22px;
    stroke: #ffffff;
}

.ai-chat-title {
    font-weight: 800;
    font-size: 15.5px;
    letter-spacing: -0.2px;
    color: #ffffff;
    line-height: 1.25;
}

.ai-chat-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.92);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
}

.ai-chat-status::before {
    content: "";
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 10px #4ade80;
    display: inline-block;
    flex-shrink: 0;
    animation: statusGlow 2s infinite ease-in-out;
}

@keyframes statusGlow {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.75; }
}

.ai-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: rotate(90deg) scale(1.05);
}

/* 04. CHAT BODY */
.ai-chat-body {
    flex: 1;
    padding: 18px 20px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

.ai-chat-body::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-body::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 999px;
}

/* MESSAGE BUBBLES */
.ai-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    box-sizing: border-box;
}

.ai-msg-bot {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.04);
}

.ai-msg-bot a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #f37021, #ff8c42);
    color: #ffffff !important;
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(243, 112, 33, 0.32);
    transition: all 0.2s ease;
}

.ai-msg-bot a:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(243, 112, 33, 0.48);
    color: #ffffff !important;
}

.ai-msg-user {
    background: linear-gradient(135deg, #f37021, #ff8038);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
    box-shadow: 0 4px 14px rgba(243, 112, 33, 0.28);
}

/* TYPING INDICATOR */
.ai-msg-loading {
    align-self: flex-start;
    background: #ffffff;
    padding: 12px 18px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.04);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

.ai-msg-loading span {
    width: 7px;
    height: 7px;
    background: #f37021;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.ai-msg-loading span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-msg-loading span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* 05. INPUT BAR & CONTROLS */
.ai-chat-footer {
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 10px;
    align-items: center;
}

.ai-chat-footer input {
    flex: 1;
    padding: 12px 18px;
    border: 1.5px solid #e2e8f0;
    border-radius: 25px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    background: #f8fafc;
    transition: all 0.2s ease;
    color: #1e293b;
}

.ai-chat-footer input:focus {
    border-color: #f37021;
    background: #ffffff;
    box-shadow: 0 0 0 3.5px rgba(243, 112, 33, 0.12);
}

.ai-chat-footer input::placeholder {
    color: #94a3b8;
}

.ai-chat-footer button {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #f37021, #ff8c42);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(243, 112, 33, 0.35);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-chat-footer button:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 18px rgba(243, 112, 33, 0.5);
}

.ai-chat-footer button svg {
    width: 19px;
    height: 19px;
    stroke: #ffffff;
}

/* 06. RESPONSIVE BREAKPOINTS */
@media (max-width: 768px) {
    .ai-chat-window {
        width: min(420px, calc(100vw - 32px));
        right: 16px;
        bottom: 88px;
        height: min(580px, calc(100vh - 110px));
        height: min(580px, calc(100dvh - 110px));
        max-height: calc(100dvh - 110px);
        min-height: 0;
    }
}

@media (max-width: 640px) {
    .ai-chat-button {
        width: 52px;
        height: 52px;
        bottom: max(16px, env(safe-area-inset-bottom, 16px));
        right: 16px;
        box-shadow: 0 6px 18px rgba(243, 112, 33, 0.42);
    }
    .ai-chat-button svg {
        width: 24px;
        height: 24px;
    }
    body:has(.ai-chat-window.active) .ai-chat-button,
    body.ai-chat-open .ai-chat-button {
        opacity: 0;
        pointer-events: none;
        visibility: hidden;
    }
    .ai-chat-window {
        left: 8px;
        right: 8px;
        bottom: max(8px, env(safe-area-inset-bottom, 8px));
        width: auto;
        max-width: none;
        height: calc(var(--ai-vvh, 100dvh) - 72px);
        max-height: calc(var(--ai-vvh, 100dvh) - 72px);
        min-height: 0;
        border-radius: 20px;
        z-index: 10005;
    }
    .ai-chat-header {
        padding: 12px 16px;
        flex-shrink: 0;
    }
    .ai-chat-avatar {
        width: 38px;
        height: 38px;
    }
    .ai-chat-title {
        font-size: 14.5px;
    }
    .ai-chat-close {
        width: 38px;
        height: 38px;
        font-size: 22px;
        flex-shrink: 0;
    }
    .ai-chat-body {
        padding: 14px;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .ai-msg {
        max-width: 90%;
        font-size: 14px;
    }
    .ai-chat-footer {
        padding: 10px 12px max(10px, env(safe-area-inset-bottom, 10px));
        flex-shrink: 0;
    }
    .ai-chat-footer input {
        font-size: 16px;
        min-height: 44px;
        padding: 10px 16px;
        box-sizing: border-box;
    }
}

@media (max-height: 540px) {
    .ai-chat-window {
        bottom: 8px;
        height: calc(var(--ai-vvh, 100dvh) - 16px);
        max-height: calc(var(--ai-vvh, 100dvh) - 16px);
        min-height: 0;
    }
}