#ai-assistant-wrap {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#ai-assistant-badge {
    position: fixed;
    bottom: 92px;
    right: 24px;
    background: var(--ai-primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    font-family: system-ui, sans-serif;
    padding: 6px 12px;
    border-radius: 999px;
    z-index: 10001;
    pointer-events: none;
    white-space: nowrap;
    letter-spacing: .4px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, .4);
    transition: opacity .4s ease, transform .4s cubic-bezier(.175, .885, .32, 1.275);
    opacity: 0;
    transform: translateY(10px);
}

#ai-assistant-badge.is-visible {
    opacity: 1;
    transform: translateY(0);
    animation: ai-wiggle 2s ease infinite;
}

@keyframes ai-wiggle {

    0%,
    100% {
        transform: rotate(0deg);
    }

    10%,
    30% {
        transform: rotate(-3deg);
    }

    20%,
    40% {
        transform: rotate(3deg);
    }

    50% {
        transform: rotate(0deg);
    }
}

/* FAB */
#ai-assistant-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--ai-primary);
    box-shadow: 0 6px 20px rgba(99, 102, 241, .45);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.2s;
    outline: none;
}

#ai-assistant-fab:hover {
    transform: scale(1.1);
}

#ai-assistant-fab .ai-fab-icon {
    font-size: 30px;
    color: white;
}

#ai-assistant-fab .ai-fab-close {
    font-size: 24px;
    color: white;
    display: none;
}

#ai-assistant-fab.active .ai-fab-icon {
    display: none;
}

#ai-assistant-fab.active .ai-fab-close {
    display: block;
}

/* Panel */
#ai-assistant-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#ai-assistant-panel.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Header */
#ai-assistant-header {
    background: var(--ai-primary);
    padding: 16px 18px;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-header-avatar {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.ai-header-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.ai-header-info p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
}

.ai-status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    margin-right: 6px;
}

/* Messages */
#ai-assistant-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8f7ff;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: none;
}

#ai-assistant-messages::-webkit-scrollbar {
    display: none;
}

.ai-msg {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ai-msg.bot {
    background: #fff;
    color: #1e1b4b;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ai-msg.user {
    background: var(--ai-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Markdown specific styles */
.ai-msg.bot strong {
    font-weight: 700;
}

.ai-msg.bot a {
    color: var(--ai-primary);
    text-decoration: underline;
}

.ai-msg.bot ul {
    padding-left: 20px;
    margin: 8px 0;
}

/* Typing indicator */
#ai-assistant-typing {
    display: none;
    align-self: flex-start;
    padding: 12px 16px;
    background: #fff;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    gap: 4px;
}

#ai-assistant-typing span {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: ai-typing 1.4s infinite ease-in-out;
}

#ai-assistant-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

#ai-assistant-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes ai-typing {

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

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

/* Chips */
#ai-assistant-chips {
    padding: 10px 15px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    background: #fff;
    border-top: 1px solid #f3f4f6;
}

#ai-assistant-chips::-webkit-scrollbar {
    display: none;
}

.ai-chip {
    padding: 8px 14px;
    background: #ffffff;
    color: var(--ai-primary);
    border: 1px solid var(--ai-primary);
    border-radius: 24px;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-chip:hover {
    background: var(--ai-primary);
    color: white;
}

/* Input Area */
#ai-assistant-input-area {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #f3f4f6;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#ai-assistant-input {
    flex: 1;
    border: 1.5px solid #ede9fe;
    border-radius: 20px;
    padding: 8px 15px;
    font-size: 13.5px;
    color: #1e1b4b;
    background: #f8f7ff;
    resize: none;
    min-height: 38px;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s;
    margin: 0;
}

#ai-assistant-input:focus {
    border-color: var(--ai-primary);
}

#ai-assistant-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--ai-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s;
}

#ai-assistant-send:hover {
    transform: scale(1.1);
}

#ai-assistant-send svg {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    margin-left: 2px; /* Slight optical adjustment for the paper plane icon */
}

/* Footer */
#ai-assistant-footer {
    padding: 10px;
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    background: #fff;
}

/* Responsive */
@media (max-width: 480px) {
    #ai-assistant-wrap {
        right: 16px;
        bottom: 16px;
    }
    #ai-assistant-panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        bottom: 75px;
        right: 0;
    }
}