:root {
    --ai-primary-color: #4f46e5;
    --ai-text-color: #1e293b;
    --ai-bg-color: #ffffff;
    --ai-bubble-size: 60px;
    --ai-offset-x: 24px;
    --ai-offset-y: 24px;
    --ai-radius: 28px;
    --ai-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --ai-assistant-text-color: #1e293b;
    --ai-user-text-color: #ffffff;
}

/* Widget root anchor */
#ai-chat-widget-root {
    position: fixed;
    width: var(--ai-bubble-size);
    height: var(--ai-bubble-size);
    bottom: var(--ai-offset-y);
    right: var(--ai-offset-x);
    z-index: 9999;
}

#ai-chat-widget-root.ai-pos-bottom-left {
    right: auto;
    left: var(--ai-offset-x);
}

#ai-chat-widget-root.ai-pos-right-middle {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
}

/* Chat Bubble */
#ai-chat-bubble {
    position: absolute;
    bottom: 0;
    right: 0;
    width: var(--ai-bubble-size);
    height: var(--ai-bubble-size);
    background: var(--ai-primary-color);
    border-radius: 50%;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05), inset 0 2px 4px rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 9999;
    color: white;
    border: none;
    outline: none;
    animation: ai-bubble-in 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes ai-bubble-in {
    from { transform: scale(0) rotate(-45deg); opacity: 0; }
    to { transform: scale(1) rotate(0); opacity: 1; }
}

/* Pulse Animation (Radio Signal Wave) */
.ai-pulse-wave {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--ai-primary-color);
    opacity: 0.6;
    z-index: -1;
    pointer-events: none;
    animation: ai-pulse-wave 2.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.ai-pulse-wave:nth-child(2) {
    animation-delay: 0.8s;
}

.ai-pulse-wave:nth-child(3) {
    animation-delay: 1.6s;
}

@keyframes ai-pulse-wave {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

/* Waving Hand Animation */
.ai-wave {
    display: inline-block;
    animation: ai-wave-animation 2.5s infinite;
    transform-origin: 70% 70%;
}

@keyframes ai-wave-animation {
    0% { transform: rotate( 0.0deg) }
    10% { transform: rotate(14.0deg) }
    20% { transform: rotate(-8.0deg) }
    30% { transform: rotate(14.0deg) }
    40% { transform: rotate(-4.0deg) }
    50% { transform: rotate(10.0deg) }
    60% { transform: rotate( 0.0deg) }
    100% { transform: rotate( 0.0deg) }
}

#ai-chat-bubble:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

#ai-chat-bubble svg {
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease;
}

#ai-chat-bubble:hover svg {
    transform: scale(1.1);
}

/* Proactive Welcome Message */
.ai-proactive-msg {
    position: absolute;
    bottom: calc(100% + 15px);
    right: 0;
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    width: 220px;
    color: #1e293b;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 9998;
    border: 1px solid #f1f5f9;
}

.ai-proactive-header {
    font-weight: 700;
    color: var(--ai-primary-color);
    margin-bottom: 4px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.ai-proactive-text {
    line-height: 1.5;
}

.ai-proactive-msg.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.ai-proactive-msg::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 24px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

.ai-proactive-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    border: 2px solid white;
    transition: all 0.2s;
    pointer-events: all;
}

.ai-proactive-close:hover {
    background: #ef4444;
    color: white;
}

.ai-bubble-dismiss {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 24px;
    height: 24px;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 2px solid #ffffff;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
    z-index: 20;
}

#ai-chat-bubble:hover .ai-bubble-dismiss {
    opacity: 1;
    transform: scale(1);
}

.ai-bubble-dismiss:hover {
    background: #ef4444;
    color: #ffffff;
}

.ai-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background-color: #ef4444;
    color: #ffffff;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 2px solid #ffffff;
    z-index: 10;
}

.ai-chat-badge.ai-chat-badge-hidden {
    display: none;
}

/* Chat Window */
#ai-chat-window {
    position: absolute;
    bottom: 12px;
    right: 0;
    width: 380px;
    height: 950px;
    height: min(950px, calc(100vh - 115px));
    max-height: calc(100vh - 115px);
    background-color: var(--ai-bg-color);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    z-index: 9999;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

