/* AIVC - AI VDC Chat - Premium Frontend Design */
/* ChatGPT/Claude inspired - Modern AI Assistant */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Premium Color Palette */
    --aivc-bg-primary: #ffffff;
    --aivc-bg-secondary: #f8fafc;
    --aivc-bg-tertiary: #f1f5f9;
    --aivc-bg-dark: #0f172a;
    --aivc-bg-dark-secondary: #1e293b;
    --aivc-bg-dark-tertiary: #334155;
    
    /* Text Colors */
    --aivc-text-primary: #0f172a;
    --aivc-text-secondary: #64748b;
    --aivc-text-muted: #94a3b8;
    --aivc-text-accent: #ffffff;
    --aivc-text-dark: #f8fafc;
    
    /* Accent Colors */
    --aivc-accent-blue: #3B82F6;
    --aivc-accent-blue-dark: #2563EB;
    --aivc-accent-green: #22c55e;
    --aivc-accent-purple: #8b5cf6;
    --aivc-accent-orange: #f59e0b;
    --aivc-accent-red: #ef4444;
    --aivc-accent-cyan: #22d3ee;
    
    /* Gradients */
    --aivc-gradient-primary: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    --aivc-gradient-secondary: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    --aivc-gradient-accent: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --aivc-gradient-glow: linear-gradient(135deg, #3B82F6 0%, #22d3ee 100%);
    --aivc-gradient-chat: linear-gradient(135deg, #3B82F6 0%, #8b5cf6 100%);
    
    /* Shadows & Effects */
    --aivc-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --aivc-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --aivc-shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --aivc-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --aivc-shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --aivc-shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);
    --aivc-shadow-glow-green: 0 0 20px rgba(34, 197, 94, 0.3);
    
    /* Border Radius */
    --aivc-radius-sm: 6px;
    --aivc-radius: 12px;
    --aivc-radius-lg: 16px;
    --aivc-radius-xl: 20px;
    --aivc-radius-full: 50%;
    
    /* Spacing */
    --aivc-space-xs: 4px;
    --aivc-space-sm: 8px;
    --aivc-space-md: 16px;
    --aivc-space-lg: 24px;
    --aivc-space-xl: 32px;
    
    /* Transitions */
    --aivc-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --aivc-transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --aivc-transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 0;
}

/* Floating Action Button (FAB) */
.aivc-chat-toggle {
    position: fixed;
    bottom: var(--aivc-space-xl);
    right: var(--aivc-space-xl);
    width: 64px;
    height: 64px;
    background: var(--aivc-gradient-glow);
    border: none;
    border-radius: var(--aivc-radius-full);
    color: var(--aivc-text-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999998;
    box-shadow: var(--aivc-shadow-xl);
    transition: var(--aivc-transition);
    font-size: 1.5rem;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.aivc-chat-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--aivc-gradient-glow);
    border-radius: var(--aivc-radius-full);
    opacity: 0;
    transition: var(--aivc-transition);
    animation: aivc-pulse-glow 2s infinite;
}

@keyframes aivc-pulse-glow {
    0%, 100% { 
        opacity: 0;
        transform: scale(1);
    }
    50% { 
        opacity: 0.3;
        transform: scale(1.1);
    }
}

.aivc-chat-toggle:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: var(--aivc-shadow-glow);
}

.aivc-chat-toggle:hover::before {
    opacity: 0.2;
}

.aivc-chat-toggle.active {
    background: var(--aivc-gradient-accent);
    transform: rotate(45deg) scale(1.1);
}

.aivc-chat-toggle.active:hover {
    transform: rotate(45deg) scale(1.2) translateY(-2px);
}

/* Notification Badge */
.aivc-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: var(--aivc-accent-green);
    border-radius: var(--aivc-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: white;
    font-weight: 600;
    animation: aivc-badge-pulse 1s infinite;
    box-shadow: var(--aivc-shadow-glow-green);
}

@keyframes aivc-badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Chat Widget */
.aivc-chat-widget {
    position: fixed;
    bottom: var(--aivc-space-xl);
    right: var(--aivc-space-xl);
    width: 400px;
    height: 600px;
    background: var(--aivc-bg-primary);
    border-radius: var(--aivc-radius-xl);
    box-shadow: var(--aivc-shadow-xl);
    display: none;
    flex-direction: column;
    z-index: 999999;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(20px);
    animation: aivc-chat-appear 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.aivc-chat-widget.aivc-open {
    display: flex;
}

@keyframes aivc-chat-appear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Chat Header */
.aivc-chat-header {
    background: var(--aivc-gradient-chat);
    color: var(--aivc-text-accent);
    padding: var(--aivc-space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.aivc-chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
}

.aivc-chat-header-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    flex: 1;
}

.aivc-chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--aivc-radius-full);
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: var(--aivc-space-md);
    font-size: 1.3rem;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    animation: aivc-avatar-float 3s ease-in-out infinite;
}

