/* AIVC - AI VDC Chat - Frontend Styles */
/* Modern ChatGPT/Claude inspired design */

:root {
    --aivc-bg-primary: #ffffff;
    --aivc-bg-secondary: #f8fafc;
    --aivc-bg-tertiary: #f1f5f9;
    --aivc-text-primary: #1e293b;
    --aivc-text-secondary: #64748b;
    --aivc-text-muted: #94a3b8;
    --aivc-accent-blue: #3B82F6;
    --aivc-accent-green: #22c55e;
    --aivc-accent-orange: #f59e0b;
    --aivc-accent-red: #ef4444;
    --aivc-border: #e2e8f0;
    --aivc-border-light: #cbd5e1;
    --aivc-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --aivc-shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);
    --aivc-shadow-strong: 0 8px 32px rgba(0, 0, 0, 0.15);
    --aivc-radius: 16px;
    --aivc-radius-sm: 12px;
    --aivc-radius-xs: 8px;
    --aivc-spacing: 20px;
    --aivc-spacing-sm: 16px;
    --aivc-spacing-xs: 12px;
    --aivc-spacing-xxs: 8px;
}

/* Dark mode variables */
@media (prefers-color-scheme: dark) {
    :root {
        --aivc-bg-primary: #0f172a;
        --aivc-bg-secondary: #1e293b;
        --aivc-bg-tertiary: #334155;
        --aivc-text-primary: #f1f5f9;
        --aivc-text-secondary: #cbd5e1;
        --aivc-text-muted: #94a3b8;
        --aivc-border: #334155;
        --aivc-border-light: #475569;
        --aivc-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        --aivc-shadow-strong: 0 8px 32px rgba(0, 0, 0, 0.4);
    }
}

/* Chat Toggle Button (FAB) */
.aivc-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--aivc-accent-blue), #22d3ee);
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 999999;
    box-shadow: var(--aivc-shadow-strong);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

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

.aivc-chat-toggle.active {
    background: linear-gradient(135deg, var(--aivc-accent-green), var(--aivc-accent-blue));
    transform: scale(1.05);
}

.aivc-chat-icon {
    transition: transform 0.3s ease;
}

.aivc-chat-toggle:hover .aivc-chat-icon {
    transform: rotate(10deg);
}

/* Chat Badge */
.aivc-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--aivc-accent-green);
    color: white;
    font-size: 12px;
    font-weight: 600;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Chat Widget */
.aivc-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    height: 550px;
    background: var(--aivc-bg-primary);
    border: 1px solid var(--aivc-border);
    border-radius: var(--aivc-radius);
    box-shadow: var(--aivc-shadow-strong);
    z-index: 999998;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
    animation: slideInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Chat Header */
.aivc-chat-header {
    display: flex;
    align-items: center;
    padding: var(--aivc-spacing-sm);
    border-bottom: 1px solid var(--aivc-border);
    background: var(--aivc-bg-secondary);
    border-radius: var(--aivc-radius) var(--aivc-radius) 0 0;
}

.aivc-chat-avatar {
    margin-right: var(--aivc-spacing-xs);
}

.aivc-avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--aivc-accent-blue), var(--aivc-accent-green));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    animation: float 3s ease-in-out infinite;
}

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

.aivc-chat-info {
    flex: 1;
}

.aivc-chat-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--aivc-text-primary);
}

.aivc-chat-subtitle {
    margin: 2px 0 0 0;
    font-size: 12px;
    color: var(--aivc-text-secondary);
}

.aivc-chat-controls {
    display: flex;
    gap: 4px;
}

.aivc-chat-control-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--aivc-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.aivc-chat-control-btn:hover {
    background: var(--aivc-bg-tertiary);
    color: var(--aivc-text-primary);
}

/* Chat Messages */
.aivc-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--aivc-spacing-sm);
    display: flex;
    flex-direction: column;
    gap: var(--aivc-spacing-xs);
}

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

.aivc-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

.aivc-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--aivc-border-light);
}

/* Message */
.aivc-message {
    display: flex;
    gap: var(--aivc-spacing-xs);
    animation: fadeIn 0.3s ease;
}

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

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

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

