/* General App Body & Layout */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f8f9fa;
    color: #212529;
}

/* Main Chat Layout */
.chat-container {
    display: flex;
    height: calc(100vh - 120px); /* Adjusted for header/footer */
    width: 100%;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
}

/* Sidebar Styles */
.chat-sidebar {
    width: 280px;
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    flex-shrink: 0;
}

.new-chat-form {
    display: flex;
    margin-bottom: 1rem;
}

.new-chat-form input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem 0 0 0.375rem;
    font-size: 0.9rem;
}

.new-chat-form button {
    padding: 0.75rem 1rem;
    background-color: #0d6efd;
    color: #fff;
    border: 1px solid #0d6efd;
    border-radius: 0 0.375rem 0.375rem 0;
    cursor: pointer;
}

.conversation-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
}

.conversation-list a {
    display: block;
    padding: 0.75rem 1rem;
    color: #495057;
    text-decoration: none;
    border-radius: 0.375rem;
    margin-bottom: 0.25rem;
}

.conversation-list a:hover {
    background-color: #e9ecef;
}

.conversation-list a.active {
    background-color: #0d6efd;
    color: #fff;
}

/* Main Content Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    position: relative; /* Needed for loader overlay */
}

/* Chat Header */
.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

/* Message Area */
.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.message {
    margin-bottom: 1rem;
    display: flex;
}

.message-content {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    line-height: 1.5;
}

.message.user {
    justify-content: flex-end;
}

.message.user .message-content {
    background-color: #0d6efd;
    color: #fff;
}

.message.ai .message-content {
    background-color: #e9ecef;
    color: #343a40;
}

.message-author {
    font-weight: bold;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

/* Message Input Form */
.chat-form-container {
    padding: 1rem 1.5rem;
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

.chat-form {
    display: flex;
}

.chat-form textarea {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    font-size: 1rem;
    resize: none;
}

.chat-form button {
    margin-left: 1rem;
    padding: 0.75rem 1.5rem;
    background-color: #0d6efd;
    color: #fff;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
}

/* Empty State for Chat */
.no-conversation-selected {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: #6c757d;
}

/* Loader Styles */
.loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.loader {
    border: 5px solid #f3f3f3; /* Light grey */
    border-top: 5px solid #0d6efd; /* Blue */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* System and AI Command Messages */
.message.system .message-content {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.ai_command .message-content {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.message.ai_command .message-content pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
}

.kanban-card .card-body {
    position: relative;
}

.delete-task-form {
    position: absolute;
    top: 10px;
    right: 10px;
}