/* =========================================================
   KMVLN Tax Law Chatbot — Floating Widget Styles
   ========================================================= */

/* ---------- Floating Trigger Button ---------- */
.chatbot-trigger {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 9990;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a2b5f 0%, #2d4a8c 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(26, 43, 95, .35);
    transition: transform .3s ease, box-shadow .3s ease;
}

.chatbot-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(26, 43, 95, .5);
}

.chatbot-trigger i {
    font-size: 1.5rem;
    transition: transform .3s ease;
}

.chatbot-trigger.active i.fa-robot {
    display: none;
}

.chatbot-trigger:not(.active) i.fa-times {
    display: none;
}

/* Pulse ring */
.chatbot-trigger::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(26, 43, 95, .4);
    animation: chatPulse 2s ease-out infinite;
}

.chatbot-trigger.active::after {
    animation: none;
    opacity: 0;
}

@keyframes chatPulse {
    0% {
        transform: scale(1);
        opacity: .6;
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* Badge */
.chatbot-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #2e7d32;
    border-radius: 50%;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-badge::after {
    content: '';
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
}

/* ---------- Chat Window ---------- */
.chatbot-window {
    position: fixed;
    bottom: 170px;
    right: 24px;
    width: 400px;
    max-height: 560px;
    border-radius: 20px;
    background: #f8fafc;
    box-shadow: 0 20px 60px rgba(26, 43, 95, .25), 0 0 0 1px rgba(26, 43, 95, .08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9991;
    transform: translateY(20px) scale(.95);
    opacity: 0;
    visibility: hidden;
    transition: all .35s cubic-bezier(.4, 0, .2, 1);
}

.chatbot-window.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* ---------- Header ---------- */
.chatbot-header {
    background: linear-gradient(135deg, #1a2b5f 0%, #2d4a8c 100%);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chatbot-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.chatbot-header-info h4 {
    margin: 0;
    font-family: 'Inter', sans-serif;
    font-size: .95rem;
    font-weight: 600;
    color: #fff;
}

.chatbot-header-info span {
    font-size: .75rem;
    opacity: .8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-header-info span::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #4caf50;
    border-radius: 50%;
    display: inline-block;
}

/* ---------- Messages ---------- */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(26, 43, 95, .15);
    border-radius: 5px;
}

/* Message bubbles */
.chat-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: msgSlide .35s ease forwards;
}

.chat-msg.bot {
    align-self: flex-start;
}

.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

@keyframes msgSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: .75rem;
    margin-top: 2px;
}

.chat-msg.bot .chat-msg-icon {
    background: linear-gradient(135deg, #1a2b5f, #2d4a8c);
    color: #fff;
}

.chat-msg.user .chat-msg-icon {
    background: rgba(46, 125, 50, .1);
    color: #2e7d32;
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: .88rem;
    line-height: 1.55;
    white-space: pre-line;
    word-break: break-word;
}

.chat-msg.bot .chat-bubble {
    background: #fff;
    color: #1f2937;
    border: 1px solid rgba(26, 43, 95, .08);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(26, 43, 95, .06);
}

.chat-msg.user .chat-bubble {
    background: linear-gradient(135deg, #1a2b5f, #2d4a8c);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Source badges (AI / KB) */
.chat-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 6px;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.chat-source-badge.ai {
    background: rgba(21, 101, 192, .1);
    color: #1565c0;
    border: 1px solid rgba(21, 101, 192, .2);
}

.chat-source-badge.kb {
    background: rgba(46, 125, 50, .1);
    color: #2e7d32;
    border: 1px solid rgba(46, 125, 50, .2);
}

/* Section reference badge */
.chat-section-ref {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 10px;
    background: rgba(46, 125, 50, .08);
    color: #2e7d32;
    font-size: .73rem;
    font-weight: 600;
    border-radius: 20px;
    border: 1px solid rgba(46, 125, 50, .15);
}

/* ---------- Typing indicator ---------- */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px;
}

.chat-typing .dots {
    display: flex;
    gap: 4px;
}

.chat-typing .dots span {
    width: 7px;
    height: 7px;
    background: rgba(26, 43, 95, .3);
    border-radius: 50%;
    animation: typeDot 1.2s ease infinite;
}

.chat-typing .dots span:nth-child(2) {
    animation-delay: .15s;
}

.chat-typing .dots span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes typeDot {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: .4;
    }

    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* ---------- Topic pills ---------- */
.chat-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.chat-topic-pill {
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid rgba(26, 43, 95, .15);
    background: rgba(26, 43, 95, .04);
    font-size: .78rem;
    font-weight: 500;
    color: #1a2b5f;
    cursor: pointer;
    transition: all .2s ease;
    white-space: nowrap;
}

.chat-topic-pill:hover {
    background: #1a2b5f;
    color: #fff;
    border-color: #1a2b5f;
}

/* Suggested question links */
.chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.chat-suggestion-btn {
    text-align: left;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(26, 43, 95, .1);
    background: rgba(26, 43, 95, .03);
    font-size: .8rem;
    color: #1a2b5f;
    cursor: pointer;
    transition: all .2s ease;
    line-height: 1.3;
}

.chat-suggestion-btn:hover {
    background: rgba(26, 43, 95, .08);
    border-color: rgba(26, 43, 95, .2);
}

/* ---------- Input area ---------- */
.chatbot-input-area {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid rgba(26, 43, 95, .08);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.chatbot-input {
    flex: 1;
    border: 1px solid rgba(26, 43, 95, .12);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: .88rem;
    font-family: 'Inter', sans-serif;
    color: #1f2937;
    background: #f8fafc;
    outline: none;
    transition: border-color .2s;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
}

.chatbot-input:focus {
    border-color: #1a2b5f;
    background: #fff;
}

.chatbot-input::placeholder {
    color: #9ca3af;
}

.chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #1a2b5f, #2d4a8c);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, box-shadow .2s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(26, 43, 95, .3);
}

.chatbot-send i {
    font-size: .9rem;
}

/* ---------- CTA fallback ---------- */
.chat-cta-card {
    margin-top: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(46, 125, 50, .06), rgba(46, 125, 50, .12));
    border: 1px solid rgba(46, 125, 50, .2);
    border-radius: 12px;
    text-align: center;
}

.chat-cta-card p {
    font-size: .82rem;
    color: #374151;
    margin-bottom: 8px;
}

.chat-cta-card a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: linear-gradient(135deg, #2e7d32, #1b5e20);
    color: #fff;
    font-size: .8rem;
    font-weight: 600;
    border-radius: 20px;
    text-decoration: none;
    transition: transform .2s, box-shadow .2s;
}

.chat-cta-card a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(46, 125, 50, .3);
    color: #fff;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .chatbot-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }

    .chatbot-trigger {
        bottom: 20px;
        right: 16px;
        width: 54px;
        height: 54px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .chatbot-window {
        width: 360px;
        max-height: 500px;
    }
}