/* 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, #667eea 0%, #764ba2 100%);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Chat Container */
.chat-container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    max-height: 700px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    padding: 20px 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.bot-avatar {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.header-info h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 2px;
}

.status {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    align-items: center;
}

.status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    margin-right: 5px;
    animation: pulse 2s infinite;
}

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

.header-actions {
    margin-left: auto;
}

.clear-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: linear-gradient(to bottom, #fafafa 0%, #f5f5f5 100%);
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

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

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

.user-message {
    flex-direction: row-reverse;
    margin-left: 60px;
}

.bot-message {
    margin-right: 60px;
}

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

.bot-message .message-avatar {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.message-content {
    background: white;
    padding: 15px 18px;
    border-radius: 18px;
    max-width: 100%;
    word-wrap: break-word;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

.user-message .message-content {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
}

.bot-message .message-content {
    background: white;
    color: #374151;
}

.message-content p {
    margin: 0;
    line-height: 1.5;
    font-size: 14px;
}

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

/* Image Messages */
.message-image {
    margin-top: 10px;
    border-radius: 12px;
    overflow: hidden;
    max-width: 100%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.message-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    transition: transform 0.2s ease;
    cursor: pointer;
}

.message-image img:hover {
    transform: scale(1.02);
}

/* Loading Indicator */
.loading-indicator {
    display: none;
    padding: 20px 25px;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    color: #6b7280;
    font-size: 13px;
}

.loading-indicator.show {
    display: flex;
}

.typing-animation {
    display: flex;
    gap: 3px;
}

.typing-animation span {
    width: 6px;
    height: 6px;
    background: #6366f1;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

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

/* Input Area */
.chat-input {
    padding: 20px 25px;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.input-container {
    display: flex;
    gap: 12px;
    align-items: center;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    background: #f9fafb;
    color: #374151;
}

#messageInput:focus {
    border-color: #6366f1;
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#sendButton {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

#sendButton:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

#sendButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    margin-top: 8px;
    text-align: center;
}

.input-footer small {
    color: #6b7280;
    font-size: 12px;
}

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

    .chat-container {
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }

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

    .chat-messages {
        padding: 20px;
    }

    .user-message {
        margin-left: 20px;
    }

    .bot-message {
        margin-right: 20px;
    }

    .message-content {
        font-size: 14px;
        padding: 12px 15px;
    }

    .chat-input {
        padding: 15px 20px;
    }

    #messageInput {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

@media (max-width: 480px) {
    .header-info h2 {
        font-size: 18px;
    }

    .user-message {
        margin-left: 10px;
    }

    .bot-message {
        margin-right: 10px;
    }

    .message-avatar {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
}

/* Error Message Styles */
.error-message {
    background: #fee2e2 !important;
    color: #dc2626 !important;
    border: 1px solid #fca5a5 !important;
}

/* Success Animation */
.message-sent {
    animation: messagePulse 0.3s ease;
}

@keyframes messagePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}