/* Custom CSS for PulseGPT Chat */

:root {
    --pulse-primary: #667eea;
    --pulse-secondary: #764ba2;
    --pulse-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

html[data-bs-theme=dark] {
    --bs-body-bg: #212529;
    --bs-body-color: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
}

/* Chat specific styles */
.chat-layout {
    height: 100vh;
    overflow: hidden;
}

.chat-header {
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.chat-sidebar {
    background: var(--bs-secondary-bg);
    border-right: 1px solid var(--bs-border-color);
    transition: all 0.3s ease;
}

.messages-container {
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--bs-secondary);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--bs-secondary-color);
}

/* Message bubbles */
.message-bubble {
    position: relative;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    background: var(--pulse-gradient);
    color: white;
    border-radius: 1.25rem 1.25rem 0.25rem 1.25rem;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.assistant-message {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 1.25rem 1.25rem 1.25rem 0.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-avatar {
    background: var(--pulse-gradient);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

/* Form controls */
.form-control:focus {
    border-color: var(--pulse-primary);
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.btn-primary {
    background: var(--pulse-gradient);
    border: none;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Composer */
.composer-container {
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#messageInput {
    border: 2px solid var(--bs-border-color);
    border-radius: 1rem;
    transition: all 0.2s ease;
    resize: none;
}

#messageInput:focus {
    border-color: var(--pulse-primary);
    transform: scale(1.01);
}

/* Buttons */
.btn {
    border-radius: 0.75rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-outline-primary {
    border-color: var(--pulse-primary);
    color: var(--pulse-primary);
}

.btn-outline-primary:hover {
    background: var(--pulse-gradient);
    border-color: transparent;
}

/* Loading states */
.typing-indicator::after {
    content: '●●●';
    animation: typing 1.4s infinite;
    font-size: 1.2em;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
    }
    30% {
        opacity: 1;
    }
}

/* Code blocks */
.code-block-container {
    margin: 0.75rem 0;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    overflow: hidden;
}

.code-block-header {
    background: var(--bs-tertiary-bg);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--bs-border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.code-block-label {
    color: var(--bs-secondary);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.copy-code-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-secondary);
    transition: all 0.2s ease;
}

.copy-code-btn:hover {
    background: var(--bs-secondary-bg);
    color: var(--bs-emphasis-color);
    border-color: var(--pulse-primary);
}

.code-block {
    background: var(--bs-secondary-bg) !important;
    font-size: 0.875rem;
    padding: 1rem;
    margin: 0;
    overflow-x: auto;
    border-radius: 0;
}

.code-block code {
    background: none !important;
    padding: 0;
    color: var(--bs-emphasis-color);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    line-height: 1.4;
}

.inline-code {
    background: var(--bs-secondary-bg);
    color: var(--bs-emphasis-color);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    border: 1px solid var(--bs-border-color);
}

/* Message formatting styles */
.message-content strong {
    font-weight: 600;
    color: var(--bs-emphasis-color);
}

.message-content em {
    font-style: italic;
    color: var(--bs-body-color);
}

.message-content del {
    text-decoration: line-through;
    color: var(--bs-secondary);
}

.message-header {
    font-weight: 600;
    color: var(--bs-emphasis-color);
    border-bottom: 1px solid var(--bs-border-color);
    padding-bottom: 0.25rem;
}

.message-list {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-list-item {
    margin-bottom: 0.25rem;
    line-height: 1.5;
}

.message-list ul,
.message-list ol {
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

.message-blockquote {
    border-left: 4px solid var(--pulse-primary);
    background: var(--bs-secondary-bg);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    font-style: italic;
    border-radius: 0 0.375rem 0.375rem 0;
}

.message-divider {
    border: none;
    border-top: 2px solid var(--bs-border-color);
    margin: 1rem 0;
    opacity: 0.5;
}

.message-link {
    color: var(--pulse-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.message-link:hover {
    color: var(--pulse-secondary);
    border-bottom-color: var(--pulse-primary);
    text-decoration: none;
}

/* Dark mode adjustments */
[data-bs-theme="dark"] .code-block-container {
    border-color: #4a5568;
}

[data-bs-theme="dark"] .code-block-header {
    background: #1a202c;
    border-color: #4a5568;
}

[data-bs-theme="dark"] .copy-code-btn {
    background: #2d3748;
    border-color: #4a5568;
    color: #a0aec0;
}

[data-bs-theme="dark"] .copy-code-btn:hover {
    background: #4a5568;
    color: #e2e8f0;
    border-color: var(--pulse-primary);
}

[data-bs-theme="dark"] .code-block {
    background: #2d3748 !important;
    border-color: #4a5568;
}

[data-bs-theme="dark"] .inline-code {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

[data-bs-theme="dark"] .message-blockquote {
    background: #2d3748;
    color: #e2e8f0;
}

/* Responsive text formatting */
@media (max-width: 768px) {
    .message-list {
        padding-left: 1.25rem;
    }
    
    .code-block {
        font-size: 0.8rem;
        padding: 0.75rem;
    }
    
    .message-header {
        font-size: 0.95em;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .message-bubble {
        max-width: 85%;
    }
    
    .chat-header h1 {
        font-size: 1.1rem;
    }
    
    .composer-container {
        padding: 0.75rem;
    }
}

/* Toast notifications */
.toast {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Settings modal */
.modal-content {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-header {
    border-bottom: 1px solid var(--bs-border-color);
}

.modal-footer {
    border-top: 1px solid var(--bs-border-color);
}

/* Sidebar animations */
@media (max-width: 768px) {
    .chat-sidebar {
        transform: translateX(-100%);
    }
    
    .chat-sidebar.show {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
}

/* Jump to latest button */
#jumpToLatest {
    animation: bounceIn 0.3s ease-out;
}

@keyframes bounceIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Empty state */
#emptyState {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Accessibility improvements */
.btn:focus-visible {
    outline: 2px solid var(--pulse-primary);
    outline-offset: 2px;
}

.form-control:focus-visible {
    outline: 2px solid var(--pulse-primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .message-bubble {
        border: 2px solid currentColor;
    }
    
    .btn {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Citation styles */
.citation-score {
    background-color: var(--pulse-primary);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.citation-confidence {
    background-color: var(--bs-success);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.extracted-citation {
    border-left: 3px solid var(--bs-info);
    background: rgba(13, 202, 240, 0.05);
}

.extracted-citation .citation-title {
    color: var(--bs-info);
    font-weight: 500;
}

/* Citation type indicators */
.citation-item .badge {
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
}

/* Enhanced citation preview */
.citation-preview-content .table td:first-child {
    font-weight: 500;
    width: 30%;
}

.citation-preview-content .alert {
    margin-top: 1rem;
    font-size: 0.875rem;
}

/* Print styles */
@media print {
    .chat-header,
    .chat-sidebar,
    .composer-container {
        display: none !important;
    }
    
    .chat-content {
        height: auto !important;
    }
    
    .message-bubble {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
}