/* General Reset */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f6;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

#chat-container {
    width: 100%;
    max-width: 600px;
    height: 80vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column; /* CRITICAL: Forces messages to stack vertically */
    gap: 15px;
    background-color: #ffffff;
}

.message {
    max-width: 85%; 
    width: 100%; /* Change from fit-content to 100% */
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: block;
    padding: 12px 16px; /* Ensure padding is here for the bubble look */
    border-radius: 12px;
    line-height: 1.5;
}

/* User Messages (Aligned Right) */
.user-message {
    align-self: flex-end;
    background-color: #007bff;
    color: white;
    border-bottom-right-radius: 2px;
}

/* AI Messages (Aligned Left) */
.ai-message {
    align-self: flex-start;
    background-color: #e9ecef;
    color: #333;
    border-bottom-left-radius: 2px;
}

.ai-message p, 
.ai-message h1, 
.ai-message h2, 
.ai-message h3, 
.ai-message ul, 
.ai-message ol {
    margin-top: 0;
    margin-bottom: 10px;
    width: 100%; /* Force full width to prevent side-by-side clashing */
}

.ai-message li {
    margin-bottom: 5px;
    padding-left: 5px;
}

#input-area {
    display: flex;
    padding: 15px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

#user-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 25px;
    outline: none;
    transition: border 0.3s;
}

#user-input:focus {
    border-color: #007bff;
}

button {
    margin-left: 10px;
    padding: 8px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

button:hover {
    background-color: #0056b3;
}

table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
}

th, td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

th {
    background-color: #f2f2f2;
}