/* Improved Chatbot Design - Premium Glassmorphism & Floating UI */

:root {
    /* Core Colors */
    --primary-color: #2563eb;
    --primary-rgb: 37, 99, 235;
    --primary-dark: #1d4ed8;
    --primary-light: #60a5fa;

    /* Text Colors */
    --text-dark: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Backgrounds */
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.5);

    /* Message Colors */
    --bg-message-user: #2563eb;
    --bg-message-assistant: #ffffff;

    /* Borders & Shadows */
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --kkbac-mobile-safe-top: 12px;
}

/* Container */
.kkbac-chatbot {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ==================== TOGGLE BUTTON ==================== */
.kkbac-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000000;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.kkbac-toggle svg {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    fill: #ffffff !important;
    stroke: none !important;
    display: block !important;
    margin: auto !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.kkbac-toggle svg path {
    fill: #ffffff !important;
    fill-opacity: 1 !important;
}

.kkbac-toggle:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.kkbac-toggle:active {
    transform: scale(0.95);
}

/* ==================== CHAT WINDOW (Glassmorphism) ==================== */
.kkbac-window {
    position: fixed;
    top: auto;
    bottom: 100px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 24px;
    box-shadow:
        0 20px 40px -10px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset,
        0 0 0 1px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    z-index: 999999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

/* State: Open */
.kkbac-window:not([style*="display: none"]) {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
}

body.admin-bar .kkbac-window {
    top: 32px;
    bottom: 100px;
    height: calc(100vh - 132px);
    max-height: calc(100vh - 132px);
}



/* Additional mobile-specific hiding when window is visible */


@media (max-width: 1024px) {
    .kkbac-window {
        width: 400px;
        max-width: calc(100vw - 24px);
        top: 20px;
        bottom: 100px;
        height: calc(100vh - 120px);
        max-height: calc(100vh - 120px);
        border-radius: 10px;
    }

    body.admin-bar .kkbac-window {
        top: 32px;
        bottom: 100px;
        height: calc(100vh - 132px);
        max-height: calc(100vh - 132px);
    }
}



/* ==================== HEADER ==================== */
/* ==================== HEADER ==================== */
.kkbac-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 24px 28px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    flex-shrink: 0;
    border-bottom: none;
}

.kkbac-header-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    padding-right: 16px;
}

.kkbac-header-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: white !important;
    letter-spacing: -0.5px;
}

.kkbac-header-subtitle {
    margin: 4px 0 0 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
}

.kkbac-status-dot {
    width: 8px;
    height: 8px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25), 0 0 8px rgba(16, 185, 129, 0.4);
    }

    50% {
        opacity: 0.8;
        box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3), 0 0 12px rgba(16, 185, 129, 0.6);
    }
}

.kkbac-lang-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 20px;
    margin-right: 8px;
    transition: all 0.2s ease;
    z-index: 1000002;
    position: relative;
}

.kkbac-lang-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.kkbac-lang-toggle:active {
    transform: translateY(0);
}

.kkbac-lang-toggle svg {
    display: block;
}

.kkbac-close {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 300;
    line-height: 1;
    transition: all 0.2s ease;
}

.kkbac-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
    color: white;
}

.kkbac-close:active {
    transform: scale(0.98);
}

/* ==================== MESSAGES AREA ==================== */
.kkbac-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    background: transparent;
    min-height: 0;
    max-height: 100%;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    position: relative;
    gap: 20px;
    display: flex;
    flex-direction: column;
}

.kkbac-messages::-webkit-scrollbar {
    width: 10px;
}

.kkbac-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 5px;
    margin: 8px 0;
}

.kkbac-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #cbd5e0, #a0aec0);
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: all 0.2s ease;
}

.kkbac-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #a0aec0, #718096);
    background-clip: padding-box;
}

.kkbac-messages:hover::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #a0aec0, #718096);
    background-clip: padding-box;
}

#kkbac-chat-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ==================== MESSAGE BUBBLES ==================== */
.kkbac-message {
    margin-bottom: 24px;
    display: flex;
    gap: 0px;
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kkbac-message.user {
    justify-content: flex-end;
}

.kkbac-message.assistant {
    justify-content: flex-start;
}

.kkbac-message-avatar {
    display: none !important;
}

.kkbac-message.user .kkbac-message-avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    order: 2;
    margin-left: 8px;
}

