/* DocChat Styles - Version 6.0 - Integrated with Platform Theme */

/* Use platform CSS variables for consistency */
:root {
    --primary-color: var(--primary, #00C853);
    --secondary-color: var(--secondary, #535758);
    --success-color: var(--brand-green, #00C853);
    --danger-color: var(--danger, #DC143C);
    --bg-color: var(--background, #fdfcfa);
    --surface-color: var(--background-warm, #f5f5f0);
    --border-color: var(--border, #d4d2c8);
    --text-primary: var(--text-primary, #000000);
    --text-secondary: var(--text-secondary, #212121);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Enhanced button hover effects */
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-primary:hover {
    background: var(--primary) !important;
    filter: brightness(1.1);
}

.btn-secondary:hover {
    background: var(--secondary) !important;
    filter: brightness(1.1);
}

/* Mode card selection styles */
.mode-option input[type="radio"]:checked + .mode-card {
    border-color: var(--primary) !important;
    background: var(--primary) !important;
    color: white !important;
}

.mode-option input[type="radio"]:checked + .mode-card strong,
.mode-option input[type="radio"]:checked + .mode-card p {
    color: white !important;
}

.mode-option:hover .mode-card {
    border-color: var(--primary) !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* Checkbox label hover */
label:has(input[type="checkbox"]):hover {
    background: var(--background-warm) !important;
    border-color: var(--primary) !important;
}

/* Export button specific colors */
#export-word-btn:hover {
    background: #1B5E20 !important;
}

#export-pdf-btn:hover {
    background: #B71C1C !important;
}

#clear-chat-btn:hover {
    filter: brightness(0.9);
}

/* Drop zone hover effect */
.drag-drop-area:hover {
    border-color: var(--primary) !important;
    background: var(--background-warm) !important;
}

/* Override platform main-content for DocChat */
.docchat-container {
    width: 100%;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    background: var(--background);
}

/* Ensure all text is visible */
.docchat-container * {
    color: inherit;
}

.docchat-container h1,
.docchat-container h2,
.docchat-container h3,
.docchat-container h4,
.docchat-container p,
.docchat-container span,
.docchat-container label,
.docchat-container div {
    color: var(--text-primary);
}

.docchat-container .text-secondary,
.docchat-container small {
    color: var(--text-secondary);
}

.docchat-body {
    font-family: var(--font-family, 'Lora', serif);
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header - Platform Styled */
.header,
.docchat-header {
    background: var(--background-warm);
    color: var(--text-primary);
    padding: 1.5rem 2rem;
    border-bottom: 2px solid var(--border);
    box-shadow: var(--shadow);
}

.header h1,
.docchat-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    font-family: var(--font-family-header, 'Comfortaa', sans-serif);
    color: var(--text-primary);
}

.subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.stats {
    display: flex;
    gap: 2rem;
    font-size: 0.9rem;
}

.stats span {
    background: var(--warm-coral-light);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.help-button {
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: inline-block;
    border: 2px solid var(--primary);
}

.help-button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Main Content */
.docchat-container .main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0;
}

/* Sidebar */
.sidebar {
    width: 340px;
    background: var(--background-warm);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-section {
    margin-bottom: 0;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.sidebar-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.6rem;
    color: var(--text-primary);
}

/* Mode Selector */
.mode-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mode-option {
    cursor: pointer;
}

.mode-option input[type="radio"] {
    display: none;
}

.mode-card {
    padding: 0.6rem 0.8rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    transition: all 0.2s;
}

.mode-option input[type="radio"]:checked + .mode-card {
    border-color: var(--primary-color);
    background: var(--warm-gold-light);
}

.mode-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.mode-card strong {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
    color: var(--text-primary);
}

.mode-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Settings */
.settings {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.settings > div {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.settings label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.3rem 0;
    color: var(--text-primary);
}

.settings label input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.settings label:has(input[type="number"]) {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.settings input[type="number"] {
    width: 60px;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.model-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.model-select:hover {
    border-color: var(--primary-color);
}

.model-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 200, 83, 0.1);
}

/* Upload Area */
.upload-area {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

/* Drag and Drop Zone */
.drag-drop-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    background: var(--background-warm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.drag-drop-area:hover {
    border-color: var(--primary-color);
    background: var(--warm-gold-light);
}

.drag-drop-area.drag-over {
    border-color: var(--primary-color);
    background: var(--warm-gold-light);
    transform: scale(1.02);
}

.drop-zone-content {
    pointer-events: none;
}

.drop-zone-text {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.drop-zone-subtext {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.upload-area input[type="file"] {
    font-size: 0.8rem;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.upload-area button {
    font-size: 0.85rem;
    padding: 0.5rem;
}

.upload-status {
    margin-top: 0.3rem;
    padding: 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.upload-status.success {
    background: #d1fae5;
    color: #065f46;
}

.upload-status.error {
    background: #fee2e2;
    color: #991b1b;
}

/* Document List */
.document-list {
    max-height: 200px;
    overflow-y: auto;
}

.document-item {
    padding: 0.5rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.document-item:last-child {
    border-bottom: none;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background);
    color: var(--text-primary);
    width: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: var(--background);
    color: var(--text-primary);
}

.welcome-message {
    background: var(--background-warm);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    max-width: 600px;
    margin: 2rem auto;
    color: var(--text-primary);
}

.welcome-message h2 {
    color: var(--primary);
    margin-bottom: 1rem;
}

.welcome-message p {
    color: var(--text-primary);
}

.welcome-message ul {
    text-align: left;
    max-width: 500px;
    margin: 1.5rem auto;
}

.welcome-message li {
    margin-bottom: 0.75rem;
}

/* Message Bubbles */
.message {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

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

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

.message-header {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message.user .message-header {
    color: var(--primary);
}

.message.assistant .message-header {
    color: var(--secondary);
}

.message.user .message-header::before {
    content: "👤";
    font-size: 1.1rem;
}

.message.assistant .message-header::before {
    content: "🤖";
    font-size: 1.1rem;
}

.message-content {
    max-width: 75%;
    padding: 1.25rem 1.5rem;
    border-radius: 16px;
    line-height: 1.7;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    position: relative;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary) 0%, #00a346 100%);
    color: white;
    border: none;
    font-weight: 500;
}

.message.assistant .message-content {
    background: var(--background-warm);
    border: 2px solid var(--border);
    color: var(--text-primary);
}

.message-metadata {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Chat Input Area */
.chat-input-area {
    border-top: 1px solid var(--border);
    padding: 1.5rem 2rem;
    background: var(--background-warm);
}

.task-progress {
    margin-bottom: 1rem;
}

.progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s;
    animation: progress-animation 2s infinite;
}

@keyframes progress-animation {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 0%; }
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.input-container {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

#chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    transition: border-color 0.2s;
}

#chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-hover);
}

/* Markdown Styling in Messages */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.message-content p {
    margin-bottom: 0.75rem;
}

.message-content ul,
.message-content ol {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'Courier New', monospace;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 0.75rem;
}

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

/* Custom Instructions */
.custom-instructions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.custom-instructions textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    resize: vertical;
    background: var(--background-warm);
    color: var(--text-primary);
}

.custom-instructions textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.instruction-buttons {
    display: flex;
    gap: 0.5rem;
}

.instruction-buttons button {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background-warm);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.instruction-buttons button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Actions Section */
.actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.actions button {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background-warm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.actions button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Upload Section */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.upload-section input[type="file"] {
    font-size: 0.8rem;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--background-warm);
    color: var(--text-primary);
}

.upload-section button {
    width: 100%;
    padding: 0.6rem;
    border: none;
    border-radius: 6px;
    background: var(--primary);
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-section button:hover {
    background: var(--primary-hover);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
    
    .message-content {
        max-width: 85%;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .message-content {
        max-width: 95%;
    }
}

/* Source Tree Styles */
.source-selection {
    display: flex;
    flex-direction: column;
}

.source-selection .help-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.selected-summary {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0.4rem;
    background: #f8f9fa;
    border-radius: 4px;
    text-align: center;
    font-style: italic;
    margin-top: 0.3rem;
}

.source-tree {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    background: #fafafa;
}

.source-tree .loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 1rem;
}

.tree-node {
    margin-left: 0;
    padding-left: 0;
}

.tree-node-item {
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
}

.tree-node-item:hover {
    background: rgba(37, 99, 235, 0.08);
}

.tree-node-item .icon {
    font-size: 0.9rem;
    width: 16px;
    text-align: center;
}

.tree-node-item input[type="checkbox"] {
    margin: 0;
}

.tree-node-item .label {
    flex: 1;
    font-size: 0.9rem;
}

.tree-node-item .badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    background: #e0e0e0;
    color: #666;
}

.tree-node-item .badge.indexed {
    background: #d4edda;
    color: #155724;
}

/* Folder items - same styling as tree-node-item for consistency */
.tree-item {
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
}

.tree-item:hover {
    background: rgba(37, 99, 235, 0.08);
}

.tree-item .icon {
    font-size: 0.9rem;
    width: 16px;
    text-align: center;
}

.tree-item input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
}

.tree-item .label {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
}

.folder-toggle {
    cursor: pointer;
    user-select: none;
    padding: 0 4px;
    font-size: 0.8rem;
    color: #666;
    transition: transform 0.2s;
    display: inline-block;
    min-width: 16px;
    text-align: center;
}

.folder-toggle:hover {
    color: var(--primary-color);
}

.tree-children {
    margin-left: 1.25rem;
    border-left: 1px dashed var(--border);
    padding-left: 0.5rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.tree-children.expanded {
    max-height: 10000px;
    transition: max-height 0.5s ease-in;
}

.source-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-sm:hover {
    opacity: 0.9;
}

.selected-count {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* References Styles */
.message-references {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.message-references h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.reference-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.reference-item {
    background: #f8f9fa;
    border-left: 3px solid var(--primary-color);
    padding: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.reference-item:hover {
    background: #e9ecef;
    transform: translateX(3px);
}

.reference-item .ref-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.reference-item .ref-number {
    background: var(--primary-color);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.reference-item .ref-title {
    font-weight: 600;
    font-size: 0.9rem;
    flex: 1;
}

.reference-item .ref-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Inline reference citations */
.inline-reference {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    margin: 0 0.2rem;
    text-decoration: none;
}

.inline-reference:hover {
    opacity: 0.8;
}

/* Document Viewer Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 900px;
    max-height: 85vh;
    width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    line-height: 1;
}

.modal-close:hover {
    background: #f0f0f0;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.document-content {
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
}

/* Source Selection Modal Styles */
.source-tree-modal {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    background: #fafafa;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.modal-actions .selected-count {
    margin-left: auto;
    font-weight: 600;
    color: var(--primary-color);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

[data-theme="night"] .sidebar-section {
    border-bottom-color: var(--border);
}

[data-theme="night"] .mode-card {
    border-color: var(--border);
    background: var(--background);
}

[data-theme="night"] .mode-option input[type="radio"]:checked + .mode-card {
    border-color: var(--primary);
    background: var(--background-alt);
}

[data-theme="night"] .mode-card:hover {
    border-color: var(--primary);
}

[data-theme="night"] .model-select,
[data-theme="night"] .settings input[type="number"] {
    background: var(--background-alt);
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="night"] .model-select:hover,
[data-theme="night"] .model-select:focus {
    border-color: var(--primary);
}

[data-theme="night"] .drag-drop-area {
    background: var(--background-alt);
    border-color: var(--border);
}

[data-theme="night"] .drag-drop-area:hover,
[data-theme="night"] .drag-drop-area.drag-over {
    border-color: var(--primary);
    background: var(--background-warm);
}

[data-theme="night"] .upload-area input[type="file"] {
    border-color: var(--border);
    background: var(--background-alt);
    color: var(--text-primary);
}

[data-theme="night"] .document-item {
    border-bottom-color: var(--border);
}

[data-theme="night"] .chat-area {
    background: var(--background);
}

[data-theme="night"] .chat-messages {
    background: var(--background);
}

[data-theme="night"] .welcome-message {
    background: var(--background-warm);
    border-color: var(--border);
}

[data-theme="night"] .message.assistant .message-content {
    background: var(--background-alt);
    border-color: var(--border);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

[data-theme="night"] .message.user .message-content {
    background: linear-gradient(135deg, var(--primary) 0%, #00a346 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

[data-theme="night"] .chat-input-area {
    background: var(--background-warm);
    border-top-color: var(--border);
}

[data-theme="night"] #chat-input,
[data-theme="night"] #question-input {
    background: var(--background-alt);
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="night"] #chat-input:focus,
[data-theme="night"] #question-input:focus {
    border-color: var(--primary);
}

[data-theme="night"] .btn-primary {
    background: var(--primary);
    color: white;
}

[data-theme="night"] .btn-primary:hover {
    background: var(--primary-hover);
}

[data-theme="night"] .btn-secondary {
    background: var(--background-alt);
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="night"] .btn-secondary:hover {
    background: var(--background-warm);
}

[data-theme="night"] .source-item {
    background: var(--background-alt);
    border-color: var(--border);
}

[data-theme="night"] .source-item:hover {
    background: var(--background-warm);
    border-color: var(--primary);
}

[data-theme="night"] .metadata-item {
    color: var(--text-secondary);
}

[data-theme="night"] .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

[data-theme="night"] .modal-content {
    background: var(--background-warm);
    border-color: var(--border);
}

[data-theme="night"] .modal-header {
    border-bottom-color: var(--border);
}

[data-theme="night"] .modal-close:hover {
    background: var(--background-alt);
}

[data-theme="night"] .document-content {
    background: var(--background-alt);
    color: var(--text-primary);
}

[data-theme="night"] .source-tree-modal {
    background: var(--background-alt);
    border-color: var(--border);
}

[data-theme="night"] .modal-footer {
    border-top-color: var(--border);
}

[data-theme="night"] .modal-actions {
    border-bottom-color: var(--border);
}

[data-theme="night"] .upload-status.success {
    background: rgba(0, 200, 83, 0.2);
    color: #6ee7b7;
}

[data-theme="night"] .upload-status.error {
    background: rgba(220, 20, 60, 0.2);
    color: #fca5a5;
}

[data-theme="night"] .back-button {
    background: var(--background-alt);
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="night"] .back-button:hover {
    border-color: var(--primary);
}

[data-theme="night"] .custom-instructions textarea {
    background: var(--background-alt);
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="night"] .instruction-buttons button {
    background: var(--background-alt);
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="night"] .instruction-buttons button:hover {
    background: var(--background-warm);
    border-color: var(--primary);
}

[data-theme="night"] .actions button {
    background: var(--background-alt);
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="night"] .actions button:hover {
    background: var(--background-warm);
    border-color: var(--primary);
}

[data-theme="night"] .upload-section input[type="file"] {
    background: var(--background-alt);
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="night"] .upload-section button {
    background: var(--primary);
    color: white;
}

[data-theme="night"] .upload-section button:hover {
    background: var(--primary-hover);
}

/* User Guide Styles */
.user-guide-content {
    background: var(--background-warm);
    color: var(--text-primary);
}

.user-guide-content section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.user-guide-content h2 {
    color: var(--text-primary);
    font-family: var(--font-family-header);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.user-guide-content h3 {
    color: var(--text-primary);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.user-guide-content p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.user-guide-content ol,
.user-guide-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.user-guide-content li {
    margin-bottom: 0.5rem;
}

.mode-descriptions .mode-desc {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--background-warm);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.mode-descriptions .mode-desc h3 {
    color: var(--primary);
    margin-top: 0;
}

.mode-descriptions .mode-desc p {
    margin-bottom: 0.5rem;
}

[data-theme="night"] .user-guide-content section {
    background: var(--background-alt);
}

[data-theme="night"] .mode-descriptions .mode-desc {
    background: var(--background-alt);
}

/* Ensure proper text colors in night mode */
[data-theme="night"] .docchat-container {
    background: var(--background);
    color: var(--text-primary);
}

[data-theme="night"] .user-guide-content {
    background: var(--background);
}

