@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

body {
    background: linear-gradient(135deg, #fafaff 0%, #f8fafc 50%, #f1f5f9 100%);
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    color: #1e293b;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(168, 85, 247, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 0 0 24px 24px;
    position: relative;
    z-index: 2;
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.08);
}

.card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease;
}
.card:hover {
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.3);
}

.card-header {
    background: rgba(248, 250, 252, 0.9);
    border-radius: 16px 16px 0 0 !important;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    font-weight: 600;
    color: #334155;
    letter-spacing: 0.5px;
    text-shadow: none;
}

.form-control {
    background: rgba(255, 255, 255, 0.9);
    color: #1e293b;
    border-radius: 12px;
    border: 1px solid rgba(203, 213, 225, 0.8);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}
.form-control:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1), 0 1px 3px rgba(15, 23, 42, 0.1);
    background: rgba(255, 255, 255, 1);
    outline: none;
}
.form-label {
    font-weight: 500;
    color: #475569;
    letter-spacing: 0.3px;
    font-size: 0.875rem;
}

.btn {
    border-radius: 12px;
    font-weight: 500;
    letter-spacing: 0.3px;
    text-transform: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: none;
    font-size: 0.875rem;
}
.btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
    border: none;
    position: relative;
    overflow: hidden;
}
.btn-primary:hover {
    background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 50%, #9333ea 100%);
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}
.btn-lg {
    padding: 12px 30px;
    font-size: 1.08rem;
}

.table {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    overflow: hidden;
    color: #1e293b;
    border: 1px solid rgba(226, 232, 240, 0.6);
}
.table thead th {
    background: rgba(248, 250, 252, 0.9);
    border: none;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.8px;
    color: #64748b;
    text-shadow: none;
}
.table tbody tr {
    transition: background 0.2s;
}
.table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.score-high {
    color: #232a34;
    font-weight: 700;
}
.score-medium {
    color: #5f6caf;
    font-weight: 700;
}
.score-low {
    color: #7ed6b5;
    font-weight: 700;
}

.badge {
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
    letter-spacing: 0.3px;
    font-size: 0.75rem;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    border-radius: 16px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 25px 50px rgba(15, 23, 42, 0.15);
    color: #1e293b;
}
.modal-header {
    background: rgba(248, 250, 252, 0.9);
    color: #334155;
    border-radius: 16px 16px 0 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    font-weight: 500;
    letter-spacing: 0.5px;
}
.modal-title {
    font-weight: 600;
    color: #334155;
    letter-spacing: 0.5px;
}

.spinner-border {
    width: 2.5rem;
    height: 2.5rem;
    border-width: 0.3em;
    border-top-color: #6366f1;
    border-right-color: #8b5cf6;
    border-bottom-color: #a855f7;
    border-left-color: rgba(100, 116, 139, 0.3);
    animation: spinGlow 1.2s linear infinite;
}
@keyframes spinGlow {
    0% { filter: none; }
    100% { filter: none; }
}

@keyframes spinner-border {
  to { transform: rotate(360deg); }
}
.spinner-border {
  animation: spinner-border 0.75s linear infinite;
}