.kkbac-message.assistant .kkbac-message-avatar {
    background: white;
    color: var(--primary-color);
    margin-right: 8px;
}

.kkbac-message-content {
    max-width: 82%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kkbac-message-bubble {
    padding: 14px 18px !important;
    border-radius: 18px !important;
    line-height: 1.6 !important;
    font-size: 15px !important;
    word-wrap: break-word !important;
    position: relative !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 !important;
    box-shadow: var(--shadow-sm) !important;
    transition: box-shadow 0.2s ease !important;
    border: none !important;
}

.kkbac-message.user .kkbac-message-bubble {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark)) !important;
    color: white !important;
    border: none !important;
    border-bottom-right-radius: 4px !important;
    box-shadow: var(--shadow-md) !important;
}

.kkbac-message.assistant .kkbac-message-bubble {
    background: white !important;
    color: var(--text-dark) !important;
    border: 1px solid rgba(226, 232, 240, 0.6) !important;
    border-bottom-left-radius: 4px !important;
    box-shadow: var(--shadow-sm) !important;
}

.kkbac-message.assistant .kkbac-message-bubble:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06) !important;
}

.kkbac-message-time {
    font-size: 11px !important;
    color: var(--text-muted) !important;
    padding: 2px 8px !important;
    font-weight: 500 !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-top: 6px !important;
    letter-spacing: 0.02em;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 6px;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.kkbac-message:hover .kkbac-message-time {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-secondary) !important;
}

.kkbac-message.user .kkbac-message-time {
    text-align: right !important;
}

.kkbac-message.assistant .kkbac-message-time {
    text-align: left !important;
}

.kkbac-message-bubble .kkbac-quick-buttons {
    display: flex;
    flex-direction: column;
    align-items: stretch; /* Stretch to fill width */
    gap: 8px;
    margin-top: 12px;
    width: 100%; /* Ensure container takes full width */
}

.kkbac-quick-button {
    border: 1px solid rgba(37, 99, 235, 0.15);
    background: #eff6ff;
    color: var(--primary-color);
    border-radius: 12px;
    padding: 12px 32px 12px 16px; /* Increased right padding permanently for arrow */
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease; /* Faster transition to feel snappier */
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.05);
    position: relative;
    overflow: hidden;
    display: flex; /* Flex for content alignment */
    align-items: center;
    justify-content: space-between; /* Space between text and arrow area */
    gap: 6px;
    line-height: 1.4;
    width: 100%; /* Full width */
    box-sizing: border-box; /* Include padding in width */
    text-align: left;
}

.kkbac-quick-button:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-color: transparent;
    transform: translateY(-1px); /* Reduced movement */
    box-shadow: 0 6px 12px rgba(37, 99, 235, 0.2), 0 2px 4px rgba(37, 99, 235, 0.1);
    /* padding-right NO LONGER CHANGES */
}

.kkbac-quick-button::after {
    content: '→';
    position: absolute;
    right: 8px;
    font-size: 14px;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.kkbac-quick-button:hover::after {
    opacity: 1;
    transform: translateX(0);
}

.kkbac-quick-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.kkbac-quick-button--used,
.kkbac-quick-button:disabled {
    cursor: default;
    background: var(--bg-light);
    border-color: var(--border-color);
    color: var(--text-muted);
    opacity: 0.6;
    transform: none;
    box-shadow: none;
    padding-right: 16px; /* Reset padding */
}

.kkbac-quick-button--used:hover::after,
.kkbac-quick-button:disabled:hover::after {
    opacity: 0;
}

/* ==================== TYPING INDICATOR ==================== */
.kkbac-typing {
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: fadeInUp 0.3s ease-out;
}

.kkbac-typing .kkbac-message-avatar {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
    border: 2px solid var(--border-color);
    flex-shrink: 0;
    font-size: 18px;
}

.kkbac-typing .kkbac-message-content {
    background: white;
    padding: 18px 22px;
    border-radius: 14px;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border-color);
    min-height: 52px;
}

.kkbac-typing-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--primary-color);
    opacity: 0.4;
    animation: typingDot 1.4s ease-in-out infinite;
}

.kkbac-typing-dot:nth-child(1) {
    animation-delay: 0s;
    opacity: 0.6;
}

