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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #e0e0e0;
    background-color: #1a1a1a;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    padding: 30px 0;
    background-color: #2a2a2a;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    margin-bottom: 30px;
}

header h1 {
    color: #ffffff;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    color: #b0b0b0;
    font-size: 1.1rem;
}

/* Sections */
section {
    background-color: #2a2a2a;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    padding: 25px;
    margin-bottom: 25px;
}

section h2 {
    color: #ffffff;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

section h3 {
    color: #e0e0e0;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

/* Configuration Section */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.config-item label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #b0b0b0;
}

.config-item input,
.config-item select {
    width: 100%;
    padding: 10px;
    border: 2px solid #404040;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s;
    background-color: #3a3a3a;
    color: #e0e0e0;
}

.config-item input:focus,
.config-item select:focus {
    outline: none;
    border-color: #3498db;
}

.config-item select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3e%3cpath fill='%23e0e0e0' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 00-1.414-1.414z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px;
}

.config-item input[type="password"] {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
}

/* Override autofill styles */
.config-item input:-webkit-autofill,
.config-item input:-webkit-autofill:hover,
.config-item input:-webkit-autofill:focus,
.config-item input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #3a3a3a inset !important;
    -webkit-text-fill-color: #e0e0e0 !important;
}

/* Data Loading */
.data-loading {
    display: flex;
    align-items: center;
    gap: 20px;
}

.progress-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
}

.progress-bar {
    flex: 1;
    height: 20px;
    background-color: #404040;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    --progress: 0%;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--progress);
    background-color: #3498db;
    transition: width 0.3s ease;
}

#loading-status {
    font-size: 0.9rem;
    color: #b0b0b0;
    min-width: 100px;
}

/* Question Section */
.prompt-area {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

#prompt-window {
    flex: 1;
    padding: 15px;
    border: 2px solid #404040;
    border-radius: 5px;
    font-size: 1rem;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.3s;
    background-color: #3a3a3a;
    color: #e0e0e0;
}

#prompt-window:focus {
    outline: none;
    border-color: #3498db;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn:disabled {
    background-color: #555555;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Results Section */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.response-container,
.rag-container {
    background-color: #333333;
    padding: 20px;
    border-radius: 8px;
}

.content-window {
    min-height: 300px;
    padding: 15px;
    background-color: #2a2a2a;
    border-radius: 5px;
    overflow-y: auto;
    max-height: 500px;
}

.placeholder {
    color: #808080;
    font-style: italic;
    text-align: center;
    margin-top: 50px;
}

/* RAG Results Styling */
.document-selection-info {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #1e3a3a;
    border-radius: 8px;
    border-left: 4px solid #27ae60;
}

.document-selection-info h3 {
    color: #27ae60;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.document-selection-info p {
    margin: 5px 0;
    color: #e0e0e0;
    font-size: 0.95rem;
}

.rag-result {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #333333;
    border-radius: 5px;
    border-left: 4px solid #3498db;
}

.rag-result h4 {
    margin-bottom: 8px;
    color: #ffffff;
}

.rag-result .score {
    font-size: 0.9rem;
    color: #b0b0b0;
    margin-bottom: 8px;
}

.rag-result .content {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 8px;
}

.rag-result .link {
    display: inline-block;
    color: #3498db;
    text-decoration: none;
    font-size: 0.9rem;
}

.rag-result .link:hover {
    text-decoration: underline;
}

/* Loading States */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #404040;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error Messages */
.error-messages {
    margin-top: 15px;
    padding: 0;
}

.error-message {
    color: #ff6b6b;
    font-size: 0.9rem;
    margin: 8px 0;
    padding: 8px 12px;
    background-color: #3a2a2a;
    border-left: 4px solid #e74c3c;
    border-radius: 4px;
    display: block;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: #b0b0b0;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .config-grid,
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .prompt-area {
        flex-direction: column;
    }
    
    #send-btn {
        width: 100%;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .container {
        padding: 10px;
    }
}

/* AI Response and Citations Styling */
.ai-response {
    margin-bottom: 20px;
    line-height: 1.8;
}

.citations-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #404040;
}

.citations-section h3 {
    color: #ffffff;
    font-size: 1.2rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.citations-list {
    list-style: none;
    padding: 0;
}

.citations-list li {
    margin-bottom: 10px;
    padding: 8px 12px;
    background-color: #333333;
    border-radius: 4px;
    border-left: 3px solid #3498db;
}

.citations-list li strong {
    color: #ffffff;
    margin-right: 8px;
}

.citations-list li a {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
}

.citations-list li a:hover {
    text-decoration: underline;
}

.citations-list li .citation-type {
    color: #b0b0b0;
    font-size: 0.9rem;
    font-style: italic;
}

/* LLM Prompt Debug Section */
.llm-prompt-debug-section {
    background-color: #2a2a2a;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    padding: 25px;
    margin-bottom: 25px;
    border: 2px solid #dc3545;
}

.llm-prompt-debug-section h2 {
    color: #dc3545;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.llm-prompt-content h4 {
    color: #e0e0e0;
    margin: 15px 0 8px 0;
    font-size: 1rem;
}

.llm-prompt-content pre {
    background-color: #333333;
    border: 1px solid #404040;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    max-height: 400px;
    overflow-y: auto;
    color: #e0e0e0;
}

/* RAG Results with improved styling */
.result-header {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.result-number {
    font-weight: bold;
    color: #3498db;
    min-width: 20px;
}

.result-title {
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    flex: 1;
    min-width: 200px;
}

.result-title:hover {
    text-decoration: underline;
}

.result-score {
    color: #b0b0b0;
    font-size: 0.85rem;
    white-space: nowrap;
}

.result-content {
    color: #d0d0d0;
    line-height: 1.6;
    margin-left: 28px;
}

.no-results {
    text-align: center;
    color: #b0b0b0;
    font-style: italic;
    margin: 40px 0;
}