/* Chat Container Styles */
.chat-container {
    max-width: 800px;
    width: 90%;
    margin: 2rem auto;
    background-color: #ffffff;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 70vh;
    min-height: 600px;
}

.chat-header {
    background: linear-gradient(135deg, #000000de, #333333);
    color: white;
    padding: 1.5rem;
    text-align: center;
    border-bottom: 3px solid #56b1fb;
}

.chat-header h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.8rem;
    font-weight: 600;
}

.chat-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.95rem;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: fadeInUp 0.3s ease-out;
}

.user-message {
    align-self: flex-end;
}

.bot-message {
    align-self: flex-start;
}

.message-content {
    padding: 0.75rem 1rem;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}

.user-message .message-content {
    background: linear-gradient(135deg, #1350ab, #5da7e3);
    color: white;
    border-bottom-right-radius: 5px;
}

.bot-message .message-content {
    background-color: #ffffff;
    color: #333;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.message-time {
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.25rem;
    padding: 0 0.5rem;
}

.user-message .message-time {
    text-align: right;
}

.bot-message .message-time {
    text-align: left;
}

/* Input Container */
.chat-input-container {
    background-color: #ffffff;
    border-top: 1px solid #e1e5e9;
    padding: 1rem;
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    margin-bottom: 0.5rem;
}

#messageInput {
    flex: 1;
    border: 2px solid #e1e5e9;
    border-radius: 20px;
    padding: 0.75rem 1rem;
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    max-height: 120px;
    min-height: 44px;
}

#messageInput:focus {
    border-color: #1350ab;
    box-shadow: 0 0 0 3px rgba(172, 14, 14, 0.1);
}

#messageInput::placeholder {
    color: #999;
}

.send-button {
    background: linear-gradient(135deg, #1350ab, #5da7e3);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(172, 14, 14, 0.3);
}

.send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(10, 42, 135, 0.4);
}

.send-button:active {
    transform: translateY(0);
}

.send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Chat Controls */
.chat-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.control-button {
    background: none;
    border: 1px solid #ddd;
    color: #666;
    padding: 0.5rem 1rem;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.control-button:hover {
    background-color: #f5f5f5;
    border-color: #1350ab;
    color: #5da7e3;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #666;
    font-size: 0.85rem;
}

.typing-dots {
    display: flex;
    gap: 2px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    background-color: #1350ab;
    border-radius: 50%;
    animation: typingDots 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typingDots {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Error Message Styles */
.error-message {
    background-color: #fee;
    border: 1px solid #fcc;
    color: #c33;
    padding: 0.75rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

/* Markdown Styling for Bot Messages */
.bot-message .message-content h1,
.bot-message .message-content h2,
.bot-message .message-content h3 {
    margin: 0.5rem 0;
    color: #333;
}

.bot-message .message-content h1 {
    font-size: 1.2rem;
    border-bottom: 2px solid #ac0e0e;
    padding-bottom: 0.25rem;
}

.bot-message .message-content h2 {
    font-size: 1.1rem;
    color: #ac0e0e;
}

.bot-message .message-content h3 {
    font-size: 1rem;
    color: #666;
}

.bot-message .message-content ul,
.bot-message .message-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.bot-message .message-content li {
    margin: 0.25rem 0;
    line-height: 1.4;
}

.bot-message .message-content code {
    background-color: #f5f5f5;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #d63384;
}

.bot-message .message-content pre {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 1rem;
    margin: 0.5rem 0;
    overflow-x: auto;
}

.bot-message .message-content pre code {
    background: none;
    padding: 0;
    color: #333;
    font-size: 0.85rem;
}

.bot-message .message-content blockquote {
    border-left: 4px solid #ac0e0e;
    margin: 0.5rem 0;
    padding-left: 1rem;
    color: #666;
    font-style: italic;
}

.bot-message .message-content hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 1rem 0;
}

.bot-message .message-content a {
    color: #ac0e0e;
    text-decoration: underline;
}

.bot-message .message-content a:hover {
    color: #ce4b4b;
}

.bot-message .message-content del {
    color: #999;
}

.bot-message .message-content p {
    margin: 0.5rem 0;
    line-height: 1.5;
}

.bot-message .message-content p:first-child {
    margin-top: 0;
}

.bot-message .message-content p:last-child {
    margin-bottom: 0;
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
    .chat-container {
        width: 95%;
        height: 75vh;
        margin: 1rem auto;
        border-radius: 10px;
    }
    
    .chat-header {
        padding: 1rem;
    }
    
    .chat-header h1 {
        font-size: 1.5rem;
    }
    
    .message {
        max-width: 90%;
    }
    
    .message-content {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }
    
    #messageInput {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .chat-controls {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .typing-indicator {
        justify-content: center;
    }
}

@media screen and (max-width: 480px) {
    .chat-container {
        height: 80vh;
        border-radius: 0;
        margin: 0;
        width: 100%;
    }
    
    .input-wrapper {
        gap: 0.25rem;
    }
    
    .send-button {
        width: 40px;
        height: 40px;
    }
}