.kkbac-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
    opacity: 0.5;
}

.kkbac-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
    opacity: 0.4;
}

@keyframes typingDot {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Thinking Indicator */
.kkbac-thinking-indicator {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
    border-radius: 14px;
    border-bottom-left-radius: 5px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
    animation: fadeInUp 0.3s ease-out;
    position: relative;
    overflow: hidden;
}

.kkbac-thinking-indicator::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(34, 113, 177, 0.05), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.kkbac-thinking-dots {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.kkbac-thinking-dots span {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--primary-color);
    opacity: 0.4;
    animation: thinkingDot 1.6s ease-in-out infinite;
}

.kkbac-thinking-dots span:nth-child(1) {
    animation-delay: 0s;
}

.kkbac-thinking-dots span:nth-child(2) {
    animation-delay: 0.3s;
}

.kkbac-thinking-dots span:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes thinkingDot {

    0%,
    60%,
    100% {
        transform: scale(1);
        opacity: 0.4;
    }

    30% {
        transform: scale(1.3);
        opacity: 1;
    }
}

/* ==================== INPUT AREA (Floating) ==================== */
/* Floating Capsule Design for Input */
.kkbac-input-area {
    display: flex;
    gap: 10px;
    padding: 16px 20px 24px;
    background: transparent;
    align-items: center;
    flex-shrink: 0;
    min-height: 0;
    position: relative;
    z-index: 10;
}

.kkbac-input-area input {
    flex: 1;
    height: 54px;
    padding: 0 24px;
    padding-right: 60px;
    border: none;
    border-radius: 27px;
    font-size: 15px;
    background: white;
    color: var(--text-dark);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    width: 100%;
}

.kkbac-input-area input:hover {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.kkbac-input-area input:focus {
    outline: none;
    background: white;
    box-shadow: 0 8px 30px rgba(34, 113, 177, 0.15), 0 2px 10px rgba(34, 113, 177, 0.08);
    transform: translateY(-2px);
}

.kkbac-input-area input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.kkbac-send {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* SVG is now inline in HTML */
    padding: 0;
}

.kkbac-send::before {
    display: none;
}

.kkbac-send:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.5);
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
}

.kkbac-send:active {
    transform: translateY(-50%) scale(0.95);
}

.kkbac-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ==================== PRE-CHAT FORM ==================== */
.kkbac-prechat {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 48px 32px;
    background: linear-gradient(135deg, #fafbfc 0%, var(--bg-light) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.kkbac-prechat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
}

.kkbac-prechat-content {
    max-width: 100%;
    width: 100%;
}

.kkbac-welcome-icon {
    font-size: 80px;
    text-align: center;
    margin-bottom: 24px;
    line-height: 1;
    display: block;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.08));
    animation: welcomeIcon 2s ease-in-out infinite;
}

@keyframes welcomeIcon {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-4px) scale(1.02);
    }
}

.kkbac-welcome-title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin: 0 0 12px 0;
    color: var(--text-dark);
    letter-spacing: -0.02em;
    line-height: 1.3;
    background: linear-gradient(135deg, var(--text-dark) 0%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.kkbac-welcome-subtitle {
    font-size: 15px;
    text-align: center;
    color: var(--text-secondary);
    margin: 0 0 40px 0;
    line-height: 1.7;
    font-weight: 400;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.kkbac-prechat-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-width: 100%;
    background: white;
    padding: 32px 28px;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
}

.kkbac-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kkbac-form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}

.kkbac-form-group input {
    padding: 15px 20px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    background: var(--bg-light);
    color: var(--text-dark);
    transition: all 0.25s ease;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.kkbac-form-group input:hover {
    border-color: rgba(34, 113, 177, 0.3);
    background: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.kkbac-form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 4px rgba(34, 113, 177, 0.12), 0 2px 8px rgba(34, 113, 177, 0.1);
    transform: translateY(-1px);
}

.kkbac-form-group input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.kkbac-btn-primary {
    padding: 17px 28px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    margin-top: 12px;
    box-shadow: 0 3px 12px rgba(34, 113, 177, 0.25), 0 1px 4px rgba(34, 113, 177, 0.15);
    transition: all 0.25s ease;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.kkbac-btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.kkbac-btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    box-shadow: 0 4px 16px rgba(34, 113, 177, 0.35), 0 2px 8px rgba(34, 113, 177, 0.2);
    transform: translateY(-2px);
}

.kkbac-btn-primary:hover::before {
    left: 100%;
}

.kkbac-btn-primary:active {
    background: var(--primary-dark);
    transform: translateY(0);
}

.kkbac-guest-controls {
    text-align: center;
    padding: 22px 26px;
    background: linear-gradient(to top, #ffffff 0%, #fafbfc 100%);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.04), 0 -2px 4px rgba(0, 0, 0, 0.02);
    position: relative;
}

.kkbac-guest-controls::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
}

.kkbac-guest-controls button {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 6px rgba(34, 113, 177, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
}

.kkbac-guest-controls button:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.25), 0 2px 6px rgba(34, 113, 177, 0.15);
}

