html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: Arial, sans-serif;
    background: #f6f6f6;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: #f4f4f4;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
}

#newChat {
    background: #4a90e2;
    color: white;
    border: none;
    padding: 10px;
    cursor: pointer;
    font-weight: bold;
    flex-shrink: 0;
}

#historyList {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column; /* Keep natural order */
}

.history-item {
    padding: 8px;
    margin: 5px 0;
    background: white;
    border: 1px solid #ddd;
    cursor: pointer;
    font-size: 0.9em;
    border-radius: 5px;
}

.history-item:hover {
    background: #e6e6e6;
}

/* Chat container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

/* Header bar */
h1 {
    background: #4a90e2;
    color: white;
    margin: 0;
    padding: 15px;
    flex-shrink: 0;
}

/* Chat box */
.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
}

/* Messages */
.message {
    margin: 8px 0;
    padding: 10px;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
}
.user {
    background: #d1f0ff;
    align-self: flex-end;
}
.bot {
    background: #f0f0f0;
    align-self: flex-start;
    padding: 12px;
    border-radius: 8px;
    line-height: 1.5;
    white-space: pre-wrap; /* preserve spaces and line breaks */
}

.bot ul {
    padding-left: 20px;
    margin: 5px 0;
}

.bot li {
    margin-bottom: 5px;
}

/* Input area */
.input-box {
    display: flex;
    gap: 5px;
    padding: 10px;
    border-top: 1px solid #ddd;
    flex-shrink: 0;
    background: white;
}
textarea {
    flex: 1;
    padding: 8px;
    border-radius: 5px;
    resize: none;
    height: 50px;
    font-size: 14px;
}
button {
    background: #4a90e2;
    color: white;
    border: none;
    padding: 0 15px;
    border-radius: 5px;
    cursor: pointer;
}
select {
    border-radius: 5px;
    padding: 5px;
}

/* Meta info preserved */
.meta-info {
    font-size: 0.75em;
    color: #666;
    text-align: right;
    margin-top: 3px;
    background: none;
    padding: 0;
    border-radius: 0;
}
.bot-meta {
    font-size: 0.75em;
    color: #666;
    align-self: flex-start !important; /* Force left alignment */
    margin-top: 2px;
    background: none;
    padding: 0;
    border-radius: 0;
}
.sidebar {
    display: flex;
    flex-direction: column;
    width: 220px;
    background: #f4f4f4;
    border-right: 1px solid #ccc;
}

.history-list {
    flex: 1; /* Push clear button to bottom */
    overflow-y: auto;
    padding: 5px;
}

.clear-btn {
    background: #ff4d4d;
    color: white;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 5px;
    margin: 8px;
}

.clear-btn:hover {
    background: #e60000;
}

.typing-status {
    display: inline-block;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 8px;
    font-style: italic;
    color: #555;
    animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}
/* Animated dot typing effect */
.typing-indicator {
    display: inline-block;
    font-style: italic;
    animation: pulseDots 1.5s infinite;
}

@keyframes pulseDots {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}
.typing-indicator::after {
    content: '...';
    animation: dots 1.5s steps(3, end) infinite;
}

@keyframes dots {
    0% { content: ''; }
    33% { content: '.'; }
    66% { content: '..'; }
    100% { content: '...'; }
}
