/* --- General Body and Font Styling --- */
html {
    height: 100%;
}
body {
    height: 100%;
    margin: 0;
    padding: 2rem; /* Add some overall padding */
    font-family: 'Lora', serif; /* Elegant, airy serif font */
    background-color: #f4f4f4; /* A soft, light grey background */
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center items horizontally */
    justify-content: flex-start; /* Align items to the top vertically */
    box-sizing: border-box;
}

/* --- Main Centered Container --- */
.container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 80%; /* Not full-width */
    max-width: 900px; /* Add a max-width for very large screens */
    margin: 0 auto; /* Center the container */
    gap: 1.5rem; /* This creates the space between the media and chat boxes */
}

/* --- Media and Chat Window as Discrete Boxes --- */
#media-window, #chat-container {
    background: #fff;
    border-radius: 12px; /* Soft rounded corners */
    box-shadow: 0 8px 30px rgba(0,0,0,0.12); /* A subtle shadow for depth */
    overflow: hidden; /* Keep content within the rounded corners */
}

#media-window {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    flex: 0.7;
    padding: 0;
}
.loading-text, .error-text {
    color: #888;
}

#chat-container {
    flex: 0.3; /* Takes up 30% of the container's height */
    display: flex;
    flex-direction: column;
    border-top: none; /* No longer needed as it's a separate box */
}

/* --- Chat History and Messages --- */
#chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.message {
    padding: 0.6rem 1.2rem;
    border-radius: 18px;
    max-width: 85%;
    line-height: 1.5;
    word-wrap: break-word;
}
.message.user {
    background-color: #007bff;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.message.bot {
    background-color: #f1f3f5;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
/* Styling for Markdown generated HTML */
.message.bot p { margin: 0 0 0.5em 0; }
.message.bot ul, .message.bot ol { padding-left: 1.5em; margin-bottom: 0.5em; }
.message.bot h1, .message.bot h2, .message.bot h3 { margin-bottom: 0.5em; }

/* --- Chat Input Area --- */
#chat-input-container {
    display: flex;
    padding: 1rem;
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
}
#userInput {
    flex-grow: 1;
    padding: 0.75rem 1rem;
    border: 1px solid #ced4da;
    border-radius: 20px; /* Pill shape */
    background-color: #fff;
    color: #333;
    font-size: 1rem;
    font-family: 'Lora', serif;
}
#userInput:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 3px rgba(0,123,255,.25);
}
#sendButton {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    margin-left: 0.75rem;
    border-radius: 20px; /* Pill shape */
    cursor: pointer;
    font-size: 1.5rem;
    transition: background-color 0.2s;
}
#sendButton:hover {
    background-color: #0056b3;
}



/* --- Top Navigation Bar --- */
/* --- Centered Minimalist Top Navigation --- */
.top-nav {
    text-align: center;
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 1rem; /* Adjusted for symmetrical vertical spacing */
    margin-top: -1rem; /* Pull it slightly up for visual balance */
}

.top-nav a,
.top-nav span {
    display: inline-block;
    margin: 0 0.5rem;
    color: #555;
    text-decoration: none;
    cursor: pointer;
}
.top-nav a:hover,
.top-nav span:hover {
    color: #007bff;
    text-decoration: underline;
}



/* --- Enhanced Media Styling --- */

/* --- Mobile Improvements --- */
@media (max-width: 768px) {
    body {
        padding: 0.5rem;
    }

    .top-nav {
        font-size: 0.7rem;
        margin: 0.5rem 0 1rem 0;
        white-space: nowrap;
        overflow-x: auto;
    }

    .container {
        width: 100%;
        height: 100vh;
        gap: 0.5rem;
        border-radius: 0;
        box-shadow: none;
    }

    #media-window {
        flex: 0.5;
        padding: 0;
        height: 100%;
        border-radius: 0;
        box-shadow: none;
    }

    #chat-container {
        flex: 0.45;
        padding-bottom: 0.5rem;
        border-top: 1px solid #dee2e6;
        border-radius: 0;
        box-shadow: none;
    }

    #chat-history {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    #chat-input-container {
        padding: 0.5rem;
    }

    #userInput {
        padding: 0.5rem 0.75rem;
        font-size: 0.95rem;
    }

    #sendButton {
        font-size: 1.2rem;
        padding: 0.4rem 1rem;
    }
}


#media-window img,
#media-window video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 20px;
    box-shadow: none;
}

/* --- Overlay Chat Console --- */
#chat-overlay {
    position: absolute;
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    max-height: 80%;
    backdrop-filter: blur(14px);
    background: rgba(255, 255, 255, 0.6);
    border-radius: 16px;
    z-index: 10;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none;
    opacity: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
}


#chat-overlay.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
#chat-overlay {
    transform: translateX(-50%) translateY(20px);
}

#chat-overlay-messages {
    overflow-y: auto;
    max-height: 100%;
    padding-right: 0.5rem;
}

/* Message styling remains the same */
#chat-overlay .message {
    background: rgba(255, 255, 255, 0.85);
    margin-bottom: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: 16px;
    max-width: 90%;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    font-size: 1rem;
    line-height: 1.6;
}

#chat-overlay .message.user {
    align-self: flex-end;
    background: rgba(0, 123, 255, 0.85);
    color: white;
}

#chat-overlay .message.bot {
    align-self: flex-start;
}

/* Close button stays top-right */
#chat-overlay .close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    backdrop-filter: blur(4px);
}

/* Typing animation */
.typing-dots::after {
    content: '⠋';
    animation: dots 1.2s infinite steps(4);
    margin-left: 0.3rem;
}

@keyframes dots {
    0% { content: '⠋'; }
    25% { content: '⠙'; }
    50% { content: '⠚'; }
    75% { content: '⠞'; }
    100% { content: '⠋'; }
}



