/**
 * ELIZA Chatbot Styles
 * Modern, professional chatbot UI with smooth animations
 * 
 * Design: Floating chat widget with glass-morphism effects
 */

/* ========================================
   CSS Custom Properties (Easy Theming)
   ======================================== */
:root {
    /* Primary Colors - Adjust for your brand */
    --chat-primary: #2563eb;
    --chat-primary-dark: #1d4ed8;
    --chat-primary-light: #3b82f6;
    --chat-accent: #f59e0b;
    
    /* Neutral Colors */
    --chat-bg: #ffffff;
    --chat-bg-secondary: #f8fafc;
    --chat-text: #1e293b;
    --chat-text-light: #64748b;
    --chat-border: #e2e8f0;
    
    /* Message Colors */
    --chat-bot-bg: #f1f5f9;
    --chat-bot-text: #1e293b;
    --chat-user-bg: linear-gradient(135deg, #2563eb, #1d4ed8);
    --chat-user-text: #ffffff;
    
    /* Shadows */
    --chat-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --chat-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --chat-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --chat-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Dimensions */
    --chat-width: 400px;
    --chat-height: 600px;
    --chat-button-size: 64px;
    --chat-border-radius: 16px;
    
    /* Animation */
    --chat-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --chat-bg: #1e293b;
        --chat-bg-secondary: #0f172a;
        --chat-text: #f1f5f9;
        --chat-text-light: #94a3b8;
        --chat-border: #334155;
        --chat-bot-bg: #334155;
        --chat-bot-text: #f1f5f9;
    }
}

/* ========================================
   Chat Toggle Button (Floating)
   ======================================== */
.eliza-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: var(--chat-button-size);
    height: var(--chat-button-size);
    border-radius: 50%;
    background: var(--chat-user-bg);
    border: none;
    cursor: pointer;
    box-shadow: var(--chat-shadow-lg);
    z-index: 9999;
    transition: var(--chat-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.eliza-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: var(--chat-shadow-xl);
}

.eliza-chat-toggle:active {
    transform: scale(0.95);
}

.eliza-chat-toggle-icon {
    width: 28px;
    height: 28px;
    fill: white;
    transition: var(--chat-transition);
}

.eliza-chat-toggle.is-open .eliza-chat-toggle-icon--chat {
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

.eliza-chat-toggle .eliza-chat-toggle-icon--close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

.eliza-chat-toggle.is-open .eliza-chat-toggle-icon--close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Notification badge */
.eliza-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: var(--chat-accent);
    border-radius: 50%;
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bounce 1s ease infinite;
}

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

/* ========================================
   Chat Container
   ======================================== */
.eliza-chat-container {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: var(--chat-width);
    height: var(--chat-height);
    max-height: calc(100vh - 140px);
    background: var(--chat-bg);
    border-radius: var(--chat-border-radius);
    box-shadow: var(--chat-shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: var(--chat-transition);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.eliza-chat-container.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .eliza-chat-container {
        width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    .eliza-chat-toggle {
        bottom: 16px;
        right: 16px;
    }
}

/* ========================================
   Chat Header
   ======================================== */
.eliza-chat-header {
    background: var(--chat-user-bg);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

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

.eliza-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.eliza-chat-header-info {
    flex: 1;
    min-width: 0;
}

.eliza-chat-name {
    font-weight: 600;
    font-size: 16px;
    margin: 0;
    line-height: 1.3;
}

.eliza-chat-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.eliza-chat-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 8px #22c55e;
}

.eliza-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--chat-transition);
}

.eliza-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.eliza-chat-close svg {
    width: 16px;
    height: 16px;
    fill: white;
}

/* ========================================
   Chat Messages Area
   ======================================== */
.eliza-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--chat-bg-secondary);
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.eliza-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

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

/* Message bubbles */
.eliza-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: messageSlide 0.3s ease;
}

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

.eliza-message--bot {
    align-self: flex-start;
}

