/**
 * Modern Chat Widget Styles - Professional, Responsive Design
 * Matching Admin Panel Design System
 * FORCED LIGHT MODE - No dark mode support
 */

/* Force light mode for chat widget */
html,
body,
:root {
    color-scheme: light !important;
}

:root {
    --lx-ai-primary: #2271b1;
    --lx-ai-primary-dark: #135e96;
    --lx-ai-primary-light: #72aee6;
    --lx-ai-secondary: #f6f7f7;
    --lx-ai-text: #1d2327;
    --lx-ai-text-light: #646970;
    --lx-ai-border: #dcdcde;
    --lx-ai-chat-bg: #ffffff;
    --lx-ai-header-bg: #f6f7f7;
    --lx-ai-user-bubble: #e7f5e9;
    --lx-ai-assistant-bubble: #ffffff;
    --lx-ai-shadow: rgba(0, 0, 0, 0.08);
    --lx-ai-shadow-lg: rgba(0, 0, 0, 0.12);
    --lx-ai-radius: 12px;
    --lx-ai-radius-sm: 8px;
    --lx-ai-spacing: 16px;
    --lx-ai-spacing-sm: 8px;
    --lx-ai-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --lx-ai-chat-font: "Bitter", Georgia, "Times New Roman", serif;
}

/* Override any dark mode attempts */
html[data-theme="dark"],
html[data-theme],
body.dark-mode,
body.darkmode,
html.dark-mode,
html.darkmode {
    color-scheme: light !important;
}

.lx-ai-chat-widget,
.lx-ai-chat-container {
    color-scheme: light !important;
    background-color: #ffffff !important;
    color: #1d2327 !important;
}

/* Widget Container */
.lx-ai-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: var(--lx-ai-font);
    font-size: 14px;
    line-height: 1.5;
    overflow: visible !important;
    pointer-events: none;
}

.lx-ai-chat-widget .lx-ai-chat-toggle-wrapper {
    pointer-events: auto !important;
}

.lx-ai-chat-widget .lx-ai-chat-toggle {
    pointer-events: auto !important;
}

/* Position Variants */
.lx-ai-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.lx-ai-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Chat Toggle Wrapper - Contains label and button */
.lx-ai-chat-toggle-wrapper {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
    position: fixed !important;
}

/* Chat Label - "Ask AI" text */
.lx-ai-chat-label {
    display: flex;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    color: #1d2327;
    background: #ffffff;
    padding: 8px 14px;
    border-radius: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    user-select: none;
    pointer-events: none;
    letter-spacing: 0.3px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.lx-ai-chat-widget:hover .lx-ai-chat-label {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* Pulse Animation Keyframes - EXTREMELY prominent attention-grabbing pulse */
@-webkit-keyframes chatIconPulse {
    0% {
        -webkit-transform: scale(1);
        transform: scale(1);
        -webkit-box-shadow: 0 4px 16px rgba(34, 113, 177, 0.4), 0 0 0 0 rgba(34, 113, 177, 0.7), 0 0 30px rgba(34, 113, 177, 0.3);
        box-shadow: 0 4px 16px rgba(34, 113, 177, 0.4), 0 0 0 0 rgba(34, 113, 177, 0.7), 0 0 30px rgba(34, 113, 177, 0.3);
    }
    50% {
        -webkit-transform: scale(1.25);
        transform: scale(1.25);
        -webkit-box-shadow: 0 15px 50px rgba(34, 113, 177, 0.9), 0 0 0 25px rgba(34, 113, 177, 0), 0 0 60px rgba(34, 113, 177, 0.6);
        box-shadow: 0 15px 50px rgba(34, 113, 177, 0.9), 0 0 0 25px rgba(34, 113, 177, 0), 0 0 60px rgba(34, 113, 177, 0.6);
    }
    100% {
        -webkit-transform: scale(1);
        transform: scale(1);
        -webkit-box-shadow: 0 4px 16px rgba(34, 113, 177, 0.4), 0 0 0 0 rgba(34, 113, 177, 0.7), 0 0 30px rgba(34, 113, 177, 0.3);
        box-shadow: 0 4px 16px rgba(34, 113, 177, 0.4), 0 0 0 0 rgba(34, 113, 177, 0.7), 0 0 30px rgba(34, 113, 177, 0.3);
    }
}

@keyframes chatIconPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 16px rgba(34, 113, 177, 0.4), 0 0 0 0 rgba(34, 113, 177, 0.7), 0 0 30px rgba(34, 113, 177, 0.3);
    }
    50% {
        transform: scale(1.25);
        box-shadow: 0 15px 50px rgba(34, 113, 177, 0.9), 0 0 0 25px rgba(34, 113, 177, 0), 0 0 60px rgba(34, 113, 177, 0.6);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 16px rgba(34, 113, 177, 0.4), 0 0 0 0 rgba(34, 113, 177, 0.7), 0 0 30px rgba(34, 113, 177, 0.3);
    }
}

