/* Modern CSS Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* CSS Variables - OSCM Journal Theme (Dark Background) */
:root {
    --primary-color: #2196f3;
    --primary-hover: #1976d2;
    --accent-color: #42a5f5;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --user-message: #2196f3;
    --assistant-message: #374151;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --radius: 8px;
    --focus-ring: rgba(33, 150, 243, 0.3);
    --welcome-bg: #1e3a5f;
    --welcome-border: #2196f3;
}

/* Base Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Container - Full Screen Responsive */
.container {
    height: 100vh;
    width: 100%;
    max-width: 100vw;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
}

/* Header - Hidden */
header {
    display: none;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Main Content Area with Sidebar - Responsive */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: var(--background);
    width: 100%;
    max-width: 100%;
}

/* Left Sidebar */
.sidebar {
    width: 320px;
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

/* Custom Scrollbar for Sidebar */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

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

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

/* PDF Upload Section */
.upload-collapsible {
    margin-bottom: 1rem;
}

.upload-header {
    cursor: pointer;
    padding: 0.75rem;
    background: var(--surface-hover);
    border-radius: 8px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}

.upload-header:hover {
    background: rgba(37, 99, 235, 0.1);
}

.upload-container {
    margin-top: 1rem;
    padding: 0.5rem;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: rgba(37, 99, 235, 0.05);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.2);
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.upload-text {
    color: var(--text-primary);
    font-weight: 500;
    margin: 0.5rem 0;
}

.upload-subtext {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

.upload-status {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 6px;
    background: var(--surface-hover);
}

.status-message {
    font-size: 0.875rem;
    line-height: 1.4;
}

.status-message.status-processing {
    color: var(--primary-color);
}

.status-message.status-success {
    color: #10b981;
}

.status-message.status-error {
    color: #ef4444;
}

.progress-bar {
    margin-top: 0.5rem;
    height: 6px;
    background: rgba(51, 65, 85, 0.5);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #60a5fa);
    width: 0;
    border-radius: 3px;
    position: relative;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.5);
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: shimmer 2s infinite;
}

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

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Upload Mode Selection */
.upload-mode {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: rgba(51, 65, 85, 0.3);
    border-radius: 6px;
}

.upload-mode-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.upload-mode-label:hover {
    background: rgba(37, 99, 235, 0.1);
    color: var(--text-primary);
}

.upload-mode-label input[type="radio"] {
    margin: 0;
    width: 12px;
    height: 12px;
}

.upload-mode-label input[type="radio"]:checked + span,
.upload-mode-label:has(input[type="radio"]:checked) {
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
}

/* Queue Status Section */
.queue-collapsible {
    margin-bottom: 1rem;
}

.queue-header {
    cursor: pointer;
    padding: 0.75rem;
    background: var(--surface-hover);
    border-radius: 8px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}

.queue-header:hover {
    background: rgba(37, 99, 235, 0.1);
}

.queue-container {
    margin-top: 1rem;
    padding: 0.5rem;
}

.queue-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(51, 65, 85, 0.3);
    border-radius: 6px;
}

.queue-stats .stat-item {
    text-align: center;
}

.queue-stats .stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.queue-stats .stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
}

.queue-jobs {
    max-height: 200px;
    overflow-y: auto;
    border-radius: 6px;
    background: rgba(51, 65, 85, 0.2);
}