@media (max-width: 767.98px) {
    #ai-chat-widget-root {
        position: fixed !important;
        right: 15px !important;
        bottom: 116px !important;
        left: auto !important;
        top: auto !important;
        width: 60px !important;
        height: 60px !important;
        z-index: 1000002 !important;
    }

    #ai-chat-bubble {
        position: absolute !important;
        right: 0 !important;
        bottom: 0 !important;
        left: auto !important;
        top: auto !important;
        width: 60px !important;
        height: 60px !important;
        pointer-events: auto !important;
        z-index: 1000003 !important;
    }

    #ai-chat-window {
        position: absolute !important;
        right: 0 !important;
        left: auto !important;
        bottom: 0 !important;
        top: auto !important;
        width: calc(100vw - 30px) !important;
        max-width: 420px !important;
        height: min(580px, calc(100vh - 145px)) !important;
        height: min(580px, calc(100dvh - 145px)) !important;
        max-height: calc(100dvh - 145px) !important;
        transform: translateY(20px) scale(0.95);
        transform-origin: bottom right !important;
        border-radius: 20px !important;
        pointer-events: none;
        z-index: 1000005 !important;
    }

    #ai-chat-widget-root.ai-pos-bottom-left {
        left: 12px !important;
        right: auto !important;
    }

    #ai-chat-widget-root.ai-pos-bottom-left #ai-chat-window {
        left: 0 !important;
        right: auto !important;
        transform-origin: bottom left !important;
    }

    #ai-chat-window.open {
        opacity: 1 !important;
        visibility: visible !important;
        display: flex !important;
        transform: translateY(0) scale(1) !important;
        pointer-events: all !important;
    }
}


#ai-chat-window.open {
    transform: translateY(0) scale(1) !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    pointer-events: all !important;
    z-index: 1000005 !important;
}

#ai-chat-bubble.ai-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

/* Position Overrides */
#ai-chat-widget-root.ai-pos-bottom-left #ai-chat-bubble {
    right: auto;
    left: 0;
}
#ai-chat-widget-root.ai-pos-bottom-left #ai-chat-window {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

#ai-chat-widget-root.ai-pos-right-middle #ai-chat-bubble {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
}
#ai-chat-widget-root.ai-pos-right-middle #ai-chat-window {
    bottom: auto;
    top: 50%;
    height: min(640px, calc(100vh - 140px));
    transform: translateY(calc(-50% + 20px)) scale(0.95);
    transform-origin: center right;
    max-height: calc(100vh - 140px);
}
#ai-chat-widget-root.ai-pos-right-middle #ai-chat-window.open {
    transform: translateY(-50%) scale(1);
}

/* Typing / Processing Indicator */
.ai-typing-indicator {
    align-self: flex-start;
    background-color: white;
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    animation: ai-msg-pop 0.3s ease-out;
}

.ai-typing-text {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    text-transform: none;
    letter-spacing: normal;
}

.ai-typing-dots {
    display: flex;
    gap: 4px;
}

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

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

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

@keyframes ai-typing-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

@keyframes ai-msg-pop {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header and Window Controls */
#ai-chat-window.minimized {
    transform: translateY(calc(100% - 60px));
}

#ai-chat-window.wide {
    width: 650px;
}

@media (max-width: 700px) {
    #ai-chat-window.wide {
        width: min(650px, calc(100vw - 40px));
        max-width: calc(100vw - 40px);
    }
    .ai-hidden-mobile {
        display: none !important;
    }
}

.ai-chat-header {
    background: var(--ai-primary-color);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    min-height: 56px;
    box-sizing: border-box;
    gap: 10px;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 15px;
    flex: 1 1 auto;
    min-width: 0;
}

.ai-chat-title span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    min-width: 0;
    font-size: 15px;
    line-height: 1.2;
    color: white;
}

.ai-chat-logo {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    max-width: 28px !important;
    max-height: 28px !important;
    border-radius: 8px;
    object-fit: contain;
    background-color: white;
    padding: 2px;
    flex-shrink: 0;
    display: block;
}

.ai-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ai-chat-header-actions button {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: white;
    padding: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    box-sizing: border-box;
    line-height: 1;
}

.ai-chat-header-actions button:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}

.ai-chat-header-actions svg {
    width: 15px;
    height: 15px;
    stroke-width: 2.5;
    display: block;
}

/* Modal Styling - Clean Theme Aesthetics */
.ai-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 20px;
    box-sizing: border-box;
}

.ai-modal-overlay.active {
    display: flex;
}