/* Pulsing ring animation - EXTRA attention grabber with multiple rings */
@-webkit-keyframes chatIconRing {
    0% {
        opacity: 1;
        -webkit-transform: scale(1);
        transform: scale(1);
    }
    100% {
        opacity: 0;
        -webkit-transform: scale(2.5);
        transform: scale(2.5);
    }
}

@keyframes chatIconRing {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(2.5);
    }
}

/* Shake/Wiggle animation - Very attention-grabbing */
@-webkit-keyframes chatIconShake {
    0%, 100% {
        -webkit-transform: translateX(0) rotate(0deg);
        transform: translateX(0) rotate(0deg);
    }
    10%, 30%, 50%, 70%, 90% {
        -webkit-transform: translateX(-3px) rotate(-5deg);
        transform: translateX(-3px) rotate(-5deg);
    }
    20%, 40%, 60%, 80% {
        -webkit-transform: translateX(3px) rotate(5deg);
        transform: translateX(3px) rotate(5deg);
    }
}

@keyframes chatIconShake {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-3px) rotate(-5deg);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(3px) rotate(5deg);
    }
}

/* Glow/Shine effect */
@-webkit-keyframes chatIconGlow {
    0%, 100% {
        -webkit-filter: brightness(1) drop-shadow(0 0 10px rgba(34, 113, 177, 0.5));
        filter: brightness(1) drop-shadow(0 0 10px rgba(34, 113, 177, 0.5));
    }
    50% {
        -webkit-filter: brightness(1.3) drop-shadow(0 0 25px rgba(34, 113, 177, 0.9));
        filter: brightness(1.3) drop-shadow(0 0 25px rgba(34, 113, 177, 0.9));
    }
}

@keyframes chatIconGlow {
    0%, 100% {
        filter: brightness(1) drop-shadow(0 0 10px rgba(34, 113, 177, 0.5));
    }
    50% {
        filter: brightness(1.3) drop-shadow(0 0 25px rgba(34, 113, 177, 0.9));
    }
}

/* Bounce entrance animation - More dramatic */
@-webkit-keyframes chatIconBounce {
    0%, 100% {
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
    50% {
        -webkit-transform: translateY(-15px);
        transform: translateY(-15px);
    }
}

@keyframes chatIconBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-15px);
    }
}

/* Toggle Button - EXTREMELY attention-grabbing */
.lx-ai-chat-toggle {
    width: 64px !important;
    height: 64px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, var(--lx-ai-primary) 0%, var(--lx-ai-primary-light) 100%) !important;
    color: #fff !important;
    border: 3px solid rgba(255, 255, 255, 0.8) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 28px !important;
    position: relative !important;
    overflow: visible !important;
    z-index: 999998 !important;
    margin: 0 !important;
    padding: 0 !important;
    /* Multiple dramatic animations for MAXIMUM attention */
    -webkit-animation: chatIconEntrance 0.8s ease-out, chatIconPulse 1.5s ease-in-out 0.8s infinite, chatIconBounce 2.5s ease-in-out 0.8s infinite, chatIconShake 4s ease-in-out 1.5s infinite, chatIconGlow 2s ease-in-out 0.8s infinite !important;
    animation: chatIconEntrance 0.8s ease-out, chatIconPulse 1.5s ease-in-out 0.8s infinite, chatIconBounce 2.5s ease-in-out 0.8s infinite, chatIconShake 4s ease-in-out 1.5s infinite, chatIconGlow 2s ease-in-out 0.8s infinite !important;
    /* Ensure transform origin */
    -webkit-transform-origin: center center !important;
    transform-origin: center center !important;
    /* Performance optimizations */
    will-change: transform, box-shadow, filter !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    /* Disable transitions that might interfere */
    -webkit-transition: none !important;
    transition: none !important;
}

