/* Basic Reset & Font */
body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Added Inter for a modern feel */
    background: linear-gradient(135deg, #e0eafc, #cfdef3); /* Subtle gradient background */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #333;
    overflow: hidden; /* Prevent body scroll */
}

/* Chat Container */
.chat-container {
    width: 100%;
    max-width: 420px; /* Slightly wider for a premium feel */
    height: 90vh;
    background-color: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); /* More pronounced shadow */
    border-radius: 20px; /* Softer corners */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease-in-out; /* Smooth transitions */
}

/* Chat Header */
.chat-header {
    background: linear-gradient(90deg, #6a11cb, #2575fc); /* Vibrant gradient header */
    color: #fff;
    padding: 18px; /* Increased padding */
    text-align: center;
    font-size: 1.3em; /* Slightly larger font */
    font-weight: 600; /* Medium bold */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-bottom: none; /* Removed bottom border, gradient is enough */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* Subtle shadow for header */
}

.chat-header i {
    font-size: 1.6em; /* Larger icon */
}

/* Chat Messages Area */
.chat-messages {
    flex-grow: 1;
    padding: 20px; /* Increased padding */
    overflow-y: auto;
    background-color: #f8f9fa; /* Very light background */
    display: flex;
    flex-direction: column;
    gap: 12px; /* More space between messages */
    scroll-behavior: smooth; /* Smooth scrolling */
}

/* Custom Scrollbar for Webkit browsers */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}


/* Individual Message Styling */
.message {
    max-width: 85%; /* Slightly wider messages */
    padding: 12px 18px; /* Adjusted padding */
    border-radius: 22px; /* More rounded */
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 0.95em; /* Slightly smaller font for messages */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); /* Subtle shadow for messages */
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(45deg, #007bff, #0056b3); /* Blue gradient for user */
    color: #fff;
    border-bottom-right-radius: 8px; /* Softer pointy corner */
    border-top-right-radius: 22px;
    border-bottom-left-radius: 22px;
    border-top-left-radius: 22px;
}

.bot-message {
    align-self: flex-start;
    background-color: #ffffff;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 8px; /* Softer pointy corner */
    border-top-right-radius: 22px;
    border-bottom-right-radius: 22px;
    border-top-left-radius: 22px;
}

/* Formatting for bot messages */
.bot-message h1 {
    font-size: 1.4em;
    margin-top: 0;
    margin-bottom: 10px;
    color: #007bff;
    font-weight: 600;
}

.bot-message h2 {
    font-size: 1.2em;
    margin-top: 15px;
    margin-bottom: 8px;
    color: #2575fc;
    font-weight: 500;
}

.bot-message p {
    margin-bottom: 8px;
    margin-top: 0;
}

.bot-message p:last-child {
    margin-bottom: 0;
}

/* Code Block Styling */
.bot-message pre {
    background-color: #2d2d2d; /* Dark background for code blocks */
    color: #f8f8f2; /* Light text color */
    padding: 10px 15px;
    border-radius: 8px;
    overflow-x: auto; /* Enable horizontal scrolling for long lines */
    margin: 10px 0;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', 'Monaco', monospace; /* Monospaced font for code */
    font-size: 0.9em;
    line-height: 1.4;
    white-space: pre-wrap; /* Wrap long lines */
    word-break: break-all; /* Break words if necessary */
}

.bot-message pre code {
    background-color: transparent; /* No background for code inside pre */
    color: inherit; /* Inherit color from pre */
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

/* Inline Code Styling */
.bot-message code {
    background-color: #e0e0e0; /* Light gray background for inline code */
    color: #c7254e; /* Distinct color for inline code */
    padding: 2px 5px;
    border-radius: 4px;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}


/* Chat Input Area */
.chat-input-area {
    display: flex;
    padding: 15px; /* Increased padding */
    background-color: #fff;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05); /* Shadow for input area */
}

#user-input {
    flex-grow: 1;
    border: 1px solid #ced4da;
    border-radius: 25px; /* More rounded input */
    padding: 12px 20px; /* Adjusted padding */
    font-size: 1em;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    background-color: #f0f2f5; /* Light background for input */
}

#user-input:focus {
    border-color: #6a11cb; /* Focus color from header gradient */
    box-shadow: 0 0 0 3px rgba(106, 17, 203, 0.2); /* Subtle focus glow */
    background-color: #fff;
}

#send-button {
    background: linear-gradient(45deg, #6a11cb, #2575fc); /* Gradient for send button */
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 50px; /* Slightly larger button */
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.3em; /* Larger icon */
    margin-left: 12px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

#send-button:hover {
    background: linear-gradient(45deg, #2575fc, #6a11cb); /* Reverse gradient on hover */
    transform: scale(1.08);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
}

#send-button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Typing Indicator */
#typing-indicator {
    background-color: #e0f7fa; /* Light blue for typing indicator */
    color: #007bff;
    font-style: italic;
    padding: 10px 15px;
    border-radius: 18px;
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.typing-dot {
    animation: bounce 1s infinite ease-in-out;
    opacity: 0;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0;
    }
    40% {
        transform: translateY(-5px);
        opacity: 1;
    }
}


/* Responsive adjustments */
@media (max-width: 480px) {
    .chat-container {
        height: 100vh;
        border-radius: 0;
        max-width: 100%;
        box-shadow: none;
    }
    .chat-header {
        border-radius: 0;
    }
    .chat-input-area {
        padding: 10px;
    }
    #user-input {
        padding: 10px 15px;
    }
    #send-button {
        width: 40px;
        height: 40px;
        font-size: 1.1em;
    }
}