.queue-job {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.queue-job:last-child {
    border-bottom: none;
}

.queue-job-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-job-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.job-status {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
}

.job-status.queued {
    background: rgba(156, 163, 175, 0.2);
    color: #9ca3af;
}

.job-status.processing {
    background: rgba(37, 99, 235, 0.2);
    color: var(--primary-color);
}

.job-status.completed {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.job-status.failed {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.job-status.duplicate {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

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

.no-jobs {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.clear-queue-btn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-queue-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.job-error {
    font-size: 0.7rem;
    color: #ef4444;
    margin-top: 0.25rem;
    padding: 0.125rem 0.25rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 3px;
    cursor: help;
}

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

.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-section:last-child {
    margin-bottom: 0;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    justify-content: center;
    overflow: hidden;
    padding: 0;
    background: var(--background);
}

/* Chat Container - Centered with Max Width */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background);
    overflow: hidden;
    width: 100%;
    max-width: none;
    margin: 0;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--background);
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--surface);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Message Styles */
.message {
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.message-content {
    padding: 0.75rem 1.25rem;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user .message-content {
    background: var(--user-message);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--surface);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

/* Message metadata */
.message-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    padding: 0 0.5rem;
}

.message.user .message-meta {
    text-align: right;
}

/* Collapsible Sources */
.sources-collapsible {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.sources-collapsible summary {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    user-select: none;
    font-weight: 500;
}

.sources-collapsible summary:hover {
    color: var(--text-primary);
}

.sources-collapsible[open] summary {
    margin-bottom: 0.25rem;
}

.sources-content {
    padding: 0 0.5rem 0.25rem 1.5rem;
    color: var(--text-secondary);
}

/* Citation Styles */
.message-content sup {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.75em;
    margin-left: 1px;
    cursor: help;
}

.citations-section {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.875rem;
}

.citations-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.citations-list {
    margin: 0;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.citation-item {
    margin: 0.5rem 0;
    line-height: 1.5;
}

.citation-filename {
    font-weight: 500;
    color: var(--primary-color);
}

.citation-course {
    font-weight: 500;
}

.citation-instructor {
    font-style: italic;
}

.citation-lesson {
    color: var(--text-secondary);
}

.citation-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.citation-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Markdown formatting styles */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 0.5rem 0;
    font-weight: 600;
}

.message-content h1 { font-size: 1.5rem; }
.message-content h2 { font-size: 1.3rem; }
.message-content h3 { font-size: 1.1rem; }

.message-content p {
    margin: 0.5rem 0;
    line-height: 1.6;
}

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

.message-content li {
    margin: 0.25rem 0;
    line-height: 1.6;
}

.message-content code {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.875em;
}

.message-content pre {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0.75rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

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

.message-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: var(--text-secondary);
}

/* Welcome message special styling */
.message.welcome-message .message-content {
    background: var(--surface);
    border: 2px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    position: relative;
}

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

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

.message-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1rem 0;
}

/* Chat Input Container */
.chat-input-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem;
    background: var(--background);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    min-height: 100px;
}

/* Chat Input */
#chatInput {
    flex: 1;
    width: 100%;
    padding: 10px 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.4;
    height: 70px;
    resize: none;
    overflow-y: auto;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

#chatInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

#chatInput::placeholder {
    color: var(--text-secondary);
}

/* Send Button */
#sendButton {
    padding: 0;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
}

#sendButton:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

#sendButton:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

#sendButton:active:not(:disabled) {
    transform: translateY(0);
}

#sendButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading Animation */
.loading {
    display: inline-flex;
    gap: 4px;
    padding: 0.75rem 1.25rem;
}

.loading span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Error Message */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    margin: 0.5rem 0;
}

/* Success Message */
.success-message {
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    border: 1px solid rgba(34, 197, 94, 0.2);
    margin: 0.5rem 0;
}

/* Sidebar Headers */
.stats-header,
.suggested-header {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem 0;
    border: none;
    background: none;
    list-style: none;
    outline: none;
    transition: color 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-header:focus,
.suggested-header:focus {
    color: var(--primary-color);
}

.stats-header:hover,
.suggested-header:hover {
    color: var(--primary-color);
}

.stats-header::-webkit-details-marker,
.suggested-header::-webkit-details-marker {
    display: none;
}

.stats-header::before,
.suggested-header::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.2s ease;
    font-size: 0.75rem;
}

details[open] .stats-header::before,
details[open] .suggested-header::before {
    transform: rotate(90deg);
}

/* Course Stats in Sidebar */
.course-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.75rem 0;
    background: transparent;
    border: none;
}

.stat-item {
    text-align: left;
    padding: 0;
    background: transparent;
    border: none;
    margin-bottom: 0;
}

.stat-item:last-child {
    margin-bottom: 0;
}


.stat-label {
    display: inline;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-value {
    display: inline;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

/* Course titles collapsible */
.course-titles-collapsible {
    width: 100%;
}

.course-titles-header {
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.5rem 0;
    list-style: none;
    display: block;
    user-select: none;
}

.course-titles-header:focus {
    outline: none;
    color: var(--primary-color);
}

.course-titles-header::-webkit-details-marker {
    display: none;
}

.course-titles-header::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.2s ease;
    font-size: 0.75rem;
}

.course-titles-collapsible[open] .course-titles-header::before {
    transform: rotate(90deg);
}

/* Course titles display */
.course-titles {
    margin-top: 0.5rem;
    /* Remove max-height to show all titles without scrolling */
}

.course-title-item {
    font-size: 0.85rem;
    color: var(--text-primary);
    padding: 0.5rem 0.25rem;
    border-bottom: 1px solid var(--border-color);
    text-transform: none;
    line-height: 1.4;
}

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

.course-title-item:first-child {
    padding-top: 0.25rem;
}

.no-courses, .loading, .error {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    text-transform: none;
}

/* Suggested Questions in Sidebar */
.suggested-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 0;
}