@keyframes aivc-avatar-float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
}

.aivc-chat-info h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.2;
}

.aivc-chat-info p {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.9;
    line-height: 1.2;
}

.aivc-chat-controls {
    position: relative;
    z-index: 1;
    display: flex;
    gap: var(--aivc-space-sm);
}

.aivc-chat-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--aivc-radius);
    background: rgba(255, 255, 255, 0.2);
    color: var(--aivc-text-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--aivc-transition);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.aivc-chat-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Chat Messages */
.aivc-chat-messages {
    flex: 1;
    padding: var(--aivc-space-lg);
    overflow-y: auto;
    background: var(--aivc-bg-secondary);
    display: flex;
    flex-direction: column;
    gap: var(--aivc-space-lg);
}

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

.aivc-chat-messages::-webkit-scrollbar-track {
    background: var(--aivc-bg-tertiary);
    border-radius: var(--aivc-radius);
}

.aivc-chat-messages::-webkit-scrollbar-thumb {
    background: var(--aivc-accent-blue);
    border-radius: var(--aivc-radius);
}

.aivc-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--aivc-accent-blue-dark);
}

/* Message Styles */
.aivc-message {
    display: flex;
    gap: var(--aivc-space-md);
    animation: aivc-message-appear 0.4s ease-out;
}

@keyframes aivc-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.aivc-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--aivc-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    font-weight: 600;
}

.aivc-message-bot .aivc-message-avatar {
    background: var(--aivc-gradient-primary);
    color: var(--aivc-text-accent);
    box-shadow: var(--aivc-shadow-glow);
}

.aivc-message-user .aivc-message-avatar {
    background: var(--aivc-gradient-secondary);
    color: var(--aivc-text-accent);
}

.aivc-message-content {
    flex: 1;
    max-width: 80%;
}

.aivc-message-bubble {
    background: var(--aivc-bg-primary);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--aivc-radius-lg);
    padding: var(--aivc-space-md) var(--aivc-space-lg);
    box-shadow: var(--aivc-shadow);
    position: relative;
    transition: var(--aivc-transition);
}

.aivc-message-bubble:hover {
    box-shadow: var(--aivc-shadow-md);
}

.aivc-message-user .aivc-message-bubble {
    background: var(--aivc-gradient-primary);
    color: var(--aivc-text-accent);
    border-color: var(--aivc-accent-blue-dark);
}

.aivc-message-bubble::before {
    content: '';
    position: absolute;
    top: 12px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
}

.aivc-message-bot .aivc-message-bubble::before {
    left: -16px;
    border-right-color: var(--aivc-bg-primary);
    border-left: none;
}

.aivc-message-user .aivc-message-bubble::before {
    right: -16px;
    border-left-color: var(--aivc-accent-blue-dark);
    border-right: none;
}

.aivc-message-text {
    margin: 0;
    word-wrap: break-word;
    line-height: 1.5;
}

.aivc-message-text a {
    color: var(--aivc-accent-blue);
    text-decoration: none;
    font-weight: 500;
}

.aivc-message-text a:hover {
    text-decoration: underline;
}

.aivc-message-user .aivc-message-text a {
    color: var(--aivc-text-accent);
    opacity: 0.9;
}

/* Source Cards */
.aivc-sources {
    margin-top: var(--aivc-space-md);
}

.aivc-sources-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--aivc-text-secondary);
    margin: 0 0 var(--aivc-space-sm) 0;
    display: flex;
    align-items: center;
    gap: var(--aivc-space-sm);
}

.aivc-sources-title::before {
    content: '📚';
    font-size: 1rem;
}

.aivc-source-card {
    background: var(--aivc-bg-primary);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--aivc-radius);
    padding: var(--aivc-space-md);
    margin-bottom: var(--aivc-space-sm);
    transition: var(--aivc-transition);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.aivc-source-card:hover {
    background: var(--aivc-bg-tertiary);
    box-shadow: var(--aivc-shadow-md);
    transform: translateY(-2px);
    border-color: var(--aivc-accent-blue);
}

.aivc-source-card:last-child {
    margin-bottom: 0;
}

