/* WP-AI-Nexus Chat Widget Styles */

:root {
    --ai-nexus-primary: #6366f1;
    --ai-nexus-primary-dark: #4f46e5;
    --ai-nexus-primary-light: #818cf8;
    --ai-nexus-secondary: #f1f5f9;
    --ai-nexus-text: #1e293b;
    --ai-nexus-text-light: #64748b;
    --ai-nexus-bg: #ffffff;
    --ai-nexus-bg-dark: #0f172a;
    --ai-nexus-border: #e2e8f0;
    --ai-nexus-success: #10b981;
    --ai-nexus-error: #ef4444;
    --ai-nexus-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --ai-nexus-shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --ai-nexus-radius: 16px;
    --ai-nexus-radius-sm: 8px;
}

/* Hide widget until Alpine.js initializes */
[x-cloak] { display: none !important; }

/* Floating Toggle Button */
.ai-nexus-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--ai-nexus-primary), var(--ai-nexus-primary-dark));
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--ai-nexus-shadow-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-nexus-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 20px 40px -8px rgba(99, 102, 241, 0.4);
}

.ai-nexus-toggle svg {
    width: 28px;
    height: 28px;
    fill: white;
    transition: transform 0.3s ease;
}

.ai-nexus-toggle img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 50%;
}

.ai-nexus-toggle[data-open="true"] svg:first-child {
    display: none;
}

.ai-nexus-toggle[data-open="false"] svg:nth-child(2) {
    display: none;
}

/* Chat Container */
.ai-nexus-chat {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 120px);
    background: var(--ai-nexus-bg);
    border-radius: var(--ai-nexus-radius);
    box-shadow: var(--ai-nexus-shadow-lg);
    overflow: hidden;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-nexus-chat[data-open="true"] {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Chat Header */
.ai-nexus-header {
    background: linear-gradient(135deg, var(--ai-nexus-primary), var(--ai-nexus-primary-dark));
    padding: 20px 24px;
    color: white;
    display: flex;
    align-items: center;
    gap: 14px;
}

.ai-nexus-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-nexus-avatar svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.ai-nexus-header-info {
    flex: 1;
}

.ai-nexus-header-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 2px 0;
}

.ai-nexus-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-nexus-status-dot {
    width: 8px;
    height: 8px;
    background: #34d399;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.ai-nexus-header-actions {
    display: flex;
    gap: 8px;
}

.ai-nexus-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-nexus-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.ai-nexus-header-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Messages Container */
.ai-nexus-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #fafbfc;
    min-height: 300px;
    max-height: 400px;
}

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

.ai-nexus-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-nexus-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Message Bubbles */
.ai-nexus-message {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    animation: fadeInUp 0.3s ease;
}

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

.ai-nexus-message.user {
    flex-direction: row-reverse;
}

.ai-nexus-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-nexus-message.user .ai-nexus-message-avatar {
    background: linear-gradient(135deg, var(--ai-nexus-primary), var(--ai-nexus-primary-dark));
}

.ai-nexus-message.bot .ai-nexus-message-avatar {
    background: #e2e8f0;
}

.ai-nexus-message-avatar svg {
    width: 16px;
    height: 16px;
}

.ai-nexus-message.user .ai-nexus-message-avatar svg {
    fill: white;
}

.ai-nexus-message.bot .ai-nexus-message-avatar svg {
    fill: var(--ai-nexus-text-light);
}

.ai-nexus-message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-nexus-message.user .ai-nexus-message-bubble {
    background: linear-gradient(135deg, var(--ai-nexus-primary), var(--ai-nexus-primary-dark));
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-nexus-message.bot .ai-nexus-message-bubble {
    background: white;
    color: var(--ai-nexus-text);
    border: 1px solid var(--ai-nexus-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ai-nexus-message.bot.error .ai-nexus-message-bubble {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--ai-nexus-error);
}

.ai-nexus-message-time {
    font-size: 10px;
    color: var(--ai-nexus-text-light);
    margin-top: 4px;
    text-align: right;
}

/* Typing Indicator */
.ai-nexus-typing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
}

.ai-nexus-typing-dots {
    display: flex;
    gap: 4px;
}

.ai-nexus-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--ai-nexus-text-light);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.ai-nexus-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-nexus-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.ai-nexus-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid var(--ai-nexus-border);
}

.ai-nexus-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--ai-nexus-secondary);
    border-radius: 24px;
    padding: 8px 8px 8px 20px;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.ai-nexus-input-wrapper:focus-within {
    background: white;
    border-color: var(--ai-nexus-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.ai-nexus-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--ai-nexus-text);
    outline: none;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
}

.ai-nexus-input::placeholder {
    color: var(--ai-nexus-text-light);
}

.ai-nexus-send-btn {
    width: 40px;
    height: 40px;
    background: var(--ai-nexus-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-nexus-send-btn:hover {
    background: var(--ai-nexus-primary-dark);
    transform: scale(1.05);
}

.ai-nexus-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.ai-nexus-send-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
    margin-left: 2px;
}

/* Welcome Message */
.ai-nexus-welcome {
    text-align: center;
    padding: 40px 20px;
    color: var(--ai-nexus-text-light);
}

.ai-nexus-welcome-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--ai-nexus-primary-light), var(--ai-nexus-primary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-nexus-welcome-icon svg {
    width: 32px;
    height: 32px;
    fill: white;
}

.ai-nexus-welcome h3 {
    font-size: 18px;
    color: var(--ai-nexus-text);
    margin: 0 0 8px;
}

.ai-nexus-welcome p {
    font-size: 14px;
    margin: 0;
    line-height: 1.5;
}

/* Responsive Design */
@media (max-width: 480px) {
    .ai-nexus-toggle {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .ai-nexus-chat {
        bottom: 84px;
        right: 16px;
        left: 16px;
        width: auto;
        max-height: calc(100vh - 100px);
    }

    .ai-nexus-header {
        padding: 16px 20px;
    }

    .ai-nexus-messages {
        padding: 16px;
        min-height: 250px;
    }

    .ai-nexus-message-bubble {
        max-width: 85%;
        padding: 10px 14px;
    }

    .ai-nexus-input-area {
        padding: 12px 16px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .ai-nexus-chat {
        background: var(--ai-nexus-bg-dark);
    }

    .ai-nexus-messages {
        background: #1e293b;
    }

    .ai-nexus-message.bot .ai-nexus-message-bubble {
        background: #334155;
        border-color: #475569;
        color: #f1f5f9;
    }

    .ai-nexus-input-area {
        background: #1e293b;
        border-top-color: #475569;
    }

    .ai-nexus-input-wrapper {
        background: #334155;
    }

    .ai-nexus-input {
        color: #f1f5f9;
    }

    .ai-nexus-input::placeholder {
        color: #94a3b8;
    }

    .ai-nexus-message-time {
        color: #94a3b8;
    }
}