.ai-modal-content {
    background: #ffffff;
    border-radius: 20px;
    width: 100%;
    max-width: 380px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    animation: ai-modal-slide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    text-align: center;
    padding: 28px 24px 22px;
}

@keyframes ai-modal-slide {
    from { transform: translateY(16px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.ai-modal-icon-wrap {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px auto;
}

.ai-modal-icon-wrap svg {
    width: 26px;
    height: 26px;
    stroke: #ef4444;
}

.ai-modal-header {
    padding: 0;
    margin-bottom: 22px;
}

.ai-modal-header h3,
.ai-modal-title {
    margin: 0 0 8px 0 !important;
    font-size: 19px !important;
    font-weight: 700 !important;
    color: #1e293b !important;
    line-height: 1.3 !important;
    font-family: inherit !important;
}

.ai-modal-desc {
    margin: 0 !important;
    color: #64748b !important;
    font-size: 14px !important;
    line-height: 1.55 !important;
    font-family: inherit !important;
}

.ai-modal-footer {
    padding: 0;
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.ai-modal-footer button {
    flex: 1;
    padding: 10px 18px !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    border: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    font-family: inherit !important;
}

.ai-btn-secondary {
    background: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #e2e8f0 !important;
}

.ai-btn-secondary:hover {
    background: #e2e8f0 !important;
    color: #1e293b !important;
}

.ai-btn-danger {
    background: #ef4444 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25) !important;
}

.ai-btn-danger:hover {
    background: #dc2626 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.35) !important;
}

.ai-hidden { display: none !important; }

.ai-chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: #f8fafc;
}

.ai-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    box-sizing: border-box !important;
}

/* ── Theme Isolation & AI Response Formatting ──
   Guarantees clean, readable styling regardless of active theme or global element rules */

/* Headings */
.ai-message h1, .ai-message .ai-h1 {
    font-family: inherit !important;
    font-size: 1.35em !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    margin: 0.85em 0 0.4em 0 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    color: inherit !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
    padding-bottom: 0.25em !important;
}

.ai-message h2, .ai-message .ai-h2 {
    font-family: inherit !important;
    font-size: 1.22em !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    margin: 0.75em 0 0.35em 0 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    color: inherit !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
    padding-bottom: 0.2em !important;
}

.ai-message h3, .ai-message .ai-h3 {
    font-family: inherit !important;
    font-size: 1.12em !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    margin: 0.7em 0 0.3em 0 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    color: inherit !important;
}

.ai-message h4, .ai-message .ai-h4 {
    font-family: inherit !important;
    font-size: 1.05em !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    margin: 0.65em 0 0.25em 0 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    color: inherit !important;
}

.ai-message h5, .ai-message .ai-h5,
.ai-message h6, .ai-message .ai-h6 {
    font-family: inherit !important;
    font-size: 1em !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    margin: 0.6em 0 0.25em 0 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    color: inherit !important;
}

.ai-message h1:first-child, .ai-message h2:first-child,
.ai-message h3:first-child, .ai-message h4:first-child,
.ai-message h5:first-child, .ai-message h6:first-child,
.ai-message .ai-h1:first-child, .ai-message .ai-h2:first-child,
.ai-message .ai-h3:first-child {
    margin-top: 0 !important;
}

/* Paragraphs */
.ai-message p,
.ai-message .ai-paragraph {
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: 1.55 !important;
    margin: 0 0 0.7em 0 !important;
    padding: 0 !important;
    color: inherit !important;
    display: block !important;
}

.ai-message p:last-child,
.ai-message .ai-paragraph:last-child {
    margin-bottom: 0 !important;
}

.ai-message p:first-child,
.ai-message .ai-paragraph:first-child {
    margin-top: 0 !important;
}

/* Lists */
.ai-message ul,
.ai-message ol,
.ai-message .ai-list,
.ai-message .ai-list-ordered {
    margin: 0.4em 0 0.7em 1.35em !important;
    padding: 0 !important;
    list-style-position: outside !important;
}

.ai-message ul,
.ai-message .ai-list {
    list-style-type: disc !important;
}

.ai-message ol,
.ai-message .ai-list-ordered {
    list-style-type: decimal !important;
}

.ai-message li {
    margin-bottom: 0.3em !important;
    padding: 0 !important;
    color: inherit !important;
    line-height: 1.5 !important;
    font-size: inherit !important;
}

.ai-message li:last-child {
    margin-bottom: 0 !important;
}

.ai-message li > ul,
.ai-message li > ol {
    margin-top: 0.25em !important;
    margin-bottom: 0.25em !important;
}

/* Blockquotes */
.ai-message blockquote,
.ai-message .ai-blockquote {
    margin: 0.65em 0 !important;
    padding: 8px 14px !important;
    border-left: 3px solid var(--ai-primary-color) !important;
    background: rgba(0, 0, 0, 0.03) !important;
    border-radius: 0 6px 6px 0 !important;
    font-style: italic !important;
    color: inherit !important;
    line-height: 1.5 !important;
}

/* Inline styling: bold, italic, strikethrough */
.ai-message strong, .ai-message b {
    font-weight: 700 !important;
    color: inherit !important;
}

.ai-message em, .ai-message i {
    font-style: italic !important;
    color: inherit !important;
}

.ai-message del {
    text-decoration: line-through !important;
    opacity: 0.75 !important;
}

/* Horizontal Rules */
.ai-message hr,
.ai-message .ai-hr {
    border: 0 !important;
    border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
    margin: 1em 0 !important;
    height: 0 !important;
}

/* Inline Code */
.ai-message code.ai-inline-code,
.ai-message :not(pre) > code {
    background-color: rgba(0, 0, 0, 0.06) !important;
    color: #0f172a !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    font-size: 0.88em !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !important;
    word-break: break-word !important;
}

/* Pre / Code Blocks */
.ai-code-block {
    background-color: #1e293b !important;
    border-radius: 8px !important;
    margin: 0.75em 0 !important;
    overflow: hidden !important;
    max-width: 100% !important;
}

.ai-code-header {
    background-color: #334155 !important;
    color: #94a3b8 !important;
    padding: 6px 12px !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    font-weight: 700 !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
}

.ai-code-block pre,
.ai-message pre {
    background: #1e293b !important;
    color: #e2e8f0 !important;
    font-size: 12.5px !important;
    padding: 12px !important;
    margin: 0 !important;
    border-radius: 6px !important;
    overflow-x: auto !important;
    white-space: pre !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
    line-height: 1.5 !important;
}

.ai-code-block pre code,
.ai-message pre code {
    background: transparent !important;
    color: inherit !important;
    padding: 0 !important;
    font-size: inherit !important;
    font-family: inherit !important;
    white-space: inherit !important;
}

/* Tables */
.ai-table-container {
    width: 100% !important;
    overflow-x: auto !important;
    margin: 0.75em 0 !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
}

.ai-table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 13px !important;
    background-color: white !important;
    margin: 0 !important;
}

.ai-th {
    background-color: #f8fafc !important;
    color: #475569 !important;
    font-weight: 700 !important;
    text-align: left !important;
    padding: 8px 12px !important;
    border: 1px solid #e2e8f0 !important;
}

.ai-td {
    padding: 7px 12px !important;
    border: 1px solid #e2e8f0 !important;
    color: #475569 !important;
}

.ai-table tr:last-child .ai-td {
    border-bottom: none !important;
}

/* Assistant Bubble Specifics */
.ai-message.assistant {
    align-self: flex-start;
    background-color: white;
    color: var(--ai-assistant-text-color) !important;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.ai-message.assistant p,
.ai-message.assistant span,
.ai-message.assistant li,
.ai-message.assistant strong,
.ai-message.assistant em,
.ai-message.assistant h1,
.ai-message.assistant h2,
.ai-message.assistant h3,
.ai-message.assistant h4,
.ai-message.assistant h5,
.ai-message.assistant h6 {
    color: inherit !important;
}

.ai-message.assistant a,
.ai-message.assistant .ai-link {
    color: var(--ai-primary-color) !important;
    text-decoration: underline !important;
    font-weight: 600 !important;
}

/* User Bubble Specifics */
.ai-message.user {
    align-self: flex-end;
    background-color: var(--ai-primary-color);
    color: var(--ai-user-text-color) !important;
    border-bottom-right-radius: 4px;
}

.ai-message.user p,
.ai-message.user span,
.ai-message.user li,
.ai-message.user strong,
.ai-message.user em,
.ai-message.user h1,
.ai-message.user h2,
.ai-message.user h3,
.ai-message.user h4,
.ai-message.user h5,
.ai-message.user h6,
.ai-message.user th,
.ai-message.user td {
    color: inherit !important;
}

.ai-message.user h1,
.ai-message.user h2 {
    border-bottom-color: rgba(255, 255, 255, 0.25) !important;
}

.ai-message.user hr {
    border-top-color: rgba(255, 255, 255, 0.25) !important;
}

.ai-message.user blockquote,
.ai-message.user .ai-blockquote {
    border-left-color: rgba(255, 255, 255, 0.7) !important;
    background: rgba(255, 255, 255, 0.12) !important;
}

.ai-message.user code.ai-inline-code,
.ai-message.user :not(pre) > code {
    background-color: rgba(255, 255, 255, 0.2) !important;
    color: inherit !important;
}

.ai-message.user a,
.ai-message.user .ai-link {
    color: inherit !important;
    text-decoration: underline !important;
}

.ai-wave {
    display: inline-block;
    animation: aiWaveAnim 2s infinite;
    transform-origin: 70% 70%;
}

@keyframes aiWaveAnim {
    0% { transform: rotate(0deg); }
    10% { transform: rotate(14deg); }
    20% { transform: rotate(-8deg); }
    30% { transform: rotate(14deg); }
    40% { transform: rotate(-4deg); }
    50% { transform: rotate(10deg); }
    60% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

/* Service/Product Result Cards */
.ai-result-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    margin: 16px 0;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    position: relative;
    border-left: 4px solid var(--ai-primary-color);
}

.ai-result-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.1), 0 8px 8px -5px rgba(0, 0, 0, 0.04);
    border-color: var(--ai-primary-color);
}

