.ai-chat-trigger-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(67, 97, 238, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted);
    border: 1px solid rgba(67, 97, 238, 0.1);
    padding: 0;
    cursor: pointer;
}

.ai-chat-trigger:hover {
    background: rgba(67, 97, 238, 0.12);
    transform: scale(1.08);
    box-shadow: 0 0 15px rgba(67, 97, 238, 0.3);
}

.ai-chat-trigger i {
    font-size: 1.2rem;
    background: linear-gradient(135deg, #4361ee, #7209b7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ai-status-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
    transition: background-color 0.3s;
}

.ai-status-indicator.online {
    background-color: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: status-pulse 2s infinite;
}

.ai-status-indicator.offline {
    background-color: #94a3b8;
    box-shadow: none;
}

@keyframes status-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Chat Widget Container */
.ai-chat-widget {
    position: fixed;
    top: 70px;
    right: 0;
    width: 380px;
    height: calc(100vh - 70px);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px 0 0 20px;
    box-shadow: -5px 0 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-chat-widget.active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.ai-chat-widget.minimized {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}

/* Header */
.ai-chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.95), rgba(114, 9, 183, 0.95));
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    user-select: none;
}

.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-avatar {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-avatar i {
    font-size: 1rem;
    color: white;
}

.ai-chat-avatar-glow {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    animation: avatar-spin 6s linear infinite;
}

@keyframes avatar-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.ai-chat-title-group h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    line-height: 1.2;
}

.ai-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    opacity: 0.85;
    margin-top: 2px;
}

.ai-chat-status .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #e2e8f0;
}

.ai-chat-status .status-dot.online {
    background-color: #4ade80;
    box-shadow: 0 0 4px #4ade80;
}

.ai-chat-status .status-dot.offline {
    background-color: #94a3b8;
}

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

.chat-action-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Chat Messages */
.ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: rgba(248, 250, 252, 0.5);
}

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

.ai-chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.08);
    border-radius: 4px;
}

.ai-chat-widget.minimized .ai-chat-messages,
.ai-chat-widget.minimized .ai-chat-suggestions,
.ai-chat-widget.minimized .ai-chat-input-area {
    display: none !important;
}

/* Message Bubbles */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: message-appear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes message-appear {
    0% {
        transform: translateY(10px) scale(0.96);
        opacity: 0;
    }

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

.chat-message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-message.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.45;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    word-break: break-word;
}

.chat-message.user .message-bubble {
    background: linear-gradient(135deg, #4361ee, #4895ef);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-bubble {
    background: var(--bg-card);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.chat-message.assistant .message-bubble p {
    margin-bottom: 8px;
}

.chat-message.assistant .message-bubble p:last-child {
    margin-bottom: 0;
}

.chat-message.assistant .message-bubble ul,
.chat-message.assistant .message-bubble ol {
    margin-left: 20px;
    margin-bottom: 8px;
}

.chat-message.assistant .message-bubble strong {
    font-weight: 600;
}

/* Message Meta & Speaker Action */
.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.message-audio-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
}

.message-audio-btn:hover {
    color: var(--primary-color);
    background: rgba(67, 97, 238, 0.08);
}

.message-audio-btn.speaking {
    color: var(--success);
    background: rgba(16, 185, 129, 0.08);
    animation: speaker-pulse 1s infinite alternate;
}

@keyframes speaker-pulse {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(1.05);
    }
}

/* Suggestions Area */
.ai-chat-suggestions {
    padding: 0 20px 12px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: rgba(248, 250, 252, 0.5);
}

.suggestion-pill {
    background: rgba(67, 97, 238, 0.06);
    border: 1px solid rgba(67, 97, 238, 0.12);
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 100%;
}

.suggestion-pill:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.2);
}

.clear-chat-pill {
    background: rgba(239, 68, 68, 0.06) !important;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
    color: #ef4444 !important;
}

.clear-chat-pill:hover {
    background: #ef4444 !important;
    color: white !important;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2) !important;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    opacity: 0.4;
    animation: typing-dot-bounce 1.4s infinite;
}

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

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

@keyframes typing-dot-bounce {

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

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

/* Input Area */
.ai-chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    display: flex;
    gap: 12px;
    align-items: center;
}

.ai-chat-input-area input {
    flex: 1;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    padding: 10px 16px;
    border-radius: 24px;
    font-size: 0.88rem;
    font-family: inherit;
    color: var(--text-main);
    transition: all 0.2s;
}

.ai-chat-input-area input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.ai-chat-send-btn {
    background: linear-gradient(135deg, #4361ee, #7209b7);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.25);
    padding: 0;
}

.ai-chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 14px rgba(67, 97, 238, 0.35);
}

.ai-chat-send-btn:active {
    transform: scale(0.95);
}

.ai-chat-send-btn i {
    font-size: 0.95rem;
}

.ai-chat-handsfree-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.ai-chat-handsfree-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.ai-chat-handsfree-btn i {
    font-size: 1.1rem;
}

/* Hands Free Pulse Animation */
#ai-chat-handsfree-toggle.listening {
    color: #ef4444 !important;
    animation: mic-pulse 1.5s infinite alternate;
}

@keyframes mic-pulse {
    0% {
        transform: scale(1);
        text-shadow: 0 0 0 rgba(239, 68, 68, 0);
    }
    100% {
        transform: scale(1.15);
        text-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
    }
}