/* Pulsing ring effect - EXTRA attention grabber with thicker ring */
.lx-ai-chat-toggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid rgba(34, 113, 177, 0.8);
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    -webkit-animation: chatIconRing 1.5s ease-out 0.8s infinite;
    animation: chatIconRing 1.5s ease-out 0.8s infinite;
    pointer-events: none;
    z-index: -1;
    box-shadow: 0 0 20px rgba(34, 113, 177, 0.5);
}

/* Notification badge - MUCH more prominent attention grabber */
.lx-ai-chat-toggle::after {
    content: 'NEW';
    position: absolute;
    top: -12px;
    right: -12px;
    min-width: 42px;
    height: 20px;
    background: linear-gradient(135deg, #ff4444 0%, #ff6666 100%);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    border: 2px solid #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    -webkit-animation: chatIconPulse 1.5s ease-in-out 0.8s infinite, chatIconShake 2s ease-in-out 0.8s infinite;
    animation: chatIconPulse 1.5s ease-in-out 0.8s infinite, chatIconShake 2s ease-in-out 0.8s infinite;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.5);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.lx-ai-chat-toggle:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 8px 24px var(--lx-ai-shadow-lg) !important;
    -webkit-animation: none !important;
    animation: none !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

.lx-ai-chat-toggle:hover::before,
.lx-ai-chat-toggle:hover::after {
    -webkit-animation: none !important;
    animation: none !important;
}

/* Entrance animation when page loads */
@-webkit-keyframes chatIconEntrance {
    0% {
        opacity: 0;
        -webkit-transform: scale(0) rotate(-180deg);
        transform: scale(0) rotate(-180deg);
    }
    60% {
        -webkit-transform: scale(1.2) rotate(10deg);
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        opacity: 1;
        -webkit-transform: scale(1) rotate(0deg);
        transform: scale(1) rotate(0deg);
    }
}

@keyframes chatIconEntrance {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
    }
    60% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.lx-ai-chat-icon {
    width: 28px;
    height: 28px;
    stroke: currentColor;
    fill: none;
    position: relative;
    z-index: 2;
}

.lx-ai-chat-icon-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    position: relative;
    z-index: 2;
    background: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.lx-ai-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #d63638;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid #fff;
}

/* Chat Container */
.lx-ai-chat-container {
    display: flex;
    flex-direction: column;
    width: 420px;
    max-width: calc(100vw - 40px);
    height: 680px;
    max-height: calc(100vh - 40px);
    background: var(--lx-ai-chat-bg);
    border-radius: var(--lx-ai-radius);
    box-shadow: 0 8px 32px var(--lx-ai-shadow-lg);
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    box-sizing: border-box;
    min-height: 0;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* Enhanced border to highlight chat widget area */
    border: 2px solid rgba(34, 113, 177, 0.25) !important;
    outline: 1px solid rgba(34, 113, 177, 0.1) !important;
    outline-offset: -1px;
}

.lx-ai-chat-container.is-open,
.lx-ai-chat-container[style*="display: flex"] {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.lx-ai-position-bottom-right .lx-ai-chat-container {
    bottom: 20px;
    right: 20px;
    left: auto;
    top: auto;
}

.lx-ai-position-bottom-left .lx-ai-chat-container {
    bottom: 20px;
    left: 20px;
    right: auto;
    top: auto;
}

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

/* Header */
.lx-ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--lx-ai-header-bg);
    border-bottom: 1px solid var(--lx-ai-border);
    flex: 0 0 auto;
    flex-shrink: 0;
    min-height: 60px;
    box-sizing: border-box;
}

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

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

.lx-ai-chat-title-wrapper {
    min-width: 0;
    flex: 1;
}

