.ai-chat-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 1000;
    overflow: hidden;
}

.ai-chat-icon::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
    filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.ai-chat-icon:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #4f46e5, #9333ea, #db2777);
}

.ai-chat-icon:hover::before {
    opacity: 0.4;
}

.ai-chat-icon:active {
    transform: translateY(0) scale(0.95);
}

.ai-chat-icon i {
    color: white;
    font-size: 24px;
}

.ai-chat-box {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 550px;
    height: 700px;
    background-color: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    border: 1px solid rgba(99, 102, 241, 0.1);
}

.ai-chat-header {
    padding: 18px 24px;
    background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
    color: white;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ai-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.ai-chat-messages {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
    background-color: #f8fafc;
    background-image: 
        radial-gradient(circle at 25px 25px, rgba(99, 102, 241, 0.03) 2%, transparent 0%),
        radial-gradient(circle at 75px 75px, rgba(168, 85, 247, 0.03) 2%, transparent 0%);
    background-size: 100px 100px;
}

.user-message, .ai-message {
    margin-bottom: 20px;
    padding: 16px 20px;
    border-radius: 16px;
    max-width: 85%;
    line-height: 1.5;
    font-size: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
}

.user-message {
    background-color: #a855f7;
    color: white;
    margin-left: auto;
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.15);
}

.ai-message {
    background: white;
    color: #1e293b;
    font-size: 14px;
    line-height: 1.6;
    border: 1px solid rgba(99, 102, 241, 0.1);
}

/* Headers in AI messages */
.ai-message .ai-chat-h1,
.ai-message .ai-chat-h2,
.ai-message .ai-chat-h3 {
    color: #2d3e50;
    font-weight: 600;
    margin: 1em 0 0.5em;
    line-height: 1.3;
}

/* Paragraphs */
.ai-message p {
    margin: 0.5em 0;
}

.ai-message p + p {
    margin-top: 1em;
}

/* Message divider */
.ai-message .message-divider {
    border: none;
    border-top: 1px solid #cbd5e1;
    margin: 1em 0;
}

/* Lists */
.ai-message ul,
.ai-message ol {
    margin: 0.25em 0;
    padding-left: 1.25em;
}

.ai-message li {
    margin: 0.15em 0;
    padding: 0.1em 0;
    line-height: 1.5;
    position: relative;
}

/* Top-level numbered items get card treatment */
.ai-message > ol > li {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-left: 3px solid #a855f7;
    border-radius: 8px;
    padding: 0.75em 1em;
    margin: 0.5em 0;
    list-style-position: inside;
}

.ai-message > ol > li strong:first-child {
    color: #6366f1;
    font-size: 0.95em;
}

/* Nested lists inside cards */
.ai-message > ol > li > ul {
    margin-top: 0.5em;
    margin-bottom: 0.25em;
    padding-left: 1em;
    border-left: 2px solid #e2e8f0;
}

/* List levels */
.ai-message .list-level-0 {
    margin-left: 0;
}

.ai-message .list-level-1 {
    margin-left: 1em;
}

.ai-message .list-level-2 {
    margin-left: 2em;
}

/* Nested lists - tighter spacing */
.ai-message ul ul,
.ai-message ul ol,
.ai-message ol ul,
.ai-message ol ol {
    margin: 0.1em 0;
    padding-left: 1.25em;
}

/* List bullet styles */
.ai-message ul > li {
    list-style-type: disc;
}

.ai-message ul ul > li {
    list-style-type: circle;
}

.ai-message ul ul ul > li {
    list-style-type: square;
}

.ai-message ol > li {
    list-style-type: decimal;
}

.ai-message ol ol > li {
    list-style-type: lower-alpha;
}

.ai-message ol ol ol > li {
    list-style-type: lower-roman;
}

/* Spacing between list items - minimal */
.ai-message li + li {
    margin-top: 0.1em;
}

/* Ensure proper spacing after lists */
.ai-message ul + p,
.ai-message ol + p {
    margin-top: 1em;
}

/* Handle transitions between list types */
.ai-message ol + ul,
.ai-message ul + ol {
    margin-top: 0.5em;
}

/* Remove old list level classes that are no longer used */
.ai-message .list-level-0,
.ai-message .list-level-1,
.ai-message .list-level-2,
.ai-message .nested-list {
    margin: inherit;
    padding: inherit;
}

/* Spacing after headings */
.ai-message .ai-chat-h3 + ol,
.ai-message .ai-chat-h3 + ul {
    margin-top: 0.5em;
}

/* Code blocks */
.ai-message code {
    background-color: #cbd5e1;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.ai-message pre {
    background-color: #cbd5e1;
    padding: 1em;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.75em 0;
}

.ai-message pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 0.9em;
    color: #2d3e50;
}

/* Links */
.ai-message a {
    color: #f97316;
    text-decoration: none;
    border-bottom: 1px dotted #f97316;
}

.ai-message a:hover {
    border-bottom-style: solid;
}

/* Bold and Italic */
.ai-message strong {
    font-weight: 600;
    color: #1e293b;
}

.ai-message em {
    font-style: italic;
}

.ai-chat-input {
    padding: 20px 24px;
    border-top: 1px solid rgba(99, 102, 241, 0.1);
    display: flex;
    gap: 12px;
    background-color: white;
    border-radius: 0 0 16px 16px;
    align-items: center;
}

.ai-chat-input textarea {
    flex-grow: 1;
    padding: 14px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    resize: none;
    height: 60px;
    font-size: 15px;
    line-height: 1.4;
    transition: all 0.3s ease;
    background-color: #f8fafc;
}

.ai-chat-input textarea:focus {
    outline: none;
    border-color: #6366f1;
    background-color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.ai-send-button {
    background-color: #a855f7;
    color: white;
    border: none;
    border-radius: 12px;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.15);
}

.ai-send-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.2);
    background-color: #9333ea;
}

.ai-send-button:active {
    transform: translateY(0);
}

/* Typing indicator */
.typing-indicator {
    display: none;
    margin: 10px 0;
    width: auto;
    max-width: 85%;
    margin-right: auto;
}

.typing-indicator-content {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeIn 0.3s ease-in;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.1);
}

.typing-indicator-text {
    color: #1e293b;
    font-size: 14px;
    font-weight: 500;
    opacity: 0.8;
}

.typing-indicator-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.typing-indicator-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
    opacity: 0.7;
}

.typing-indicator-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% { 
        transform: translateY(0);
        opacity: 0.4;
    }
    40% { 
        transform: translateY(-6px);
        opacity: 1;
    }
}

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

/* Disabled state styles */
.ai-send-button:disabled,
.ai-chat-input textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Streaming message styles */
.ai-message.streaming {
    min-height: 40px;
}

.streaming-cursor {
    display: inline;
    animation: blink 0.8s infinite;
    color: #a855f7;
    font-weight: bold;
    margin-left: 2px;
}

@keyframes blink {
    0%, 40% { opacity: 1; }
    41%, 100% { opacity: 0; }
}

/* Smooth scroll behavior for chat messages */
.ai-chat-messages {
    scroll-behavior: smooth;
}

/* Smooth open/close animation for chat box */
.ai-chat-box {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s ease-out, transform 0.25s ease-out;
}

.ai-chat-box.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}