.aivc-source-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--aivc-text-primary);
    margin: 0 0 var(--aivc-space-sm) 0;
    display: flex;
    align-items: center;
    gap: var(--aivc-space-sm);
}

.aivc-source-title::before {
    content: '📄';
    font-size: 1rem;
}

.aivc-source-snippet {
    font-size: 0.85rem;
    color: var(--aivc-text-secondary);
    line-height: 1.4;
    margin: 0;
}

.aivc-source-snippet mark {
    background: rgba(59, 130, 246, 0.2);
    color: var(--aivc-accent-blue);
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
    font-weight: 500;
}

.aivc-source-meta {
    display: flex;
    align-items: center;
    gap: var(--aivc-space-md);
    margin-top: var(--aivc-space-sm);
    font-size: 0.75rem;
    color: var(--aivc-text-muted);
}

.aivc-source-date {
    display: flex;
    align-items: center;
    gap: var(--aivc-space-xs);
}

.aivc-source-date::before {
    content: '📅';
}

/* Chat Input */
.aivc-chat-input-container {
    padding: var(--aivc-space-lg);
    background: var(--aivc-bg-primary);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    gap: var(--aivc-space-md);
    align-items: flex-end;
}

.aivc-chat-input {
    flex: 1;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--aivc-radius-lg);
    padding: var(--aivc-space-md) var(--aivc-space-lg);
    font-size: 0.9rem;
    resize: none;
    min-height: 48px;
    max-height: 120px;
    transition: var(--aivc-transition);
    background: var(--aivc-bg-primary);
    font-family: inherit;
    line-height: 1.4;
}

.aivc-chat-input:focus {
    outline: none;
    border-color: var(--aivc-accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.aivc-chat-input::placeholder {
    color: var(--aivc-text-muted);
}

.aivc-chat-send {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: var(--aivc-radius-lg);
    background: var(--aivc-gradient-primary);
    color: var(--aivc-text-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--aivc-transition);
    flex-shrink: 0;
    font-size: 1.1rem;
    box-shadow: var(--aivc-shadow);
}

.aivc-chat-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--aivc-shadow-glow);
}

.aivc-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Typing Indicator */
.aivc-typing-indicator {
    display: flex;
    align-items: center;
    gap: var(--aivc-space-md);
    padding: var(--aivc-space-md) var(--aivc-space-lg);
    background: var(--aivc-bg-primary);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--aivc-radius-lg);
    margin-bottom: var(--aivc-space-lg);
    box-shadow: var(--aivc-shadow-sm);
}

.aivc-typing-dots {
    display: flex;
    gap: var(--aivc-space-xs);
}

.aivc-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--aivc-radius-full);
    background: var(--aivc-accent-blue);
    animation: aivc-typing-dot 1.4s infinite ease-in-out;
}

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

@keyframes aivc-typing-dot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 480px) {
    .aivc-chat-widget {
        width: calc(100vw - 2rem);
        height: calc(100vh - 2rem);
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        top: 1rem;
        border-radius: var(--aivc-radius-lg);
    }
    
    .aivc-chat-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 56px;
        height: 56px;
    }
    
    .aivc-message-content {
        max-width: 85%;
    }
}

@media (max-width: 768px) {
    .aivc-chat-widget {
        width: 380px;
        height: 580px;
    }
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --aivc-bg-primary: #0f172a;
        --aivc-bg-secondary: #1e293b;
        --aivc-bg-tertiary: #334155;
        --aivc-text-primary: #f8fafc;
        --aivc-text-secondary: #cbd5e1;
        --aivc-text-muted: #94a3b8;
    }
    
    .aivc-chat-widget {
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .aivc-message-bubble {
        background: var(--aivc-bg-secondary);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .aivc-source-card {
        background: var(--aivc-bg-secondary);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .aivc-chat-input {
        background: var(--aivc-bg-secondary);
        border-color: rgba(255, 255, 255, 0.1);
        color: var(--aivc-text-primary);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .aivc-chat-widget,
    .aivc-message,
    .aivc-chat-toggle,
    .aivc-source-card {
        animation: none;
        transition: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .aivc-chat-widget {
        border: 2px solid var(--aivc-accent-blue);
    }
    
    .aivc-message-bubble {
        border: 2px solid var(--aivc-accent-blue);
    }
    
    .aivc-chat-toggle {
        border: 3px solid var(--aivc-text-accent);
    }
}

/* Print Styles */
@media print {
    .aivc-chat-toggle,
    .aivc-chat-widget {
        display: none !important;
    }
}