.lx-ai-chat-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--lx-ai-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lx-ai-chat-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.lx-ai-chat-close {
    background: transparent;
    border: none;
    color: var(--lx-ai-text);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--lx-ai-radius-sm);
    transition: background 0.2s;
    padding: 0;
}

.lx-ai-chat-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Messages Area - Improved Responsive Design */
.lx-ai-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 12px;
    background: var(--lx-ai-chat-bg);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    position: relative;
    display: flex;
    flex-direction: column;
    overscroll-behavior: contain;
    user-select: text;
    -webkit-user-select: text;
    box-sizing: border-box;
    /* Ensure messages scroll independently, input stays visible */
    flex-shrink: 1;
    flex-grow: 1;
}

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

.lx-ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.lx-ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.lx-ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Date Separator */
.lx-ai-date-separator {
    text-align: center;
    margin: 16px 0;
    position: relative;
    flex-shrink: 0;
}

.lx-ai-date-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--lx-ai-border);
}

.lx-ai-date-separator span {
    background: var(--lx-ai-chat-bg);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    color: var(--lx-ai-text-light);
    position: relative;
    display: inline-block;
    border: 1px solid var(--lx-ai-border);
}

/* Messages */
.lx-ai-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
    padding: 0 4px;
    user-select: text;
    -webkit-user-select: text;
    flex-shrink: 0;
}

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

.lx-ai-message-user {
    align-items: flex-end;
}

.lx-ai-message-assistant {
    align-items: flex-start;
}

/* Message Wrapper - Improved Responsiveness */
.lx-ai-message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 85%;
    position: relative;
    width: 100%;
    user-select: text;
    -webkit-user-select: text;
}

.lx-ai-message-user .lx-ai-message-wrapper {
    flex-direction: row-reverse;
    margin-left: auto;
    max-width: 75%;
}

.lx-ai-message-assistant .lx-ai-message-wrapper {
    flex-direction: row;
    margin-right: auto;
    max-width: 85%;
    margin-left: 0;
}

/* Message Content Wrapper */
.lx-ai-message-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
    width: 100%;
}

.lx-ai-message-user .lx-ai-message-content-wrapper {
    align-items: flex-end;
}

.lx-ai-message-assistant .lx-ai-message-content-wrapper {
    align-items: flex-start;
}

.lx-ai-message-content-holder {
    position: relative;
    display: inline-block;
    max-width: 100%;
    width: 100%;
}

/* Message Avatar */
.lx-ai-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--lx-ai-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 1px 2px var(--lx-ai-shadow);
    margin-top: 2px;
}

.lx-ai-message-user .lx-ai-message-avatar {
    display: none;
}

/* Message Content - Improved Professional Design */
.lx-ai-message-content {
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
    font-family: var(--lx-ai-chat-font);
    position: relative;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    display: block;
    user-select: text;
    -webkit-user-select: text;
}

.lx-ai-message-user .lx-ai-message-content {
    background: var(--lx-ai-user-bubble);
    color: var(--lx-ai-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 2px var(--lx-ai-shadow);
}

.lx-ai-message-assistant .lx-ai-message-content {
    background: var(--lx-ai-assistant-bubble);
    color: var(--lx-ai-text);
    border: 1px solid var(--lx-ai-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px var(--lx-ai-shadow);
}

/* Message Links */
.lx-ai-message-content a,
.lx-ai-message-link {
    color: var(--lx-ai-primary);
    text-decoration: none;
    word-break: break-all;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.lx-ai-message-content a:hover,
.lx-ai-message-link:hover {
    color: var(--lx-ai-primary-dark);
    border-bottom-color: var(--lx-ai-primary-dark);
}

/* Message Metadata */
.lx-ai-message-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--lx-ai-text-light);
    padding: 0 4px;
}

.lx-ai-message-user .lx-ai-message-meta {
    justify-content: flex-end;
    flex-direction: row-reverse;
}

.lx-ai-message-time {
    font-size: 11px;
    opacity: 0.7;
}

.lx-ai-message-status {
    font-size: 14px;
    opacity: 0.6;
}

.lx-ai-message-status.read {
    color: var(--lx-ai-primary);
    opacity: 1;
}

/* Copy Button */
.lx-ai-message-copy {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--lx-ai-border);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    color: var(--lx-ai-text);
}