.suggested-item {
    padding: 0.75rem 1rem;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.suggested-item:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.suggested-item:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateX(2px);
}

/* Responsive Design */
/* Mobile Header - Hidden by default */
.mobile-header {
    display: none;
    align-items: center;
    padding: 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

.hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    color: var(--text-primary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-right: 1rem;
}

.hamburger-btn:hover {
    background: var(--surface-hover);
    color: var(--primary-color);
}

.mobile-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Mobile Sidebar Close Button */
.mobile-close-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem 0.5rem 1rem;
    margin: -1.5rem -1.5rem 0.5rem -1.5rem;
    background: var(--surface);
}

.close-sidebar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.close-sidebar-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 60;
    display: none;
}

.sidebar.mobile-open {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 70;
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.sidebar.mobile-open .mobile-close-header {
    display: flex !important;
}

.mobile-library-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.mobile-library-info .stat-value {
    color: var(--primary-color);
    font-weight: 600;
}

.desktop-only {
    display: block;
}

.sidebar.mobile-closed {
    transform: translateX(-100%);
}

/* Mobile - Hide sidebar completely by default */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }
    
    .main-content {
        flex-direction: row;
        height: 100%;
    }
    
    .sidebar {
        display: none;
        transform: translateX(-100%);
    }
    
    .chat-container {
        flex: 1;
        width: 100%;
        min-height: 100vh;
    }
    
    .chat-messages {
        padding: 1rem;
        flex: 1;
    }
    
    .message {
        max-width: 95%;
    }
    
    .message-content {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .chat-input-container {
        padding: 1.5rem 1rem;
        gap: 0.75rem;
        align-items: center;
        min-height: 90px;
    }
    
    #chatInput {
        width: 100%;
        padding: 8px 1.25rem;
        font-size: 0.95rem;
        height: 60px;
        line-height: 1.4;
        border-radius: 24px;
        box-sizing: border-box;
    }
    
    #sendButton {
        padding: 0;
        width: 48px;
        height: 48px;
        border-radius: 50%;
    }
    
    /* Reference controls responsive */
    .reference-controls-bottom {
        flex-direction: column;
        align-items: flex-end;
        gap: 0.5rem;
    }
    
    .control-buttons {
        gap: 0.5rem;
    }
    
    .dropdown-container {
        position: static;
    }
    
    .copy-dropdown {
        position: fixed;
        top: auto;
        bottom: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        z-index: 1000;
    }
    
    /* Template questions mobile */
    .template-question {
        padding: 0.75rem;
        font-size: 0.8rem;
        text-align: center;
    }
    
    /* Sidebar sections mobile */
    .sidebar-section {
        margin-bottom: 1rem;
    }
    
    .desktop-only {
        display: none;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .chat-messages {
        padding: 0.75rem;
    }
    
    .message-content {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    .references-section {
        padding: 0.75rem;
        margin-top: 1rem;
    }
    
    .reference-content {
        font-size: 0.8rem;
        line-height: 1.5;
    }
    
    .chat-input-container {
        padding: 0.75rem;
    }
    
    #chatInput {
        padding: 0.75rem;
        font-size: 0.85rem;
    }
    
    .sidebar {
        padding: 0.75rem;
        max-height: 35vh;
    }
    
    .template-question {
        padding: 0.6rem;
        font-size: 0.75rem;
    }
}

/* Large screens - Full width usage */
@media (min-width: 1200px) {
    .chat-container {
        max-width: none;
        padding: 0 2rem;
    }
    
    .chat-messages {
        padding: 2rem 4rem;
    }
    
    .message {
        max-width: 85%;
    }
    
    .sidebar {
        width: 350px;
        padding: 2rem;
    }
}

/* Desktop - Optimized layout */
@media (min-width: 1024px) and (max-width: 1199px) {
    .chat-messages {
        padding: 1.5rem 2rem;
    }
    
    .sidebar {
        width: 320px;
    }
}

/* Tablet - Adjusted sidebar */
@media (max-width: 1023px) {
    .sidebar {
        width: 280px;
        padding: 1.25rem;
    }
    
    .chat-messages {
        padding: 1rem 1.5rem;
    }
}

/* Academic Citation Styling */
.citations-section {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--surface);
    border-left: 3px solid var(--primary-color);
    border-radius: 8px;
    font-size: 0.9rem;
}

