/* Chat UI Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

.chat-container {
    max-width: 800px;
    height: 100vh;
    margin: 0 auto;
    background: white;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Header */
.chat-header {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-header h1 {
    font-size: 1.5rem;
    font-weight: 500;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.connection-status .indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e74c3c;
}

.connection-status.connected .indicator {
    background: #27ae60;
}

/* API Key Section */
.api-key-section {
    padding: 2rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.api-key-prompt {
    max-width: 400px;
    margin: 0 auto;
    text-align: center;
}

.api-key-prompt h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.api-key-prompt input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.api-key-prompt button {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.api-key-prompt button:hover {
    background: #2980b9;
}

.api-key-prompt .hint {
    margin-top: 0.5rem;
    color: #6c757d;
    font-size: 0.875rem;
}

.api-key-section.hidden {
    display: none;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #fafafa;
}

.message {
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    animation: fadeIn 0.3s ease-in;
}

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

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

.message-content {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    position: relative;
}

.message.user .message-content {
    background: #3498db;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.agent .message-content {
    background: white;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.agent-name {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-bottom: 0.25rem;
    display: block;
}

.message-text {
    word-wrap: break-word;
}

.message-time {
    font-size: 0.75rem;
    color: #95a5a6;
    margin-top: 0.25rem;
}

.message.user .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Quick Replies */
.quick-replies {
    padding: 0.5rem 1rem;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-height: 0;
    transition: all 0.3s ease;
}

.quick-replies:empty {
    padding: 0;
    border: none;
}

.quick-reply-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.quick-reply-btn:hover {
    background: #3498db;
    color: white;
}

/* Input Area */
.chat-input-container {
    padding: 1rem;
    background: white;
    border-top: 1px solid #eee;
}

.chat-input {
    display: flex;
    gap: 0.5rem;
}

#messageInput {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 24px;
    outline: none;
    font-size: 1rem;
    transition: border-color 0.2s;
}

#messageInput:focus {
    border-color: #3498db;
}

#sendButton {
    background: #3498db;
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#sendButton:hover:not(:disabled) {
    background: #2980b9;
}

#sendButton:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

/* Debug Panel */
.debug-panel {
    position: fixed;
    bottom: 70px;
    right: 20px;
    width: 300px;
    max-height: 400px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    overflow-y: auto;
    z-index: 1000;
}

.debug-panel h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.debug-content p {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.debug-content strong {
    color: #2c3e50;
}

.raw-messages {
    margin-top: 1rem;
}

.raw-messages h4 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.raw-messages pre {
    background: #f8f9fa;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    overflow-x: auto;
}

.debug-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #95a5a6;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.875rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 999;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    margin-bottom: 1rem;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #95a5a6;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

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

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .chat-container {
        max-width: 100%;
        height: 100vh;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .debug-panel {
        width: 90%;
        left: 5%;
        right: 5%;
    }
}