/* ========================================================
   K.C. IMPEX - BUILT-IN AI CHATBOT ASSISTANT
   ======================================================== */

:root {
    --ai-primary: #0b3a75;
    --ai-secondary: #0099ff;
    --ai-accent: #38bdf8;
    --ai-bg-dark: #07182e;
    --ai-card-bg: #ffffff;
    --ai-text-main: #0f172a;
    --ai-text-muted: #64748b;
    --ai-border: #e2e8f0;
}

/* 1. Floating AI Chat Toggle Button */
.floating-btn.floating-aichat {
    background: linear-gradient(135deg, #0b3a75 0%, #0099ff 100%);
    box-shadow: 0 6px 22px rgba(0, 153, 255, 0.45);
    position: relative;
    border: none;
    cursor: pointer;
}

.floating-btn.floating-aichat:hover {
    box-shadow: 0 8px 28px rgba(0, 153, 255, 0.7);
    transform: scale(1.12);
}

.floating-btn.floating-aichat .ai-badge-pulse {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #10b981;
    color: #ffffff;
    font-size: 0.62rem;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 8px;
    border: 2px solid #ffffff;
    letter-spacing: 0.5px;
    animation: aiPulse 2s infinite;
}

@keyframes aiPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.9; }
}

/* 2. Chat Widget Window Container */
.kci-ai-chat-window {
    position: fixed;
    bottom: 95px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(7, 24, 46, 0.28), 0 2px 10px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(11, 58, 117, 0.12);
}

.kci-ai-chat-window.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* 3. Chat Header */
.kci-chat-header {
    background: linear-gradient(135deg, #07182e 0%, #0b3a75 70%, #0077cc 100%);
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.kci-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.kci-chat-avatar-wrap {
    position: relative;
    width: 44px;
    height: 44px;
    background: #ffffff;
    border-radius: 50%;
    padding: 3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.kci-chat-avatar-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.kci-chat-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.kci-chat-title-group h3 {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.25;
}

.kci-chat-status {
    font-size: 0.74rem;
    color: #93c5fd;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.kci-chat-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.kci-chat-btn-action {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.2s ease;
}

.kci-chat-btn-action:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.08);
}

/* 4. Chat Messages Area */
.kci-chat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.kci-chat-body::-webkit-scrollbar {
    width: 5px;
}

.kci-chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Messages */
.kci-msg-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: msgFadeIn 0.25s ease-out;
}

@keyframes msgFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.kci-msg-row.bot {
    justify-content: flex-start;
}

.kci-msg-row.user {
    justify-content: flex-end;
}

.kci-msg-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.kci-msg-row.bot .kci-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 3px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.kci-msg-row.user .kci-msg-bubble {
    background: linear-gradient(135deg, #0b3a75 0%, #0084d6 100%);
    color: #ffffff;
    border-bottom-right-radius: 3px;
    box-shadow: 0 4px 12px rgba(0, 132, 214, 0.25);
}

.kci-msg-bubble p {
    margin: 0 0 6px 0;
}

.kci-msg-bubble p:last-child {
    margin-bottom: 0;
}

.kci-msg-bubble ul {
    margin: 6px 0 6px 18px;
    padding: 0;
}

.kci-msg-bubble li {
    margin-bottom: 4px;
}

.kci-msg-bubble strong {
    color: #0b3a75;
}

.kci-msg-row.user .kci-msg-bubble strong {
    color: #ffffff;
}

.kci-msg-bubble a {
    color: #0084d6;
    font-weight: 600;
    text-decoration: underline;
}

.kci-msg-time {
    font-size: 0.65rem;
    color: #94a3b8;
    margin-top: 4px;
    text-align: right;
    display: block;
}

.kci-msg-row.user .kci-msg-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Chat CTA Button in Bubble */
.kci-chat-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #25d366;
    color: #ffffff !important;
    text-decoration: none !important;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 7px 12px;
    border-radius: 20px;
    margin-top: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.35);
}

.kci-chat-cta-btn:hover {
    background: #1ebd5a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.5);
}

.kci-chat-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #0b3a75;
    color: #ffffff !important;
    text-decoration: none !important;
    font-size: 0.80rem;
    font-weight: 600;
    padding: 6px 11px;
    border-radius: 16px;
    margin-top: 6px;
    margin-right: 4px;
    transition: all 0.2s ease;
}

.kci-chat-link-btn:hover {
    background: #0099ff;
    transform: translateY(-1px);
}

/* Typing Indicator */
.kci-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    border-bottom-left-radius: 3px;
    width: fit-content;
}

.kci-typing-dot {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.kci-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.kci-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); background: #0084d6; }
}

/* 5. Quick Suggestion Chips */
.kci-chat-chips-wrap {
    padding: 8px 12px 6px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    max-height: 90px;
    overflow-y: auto;
}

.kci-chip-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #0b3a75;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 9px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.kci-chip-btn:hover {
    background: #0b3a75;
    color: #ffffff;
    border-color: #0b3a75;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(11, 58, 117, 0.2);
}

.kci-chip-btn i {
    font-size: 0.72rem;
    color: #0084d6;
    transition: color 0.2s ease;
}

.kci-chip-btn:hover i {
    color: #ffffff;
}

/* 6. Chat Input Area */
.kci-chat-footer {
    padding: 10px 14px 12px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kci-chat-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    border-radius: 22px;
    padding: 9px 16px;
    font-size: 0.88rem;
    color: #0f172a;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.kci-chat-input:focus {
    border-color: #0084d6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 132, 214, 0.12);
}

.kci-chat-send-btn {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #0b3a75 0%, #0084d6 100%);
    border: none;
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.kci-chat-send-btn:hover {
    background: #0099ff;
    transform: scale(1.08);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .kci-ai-chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .kci-chat-header {
        padding: 16px 14px;
    }
}
