/* 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;
}

.btn-icon {
    padding: 8px 12px;
    font-size: 18px;
    line-height: 1;
}

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

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

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

.sidebar-header .close-sidebar-btn {
    position: absolute;
    top: 10px;
    right: 10px;
}

.user-info {
    padding: 10px 0 15px 0;
    font-size: 16px;
    text-align: center;
}

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

.btn-sidebar {
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 10px;
}

.btn-sidebar:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-new-chat {
    background: #667eea;
    margin: 0 15px 15px 15px;
    width: calc(100% - 30px);
}

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

.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: 15px;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px 10px 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: 15px;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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


/* 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-sources .source-link {
    color: #856404;
    text-decoration: none;
    display: inline-block;
    transition: color 0.2s;
}

.message-sources .source-link:hover {
    color: #533f03;
    text-decoration: underline;
}

.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;
}

#chatForm .btn-primary {
    width: auto;
    padding: 12px 20px;
    flex-shrink: 0;
}

#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); }
}

/* Acknowledgment message - shown while RAG is searching */
.acknowledgment {
    font-style: italic;
    color: #666;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.message.assistant .acknowledgment {
    color: #555;
}

/* Error message styling */
.message-content .error {
    color: #e74c3c;
}

/* Command styling - console/terminal appearance */
.command-block {
    margin-bottom: 20px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.command-input {
    background: #1e1e1e;
    color: #4ec9b0;
    padding: 10px 15px;
    border-radius: 6px 6px 0 0;
    border-left: 3px solid #4ec9b0;
}

.command-prompt {
    color: #569cd6;
    margin-right: 8px;
    font-weight: bold;
}

.command-output {
    background: #252526;
    color: #d4d4d4;
    padding: 15px;
    border-radius: 0 0 6px 6px;
    border-left: 3px solid #3c3c3c;
    overflow-x: auto;
}

.command-output pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* Burger menu button - hidden on desktop */
.burger-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 15px;
}

.burger-menu-btn span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: #333;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Close sidebar button - hidden on desktop */
.close-sidebar-btn {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.close-sidebar-btn:hover {
    color: #667eea;
}


/* Sidebar overlay - hidden by default */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

.sidebar-overlay.show {
    display: block;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    /* Show burger menu */
    .burger-menu-btn {
        display: flex;
    }

    /* Show close button in sidebar */
    .close-sidebar-btn {
        display: block;
    }

    /* Sidebar as overlay */
    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        height: 100vh;
        z-index: 999;
        transition: left 0.3s ease;
    }

    .sidebar.show {
        left: 0;
    }

    /* Chat header adjustments */
    .chat-header {
        padding: 15px;
    }

    .chat-header h3 {
        font-size: 16px;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }


    /* Messages container */
    .messages-container {
        padding: 15px;
    }

    /* Message content wider on mobile */
    .message-content {
        max-width: 85%;
    }

    /* Chat input adjustments */
    .chat-input-container {
        padding: 15px;
    }

    #chatForm {
        gap: 8px;
    }

    #chatForm .btn-primary {
        padding: 12px 16px;
    }

    /* Welcome message */
    .welcome-message {
        margin-top: 50px;
        padding: 0 20px;
    }

    .welcome-message h2 {
        font-size: 20px;
    }

    /* Modal adjustments */
    .modal-content {
        margin: 20% auto;
        padding: 20px;
        width: 95%;
    }

    /* Conversations list responsive */
    .conversations-list {
        padding: 8px;
    }

    .conversation-item {
        padding: 14px 12px;
        margin-bottom: 6px;
        min-height: 48px;
    }

    .conversation-title {
        font-size: 15px;
    }

    .conversation-date {
        font-size: 13px;
    }

    /* User info in sidebar */
    .user-info {
        padding: 10px 0;
        font-size: 17px;
    }

    /* Sidebar buttons */
    .btn-sidebar {
        font-size: 17px;
        padding: 16px 20px;
        min-height: 52px;
    }

    .btn-new-chat {
        margin: 0 10px 10px 10px;
        width: calc(100% - 20px);
    }

    /* Sidebar header */
    .sidebar-header {
        padding: 15px;
    }
}