.ai-card-image-wrap {
    width: 100%;
    height: 140px;
    overflow: hidden;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.ai-card-icon-wrap {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    color: var(--ai-primary-color);
}

.ai-card-placeholder-icon {
    font-size: 48px;
    opacity: 0.8;
    transition: transform 0.3s ease;
}

.ai-result-card:hover .ai-card-placeholder-icon {
    transform: scale(1.1) rotate(-5deg);
}

.ai-result-card:hover .ai-card-img {
    transform: scale(1.1);
}

.ai-card-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-card-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    width: fit-content;
}

.ai-card-sale-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #ef4444;
    color: white;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 900;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    letter-spacing: 0.05em;
    animation: ai-sale-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes ai-sale-pop {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.ai-card-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.3;
}

.ai-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
}

.ai-card-pricing {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ai-card-price {
    font-size: 15px;
    font-weight: 800;
    color: var(--ai-primary-color);
}

.ai-card-price-sale {
    font-size: 16px;
    font-weight: 900;
    color: #ef4444;
}

.ai-card-price-old {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-decoration: line-through;
}

.ai-card-link {
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-result-card:hover .ai-card-link {
    color: var(--ai-primary-color);
}

.ai-hr {
    border: 0;
    border-top: 1px solid #e2e8f0;
    margin: 1.5em 0;
}

.ai-message.user {
    align-self: flex-end;
    background-color: var(--ai-primary-color);
    color: var(--ai-user-text-color) !important;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Prevent theme global p/a/span rules overriding user bubble text */
.ai-message.user p,
.ai-message.user span,
.ai-message.user li,
.ai-message.user strong,
.ai-message.user em {
    color: inherit !important;
}
.ai-message.user a {
    color: inherit !important;
    text-decoration: underline;
}

/* Quick Questions */
.ai-quick-questions {
    padding: 12px 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background-color: #f8fafc;
}

.ai-quick-question-btn {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background-color: white;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-quick-question-btn:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--ai-text-color);
}

/* Input Area */
.ai-chat-input-area {
    padding: 12px 16px !important;
    background: white !important;
    border-top: 1px solid #f1f5f9 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-end !important;
    gap: 10px !important;
    box-sizing: border-box !important;
    width: 100% !important;
}

.ai-chat-disclaimer {
    padding: 0 16px 10px !important;
    font-size: 10px !important;
    color: #94a3b8 !important;
    text-align: center !important;
    background: white !important;
    font-weight: 500 !important;
    letter-spacing: 0.01em !important;
}

.ai-chat-input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: 0 !important; /* Let flex-grow handle it */
    max-width: 100% !important;
    min-height: 42px !important;
    height: 42px !important;
    max-height: 140px !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 10px 14px !important;
    font-size: 14px !important;
    font-family: inherit !important;
    color: var(--ai-text-color, #1e293b) !important;
    background-color: #ffffff !important;
    resize: none !important;
    overflow-y: hidden !important;
    transition: border-color 0.2s, height 0.15s ease !important;
    outline: none !important;
    line-height: 1.45 !important;
    box-sizing: border-box !important;
}

.ai-chat-input:focus {
    border-color: var(--ai-primary-color) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12) !important;
}

.ai-input-actions {
    display: flex !important;
    gap: 6px !important;
    align-items: center !important;
    flex-shrink: 0 !important;
    margin-bottom: 2px !important;
}

.ai-voice-btn, .ai-send-btn {
    background-color: var(--ai-primary-color) !important;
    color: white !important;
    border: none !important;
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    border-radius: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.ai-voice-btn {
    background-color: #f1f5f9 !important;
    color: #64748b !important;
}

.ai-voice-btn:hover {
    background-color: #e2e8f0 !important;
    color: var(--ai-primary-color) !important;
}

.ai-voice-btn.recording {
    background-color: #ef4444 !important;
    color: white !important;
    animation: ai-voice-pulse 1.5s infinite !important;
}

@keyframes ai-voice-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.ai-send-btn:disabled {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
}

.ai-voice-btn svg, .ai-send-btn svg {
    width: 18px !important;
    height: 18px !important;
}

/* Tablet & Mobile Responsiveness for AI Chat */
@media (max-width: 767.98px) {
    #ai-chat-window {
        position: absolute !important;
        right: 0 !important;
        left: auto !important;
        bottom: 0 !important;
        top: auto !important;
        width: calc(100vw - 30px) !important;
        max-width: 420px !important;
        height: min(580px, calc(100vh - 145px)) !important;
        height: min(580px, calc(100dvh - 145px)) !important;
        max-height: calc(100dvh - 145px) !important;
        transform-origin: bottom right !important;
        border-radius: 20px !important;
        z-index: 1000005 !important;
    }
    .ai-chat-header {
        padding: 10px 14px !important;
        min-height: 50px !important;
    }
    .ai-chat-title {
        font-size: 14px !important;
        gap: 8px !important;
    }
    .ai-chat-title span {
        font-size: 14px !important;
    }
    .ai-chat-header-actions button {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
    }
    .ai-chat-input-area {
        padding: 10px 12px !important;
        gap: 8px !important;
    }
    .ai-chat-input {
        padding: 8px 12px !important;
        font-size: 13.5px !important;
        min-height: 38px !important;
        height: 38px !important;
    }
    .ai-voice-btn, .ai-send-btn {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
    }
}

@media (max-width: 400px) {
    #ai-chat-window {
        position: absolute !important;
        right: 0 !important;
        left: auto !important;
        bottom: 0 !important;
        top: auto !important;
        width: calc(100vw - 30px) !important;
        max-width: calc(100vw - 30px) !important;
        height: min(560px, calc(100dvh - 140px)) !important;
        max-height: calc(100dvh - 140px) !important;
        border-radius: 16px !important;
        z-index: 1000005 !important;
    }
    .ai-chat-header {
        padding: 8px 10px !important;
        gap: 6px !important;
    }
    .ai-chat-title {
        font-size: 13px !important;
        gap: 6px !important;
    }
    .ai-chat-title span {
        font-size: 13px !important;
    }
    .ai-chat-logo {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px !important;
        min-height: 24px !important;
    }
    .ai-chat-header-actions {
        gap: 4px !important;
    }
    .ai-chat-header-actions button {
        width: 26px !important;
        height: 26px !important;
        min-width: 26px !important;
        min-height: 26px !important;
        border-radius: 6px !important;
    }
    .ai-chat-header-actions svg {
        width: 13px !important;
        height: 13px !important;
    }
    .ai-chat-input-area {
        padding: 8px 10px !important;
        gap: 6px !important;
    }
    .ai-chat-input {
        padding: 7px 10px !important;
        font-size: 13px !important;
        min-height: 36px !important;
        height: 36px !important;
        border-radius: 10px !important;
    }
    .ai-voice-btn, .ai-send-btn {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        min-height: 34px !important;
        border-radius: 8px !important;
    }
    .ai-voice-btn svg, .ai-send-btn svg {
        width: 16px !important;
        height: 16px !important;
    }
}