.progress {
    border-radius: 12px;
    background: rgba(241, 245, 249, 0.8);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
    border: 1px solid rgba(226, 232, 240, 0.6);
}
.progress-bar {
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

@media (max-width: 768px) {
    .container-fluid {
        padding: 0 8px;
    }
    .card-body {
        padding: 0.7rem;
    }
    .btn-lg {
        padding: 10px 18px;
        font-size: 1rem;
    }
    .table-responsive {
        font-size: 0.92rem;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.fade-in-up {
    animation: fadeInUp 0.6s cubic-bezier(0.4,0,0.2,1);
}

.variant-details {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 1.2rem;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(226, 232, 240, 0.6);
    color: #1e293b;
}
.variant-details h6 {
    color: #334155;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
}
.evidence-section {
    background: rgba(99, 102, 241, 0.05);
    border-left: 3px solid #6366f1;
    padding: 1.2rem;
    margin: 1.2rem 0;
    border-radius: 0 12px 12px 0;
    color: #1e293b;
}
.confidence-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    box-shadow: none;
}
.confidence-high {
    background-color: #232a34;
}
.confidence-medium {
    background-color: #5f6caf;
}
.confidence-low {
    background-color: #7ed6b5;
}

.file-upload-area {
    border: 2px dashed rgba(99, 102, 241, 0.3);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    background: rgba(248, 250, 252, 0.8);
    color: #475569;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.file-upload-area:hover, .file-upload-area.dragover {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.08);
    color: #6366f1;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.92rem;
    font-weight: 600;
    background: rgba(248, 250, 252, 0.9);
    color: #334155;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.status-processing {
    background: #fffbe6;
    color: #bdbd3a;
}
.status-completed {
    background: #e6fff8;
    color: #7ed6b5;
}
.status-error {
    background: #ffe6ef;
    color: #ff0055;
}

.score-bar-outer {
    width: 100%;
    height: 16px;
    background: rgba(241, 245, 249, 0.9);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 4px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.score-bar-inner {
    height: 100%;
    border-radius: 8px 0 0 8px;
    transition: width 0.7s cubic-bezier(0.4,0,0.2,1), background 0.7s;
    box-shadow: none;
}
.score-bar-label {
    font-size: 0.98em;
    font-weight: 600;
    margin-bottom: 2px;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
    letter-spacing: 0.5px;
}
.score-bar-value {
    font-weight: 600;
    margin-left: 6px;
    color: #6366f1;
} 

.variant-summary {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    cursor: pointer;
    color: #1e293b;
}
.variant-summary:hover {
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.3);
}
.variant-summary .card-body {
    padding: 1.1rem 1.5rem;
}

/* Show multiple lines of verdict text in the preview (3-4 lines) */
.preview-verdict {
    color: #6c757d; /* muted */
    margin-top: 6px;
    width: 100%;
    max-width: none;
    font-size: 0.88rem; /* slightly smaller than other preview text */
}
/* The text block is clamped to 4 lines */
.preview-verdict .verdict-text {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Expanded state: show full verdict without clamping */
.preview-verdict.expanded .verdict-text {
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
    text-overflow: clip;
}
/* Place actions below and always visible */
.preview-verdict .verdict-actions {
    margin-top: 4px;
}
/* Style the toggle link subtly */
.preview-verdict .verdict-toggle {
    font-size: 0.84rem;
}

/* Increase preview area slightly so multiple lines fit visually */
.variant-summary .card-body {
    min-height: 84px; /* slightly larger than default */
}

/* Make non-verdict preview text slightly larger for readability */
.variant-summary .preview-top,
.variant-summary .preview-top span,
.variant-summary .preview-top code {
    font-size: 0.98rem;
}

/* Increase score label and value sizes inside the preview bars */
.variant-summary .score-bar-label {
    font-size: 0.96rem;
}
.variant-summary .score-bar-value {
    font-size: 0.96rem;
}
.variant-details-expanded {
    background: rgba(248, 250, 252, 0.9);
    border-radius: 0 0 16px 16px;
    border-top: 1px solid rgba(226, 232, 240, 0.6);
    margin-top: -8px;
    animation: fadeInExpand 0.3s;
    cursor: default;
}
@keyframes fadeInExpand {
    from { opacity: 0; transform: scaleY(0.98); }
    to { opacity: 1; transform: scaleY(1); }
}
.variant-summary .fa-chevron-up, .variant-summary .fa-chevron-down {
    transition: transform 0.2s;
    font-size: 1.1em;
    color: #6366f1;
}
.variant-summary.expanded .fa-chevron-up {
    color: #334155;
    transform: rotate(180deg);
} 

.variant-group-outline {
    border: 2px solid #6ec1e4 !important;
    background: #f3f6fa !important;
    border-radius: 14px !important;
    box-shadow: 0 1px 8px rgba(110,193,228,0.03);
    margin-bottom: 1.5rem;
    padding: 0.5rem 0.5rem 0.5rem 0.5rem;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.form-check-label {
    color: #334155;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.form-check-label.disabled, .form-check-input:disabled ~ .form-check-label {
    color: #94a3b8;
    opacity: 0.7;
} 

/* Modern hover effects */
.card, .variant-summary, .btn, .btn-primary, .file-upload-area, .table tbody tr, .badge {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Restore interactive cursor */
.variant-summary, .card {
    cursor: pointer;
}

/* Chat window styling inside variant details */
.variant-chat {
    /* Add internal padding so the heading, chat window and input aren't flush to the edges */
    padding: 0.9rem 1.1rem;
    box-sizing: border-box;
}
.variant-chat .chat-window {
    padding: 14px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    border: 1px solid rgba(226, 232, 240, 0.6);
    max-height: 240px;
    min-height: 120px;
    height: 240px;
    overflow: auto;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
    resize: vertical;
    position: relative;
}

/* Chat window wrapper with resize handle */
.variant-chat {
    position: relative;
}

.chat-window-wrapper {
    position: relative;
    border-radius: 8px;
}

.variant-chat .chat-window {
    border-radius: 8px 8px 0 0; /* Remove bottom border radius */
}

/* Separate resize handle element */
.chat-resize-handle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 14px;
    cursor: row-resize;
    background: linear-gradient(to bottom, transparent, rgba(99, 102, 241, 0.1));
    border-radius: 0 0 8px 8px;
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-top: none;
    transition: background 0.2s ease;
    z-index: 10;
}

.chat-resize-handle:hover,
.chat-window-wrapper:hover .chat-resize-handle {
    background: linear-gradient(to bottom, transparent, rgba(99, 102, 241, 0.2));
}
.variant-chat h6 {
    margin-bottom: 0.6rem; /* more space below the heading */
    padding-left: 2px; /* tiny left inset to align visually with the chat window */
}
.variant-chat .chat-form {
    padding-top: 0.5rem; /* space between chat window and input */
    gap: 0.5rem; /* small gap between input and button when using flex */
}
.variant-chat .chat-form .form-control {
    padding: 0.55rem 0.75rem; /* slightly more vertical padding for the textbox */
}
.variant-chat .chat-form .btn {
    min-width: 60px; /* Ensure Send button is wide enough */
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
    white-space: nowrap; /* Prevent text wrapping */
}

.variant-chat .chat-window .chat-msg {
    margin-bottom: 8px;
}
.variant-chat .chat-window .chat-user {
    text-align: right;
}
.variant-chat .chat-window .chat-assistant {
    text-align: left;
}

/* Prevent early wrapping of verdict text in preview; allow longer words to wrap only at word boundaries */
.variant-summary .preview-verdict {
    word-break: normal;
    white-space: normal;
}

/* Research details toggle section */
.variant-research .research-header {
    padding: 0.6rem 0.2rem;
    border-top: 1px solid #e3e6ea;
    cursor: pointer;
    user-select: none;
}
.variant-research .research-content .variant-details + .variant-details {
    margin-top: 0.8rem;
}

/* Ranking-specific UI elements */
.ranking-info {
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ranking-info .badge.bg-warning {
    background: linear-gradient(90deg, #ffc107 0%, #fd7e14 100%) !important;
    color: #000 !important;
    font-weight: 700;
}

.ranking-info .text-warning {
    color: #fd7e14 !important;
}

.ranking-actions {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ranking-question-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 6px;
    border: 1px solid #6c757d;
    background: #fff;
    color: #6c757d;
    transition: all 0.2s ease-in-out;
}

.ranking-question-btn:hover {
    background: #f8f9fa;
    border-color: #5f6caf;
    color: #5f6caf;
}

.ranking-question-btn:active, .ranking-question-btn:focus {
    background: #e9ecef;
    border-color: #5f6caf;
    color: #5f6caf;
    box-shadow: 0 0 0 0.1rem rgba(95, 108, 175, 0.25);
}

.ranking-question-btn i {
    font-size: 0.8em;
}

.variant-location {
    font-size: 0.95rem;
    line-height: 1.3;
}

/* Adjust spacing for the new ranking layout */
.preview-left {
    width: 100%;
}

.preview-top {
    margin-bottom: 0.5rem;
}

/* Ranking statistics section */
.ranking-statistics {
    border: 1px solid #e3e6ea;
    background: #f8f9fa !important;
}

.ranking-statistics h6 {
    color: #232a34;
    font-weight: 600;
    margin-bottom: 1rem;
}

.stat-item {
    padding: 0.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.875rem;
    margin-top: 0.25rem;
    line-height: 1.2;
}

@media (max-width: 768px) {
    .ranking-actions {
        margin-top: 0.5rem;
    }
    
    .ranking-question-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .ranking-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .ranking-statistics .row > div {
        margin-bottom: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
}

/* Citation Link Styles */
.citation-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-block;
    background: rgba(37, 99, 235, 0.05);
    border: 1px solid rgba(37, 99, 235, 0.15);
    font-size: 0.9em;
}

.citation-link:hover {
    color: #1d4ed8;
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.25);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.15);
}

.citation-link:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

/* Citation reference list styles */
.citation-item {
    display: block;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.citation-item:last-child {
    border-bottom: none;
}

.citation-ref {
    color: #4f46e5;
    text-decoration: none;
    font-size: 0.9em;
    transition: all 0.2s ease;
    display: inline;
}

.citation-ref:hover {
    color: #3730a3;
    text-decoration: underline;
}

/* Ensure citations in dark areas remain visible */
.variant-details .citation-link,
.research-content .citation-link {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(37, 99, 235, 0.3);
}

.variant-details .citation-link:hover,
.research-content .citation-link:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(37, 99, 235, 0.4);
}