:root {
    --rb-body-bg: #f8f9fa;
    --rb-body-color: #212529;
    --rb-card-bg: #ffffff;
    --rb-card-shadow: 0 2px 4px rgba(0,0,0,0.1);
    --rb-border-color: #dee2e6;
    --rb-text-muted: #6c757d;
}

[data-bs-theme="dark"] {
    --rb-body-bg: #212529;
    --rb-body-color: #f8f9fa;
    --rb-card-bg: #2b3035;
    --rb-card-shadow: 0 2px 4px rgba(0,0,0,0.3);
    --rb-border-color: #495057;
    --rb-text-muted: #adb5bd;
}

body {
    background-color: var(--rb-body-bg);
    color: var(--rb-body-color);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.card {
    background-color: var(--rb-card-bg);
    box-shadow: var(--rb-card-shadow);
    border: 1px solid var(--rb-border-color);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.card-body h3 {
    margin-bottom: 0;
}

.table {
    color: var(--rb-body-color);
}

.table th {
    font-size: 0.9rem;
    border-color: var(--rb-border-color);
}

.table td {
    border-color: var(--rb-border-color);
}

.text-muted {
    color: var(--rb-text-muted) !important;
}

.bg-light {
    background-color: var(--rb-card-bg) !important;
}

footer {
    background-color: var(--rb-card-bg) !important;
    border-top: 1px solid var(--rb-border-color);
}

.btn-outline-secondary {
    color: var(--rb-body-color);
    border-color: var(--rb-border-color);
}

.btn-outline-secondary:hover {
    background-color: var(--rb-border-color);
    color: var(--rb-body-color);
}

.navbar-brand small {
    color: var(--rb-text-muted);
}

[data-bs-theme="dark"] .navbar.bg-dark {
    background-color: #1a1d20 !important;
}

[data-bs-theme="dark"] .table-hover tbody tr:hover {
    background-color: rgba(255,255,255,0.04);
}

.chat-container {
    height: calc(100vh - 200px);
    min-height: 400px;
    max-height: 600px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-bubble {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    position: relative;
    word-wrap: break-word;
}

.chat-bubble-user {
    background-color: var(--rb-chat-user-bg, #0d6efd);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 0.25rem;
}

.chat-bubble-bot {
    background-color: var(--rb-chat-bot-bg, #e9ecef);
    color: var(--rb-body-color);
    margin-right: auto;
    border-bottom-left-radius: 0.25rem;
}

.chat-bubble-time {
    font-size: 0.65rem;
    opacity: 0.7;
    margin-top: 0.25rem;
    text-align: right;
}

.chat-bubble-user .chat-bubble-time {
    color: rgba(255,255,255,0.8);
}

.chat-bubble-bot .chat-bubble-time {
    color: var(--rb-text-muted);
}

.chat-bubble p {
    margin-bottom: 0.5rem;
}

.chat-bubble p:last-child {
    margin-bottom: 0;
}

.chat-bubble ul, .chat-bubble ol {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
}

.chat-bubble code {
    background-color: rgba(0,0,0,0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

[data-bs-theme="dark"] .chat-bubble-bot code {
    background-color: rgba(255,255,255,0.1);
}

.chat-bubble pre {
    background-color: rgba(0,0,0,0.1);
    padding: 0.5rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

[data-bs-theme="dark"] .chat-bubble-bot pre {
    background-color: rgba(255,255,255,0.1);
}

.chat-sources {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--rb-border-color);
}

.chat-source-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: rgba(0,0,0,0.03);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
}

[data-bs-theme="dark"] .chat-source-item {
    background-color: rgba(255,255,255,0.05);
}

.chat-source-badge {
    background-color: var(--rb-primary, #0d6efd);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    white-space: nowrap;
}

.chat-source-text {
    flex: 1;
    color: var(--rb-text-muted);
    line-height: 1.4;
}

.chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--rb-border-color);
    background-color: var(--rb-card-bg);
}

.chat-textarea {
    resize: none;
    border-radius: 1.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--rb-border-color);
    background-color: var(--rb-body-bg);
    color: var(--rb-body-color);
    min-height: 48px;
    max-height: 150px;
}

.chat-textarea:focus {
    border-color: var(--rb-primary, #0d6efd);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.chat-btn-send {
    border-radius: 50%;
    width: 48px;
    height: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-btn-cancel {
    border-radius: 1.5rem;
    padding: 0.5rem 1rem;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: var(--rb-text-muted);
}

.chat-status-dots::after {
    content: '';
    animation: chatDots 1.5s steps(4, end) infinite;
}

@keyframes chatDots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

mark {
    background-color: rgba(13, 110, 253, 0.2);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    cursor: help;
}

[data-bs-theme="dark"] mark {
    background-color: rgba(13, 110, 253, 0.4);
}

.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--rb-text-muted);
    text-align: center;
    padding: 2rem;
}

.chat-empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

[data-bs-theme="dark"] .chat-bubble-bot {
    --rb-chat-bot-bg: #2b3035;
}

[data-bs-theme="dark"] .chat-bubble-user {
    --rb-chat-user-bg: #0d6efd;
}

[data-bs-theme="light"] .chat-bubble-bot {
    --rb-chat-bot-bg: #e9ecef;
}

[data-bs-theme="light"] .chat-bubble-user {
    --rb-chat-user-bg: #0d6efd;
}