.lx-ai-message-user .lx-ai-message-copy {
    right: auto;
    left: 6px;
}

.lx-ai-message-content-holder:hover .lx-ai-message-copy {
    opacity: 1;
}

.lx-ai-message-copy:hover {
    background: #fff;
    border-color: var(--lx-ai-primary);
    color: var(--lx-ai-primary);
}

.lx-ai-message-copy svg {
    width: 14px;
    height: 14px;
}

/* Message Sources */
.lx-ai-message-sources {
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--lx-ai-secondary);
    border: 1px solid var(--lx-ai-border);
    border-radius: var(--lx-ai-radius-sm);
    font-size: 12px;
    max-width: 100%;
    box-sizing: border-box;
}

.lx-ai-sources-header {
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--lx-ai-text);
}

.lx-ai-source-item {
    margin: 4px 0;
    padding: 4px 0;
}

.lx-ai-source-item a {
    color: var(--lx-ai-primary);
    text-decoration: none;
    word-break: break-word;
    display: block;
    transition: color 0.2s;
}

.lx-ai-source-item a:hover {
    color: var(--lx-ai-primary-dark);
    text-decoration: underline;
}

/* Message Feedback */
.lx-ai-message-feedback {
    margin-top: 6px;
    display: flex;
    gap: 4px;
    justify-content: flex-start;
    align-items: center;
}

.lx-ai-feedback-btn {
    background: transparent;
    border: 1px solid var(--lx-ai-border);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s;
    color: var(--lx-ai-text-light);
}

.lx-ai-feedback-btn:hover {
    background: var(--lx-ai-secondary);
    border-color: var(--lx-ai-primary);
    color: var(--lx-ai-primary);
}

.lx-ai-feedback-btn.active {
    background: var(--lx-ai-primary);
    border-color: var(--lx-ai-primary);
    color: #fff;
}

.lx-ai-feedback-btn svg {
    width: 16px;
    height: 16px;
}

/* Empty State */
.lx-ai-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--lx-ai-text-light);
    padding: 32px 16px;
}

.lx-ai-empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.lx-ai-empty-state-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--lx-ai-text);
    margin-bottom: 8px;
}

.lx-ai-empty-state-hint {
    font-size: 13px;
    color: var(--lx-ai-text-light);
    max-width: 280px;
}

/* Suggested Questions */
.lx-ai-suggestions {
    padding: var(--lx-ai-spacing);
    border-top: 1px solid var(--lx-ai-border);
    background: var(--lx-ai-chat-bg);
    animation: fadeInUp 0.3s ease-out;
}

.lx-ai-suggestions-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--lx-ai-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--lx-ai-spacing-sm);
}

.lx-ai-suggestions-list {
    display: flex;
    flex-direction: column;
    gap: var(--lx-ai-spacing-sm);
}

.lx-ai-suggestion-item {
    display: block;
    width: 100%;
    padding: 12px var(--lx-ai-spacing);
    text-align: left;
    background: var(--lx-ai-secondary);
    border: 1px solid var(--lx-ai-border);
    border-radius: var(--lx-ai-radius-sm);
    color: var(--lx-ai-text);
    font-size: 14px;
    line-height: 1.5;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--lx-ai-font);
}

.lx-ai-suggestion-item:hover {
    background: var(--lx-ai-primary);
    color: #ffffff;
    border-color: var(--lx-ai-primary);
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.2);
}

.lx-ai-suggestion-item:active {
    transform: translateX(2px);
}

.lx-ai-suggestion-item:focus {
    outline: 2px solid var(--lx-ai-primary);
    outline-offset: 2px;
}

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

/* Typing Indicator */
.lx-ai-typing-indicator {
    background: var(--lx-ai-assistant-bubble);
    border: 1px solid var(--lx-ai-border);
    border-radius: 18px;
    padding: 12px 16px;
    display: inline-flex;
    gap: 4px;
    align-items: center;
    box-shadow: 0 1px 2px var(--lx-ai-shadow);
    margin-left: 44px;
    margin-bottom: 12px;
    max-width: 60px;
    border-bottom-left-radius: 4px;
}