.citations-header {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.citations-list {
    margin: 0;
    padding-left: 1.2rem;
    list-style: none;
    counter-reset: citation-counter;
}

.citation-item {
    counter-increment: citation-counter;
    margin-bottom: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    position: relative;
}

.citation-item::before {
    content: counter(citation-counter);
    position: absolute;
    left: -1.2rem;
    top: 0;
    font-weight: 600;
    color: var(--primary-color);
    background: var(--primary-color);
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.citation-item:last-child {
    margin-bottom: 0;
}

/* APA-specific styling */
.citation-item em {
    font-style: italic;
    color: var(--text-primary);
}

.citation-section {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.citation-filename {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* Update document titles styling */
.document-title-item {
    font-size: 0.85rem;
    color: var(--text-primary);
    padding: 0.5rem 0.25rem;
    border-bottom: 1px solid var(--border-color);
    text-transform: none;
    line-height: 1.4;
}

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

.document-title-item:first-child {
    padding-top: 0.25rem;
}

.no-documents {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    text-transform: none;
}

/* Minimal Admin Access Icon */
.admin-access-minimal {
    margin-top: auto;
    padding-top: 1rem;
    display: flex;
    justify-content: center;
}

.admin-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.admin-icon-btn:hover {
    color: var(--primary-color);
    background: rgba(30, 64, 175, 0.1);
    opacity: 1;
    transform: scale(1.1);
}

.admin-icon-btn svg {
    flex-shrink: 0;
}


/* Admin/User Mode Styling */
body.admin-mode {
    --accent-color: #dc2626;
}

body.user-mode {
    --accent-color: #2563eb;
}

/* Citation Settings */
.citation-settings {
    padding: 1rem;
}

.citation-settings label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.citation-style-select {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

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

/* Enhanced References Section */
.references-section {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.references-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.references-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.reference-controls {
    display: flex;
    gap: 0.5rem;
}

.reference-controls-bottom {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.control-buttons {
    display: flex;
    gap: 0.25rem;
    justify-content: flex-end;
    align-items: flex-start;
}

.download-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
}

.reference-controls-bottom button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.reference-controls-bottom button:hover {
    color: var(--text-primary);
    background: var(--surface);
}

.reference-controls-bottom button svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.download-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-disclaimer {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: right;
    font-style: italic;
    opacity: 0.8;
}

/* Legacy citations support */
.citations-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.citation-controls {
    display: flex;
    gap: 0.5rem;
}

.copy-all-btn,
.export-all-ris-btn,
.export-all-bib-btn {
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-all-btn:hover,
.export-all-ris-btn:hover,
.export-all-bib-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.references-list {
    list-style-type: decimal;
    padding-left: 1.5rem;
}

.reference-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

.reference-content {
    flex: 1;
    line-height: 1.6;
    font-size: 0.85rem;
}

.reference-actions {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    flex-shrink: 0;
}

.dropdown-container {
    position: relative;
}

.copy-dropdown-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.copy-dropdown-btn:hover {
    color: var(--text-primary);
    background: var(--surface);
}

.copy-dropdown-btn svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.copy-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow);
    z-index: 100;
    min-width: 80px;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: transparent;
    color: var(--text-primary);
    border: none;
    text-align: left;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.dropdown-item:hover {
    background: var(--surface-hover);
}

.dropdown-item:first-child {
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.dropdown-item:last-child {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.doi-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.doi-link:hover {
    text-decoration: underline;
}

.section-details {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    border-left: 3px solid var(--border-color);
    padding-left: 0.5rem;
}

/* Legacy citation styles for backwards compatibility */
.citation-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem 0;
}

.citation-content {
    flex: 1;
    line-height: 1.6;
}

.citation-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.copy-citation-btn,
.export-ris-btn,
.export-bib-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.copy-citation-btn:hover,
.export-ris-btn:hover,
.export-bib-btn:hover {
    color: var(--text-primary);
    background: var(--surface);
}

.copy-citation-btn svg,
.export-ris-btn svg,
.export-bib-btn svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}


/* Template Questions Styles */
.questions-collapsible {
    margin-bottom: 1rem;
}

.questions-header {
    cursor: pointer;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.questions-header:hover {
    background: rgba(37, 99, 235, 0.1);
    color: var(--accent-color);
}

.questions-container {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.template-question {
    width: 100%;
    text-align: left;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8rem;
    line-height: 1.4;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.template-question:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.template-question:active {
    transform: translateY(0);
}

.template-question:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}

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

.modal[style*="flex"] {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.modal-content input {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.modal-buttons button {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

#confirmAdminBtn {
    background: #dc2626;
    color: white;
    border: none;
}

#confirmAdminBtn:hover {
    background: #b91c1c;
}

#cancelAdminBtn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

#cancelAdminBtn:hover {
    background: var(--bg-primary);
}
