/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

/* Login page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 32px;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

/* Form styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.error-message {
    color: #e74c3c;
    font-size: 14px;
    margin: 10px 0;
    display: none;
}

.error-message.show {
    display: block;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-secondary {
    padding: 10px 20px;
    background: #f0f0f0;
    color: #333;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-text {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 14px;
    padding: 10px;
}

.btn-text:hover {
    text-decoration: underline;
}

/* Chat interface */
.chat-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    margin-bottom: 15px;
    color: #667eea;
}

.user-info {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
}

.user-department {
    color: #95a5a6;
    margin-top: 5px;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.conversation-item {
    padding: 12px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.conversation-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.conversation-item.active {
    background: #667eea;
}

.conversation-title {
    font-size: 14px;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-date {
    font-size: 12px;
    color: #95a5a6;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Main chat area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.welcome-message {
    text-align: center;
    margin-top: 100px;
    color: #666;
}

.welcome-message h2 {
    margin-bottom: 10px;
}

.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-items: flex-end;
}

.message.assistant {
    align-items: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 15px;
    border-radius: 10px;
    line-height: 1.5;
}

.message.user .message-content {
    background: #667eea;
    color: white;
}

.message.assistant .message-content {
    background: #f0f0f0;
    color: #333;
}

/* Markdown styling in messages */
.message-content.markdown-body h1,
.message-content.markdown-body h2,
.message-content.markdown-body h3,
.message-content.markdown-body h4 {
    margin-top: 0.5em;
    margin-bottom: 0.3em;
    font-weight: 600;
}

.message-content.markdown-body h1 { font-size: 1.3em; }
.message-content.markdown-body h2 { font-size: 1.2em; }
.message-content.markdown-body h3 { font-size: 1.1em; }
.message-content.markdown-body h4 { font-size: 1em; }

.message-content.markdown-body p {
    margin: 0.5em 0;
}

.message-content.markdown-body ul,
.message-content.markdown-body ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-content.markdown-body li {
    margin: 0.3em 0;
}

.message-content.markdown-body strong {
    font-weight: 600;
}

.message-content.markdown-body em {
    font-style: italic;
}

.message-content.markdown-body code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

.message-content.markdown-body pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.8em;
    border-radius: 5px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.message-content.markdown-body pre code {
    background: none;
    padding: 0;
}

.message-content.markdown-body blockquote {
    border-left: 3px solid #667eea;
    margin: 0.5em 0;
    padding-left: 1em;
    color: #666;
}

.message-content.markdown-body table {
    border-collapse: collapse;
    margin: 0.5em 0;
    width: 100%;
}

.message-content.markdown-body th,
.message-content.markdown-body td {
    border: 1px solid #ddd;
    padding: 0.5em;
    text-align: left;
}

.message-content.markdown-body th {
    background: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.message-content.markdown-body hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 1em 0;
}

.message-sources {
    margin-top: 10px;
    padding: 10px;
    background: #fff3cd;
    border-radius: 5px;
    font-size: 12px;
}

.message-sources strong {
    display: block;
    margin-bottom: 5px;
}

.message-time {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

/* Chat input */
.chat-input-container {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
}

#chatForm {
    display: flex;
    gap: 10px;
}

#messageInput {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

#messageInput:focus {
    outline: none;
    border-color: #667eea;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.show {
    display: block;
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

/* Loading indicator */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
