* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f7;
    min-height: 100vh;
    padding: 20px;
    color: #1d1d1f;
    position: relative;
    overflow-x: hidden;
}

/* Animated Particle Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(59, 130, 246, 0.06) 0%, transparent 50%);
    z-index: 0;
    pointer-events: none;
    animation: particleFloat 20s ease-in-out infinite;
}

@keyframes particleFloat {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.02),
        0 12px 24px rgba(0, 0, 0, 0.04),
        0 0 0 1px rgba(0, 0, 0, 0.02);
    position: relative;
    z-index: 1;
}

.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 2.5em;
    font-weight: 700;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    letter-spacing: -0.03em;
}

.subtitle {
    color: #6b7280;
    font-size: 1.1em;
    font-weight: 500;
}

.info {
    color: #9ca3af;
    margin-top: 8px;
    font-size: 0.95em;
}

/* Context Form */
.context-form {
    margin-bottom: 20px;
}

.context-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    color: #374151;
    font-size: 1em;
}

.context-form textarea {
    width: 100%;
    padding: 16px;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    transition: all 0.2s;
    background: #fafafa;
}

.context-form textarea:focus {
    outline: none;
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Q&A Container */
.qa-container {
    margin-bottom: 30px;
}

.question-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    color: #374151;
    font-size: 1em;
}

.input-group {
    display: flex;
    gap: 12px;
}

.input-group input {
    flex: 1;
    padding: 14px 18px;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    font-size: 1em;
    transition: all 0.2s;
    background: #fafafa;
}

.input-group input:focus {
    outline: none;
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow:
        0 2px 4px rgba(59, 130, 246, 0.2),
        0 4px 12px rgba(59, 130, 246, 0.15);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow:
        0 4px 8px rgba(59, 130, 246, 0.25),
        0 8px 20px rgba(59, 130, 246, 0.2);
}

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

/* Answer Container */
.answer-container {
    margin-top: 30px;
    padding: 24px;
    background: #f9fafb;
    border-radius: 16px;
    border: 1.5px solid #e5e7eb;
}

.answer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.confidence-badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9em;
}

.confidence-badge.high {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

.confidence-badge.low {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

.chunks-info {
    color: #6b7280;
    font-size: 0.9em;
    font-weight: 500;
}

.answer-text {
    color: #1f2937;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 1em;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #3b82f6;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Info Box */
.info-box {
    background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
    border-left: 4px solid #3b82f6;
    padding: 16px;
    border-radius: 12px;
    color: #1e40af;
}

.info-box p {
    margin: 0;
}

/* Back Link */
.back-link {
    display: inline-block;
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.95em;
}

.back-link:hover {
    color: #8b5cf6;
    transform: translateX(-4px);
}

.upload-link {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.upload-link:hover {
    color: #8b5cf6;
}

/* File Upload */
.upload-form {
    margin-bottom: 20px;
}

.file-upload-wrapper {
    margin-bottom: 20px;
}

.file-upload-wrapper input[type="file"] {
    display: none;
}

.file-label {
    display: block;
    padding: 48px;
    border: 2px dashed #d1d5db;
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafafa;
}

.file-label:hover {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
    transform: translateY(-2px);
}

.file-icon {
    font-size: 3.5em;
    margin-bottom: 12px;
}

.file-text {
    font-size: 1.1em;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 6px;
}

.file-subtext {
    color: #9ca3af;
    font-size: 0.9em;
}

.file-name {
    margin-top: 12px;
    font-weight: 600;
    color: #3b82f6;
    text-align: center;
}

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

.btn-primary:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 24px;
    }

    .header h1 {
        font-size: 2em;
    }

    .input-group {
        flex-direction: column;
    }
}

/* Preview Page */
.preview-container {
    margin-bottom: 20px;
}

.preview-container label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    color: #374151;
    font-size: 1em;
}

.preview-container textarea {
    width: 100%;
    padding: 16px;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    font-size: 0.95em;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    resize: vertical;
    background: #fafafa;
    color: #1f2937;
    line-height: 1.6;
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn-secondary {
    background: #6b7280;
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
    box-shadow:
        0 2px 4px rgba(107, 114, 128, 0.2),
        0 4px 12px rgba(107, 114, 128, 0.15);
}

.btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-2px);
    box-shadow:
        0 4px 8px rgba(107, 114, 128, 0.25),
        0 8px 20px rgba(107, 114, 128, 0.2);
}

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

/* Extraction Section */
.extraction-section {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1.5px solid #e5e7eb;
}

.extraction-section h3 {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 1.5em;
}

.extraction-info {
    color: #6b7280;
    margin-bottom: 16px;
    font-size: 0.95em;
}

.extraction-result {
    margin-top: 24px;
    padding: 24px;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-radius: 16px;
    border: 1.5px solid #10b981;
}

.extraction-result h4 {
    color: #065f46;
    margin-bottom: 12px;
    font-weight: 700;
}

.extraction-result .extraction-method {
    color: #047857;
    margin-bottom: 12px;
    font-size: 0.9em;
}

.extraction-result pre {
    background: #fff;
    padding: 16px;
    border-radius: 12px;
    border: 1.5px solid #d1d5db;
    overflow-x: auto;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.6;
    color: #1f2937;
}