.kkbac-guest-controls button:active {
    transform: translateY(0);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 480px) {
    .kkbac-window {
        width: calc(100vw - 16px);
        height: calc(100dvh - 100px - var(--kkbac-mobile-safe-top));
        max-height: calc(100dvh - 100px - var(--kkbac-mobile-safe-top));
        min-height: 400px;
        bottom: 100px;
        top: var(--kkbac-mobile-safe-top);
        border-radius: 12px;
    }

    body.admin-bar .kkbac-window {
        top: 32px;
        height: calc(100vh - 132px);
        max-height: calc(100vh - 132px);
    }

    .kkbac-toggle {
        width: 52px;
        height: 52px;
        font-size: 24px;
        bottom: 20px;
        right: 20px;
    }

    .kkbac-header {
        padding: 16px 20px;
    }

    .kkbac-header-title {
        font-size: 17px;
    }

    .kkbac-header-subtitle {
        font-size: 12px;
    }

    .kkbac-close {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        font-size: 20px;
    }

    .kkbac-messages {
        padding: 20px 16px;
    }

    .kkbac-message-bubble {
        font-size: 14px !important;
        padding: 12px 16px !important;
    }

    .kkbac-message-content {
        max-width: 85%;
    }

    .kkbac-prechat {
        padding: 32px 20px;
    }

    .kkbac-welcome-icon {
        font-size: 56px;
        margin-bottom: 16px;
    }

    .kkbac-welcome-title {
        font-size: 22px;
        margin-bottom: 8px;
    }

    .kkbac-welcome-subtitle {
        font-size: 14px;
        margin-bottom: 28px;
    }

    .kkbac-prechat-form {
        gap: 14px;
    }

    .kkbac-form-group input {
        padding: 12px 16px;
        font-size: 14px;
    }

    .kkbac-btn-primary {
        padding: 14px 20px;
        font-size: 14px;
    }

    .kkbac-input-area {
        padding: 16px 20px;
        gap: 10px;
    }

    .kkbac-input-area input {
        padding: 12px 16px;
        font-size: 14px;
    }

    .kkbac-send {
        padding: 12px 20px;
        font-size: 14px;
    }

    .kkbac-guest-controls {
        padding: 16px 20px;
    }

    .kkbac-guest-controls button {
        padding: 8px 16px;
        font-size: 12px;
    }
}

/* ==================== ACCESSIBILITY ==================== */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ==================== FORCE LIGHT MODE ==================== */
.kkbac-chatbot,
.kkbac-window,
.kkbac-messages,
.kkbac-prechat,
.kkbac-message,
.kkbac-message-bubble,
.kkbac-input-area,
.kkbac-form-group {
    color-scheme: light !important;
}

/* Ensure light backgrounds always */
.kkbac-messages {
    background: var(--bg-light) !important;
}

.kkbac-window {
    background: var(--bg-white) !important;
}

.kkbac-message.assistant .kkbac-message-bubble {
    background: var(--bg-message-assistant) !important;
    color: var(--text-dark) !important;
    border: 1px solid var(--border-color) !important;
}

.kkbac-message.user .kkbac-message-bubble {
    background: var(--bg-message-user) !important;
    color: white !important;
}

.kkbac-input-area {
    background: white !important;
}

.kkbac-input-area input {
    background: var(--bg-light) !important;
    color: var(--text-dark) !important;
}

.kkbac-prechat {
    background: var(--bg-light) !important;
}

.kkbac-guest-controls {
    background: white !important;
}

