/* =========================================================================
   AI CHAT WIDGET STYLES
   ========================================================================= */

/* Floating Action Button */
#ai-chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5), 0 0 60px rgba(139, 92, 246, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fabPulse 3s ease-in-out infinite;
}

#ai-chat-fab:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.6), 0 0 80px rgba(139, 92, 246, 0.3);
}

@keyframes fabPulse {
    0%, 100% { box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5), 0 0 0 0 rgba(139, 92, 246, 0.4); }
    50% { box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5), 0 0 0 12px rgba(139, 92, 246, 0); }
}

/* Chat Panel */
#ai-chat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: rgba(15, 23, 42, 0.97);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 999;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(139, 92, 246, 0.1);
    animation: chatSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

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

/* Chat Header */
.ai-chat-header {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.15));
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-chat-header h3 {
    font-size: 0.85rem;
    font-weight: 800;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-chat-header-actions {
    display: flex;
    gap: 0.3rem;
}

.ai-chat-header-actions button {
    width: 28px;
    height: 28px;
    border-radius: 0.5rem;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-header-actions button:hover {
    background: rgba(139, 92, 246, 0.3);
    color: #a5b4fc;
}

/* Provider Toggle (hidden - Gemini only now) */
.ai-provider-toggle { display: none; }

/* Chat View must be flex child to allow messages to scroll */
#ai-chat-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.ai-provider-btn {
    flex: 1;
    padding: 0.4rem 0.75rem;
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 0.5rem;
    background: transparent;
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.ai-provider-btn:hover {
    border-color: rgba(139, 92, 246, 0.4);
    color: #a5b4fc;
}

.ai-provider-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(168, 85, 247, 0.3));
    border-color: rgba(139, 92, 246, 0.5);
    color: #e2e8f0;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.2);
}

/* Messages Area */
#ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

#ai-chat-messages::-webkit-scrollbar { width: 4px; }
#ai-chat-messages::-webkit-scrollbar-track { background: transparent; }
#ai-chat-messages::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.3); border-radius: 99px; }

.ai-msg {
    max-width: 85%;
    padding: 0.6rem 0.9rem;
    border-radius: 1rem;
    font-size: 0.78rem;
    line-height: 1.5;
    word-break: break-word;
    animation: msgIn 0.3s ease-out;
    user-select: text;
    flex-shrink: 0;
}

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

.ai-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-bottom-right-radius: 0.25rem;
    cursor: pointer;
    position: relative;
}

.ai-msg-user:hover::after {
    content: '✏️';
    position: absolute;
    top: -6px;
    left: -6px;
    font-size: 0.6rem;
    background: rgba(15, 23, 42, 0.9);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-msg-assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-bottom-left-radius: 0.25rem;
}

.ai-msg-system {
    align-self: center;
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
    font-size: 0.7rem;
    text-align: center;
    max-width: 95%;
}

.ai-msg code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.1rem 0.3rem;
    border-radius: 0.25rem;
    font-size: 0.72rem;
}

.typing-indicator {
    animation: blink 1.2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Input Area */
.ai-chat-input-area {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.2);
}

#ai-chat-input {
    flex: 1;
    padding: 0.6rem 0.9rem;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 0.75rem;
    background: rgba(15, 23, 42, 0.6);
    color: #e2e8f0;
    font-size: 0.8rem;
    outline: none;
    transition: all 0.2s;
}

#ai-chat-input:focus {
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

#ai-chat-input::placeholder {
    color: #475569;
}

.ai-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 0.75rem;
    border: none;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.ai-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* Settings Panel */
#ai-settings-panel {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

#ai-settings-panel h4 {
    font-size: 0.8rem;
    font-weight: 800;
    color: #e2e8f0;
    margin-bottom: 0.25rem;
}

#ai-settings-panel label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    display: block;
    margin-bottom: 0.3rem;
}

#ai-settings-panel input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 0.6rem;
    background: rgba(15, 23, 42, 0.6);
    color: #e2e8f0;
    font-size: 0.75rem;
    outline: none;
    font-family: monospace;
}

#ai-settings-panel input:focus {
    border-color: rgba(139, 92, 246, 0.6);
}

.ai-settings-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
}

.ai-settings-actions button {
    flex: 1;
    padding: 0.6rem;
    border: none;
    border-radius: 0.6rem;
    font-size: 0.7rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-settings-save {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
}

.ai-settings-cancel {
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}