.lx-ai-typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--lx-ai-text-light);
    border-radius: 50%;
    animation: typing 1.4s infinite;
    opacity: 0.6;
}

.lx-ai-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.lx-ai-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Input Area - Always visible at bottom */
.lx-ai-chat-input-area {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    background: var(--lx-ai-header-bg);
    border-top: 1px solid var(--lx-ai-border);
    flex: 0 0 auto;
    flex-shrink: 0;
    min-height: 0;
    box-sizing: border-box;
    /* Ensure input area stays at bottom and is always visible */
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    /* Add subtle shadow to separate from messages */
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.lx-ai-chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #fff;
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    border: 1px solid var(--lx-ai-border);
    box-shadow: 0 1px 2px var(--lx-ai-shadow);
    transition: all 0.2s;
}

.lx-ai-chat-input-wrapper:focus-within {
    border-color: var(--lx-ai-primary);
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.1);
}

.lx-ai-chat-input {
    flex: 1;
    padding: 10px 8px;
    border: none;
    border-radius: 0;
    font-size: 14px;
    font-family: var(--lx-ai-chat-font);
    resize: none;
    min-height: 20px;
    max-height: 100px;
    overflow-y: auto;
    background: transparent;
    outline: none;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    line-height: 1.4;
    color: var(--lx-ai-text);
}

.lx-ai-chat-input:focus {
    outline: none;
}

.lx-ai-chat-input::placeholder {
    color: var(--lx-ai-text-light);
    opacity: 0.6;
}

.lx-ai-send-wrapper {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.lx-ai-chat-send {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    background: var(--lx-ai-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(34, 113, 177, 0.3);
}

.lx-ai-chat-send:hover:not(:disabled) {
    background: var(--lx-ai-primary-dark);
    transform: scale(1.05);
    box-shadow: 0 3px 6px rgba(34, 113, 177, 0.4);
}

.lx-ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.lx-ai-chat-send svg {
    width: 18px;
    height: 18px;
}

/* Responsive Design - Tablet */
@media (max-width: 991.98px) {
    .lx-ai-chat-container {
        width: calc(100vw - 32px) !important;
        max-width: 500px !important;
        height: calc(100vh - 32px) !important;
        max-height: 700px !important;
        /* Enhanced border for tablet */
        border: 2px solid rgba(34, 113, 177, 0.25) !important;
        outline: 1px solid rgba(34, 113, 177, 0.1) !important;
        outline-offset: -1px;
    }
    
    .lx-ai-position-bottom-right .lx-ai-chat-container {
        bottom: 16px !important;
        right: 16px !important;
    }
    
    .lx-ai-position-bottom-left .lx-ai-chat-container {
        bottom: 16px !important;
        left: 16px !important;
    }
    
    .lx-ai-message-wrapper {
        max-width: 82% !important;
    }
    
    .lx-ai-message-user .lx-ai-message-wrapper {
        max-width: 78% !important;
    }
    
    .lx-ai-message-assistant .lx-ai-message-wrapper {
        max-width: 85% !important;
    }
}

/* Responsive Design - Mobile */
@media (max-width: 768px) {
    .lx-ai-chat-container {
        /* Smaller, floating modal on mobile - ensures input field is always visible */
        width: 95% !important;
        max-width: 420px !important;
        height: 85vh !important;
        max-height: 85vh !important;
        /* Center the widget on screen */
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        bottom: auto !important;
        transform: translate(-50%, -50%) !important;
        /* Restore border radius for floating appearance */
        border-radius: 16px !important;
        /* Remove padding that was for full-screen */
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        /* Ensure it's above everything */
        z-index: 999999 !important;
        /* Add margin for safe areas */
        margin: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px) !important;
        /* Enhanced border for mobile */
        border: 2px solid rgba(34, 113, 177, 0.25) !important;
        outline: 1px solid rgba(34, 113, 177, 0.1) !important;
        outline-offset: -1px;
    }
    
    .lx-ai-position-bottom-right .lx-ai-chat-container,
    .lx-ai-position-bottom-left .lx-ai-chat-container {
        /* On mobile, always center the widget */
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        bottom: auto !important;
        transform: translate(-50%, -50%) !important;
        border-radius: 16px !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }
    
    .lx-ai-chat-header {
        padding: 12px 14px;
        min-height: 56px;
    }
    
    .lx-ai-chat-title {
        font-size: 15px;
    }
    
    .lx-ai-chat-messages {
        padding: 12px 8px;
    }
    
    .lx-ai-message {
        margin-bottom: 10px;
        padding: 0 2px;
    }
    
    .lx-ai-message-wrapper {
        max-width: 88% !important;
    }
    
    .lx-ai-message-assistant .lx-ai-message-wrapper {
        max-width: 90% !important;
    }
    
    .lx-ai-message-user .lx-ai-message-wrapper {
        max-width: 85% !important;
    }
    
    .lx-ai-message-content {
        font-size: 14px;
        padding: 9px 12px;
    }
    
    .lx-ai-message-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
    
    .lx-ai-typing-indicator {
        margin-left: 36px;
    }
    
    .lx-ai-chat-input-area {
        padding: 10px 12px !important;
        /* Normal padding since widget is floating and centered */
        padding-bottom: 10px !important;
        /* Ensure sticky positioning works on mobile */
        position: sticky !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 100 !important;
        background: var(--lx-ai-header-bg) !important;
        /* Add subtle shadow to separate from messages */
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05) !important;
        margin-bottom: 0 !important;
        border-bottom-left-radius: 16px !important;
        border-bottom-right-radius: 16px !important;
    }
    
    .lx-ai-chat-input {
        font-size: 14px; /* Reverted to original size */
    }
    
    .lx-ai-chat-input-wrapper {
        padding: 3px 3px 3px 12px !important;
        /* Normal padding since widget is floating */
        padding-bottom: 3px !important;
    }
    
    .lx-ai-chat-messages {
        /* Ensure messages scroll independently, input area stays visible */
        padding-bottom: 12px !important;
        /* Use flex to fill available space, input area will stay at bottom */
        flex: 1 1 0% !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        /* Let flex handle the height */
        max-height: none !important;
    }
    
    .lx-ai-chat-send {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }
    
    .lx-ai-chat-send svg {
        width: 16px;
        height: 16px;
    }
    
    .lx-ai-empty-state-icon {
        font-size: 40px;
    }
    
    .lx-ai-empty-state-text {
        font-size: 15px;
    }
    
    .lx-ai-empty-state-hint {
        font-size: 12px;
        max-width: 100%;
        padding: 0 16px;
    }
}

