/* General Body & Font Styling */
body {
    background-color: #000;
    font-family: 'Inter', sans-serif;
    overflow: hidden; /* Prevents scrollbars from background pattern */
}

/* Alignment Container */
.container {
    justify-content: center; /* Center content vertically by default */
    transition: justify-content 0.5s ease-in-out;
}

.container.chat-started {
    justify-content: flex-start; /* Align to top once chat starts */
}

/* Futuristic Background Grid Pattern */
#background-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle at center, rgba(128, 128, 128, 0.1) 1px, transparent 1px),
                      linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
                      linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 50px 50px, 50px 50px, 50px 50px;
    z-index: 0;
}

/* Main Chat Container */
#chat-container {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1.5rem;
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.05);
}

#chat-wrapper {
    max-height: 60px; 
    display: flex;
    flex-direction: column;
    justify-content: flex-end; 
    transition: max-height 0.5s ease-in-out;
}

#chat-wrapper.expanded {
    max-height: 80vh; 
    width: 100%;
    flex-grow: 1; 
    justify-content: flex-start; 
}

#chat-box {
    flex-grow: 1; 
}

/* Input Area Styling */
#input-area {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    transition: all 0.3s ease;
}

#input-area:focus-within {
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

#user-input {
    background: transparent;
    border: none;
}

#send-button {
    background-color: #fff;
    color: #000;
    border-radius: 6px;
    margin: 4px;
    transition: all 0.2s ease;
}

#send-button:hover {
    background-color: #ccc;
}

#send-button:disabled {
    background-color: #555;
    color: #888;
}

/* Example Questions */
#example-question-container {
    color: #aaa;
}

.example-question-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    transition: all 0.2s ease;
}

.example-question-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

/* Chat Message Styling */
.message {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    max-width: 100%;
}

.message.self-end {
    background: linear-gradient(to right, #4a00e0, #8e2de2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.message.self-start {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ddd; /* Default text color for bot messages */
}

/* Blinking Cursor for AI response */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.blinking-cursor {
    animation: blink 1s step-end infinite;
}

/* --- Enhanced Markdown Content Styling --- */
.message.self-start > *:first-child {
    margin-top: 0;
}
.message.self-start > *:last-child {
    margin-bottom: 0;
}

.message.self-start p {
    margin-bottom: 1rem;
}

.message.self-start h1, .message.self-start h2, .message.self-start h3 {
    font-weight: 500;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 0.5rem;
}

.message.self-start h1 { font-size: 1.25em; }
.message.self-start h2 { font-size: 1.15em; }
.message.self-start h3 { font-size: 1.1em; }

.message.self-start ul, .message.self-start ol {
    list-style-position: outside;
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.message.self-start li {
    margin-bottom: 0.25rem;
}

.message.self-start pre {
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f1f1f1;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow-x: auto;
    font-family: monospace;
}

.message.self-start code {
    font-family: monospace;
    background-color: rgba(255, 255, 255, 0.15);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

.message.self-start pre code {
    background: transparent;
    border: none;
    padding: 0;
}

.message.self-start blockquote {
    border-left: 3px solid rgba(255, 255, 255, 0.4);
    padding-left: 1rem;
    margin: 1rem 0;
    color: #ccc;
    font-style: italic;
}

.message.self-start a {
    color: #81a2ff; /* A lighter, more vibrant blue */
    text-decoration: none;
    border-bottom: 1px solid #81a2ff;
}

.message.self-start a:hover {
    color: #a3bfff;
    border-bottom-color: #a3bfff;
}
