/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #1f2937;
    position: relative;
    overflow: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(236, 72, 153, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 1;
}

.chat-container {
    position: relative;
    z-index: 2;
}

/* Chat container */
.chat-container {
    width: 100%;
    max-width: 900px;
    height: 85vh;
    max-height: 800px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    box-shadow:
        0 32px 64px -12px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    animation: containerFloat 6s ease-in-out infinite;
}

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

/* Chat header */
.chat-header {
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    background-size: 200% 200%;
    animation: gradientShift 8s ease-in-out infinite;
    color: white;
    padding: 24px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 1;
}

.bot-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.bot-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.bot-avatar.large {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    margin-bottom: 24px;
    box-shadow: 0 16px 64px rgba(99, 102, 241, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.bot-avatar.small {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.2);
}

.header-info {
    flex: 1;
}

.header-info h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.status-indicator {
    font-size: 14px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    position: relative;
}

.status-dot.online::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: #10b981;
    border-radius: 50%;
    opacity: 0.3;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.2); opacity: 0.1; }
}

/* Connection Status Styles */
.status-dot.connecting {
    background: #f59e0b;
    animation: connectingPulse 1s ease-in-out infinite;
}

.status-dot.connecting::after {
    background: #f59e0b;
    animation: connectingPulse 1s ease-in-out infinite;
}

.status-dot.offline {
    background: #ef4444;
}

.status-dot.offline::after {
    background: #ef4444;
    animation: none;
    opacity: 0.3;
}

@keyframes connectingPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.1); opacity: 0.2; }
}

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

.icon-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

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

/* Chat messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Welcome message */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    max-width: 500px;
    margin: 0 auto;
}

.welcome-content h2 {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 12px;
}

.welcome-content p {
    font-size: 16px;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 32px;
}

.suggested-questions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.suggestion-btn {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 16px;
    padding: 20px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 15px;
    color: #1f2937;
    line-height: 1.5;
    position: relative;
    overflow: hidden;
}

.suggestion-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
    transition: left 0.5s ease;
}

.suggestion-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: #6366f1;
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.2);
}

.suggestion-btn:hover::before {
    left: 100%;
}

.suggestion-btn:active {
    transform: translateY(-2px) scale(1.01);
}

/* Message styles */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: messageSlideIn 0.3s ease-out;
}

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

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

.message-content {
    max-width: 70%;
    padding: 16px 20px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
}

.message.user .message-content {
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.message.bot .message-content {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    color: #1f2937;
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.message-text {
    line-height: 1.5;
    white-space: pre-wrap;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 8px;
    display: block;
}

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

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 0 8px;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 16px;
    padding: 16px 20px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50%;
    animation: typingDot 1.4s ease-in-out infinite;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

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

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

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Enhanced Processing Status Indicator */
.processing-status {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    margin: 12px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    animation: slideUp 0.3s ease-out;
}

.status-content {
    flex: 1;
}

.status-title {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 12px;
    font-size: 14px;
}

.status-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.status-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.status-step.active {
    background: linear-gradient(135deg, #dbeafe, #e0e7ff);
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.status-step.completed {
    background: linear-gradient(135deg, #dcfce7, #d1fae5);
    border-color: #10b981;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.step-icon {
    font-size: 16px;
    min-width: 16px;
}

.step-text {
    flex: 1;
    font-size: 13px;
    color: #475569;
    font-weight: 500;
}

.step-status {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

.status-step.active .step-status {
    color: #3b82f6;
    animation: pulse 1.5s ease-in-out infinite;
}

.status-step.completed .step-status {
    color: #10b981;
}

.status-time {
    font-size: 11px;
    color: #94a3b8;
    text-align: right;
    font-style: italic;
}

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

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

/* Chat input */
.chat-input-container {
    padding: 20px 24px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(99, 102, 241, 0.2);
    border-radius: 20px;
    padding: 16px 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.input-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(236, 72, 153, 0.05));
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.input-wrapper:focus-within {
    border-color: #6366f1;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.input-wrapper:focus-within::before {
    opacity: 1;
}

.attach-btn {
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.attach-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.attach-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#messageInput {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    min-height: 20px;
    max-height: 120px;
    color: #1f2937;
}

#messageInput::placeholder {
    color: #9ca3af;
}

.send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    background-size: 200% 200%;
    animation: gradientShift 8s ease-in-out infinite;
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.send-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.4s ease;
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
}

.send-btn:hover:not(:disabled)::before {
    width: 100%;
    height: 100%;
}

.send-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

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

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 12px;
    color: #6b7280;
}

.char-count {
    font-family: monospace;
}

.powered-by {
    opacity: 0.7;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .chat-container {
        height: 95vh;
        max-height: none;
        border-radius: 16px;
    }

    .chat-header {
        padding: 16px 20px;
    }

    .header-info h1 {
        font-size: 16px;
    }

    .status-indicator {
        font-size: 13px;
    }

    .chat-messages {
        padding: 16px;
    }

    .message-content {
        max-width: 85%;
    }

    .welcome-message {
        padding: 20px 16px;
    }

    .suggested-questions {
        grid-template-columns: 1fr;
    }

    .chat-input-container {
        padding: 16px 20px;
    }
}

@media (max-width: 480px) {
    .header-actions {
        display: none;
    }

    .suggestion-btn {
        padding: 12px;
        font-size: 13px;
    }
}

/* ChatGPT-style Processing Message */
.processing-message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: messageSlideIn 0.3s ease-out;
}

.processing-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.2);
    flex-shrink: 0;
}

.processing-content {
    flex: 1;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    padding: 16px 20px;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
}

.processing-text {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.processing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.processing-dot {
    width: 6px;
    height: 6px;
    background: #6366f1;
    border-radius: 50%;
    animation: processingDot 1.4s ease-in-out infinite;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

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

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

@keyframes processingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Stream response text */
.streaming-text {
    color: #1f2937;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 20px;
    background: #6366f1;
    animation: blink 1s ease-in-out infinite;
    margin-left: 2px;
    vertical-align: text-bottom;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Error states */
.error-message {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.retry-btn {
    background: #dc2626;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    margin-top: 8px;
    transition: background-color 0.2s ease;
}

.retry-btn:hover {
    background: #b91c1c;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}