@media (max-width: 480px) {
    .lx-ai-chat-container {
        /* Even smaller on very small screens */
        width: 92% !important;
        height: 80vh !important;
        max-height: 80vh !important;
        /* Enhanced border for small mobile */
        border: 2px solid rgba(34, 113, 177, 0.25) !important;
        outline: 1px solid rgba(34, 113, 177, 0.1) !important;
        outline-offset: -1px;
    }
    
    .lx-ai-chat-header {
        padding: 10px 12px;
        min-height: 52px;
        border-top-left-radius: 16px !important;
        border-top-right-radius: 16px !important;
    }
    
    .lx-ai-chat-title {
        font-size: 14px;
    }
    
    .lx-ai-chat-messages {
        padding: 10px 6px !important;
        padding-bottom: 10px !important;
        /* Let flex handle the height */
        max-height: none !important;
    }
    
    .lx-ai-message {
        margin-bottom: 8px;
    }
    
    .lx-ai-message-wrapper {
        max-width: 92% !important;
    }
    
    .lx-ai-message-assistant .lx-ai-message-wrapper {
        max-width: 94% !important;
    }
    
    .lx-ai-message-user .lx-ai-message-wrapper {
        max-width: 90% !important;
    }
    
    .lx-ai-message-content {
        padding: 8px 11px;
        font-size: 13px;
    }
    
    .lx-ai-message-avatar {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }
    
    .lx-ai-typing-indicator {
        margin-left: 32px;
        max-width: 50px;
    }
    
    .lx-ai-chat-input-area {
        padding: 8px 10px !important;
        padding-bottom: 8px !important;
        position: sticky !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 100 !important;
        background: var(--lx-ai-header-bg) !important;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05) !important;
        border-bottom-left-radius: 16px !important;
        border-bottom-right-radius: 16px !important;
    }
    
    .lx-ai-chat-input-wrapper {
        padding: 3px 3px 3px 12px !important;
        padding-bottom: 3px !important;
    }
    
    .lx-ai-chat-input {
        font-size: 14px; /* Reverted to original size */
        padding: 8px 6px;
    }
    
    .lx-ai-chat-messages {
        /* Ensure messages scroll independently, input area stays visible */
        padding-bottom: 10px !important;
        /* Use flex to fill available space, input area will stay at bottom */
        flex: 1 1 0% !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        max-height: none !important;
    }
    
    .lx-ai-suggestions {
        padding: 8px;
    }
    
    .lx-ai-suggestion-item {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .lx-ai-chat-send {
        width: 28px;
        height: 28px;
        min-width: 28px;
    }
    
    .lx-ai-message-sources {
        padding: 8px 10px;
        font-size: 11px;
    }
    
    .lx-ai-feedback-btn {
        width: 24px;
        height: 24px;
    }
    
    .lx-ai-feedback-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .lx-ai-chat-toggle-wrapper {
        gap: 8px !important;
    }
    
    .lx-ai-chat-label {
        font-size: 12px !important;
        padding: 5px 10px !important;
    }
    
    .lx-ai-chat-toggle {
        width: 52px !important;
        height: 52px !important;
    }
}