/* ==================== UTILITIES ==================== */
.kkbac-hidden {
    display: none !important;
}

.kkbac-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== SCROLLBAR STYLING ==================== */
.kkbac-prechat::-webkit-scrollbar {
    width: 8px;
}

.kkbac-prechat::-webkit-scrollbar-track {
    background: transparent;
}

.kkbac-prechat::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.kkbac-prechat::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* ==================== MESSAGE LINKS ==================== */
.kkbac-message-bubble a {
    color: var(--primary-color);
    text-decoration: underline;
    text-decoration-color: rgba(34, 113, 177, 0.3);
    text-underline-offset: 2px;
    transition: all 0.2s ease;
}

.kkbac-message-bubble a:hover {
    color: var(--primary-dark);
    text-decoration-color: var(--primary-dark);
}

.kkbac-message.user .kkbac-message-bubble a {
    color: rgba(255, 255, 255, 0.95);
    text-decoration-color: rgba(255, 255, 255, 0.5);
}

.kkbac-message.user .kkbac-message-bubble a:hover {
    color: white;
    text-decoration-color: white;
}

/* ==================== MESSAGE CODE ==================== */
.kkbac-message-bubble code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

.kkbac-message.user .kkbac-message-bubble code {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.95);
}

/* ==================== MESSAGE LISTS ==================== */
.kkbac-message-bubble ul,
.kkbac-message-bubble ol {
    margin: 8px 0;
    padding-left: 10px !important; /* Reduced padding since we are using inside */
    list-style-position: inside !important; /* Forces bullet inside the box model */
}

.kkbac-message-bubble ul {
    list-style-type: disc !important;
}

.kkbac-message-bubble ol {
    list-style-type: decimal !important;
}

.kkbac-message-bubble li {
    margin: 4px 0;
    line-height: 1.6;
    display: list-item !important;
    text-align: left; /* Ensure text alignment doesn't hide start */
}

/* Ensure markers are visible */
.kkbac-message-bubble li::marker {
    color: inherit;
    font-weight: bold;
}

/* ==================== KB LINKS ==================== */
.kkbac-kb-links-container {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.kkbac-kb-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kkbac-kb-link-item {
    padding: 14px 18px;
    background: white;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
}

.kkbac-kb-link-item:hover {
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f2ff 100%);
    border-color: var(--primary-color);
    transform: translateX(6px);
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.15), 0 2px 6px rgba(0, 0, 0, 0.08);
}

.kkbac-kb-link-item:active {
    transform: translateX(2px);
}

.kkbac-kb-link-item .kkbac-kb-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary-color);
    margin-bottom: 4px;
    line-height: 1.4;
}

.kkbac-kb-link-item .kkbac-kb-excerpt {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 4px;
}

* {
    box-sizing: border-box;
}

button {
    font-family: inherit;
}

input {
    font-family: inherit;
}

::selection {
    background: rgba(34, 113, 177, 0.2);
}

/* Support Chat Overrides */
/* 1. Hide Avatars */
.kkbac-chatbot[data-chat-type="support"] .kkbac-message-avatar {
    display: none !important;
}

.kkbac-chatbot[data-chat-type="support"] .kkbac-message-content {
    margin-left: 0 !important;
}

/* 2. Force Timestamps Visible */
.kkbac-chatbot[data-chat-type="support"] .kkbac-message-time {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: #94a3b8 !important;
    /* Slightly nicer gray */
    font-size: 11px !important;
    margin-top: 6px !important;
}

/* 3. Polish Layout (Background & Spacing) */
.kkbac-chatbot[data-chat-type="support"] .kkbac-chat-area {
    background-color: #f8fafc !important;
    /* Light gray background */
}

.kkbac-chatbot[data-chat-type="support"] .kkbac-message {
    margin-bottom: 24px !important;
    /* Increased spacing */
}

/* ==================== TABLES ==================== */
.kkbac-message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: block;
    overflow-x: auto;
}

.kkbac-message-bubble th,
.kkbac-message-bubble td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    min-width: 100px;
}

.kkbac-message-bubble th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-dark);
}

.kkbac-message-bubble tr:last-child td {
    border-bottom: none;
}

.kkbac-message-bubble td {
    color: var(--text-secondary);
}

.kkbac-message-bubble pre {
    margin: 14px 0;
    max-width: 100%;
}
