/* Basic Reset & Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    background-color: #343541; /* Dark background for the page */
    color: #ececec; /* Light text color */
    display: flex;
    height: 100vh;
    overflow: hidden; /* Prevent body scroll, app-container will handle scroll */
}

/* App Container Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background-color: #202123; /* Darker sidebar background */
    display: flex;
    flex-direction: column;
    padding: 10px;
    border-right: 1px solid #40414f;
}

.sidebar-header {
    padding: 10px 0;
    margin-bottom: 10px;
}

#new-research-btn {
    width: 100%;
    padding: 10px 15px;
    background-color: transparent;
    color: #ececec;
    border: 1px solid #565869;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    text-align: left;
}

#new-research-btn:hover {
    background-color: #2d2f32;
}

.research-history {
    flex-grow: 1;
    overflow-y: auto; /* Scroll for history items if they overflow */
}

#research-items-list {
    list-style-type: none;
}

#research-items-list li {
    padding: 10px 15px;
    margin-bottom: 5px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#research-items-list li:hover {
    background-color: #2d2f32;
}

.sidebar-footer {
    padding: 15px 0;
    font-size: 0.8em;
    color: #8e8ea0;
}

/* Main Content Styling */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: #343541; /* Main chat area background */
    overflow: hidden; /* Important for chat area scrolling */
}

.chat-area {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto; /* Crucial for scrolling messages */
    display: flex;
    flex-direction: column;
    gap: 20px; /* Space between messages */
}

.message {
    padding: 15px;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
}

.user-message {
    background-color: #40414F; /* Slightly different for user messages */
    align-self: flex-end; /* Align user messages to the right */
}

.ai-message {
    background-color: #444654; /* AI messages background */
    align-self: flex-start;
}
.ai-message h4 {
    margin-bottom: 8px;
    font-size: 0.9em;
    color: #b0b0c0;
}
.ai-message p {
    line-height: 1.6;
}
.ai-message code { /* For displaying tags nicely */
    background-color: #202123;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.9em;
}

.welcome-message {
    text-align: center;
    color: #8e8ea0;
    background-color: transparent;
    align-self: center; /* Center the welcome message */
}


/* Input Area Styling */
.input-area {
    padding: 15px 20px 20px 20px; /* Adjusted padding */
    border-top: 1px solid #40414f;
    background-color: #343541; /* Ensure it matches main content bg */
}

#research-form {
    display: flex;
    align-items: center; /* Align items vertically in the middle */
    background-color: #40414F; /* Input field background */
    border-radius: 8px;
    padding: 5px 5px 5px 10px; /* Adjusted padding for icon */
    border: 1px solid #565869;
}

#text-input {
    flex-grow: 1;
    background-color: transparent;
    color: #ececec;
    border: none;
    outline: none;
    padding: 10px;
    font-size: 1em;
    resize: none; 
    min-height: 24px; 
    max-height: 200px; 
    overflow-y: auto;
    line-height: 1.5; /* Improved line height for textarea */
}

#text-input::placeholder {
    color: #8e8ea0;
}

#submit-btn {
    background-color: transparent;
    color: #8e8ea0; 
    border: none;
    padding: 8px;
    margin-left: 5px; /* Reduced margin */
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px; /* Match typical button height */
    width: 38px;
}

#submit-btn:hover {
    background-color: #202123; 
}
#submit-btn:disabled { 
    opacity: 0.5;
    cursor: not-allowed;
}
#submit-btn .send-icon { 
    width: 20px; 
    height: 20px;
}

/* PDF Upload Button Styling */
.pdf-upload-label {
    padding: 8px; /* Padding around the icon */
    margin-right: 5px; /* Space between icon and textarea */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8e8ea0;
    border-radius: 5px;
    height: 38px; /* Match submit button height */
    width: 38px;
}

.pdf-upload-label:hover {
    background-color: #202123; /* Darker on hover, same as submit */
    color: #ececec; /* Lighter icon on hover */
}

.pdf-upload-label svg {
    width: 20px; /* Size of the paperclip icon */
    height: 20px;
}

/* PDF Status Message Styling */
.pdf-status-message {
    font-size: 0.8em;
    color: #8e8ea0;
    margin-top: 8px; /* Space above the status message */
    text-align: left; /* Align to the start of the input area */
    min-height: 1.2em; /* Reserve space to prevent layout shift */
}


/* Scrollbar styling (Optional, for a more polished look) */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #202123; /* Sidebar scrollbar track */
}
.main-content ::-webkit-scrollbar-track, 
.chat-area ::-webkit-scrollbar-track { /* Ensure chat area also uses correct track */
    background: #343541; /* Main content scrollbar track */
}

::-webkit-scrollbar-thumb {
    background: #565869;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #8e8ea0;
}

/* Add this at the end for active history item */
#research-items-list li.active-history-item {
    background-color: #40414F; /* A slightly different background for selected item */
    font-weight: bold;
}

/* Optional: more distinct styling for history item titles and dates */
.history-item-title {
    display: block; /* Ensure it takes full width for ellipsis */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px; /* Add a little space below title */
}

.history-item-date {
    font-size: 0.8em;
    color: #8e8ea0; /* Lighter color for the date */
}