/* Accessibility - Only disable animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    /* Only disable animation on toggle, not everything */
    .lx-ai-chat-toggle {
        -webkit-animation: none !important;
        animation: none !important;
    }
}

/* CRITICAL: Force ALL animations to work - highest priority after media queries */
.lx-ai-chat-toggle:not(:hover) {
    -webkit-animation: chatIconEntrance 0.8s ease-out, chatIconPulse 1.5s ease-in-out 0.8s infinite, chatIconBounce 2.5s ease-in-out 0.8s infinite, chatIconShake 4s ease-in-out 1.5s infinite, chatIconGlow 2s ease-in-out 0.8s infinite !important;
    animation: chatIconEntrance 0.8s ease-out, chatIconPulse 1.5s ease-in-out 0.8s infinite, chatIconBounce 2.5s ease-in-out 0.8s infinite, chatIconShake 4s ease-in-out 1.5s infinite, chatIconGlow 2s ease-in-out 0.8s infinite !important;
    -webkit-transform-origin: center center !important;
    transform-origin: center center !important;
    will-change: transform, box-shadow, filter !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    -webkit-transition: none !important;
    transition: none !important;
}

.lx-ai-chat-toggle:not(:hover)::before {
    -webkit-animation: chatIconRing 1.5s ease-out 0.8s infinite !important;
    animation: chatIconRing 1.5s ease-out 0.8s infinite !important;
}

.lx-ai-chat-toggle:not(:hover)::after {
    -webkit-animation: chatIconPulse 1.5s ease-in-out 0.8s infinite, chatIconShake 2s ease-in-out 0.8s infinite !important;
    animation: chatIconPulse 1.5s ease-in-out 0.8s infinite, chatIconShake 2s ease-in-out 0.8s infinite !important;
}

/* Override reduced motion for users who don't have it */
@media (prefers-reduced-motion: no-preference) {
    .lx-ai-chat-toggle:not(:hover) {
        -webkit-animation: chatIconEntrance 0.8s ease-out, chatIconPulse 1.5s ease-in-out 0.8s infinite, chatIconBounce 2.5s ease-in-out 0.8s infinite, chatIconShake 4s ease-in-out 1.5s infinite, chatIconGlow 2s ease-in-out 0.8s infinite !important;
        animation: chatIconEntrance 0.8s ease-out, chatIconPulse 1.5s ease-in-out 0.8s infinite, chatIconBounce 2.5s ease-in-out 0.8s infinite, chatIconShake 4s ease-in-out 1.5s infinite, chatIconGlow 2s ease-in-out 0.8s infinite !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .lx-ai-chat-container {
        border: 2px solid var(--lx-ai-text);
    }
    
    .lx-ai-message-content {
        border: 2px solid var(--lx-ai-text);
    }
}
