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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Chat container */
.chat-container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Chat header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header-title {
    text-align: left;
}

.chat-header h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.chat-header p {
    font-size: 14px;
    opacity: 0.9;
}

/* User info section */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
}

.user-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.user-details {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.user-email {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

.logout-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
}

.logout-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.logout-button svg {
    width: 16px;
    height: 16px;
}

/* Conversation display */
.conversation-display {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f5;
}

/* Message styles */
.message {
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease-in;
}

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

.message-content {
    padding: 12px 16px;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.5;
}

.message-timestamp {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* User message */
.user-message {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
}

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

/* Assistant message */
.assistant-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.assistant-message .message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
}

.assistant-message .message-timestamp {
    text-align: left;
}

/* Error message */
.error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.error-message .message-content {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
    max-width: 90%;
    text-align: center;
}

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

#chat-form {
    display: flex;
    gap: 10px;
}

#message-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

#message-input:focus {
    border-color: #667eea;
}

#message-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

#send-button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

#send-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#send-button:active:not(:disabled) {
    transform: translateY(0);
}

#send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading indicator */
.loading-indicator {
    padding: 10px 20px;
    text-align: center;
    background: #f0f0f0;
    border-top: 1px solid #e0e0e0;
    font-size: 14px;
    color: #666;
}

.loading-indicator span {
    display: inline-block;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Responsive design for mobile */
@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .chat-container {
        height: 100vh;
        max-width: 100%;
        border-radius: 0;
    }
    
    .chat-header {
        padding: 15px;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .chat-header h1 {
        font-size: 20px;
    }
    
    .user-info {
        width: 100%;
        justify-content: space-between;
    }
    
    .user-details {
        display: none; /* Hide email on mobile to save space */
    }
    
    .user-avatar,
    .user-avatar-placeholder {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .logout-button {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    #chat-form {
        gap: 8px;
    }
    
    #message-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    #send-button {
        padding: 12px 20px;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 12px;
    }
    
    .header-content {
        gap: 10px;
    }
    
    .chat-header h1 {
        font-size: 18px;
    }
    
    .chat-header p {
        font-size: 12px;
    }
    
    .user-avatar,
    .user-avatar-placeholder {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .logout-button {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .logout-button svg {
        width: 14px;
        height: 14px;
    }
    
    .conversation-display {
        padding: 15px;
    }
    
    .chat-input-container {
        padding: 15px;
    }
    
    .message-content {
        max-width: 90%;
        font-size: 14px;
    }
}

/* Scrollbar styling */
.conversation-display::-webkit-scrollbar {
    width: 8px;
}

.conversation-display::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.conversation-display::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.conversation-display::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Markdown formatting styles */
.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
}

.assistant-message .message-content code {
    background: #f0f0f0;
}

.user-message .message-content code {
    background: rgba(255, 255, 255, 0.2);
}