.aivc-message-user .aivc-message-avatar {
    background: linear-gradient(135deg, var(--aivc-accent-blue), #2563EB);
    color: white;
}

.aivc-message-bot .aivc-message-avatar {
    background: var(--aivc-bg-tertiary);
    color: var(--aivc-text-secondary);
}

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

.aivc-message-user .aivc-message-content {
    display: flex;
    justify-content: flex-end;
}

/* Message Bubble */
.aivc-message-bubble {
    padding: var(--aivc-spacing-xs) var(--aivc-spacing-sm);
    border-radius: var(--aivc-radius-sm);
    position: relative;
    word-wrap: break-word;
}

.aivc-message-user .aivc-message-bubble {
    background: linear-gradient(135deg, var(--aivc-accent-blue), #2563EB);
    color: white;
    border-bottom-right-radius: 4px;
}

.aivc-message-bot .aivc-message-bubble {
    background: var(--aivc-bg-secondary);
    color: var(--aivc-text-primary);
    border: 1px solid var(--aivc-border);
    border-bottom-left-radius: 4px;
}

.aivc-message-text {
    line-height: 1.5;
    font-size: 14px;
}

.aivc-message-text p {
    margin: 0 0 8px 0;
}

.aivc-message-text p:last-child {
    margin-bottom: 0;
}

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

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

.aivc-message-text mark {
    background: rgba(59, 130, 246, 0.2);
    color: var(--aivc-accent-blue);
    padding: 2px 4px;
    border-radius: 4px;
}

/* Source Cards */
.aivc-source-cards {
    margin-top: var(--aivc-spacing-xs);
    display: flex;
    flex-direction: column;
    gap: var(--aivc-spacing-xxs);
}

.aivc-source-card {
    display: block;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--aivc-border);
    border-radius: var(--aivc-radius-xs);
    padding: var(--aivc-spacing-xs);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.aivc-source-card:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--aivc-accent-blue);
    transform: translateY(-2px);
    box-shadow: var(--aivc-shadow);
}

.aivc-source-card-header {
    display: flex;
    gap: var(--aivc-spacing-xs);
    margin-bottom: var(--aivc-spacing-xxs);
}

.aivc-source-card-image {
    width: 40px;
    height: 40px;
    border-radius: var(--aivc-radius-xs);
    object-fit: cover;
    flex-shrink: 0;
}

.aivc-source-card-content {
    flex: 1;
    min-width: 0;
}

.aivc-source-card-title {
    margin: 0 0 4px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--aivc-text-primary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.aivc-source-card-date {
    font-size: 11px;
    color: var(--aivc-text-muted);
}

.aivc-source-card-snippet {
    font-size: 12px;
    color: var(--aivc-text-secondary);
    line-height: 1.4;
    margin-bottom: var(--aivc-spacing-xxs);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.aivc-source-card-url {
    font-size: 11px;
    color: var(--aivc-accent-blue);
    text-decoration: none;
    word-break: break-all;
}

/* Chat Input */
.aivc-chat-input-container {
    padding: var(--aivc-spacing-sm);
    border-top: 1px solid var(--aivc-border);
    background: var(--aivc-bg-secondary);
    border-radius: 0 0 var(--aivc-radius) var(--aivc-radius);
}

.aivc-chat-input-wrapper {
    display: flex;
    gap: var(--aivc-spacing-xs);
    align-items: flex-end;
}

.aivc-chat-input {
    flex: 1;
    padding: var(--aivc-spacing-xs) var(--aivc-spacing-sm);
    border: 1px solid var(--aivc-border);
    border-radius: var(--aivc-radius-sm);
    background: var(--aivc-bg-primary);
    color: var(--aivc-text-primary);
    font-size: 14px;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    transition: all 0.2s ease;
}

.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-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--aivc-accent-blue), #2563EB);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

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

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

/* Typing Indicator */
.aivc-typing-indicator {
    display: flex;
    align-items: center;
    gap: var(--aivc-spacing-xs);
    padding: var(--aivc-spacing-xs) var(--aivc-spacing-sm);
    background: var(--aivc-bg-secondary);
    border: 1px solid var(--aivc-border);
    border-radius: var(--aivc-radius-sm);
    border-bottom-left-radius: 4px;
}

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

.aivc-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--aivc-text-muted);
    animation: typingDot 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 typingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Chat Shortcode */
.aivc-chat-shortcode {
    margin: var(--aivc-spacing) 0;
}

.aivc-chat-toggle-shortcode {
    display: inline-flex;
    align-items: center;
    gap: var(--aivc-spacing-xs);
    padding: var(--aivc-spacing-xs) var(--aivc-spacing-sm);
    background: linear-gradient(135deg, var(--aivc-accent-blue), #2563EB);
    color: white;
    border: none;
    border-radius: var(--aivc-radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .aivc-chat-widget {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
    }
    
    .aivc-chat-toggle {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        font-size: 20px;
    }
    
    .aivc-chat-header {
        border-radius: 0;
        padding: var(--aivc-spacing-sm) var(--aivc-spacing);
    }
    
    .aivc-chat-input-container {
        border-radius: 0;
        padding: var(--aivc-spacing-sm) var(--aivc-spacing);
    }
    
    .aivc-message-content {
        max-width: 90%;
    }
    
    .aivc-source-card {
        padding: var(--aivc-spacing-sm);
    }
    
    .aivc-source-card-header {
        gap: var(--aivc-spacing-sm);
    }
    
    .aivc-source-card-image {
        width: 50px;
        height: 50px;
    }
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --aivc-border: #000000;
        --aivc-text-secondary: #000000;
        --aivc-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    }
}

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