/* Unified Chat Styles for MaMate */
/* Used by: chatbot.html, user/chat.html, user/view_consultation.html */

/* Common Avatar Styles */
.avatar-circle {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 123, 255, 0.2);
}

.avatar-initials {
    color: white;
    font-size: 20px;
    font-weight: bold;
}

/* Chat Container */
.chat-container {
    height: 500px;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    padding: 1rem 0.5rem 1rem 1rem;
    height: 400px;
    overflow-y: auto;
}

/* Message Styles */
.message {
    display: flex;
    margin-bottom: 1rem;
    max-width: 80%;
    animation: fadeIn 0.3s ease-in-out;
}

.user-message {
    max-width: 75%;
}

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

/* Bot Message - Left Side */
.bot-message {
    align-self: flex-start;
}

/* User Message - Right Side */
.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
    margin-left: auto;
    margin-right: 0;
    justify-content: flex-end;
}

/* Expert Message - Left Side (for consultation) */
.expert-message {
    align-self: flex-start;
}

/* Message Avatar */
.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 0.5rem;
    flex-shrink: 0;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 2px 10px rgba(0, 123, 255, 0.2);
}

.user-message .message-avatar {
    background-color: #6c757d;
    color: white;
}

.expert-message .message-avatar {
    background-color: #ffffff;
    color: #333;
    border: 1px solid #dee2e6;
}

.message-avatar .avatar-initials {
    color: white;
    font-size: 14px;
    font-weight: bold;
}

/* Message Content */
.message-content {
    display: flex;
    flex-direction: column;
}

.message-text {
    padding: 0.75rem 1rem;
    border-radius: 18px;
    position: relative;
    max-width: 100%;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Bot Message Bubble */
.bot-message .message-text,
.expert-bubble {
    background-color: #ffffff;
    color: #333;
    border-bottom-left-radius: 4px;
    border: 1px solid #e5e5ea;
}

/* User Message Bubble */
.user-message .message-text,
.user-bubble {
    background-color: #ffffff !important;
    color: #333 !important;
    border-bottom-right-radius: 4px;
    border: 1px solid #e5e5ea !important;
}

/* Message Tails */
.bot-message .message-text::before,
.expert-bubble::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-right-color: #ffffff;
    border-bottom: 0;
    border-left: 0;
    margin-bottom: -8px;
}

.user-message .message-text::before,
.user-bubble::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-left-color: #ffffff !important;
    border-bottom: 0;
    border-right: 0;
    margin-bottom: -8px;
}

/* Message Time */
.message-time {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.25rem;
    align-self: flex-end;
}

.user-message .message-time {
    color: #6c757d;
}

/* Chat Input */
.chat-input-container {
    padding: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background-color: white;
}

#messageInput {
    resize: none;
    height: 60px;
}

/* Welcome Container */
.welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    height: 100%;
}

.welcome-header {
    margin-bottom: 2rem;
}

.welcome-header h4 {
    text-align: left;
    margin-bottom: 0.5rem;
}

/* Chat Header Title Alignment */
.chat-header-title {
    text-align: left !important;
}

.chat-header-title h5 {
    margin-bottom: 0;
    text-align: left !important;
}

.chat-header-title p {
    margin-bottom: 0;
    text-align: left !important;
}

.chat-header-title * {
    text-align: left !important;
}

/* All titles and headers in chat pages should be left-aligned */
h1, h2, h3, h4, h5, h6 {
    text-align: left !important;
}

h2::after {
    margin: 15px 0 !important;
}

.welcome-examples {
    width: 100%;
    max-width: 600px;
}

.example-questions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}

.example-question {
    text-align: left;
    white-space: normal;
    height: auto;
    transition: all 0.3s ease;
    border: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

.example-question:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    background-color: #e9ecef;
}

/* Typing Indicator */
.typing-indicator {
    opacity: 0.7;
}

.typing-dots {
    display: flex;
    align-items: center;
    height: 20px;
}

.typing-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #6c757d;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out both;
}

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

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

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

@keyframes typing {
    0%, 100% {
        transform: scale(0.7);
        opacity: 0.5;
    }
    50% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Copy Button */
.copy-btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background-color: #6c757d;
    color: white;
}

/* Recommended Questions */
.recommended-questions {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    border-top: 1px solid #dee2e6;
}

.recommended-questions h6 {
    margin-bottom: 0.75rem;
    color: #495057;
}

.recommended-question {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    color: #495057;
    text-decoration: none;
    transition: all 0.2s ease;
}

.recommended-question:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    color: #495057;
    text-decoration: none;
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .example-questions {
        grid-template-columns: 1fr;
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-container {
        height: 400px;
    }
    
    .chat-messages {
        height: 300px;
    }
    
    .welcome-header h4 {
        text-align: left;
    }
}

/* Scrollbar Styling */
.chat-container::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

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

.chat-container::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Animation for new messages */
.message.new-message {
    animation: slideInUp 0.3s ease-out;
}

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

/* Loading state */
.message.loading {
    opacity: 0.6;
}

/* Error state */
.message.error .message-text {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* Success state */
.message.success .message-text {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}