/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0f0f23;
    color: #e6e6e6;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    background: #1a1a2e;
    border-bottom: 1px solid #2d2d44;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #64ffda;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #64ffda;
}

.user-name {
    font-weight: 500;
    color: #e6e6e6;
}

/* Button Styles */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #64ffda;
    color: #0f0f23;
}

.btn-primary:hover:not(:disabled) {
    background: #4cd6b3;
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: #2d2d44;
    color: #666;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    color: #e6e6e6;
    border: 1px solid #2d2d44;
}

.btn-secondary:hover {
    background: #2d2d44;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    background: #1a1a2e;
    border-radius: 25px;
    padding: 0.25rem;
    border: 1px solid #2d2d44;
    position: relative;
    width: 200px;
    height: 40px;
}

.toggle-label input {
    display: none;
}

.toggle-slider {
    position: absolute;
    top: 0.25rem;
    left: 0.25rem;
    width: calc(50% - 0.25rem);
    height: calc(100% - 0.5rem);
    background: #64ffda;
    border-radius: 20px;
    transition: transform 0.3s ease;
}

.toggle-label input:checked + .toggle-slider {
    transform: translateX(100%);
}

.toggle-text {
    display: flex;
    width: 100%;
    position: relative;
    z-index: 1;
}

.toggle-option {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

.toggle-label input:not(:checked) ~ .toggle-text .toggle-option:first-child,
.toggle-label input:checked ~ .toggle-text .toggle-option:last-child {
    color: #0f0f23;
}

/* Chat Container */
.chat-container {
    background: #1a1a2e;
    border-radius: 12px;
    border: 1px solid #2d2d44;
    height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.welcome-message {
    text-align: center;
    padding: 2rem;
    color: #999;
}

.welcome-message h2 {
    color: #64ffda;
    margin-bottom: 1rem;
}

/* Message Styles */
.message {
    max-width: 80%;
    padding: 1rem;
    border-radius: 12px;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background: #64ffda;
    color: #0f0f23;
}

.message.ai {
    align-self: flex-start;
    background: #2d2d44;
    color: #e6e6e6;
    border: 1px solid #3d3d54;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.8;
}

.message-content {
    line-height: 1.6;
}

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

.message-content p:last-child {
    margin-bottom: 0;
}

/* Evidence Score */
.evidence-score {
    display: inline-block;
    background: #1a1a2e;
    color: #64ffda;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

/* Sources List - Simple, Clean Design */
.sources-list {
    list-style: none !important;
    counter-reset: source-counter;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: none !important;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.source-item {
    counter-increment: source-counter;
    padding: 0.25rem 0 !important;
    position: relative;
    background: none !important;
    border: none !important;
    margin: 0 !important;
    list-style: none !important;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.source-item::before {
    content: "Source " counter(source-counter) ": ";
    font-weight: 600;
    color: #374151;
    font-size: 0.875rem;
}

.source-link {
    color: #2563eb !important;
    text-decoration: none !important;
    font-size: 0.875rem !important;
    line-height: 1.4 !important;
    word-break: break-all !important;
    transition: color 0.2s ease !important;
    cursor: pointer !important;
    display: inline !important;
}

.source-link:hover {
    color: #1d4ed8 !important;
    text-decoration: underline !important;
}

/* Override any Tailwind link styles */
a.source-link {
    color: #2563eb !important;
    text-decoration: none !important;
    font-size: 0.875rem !important;
    line-height: 1.4 !important;
    word-break: break-all !important;
    transition: color 0.2s ease !important;
    cursor: pointer !important;
    display: inline !important;
}

a.source-link:hover {
    color: #1d4ed8 !important;
    text-decoration: underline !important;
}

.similarity-badge {
    margin-left: 0.5rem;
    background: #dbeafe;
    color: #1e40af;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Citation Links */
.citation-link {
    color: #2563eb !important;
    text-decoration: none !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: color 0.2s ease !important;
    display: inline !important;
}

.citation-link:hover {
    color: #1d4ed8 !important;
    text-decoration: underline !important;
}

/* Override any Tailwind link styles */
a.citation-link {
    color: #2563eb !important;
    text-decoration: none !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: color 0.2s ease !important;
    display: inline !important;
}

a.citation-link:hover {
    color: #1d4ed8 !important;
    text-decoration: underline !important;
}

/* Citation Tooltip */
.citation-tooltip {
    background: #1f2937;
    color: #f9fafb;
    padding: 0.75rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #374151;
    max-width: 300px;
    font-size: 0.875rem;
    line-height: 1.4;
}

.tooltip-url {
    color: #60a5fa;
    font-weight: 600;
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.tooltip-preview {
    color: #d1d5db;
    font-size: 0.8rem;
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    color: #64ffda;
    font-style: italic;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #2d2d44;
    border-top: 2px solid #64ffda;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Input Form */
.chat-input-form {
    border-top: 1px solid #2d2d44;
    padding: 1rem;
}

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

#messageInput {
    flex: 1;
    background: #2d2d44;
    border: 1px solid #3d3d54;
    border-radius: 8px;
    padding: 0.75rem;
    color: #e6e6e6;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 60px;
    max-height: 120px;
}

#messageInput:focus {
    outline: none;
    border-color: #64ffda;
}

#messageInput:disabled {
    background: #1a1a2e;
    color: #666;
    cursor: not-allowed;
}

#messageInput::placeholder {
    color: #999;
}

/* Footer */
.footer {
    background: #1a1a2e;
    border-top: 1px solid #2d2d44;
    padding: 1rem;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        padding: 0 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .main-content {
        padding: 1rem;
    }

    .chat-container {
        height: 60vh;
    }

    .message {
        max-width: 90%;
    }

    .input-container {
        flex-direction: column;
        align-items: stretch;
    }

    #sendBtn {
        align-self: flex-end;
        width: fit-content;
    }

    .toggle-label {
        width: 160px;
        height: 36px;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0 0.5rem;
    }

    .main-content {
        padding: 0.5rem;
    }

    .chat-messages {
        padding: 1rem;
    }

    .message {
        max-width: 95%;
        padding: 0.75rem;
    }
}

/* Export Button Styles */
.export-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.8);
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.7;
    backdrop-filter: blur(4px);
}

.export-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.95);
    color: #374151;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.export-btn:active {
    transform: translateY(0);
}

.markdown-btn:hover {
    color: #059669;
}

.pdf-btn:hover {
    color: #dc2626;
}

/* Export button container */
.export-btn + .export-btn {
    margin-left: 4px;
}

/* Responsive adjustments for export buttons */
@media (max-width: 768px) {
    .export-btn {
        width: 28px;
        height: 28px;
    }
    
    .export-btn svg {
        width: 14px;
        height: 14px;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #1a1a2e;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #2d2d44;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #3d3d54;
}