.eliza-message--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.eliza-message-avatar {
    width: 32px;
    height: 32px;
    background: var(--chat-bot-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.eliza-message--user .eliza-message-avatar {
    background: var(--chat-primary);
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.eliza-message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.eliza-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
}

.eliza-message--bot .eliza-message-bubble {
    background: var(--chat-bot-bg);
    color: var(--chat-bot-text);
    border-bottom-left-radius: 6px;
}

.eliza-message--user .eliza-message-bubble {
    background: var(--chat-user-bg);
    color: var(--chat-user-text);
    border-bottom-right-radius: 6px;
}

.eliza-message-time {
    font-size: 11px;
    color: var(--chat-text-light);
    padding: 0 4px;
}

.eliza-message--user .eliza-message-time {
    text-align: right;
}

/* Info box (knowledge base snippets) */
.eliza-message-info {
    background: linear-gradient(135deg, #dbeafe, #ede9fe);
    border: 1px solid #c7d2fe;
    border-radius: 12px;
    padding: 12px;
    font-size: 12px;
    color: #4338ca;
    margin-top: 8px;
    line-height: 1.5;
}

.eliza-message-info::before {
    content: '💡 ';
}

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

.eliza-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--chat-bot-bg);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
}

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

.eliza-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.eliza-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingPulse {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.4;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* ========================================
   Chat Input Area
   ======================================== */
.eliza-chat-input-area {
    padding: 16px;
    background: var(--chat-bg);
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.eliza-chat-input-wrapper {
    flex: 1;
    position: relative;
}

.eliza-chat-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--chat-border);
    border-radius: 24px;
    font-size: 14px;
    background: var(--chat-bg-secondary);
    color: var(--chat-text);
    transition: var(--chat-transition);
    resize: none;
    max-height: 120px;
    min-height: 44px;
    line-height: 1.4;
    font-family: inherit;
}

.eliza-chat-input:focus {
    outline: none;
    border-color: var(--chat-primary);
    background: var(--chat-bg);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.eliza-chat-input::placeholder {
    color: var(--chat-text-light);
}

.eliza-chat-send {
    width: 44px;
    height: 44px;
    background: var(--chat-user-bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--chat-transition);
    flex-shrink: 0;
}

.eliza-chat-send:hover {
    transform: scale(1.08);
    box-shadow: var(--chat-shadow-md);
}

.eliza-chat-send:active {
    transform: scale(0.95);
}

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

.eliza-chat-send svg {
    width: 20px;
    height: 20px;
    fill: white;
    margin-left: 2px;
}

/* ========================================
   Contact Form Integration
   ======================================== */
.eliza-chat-form-trigger {
    padding: 12px 16px;
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border: 1px solid #86efac;
    border-radius: 12px;
    text-align: center;
    margin-top: 8px;
    cursor: pointer;
    transition: var(--chat-transition);
}

.eliza-chat-form-trigger:hover {
    background: linear-gradient(135deg, #dcfce7, #d1fae5);
}

.eliza-chat-form-trigger-text {
    font-size: 13px;
    color: #166534;
    font-weight: 500;
}

.eliza-chat-form-trigger-text::before {
    content: '📝 ';
}

/* ========================================
   Quick Replies / Suggestions
   ======================================== */
.eliza-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 12px;
    background: var(--chat-bg);
}

.eliza-quick-reply {
    padding: 8px 14px;
    background: var(--chat-bg-secondary);
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    font-size: 13px;
    color: var(--chat-text);
    cursor: pointer;
    transition: var(--chat-transition);
}

.eliza-quick-reply:hover {
    background: var(--chat-primary);
    color: white;
    border-color: var(--chat-primary);
}

/* ========================================
   Collected Data Display (Dev Mode)
   ======================================== */
.eliza-data-panel {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px;
    font-size: 11px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    max-height: 150px;
    overflow-y: auto;
    border-top: 1px solid #334155;
}

.eliza-data-panel summary {
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 8px;
    color: #94a3b8;
}

.eliza-data-item {
    margin: 4px 0;
    padding-left: 12px;
}

.eliza-data-key {
    color: #f472b6;
}

.eliza-data-value {
    color: #34d399;
}

/* ========================================
   Hidden Contact Form Field
   ======================================== */
#eliza-collected-data,
#eliza-chat-transcript {
    display: none !important;
}

/* ========================================
   Form Highlight Effect (when scrolling to form)
   ======================================== */
.eliza-form-highlight {
    animation: formHighlight 2s ease;
}

@keyframes formHighlight {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7);
    }
    30% {
        box-shadow: 0 0 0 15px rgba(37, 99, 235, 0.3);
    }
    60% {
        box-shadow: 0 0 0 15px rgba(37, 99, 235, 0.1);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
    }
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Entrance animation for chat */
.eliza-chat-container.is-open .eliza-chat-header {
    animation: slideUp 0.3s ease 0.1s both;
}

.eliza-chat-container.is-open .eliza-chat-messages {
    animation: fadeIn 0.3s ease 0.2s both;
}

.eliza-chat-container.is-open .eliza-chat-input-area {
    animation: slideUp 0.3s ease 0.3s both;
}
