/* ai-assistant.css - Modular AI Assistant Styles */

:root {
    --ai-primary: #8b5cf6;
    --ai-primary-hover: #7c3aed;
    --ai-gradient: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    --ai-bg-glass: rgba(15, 23, 42, 0.92);
    --ai-border: rgba(139, 92, 246, 0.3);
    --ai-shadow: 0 12px 36px rgba(0, 0, 0, 0.4), 0 0 24px rgba(139, 92, 246, 0.2);
}

/* Floating Trigger Button */
.ai-trigger-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9990;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--ai-bg-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--ai-border);
    border-radius: 9999px;
    color: #ffffff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--ai-shadow);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
}

.ai-trigger-btn:hover {
    transform: translateY(-2px) scale(1.02);
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(139, 92, 246, 0.35);
}

.ai-trigger-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Animated Sparkle Icon */
.ai-spark-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ai-spark-icon svg {
    width: 100%;
    height: 100%;
    fill: url(#aiSparkGrad);
    filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.8));
    animation: aiSparkPulse 2.8s infinite ease-in-out;
}

@keyframes aiSparkPulse {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.6));
    }
    50% {
        transform: scale(1.15) rotate(5deg);
        filter: drop-shadow(0 0 10px rgba(168, 85, 247, 0.95));
    }
}

/* Status Dot on Trigger */
.ai-trigger-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 6px #10b981;
}

/* AI Assistant Chat Card Window */
.ai-chat-window {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 400px;
    min-width: 360px;
    max-width: calc(100vw - 32px);
    height: 580px;
    min-height: 440px;
    max-height: calc(100vh - 100px);
    z-index: 9995;
    background: linear-gradient(180deg, rgba(20, 24, 43, 0.96) 0%, rgba(11, 15, 29, 0.98) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 35px rgba(139, 92, 246, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), width 0.22s ease, height 0.22s ease;
}

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

.ai-chat-window.resizing {
    transition: none !important;
    user-select: none !important;
}

.ai-chat-window.expanded {
    width: 780px !important;
    height: calc(100vh - 110px) !important;
    max-width: calc(100vw - 32px) !important;
}

/* Resize Handles */
.ai-resize-handle {
    position: absolute;
    z-index: 25;
}
.ai-resize-handle.top-left {
    top: 0;
    left: 0;
    width: 22px;
    height: 22px;
    cursor: nwse-resize;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ai-resize-handle.top-left::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    width: 9px;
    height: 9px;
    border-top: 2px solid rgba(168, 85, 247, 0.6);
    border-left: 2px solid rgba(168, 85, 247, 0.6);
    border-top-left-radius: 4px;
    transition: border-color 0.2s, transform 0.2s;
}
.ai-resize-handle.top-left:hover::after {
    border-color: #c084fc;
    transform: scale(1.3);
}
.ai-resize-handle.left {
    top: 22px;
    left: 0;
    bottom: 0;
    width: 8px;
    cursor: ew-resize;
}
.ai-resize-handle.top {
    top: 0;
    left: 22px;
    right: 0;
    height: 8px;
    cursor: ns-resize;
}

/* Header */
.ai-header {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

.ai-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-header-title {
    font-size: 0.96rem;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.2px;
    margin: 0;
}

.ai-header-badge {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 7px;
    border-radius: 9999px;
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

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

.ai-btn-icon {
    background: transparent;
    border: none;
    color: #94a3b8;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.15s, color 0.15s;
}

.ai-btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

/* Proactive Briefing Box */
.ai-briefing-box {
    margin: 12px 14px 8px 14px;
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12) 0%, rgba(99, 102, 241, 0.08) 100%);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 12px;
    font-size: 0.81rem;
    line-height: 1.45;
    color: #e2e8f0;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.ai-briefing-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Suggestion Chips */
.ai-chips-wrap {
    padding: 0 14px 10px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ai-chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    font-size: 0.74rem;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    text-align: left;
}

.ai-chip:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
    color: #f1f5f9;
    transform: translateY(-1px);
}

/* Chat Messages Stream */
.ai-messages-stream {
    flex: 1;
    padding: 10px 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.ai-messages-stream::-webkit-scrollbar {
    width: 5px;
}

.ai-messages-stream::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Message Bubbles */
.ai-msg {
    max-width: 86%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 0.82rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-msg.user {
    align-self: flex-end;
    background: var(--ai-gradient);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.ai-msg.assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 4px;
}

.ai-msg.assistant p {
    margin: 0 0 6px 0;
}

.ai-msg.assistant p:last-child {
    margin-bottom: 0;
}

.ai-msg.assistant ul, .ai-msg.assistant ol {
    margin: 4px 0 6px 0;
    padding-left: 18px;
}

.ai-msg.assistant strong {
    color: #ffffff;
}

/* Typing Indicator */
.ai-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
}

.ai-typing span {
    width: 6px;
    height: 6px;
    background: #8b5cf6;
    border-radius: 50%;
    animation: aiBlink 1.4s infinite both;
}

.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiBlink {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.1); }
}

/* Input Area */
.ai-input-area {
    padding: 10px 14px 14px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-input-field {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 9px 12px;
    color: #f8fafc;
    font-size: 0.83rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.ai-input-field:focus {
    border-color: rgba(139, 92, 246, 0.6);
    background: rgba(255, 255, 255, 0.09);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}

.ai-input-field::placeholder {
    color: #64748b;
}

.ai-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--ai-gradient);
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
    flex-shrink: 0;
}

.ai-send-btn:hover {
    transform: scale(1.05);
}

.ai-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.ai-mic-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.13);
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-mic-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #c084fc;
    border-color: rgba(168, 85, 247, 0.4);
    transform: scale(1.05);
}

.ai-mic-btn.recording {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
    animation: aiMicPulse 1.4s infinite ease-in-out;
}

@keyframes aiMicPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
        transform: scale(1.08);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
        transform: scale(1);
    }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .ai-chat-window {
        right: 12px;
        bottom: 74px;
        width: calc(100vw - 24px);
        height: calc(100vh - 90px);
    }
    .ai-trigger-btn {
        right: 16px;
        bottom: 16px;
        padding: 8px 14px;
        font-size: 0.8rem;
    }
}
