<!-- Test Modal - Shared Component -->
<div id="test-modal" class="modal" style="display: none;">
    <div class="modal-content">
        <div class="modal-header" id="modal-header">
            <h3 id="modal-title">Test Details</h3>
            <span class="modal-close" onclick="closeModal()">&times;</span>
        </div>
        <div id="modal-body" class="modal-body"></div>
    </div>
</div>

<style>
/* Test Modal Two-Column Layout */
.modal-two-col {
    display: flex;
    gap: 1rem;
    min-height: 400px;
}

.modal-test-list {
    width: 220px;
    flex-shrink: 0;
    border-right: 1px solid #e5e7eb;
    padding-right: 1rem;
}

.test-list-header {
    font-weight: 600;
    color: #374151;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.test-list-header .pass-count {
    font-size: 0.85rem;
    color: #059669;
}

.test-list-items {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 500px;
    overflow-y: auto;
}

.test-list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.test-list-item:hover {
    background: #f3f4f6;
}

.test-list-item.active {
    background: #e0e7ff;
    font-weight: 600;
}

.test-list-item.passed .test-status-icon {
    color: #10b981;
}

.test-list-item.failed .test-status-icon {
    color: #ef4444;
}

.test-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-test-detail {
    flex: 1;
    overflow-y: auto;
    max-height: max-content;
}

.test-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e5e7eb;
}

.test-detail-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #1f2937;
    word-break: break-word;
}

.test-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.test-meta .score {
    font-size: 1.25rem;
    font-weight: bold;
}

.test-meta .duration {
    font-size: 0.75rem;
    color: #6b7280;
}

.test-detail-section {
    margin-bottom: 1rem;
}

.section-header {
    font-weight: 600;
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.section-content {
    background: #f9fafb;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
}

.prompt-box { max-height: 120px; overflow-y: auto; }
.expected-box { max-height: 200px; overflow-y: auto; }
.response-box { max-height: 400px; overflow-y: auto; }
.thinking-box { background: #f5f3ff; overflow-y: auto; max-height: 400px; }

/* Collapsible section headers */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.collapsible-header:hover {
    color: #374151;
}

/* Side-by-side compare row */
.compare-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.compare-col {
    min-width: 0;
}

.compare-col .section-content {
    min-height: 80px;
}

.tools-box {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
    font-family: monospace;
    font-size: 0.8rem;
    background: #f0f9ff;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
}

.tool-name {
    color: #0369a1;
    font-weight: 600;
}

.tool-params-inline {
    color: #6b7280;
    font-size: 0.75rem;
}

.eval-box {
    font-size: 0.85rem;
}

.eval-box code {
    background: #e5e7eb;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Modal Base Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.modal-header-success {
    background: #d1fae5 !important;
    border-bottom: 1px solid #6ee7b7 !important;
}

.modal-header-error {
    background: #fef2f2 !important;
    border-bottom: 1px solid #fecaca !important;
}

.modal-close {
    font-size: 1.75rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge-passed {
    background: #d1fae5;
    color: #059669;
}

.status-badge-failed {
    background: #fee2e2;
    color: #dc2626;
}

.score-passed {
    color: #10b981;
}

.score-failed {
    color: #ef4444;
}

/* Mobile test selector dropdown */
.modal-test-select-mobile {
    display: none;
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
}

/* Mobile responsive modal */
@media (max-width: 768px) {
    .modal-content {
        width: 98%;
        max-width: 100%;
        max-height: 95vh;
        border-radius: 8px;
    }

    .modal-body {
        padding: 0.75rem;
    }

    .modal-two-col {
        flex-direction: column;
        min-height: auto;
    }

    .modal-test-list {
        display: none;
    }

    .modal-test-select-mobile {
        display: block;
    }

    .modal-test-detail {
        max-height: none;
    }

    .test-detail-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .prompt-box, .response-box {
        max-height: none;
    }

    .compare-row {
        grid-template-columns: 1fr;
    }
}

/* Dark mode support (tailwind darkMode: 'class') */
html.dark .modal-content {
    background: #1f2937;
}

html.dark .modal-header {
    background: #111827;
    border-bottom-color: #374151;
}

html.dark .modal-header h3 {
    color: #f3f4f6;
}

html.dark .modal-header-success {
    background: #064e3b !important;
    border-bottom-color: #059669 !important;
}

html.dark .modal-header-error {
    background: #7f1d1d !important;
    border-bottom-color: #b91c1c !important;
}

html.dark .modal-header-success h3,
html.dark .modal-header-error h3 {
    color: #f3f4f6 !important;
}

html.dark .modal-close {
    color: #d1d5db;
}

html.dark .modal-close:hover {
    color: #f3f4f6;
}

html.dark .modal-test-list {
    border-right-color: #374151;
}

html.dark .test-list-header {
    color: #e5e7eb;
    border-bottom-color: #374151;
}

html.dark .test-list-item:hover {
    background: #374151;
}

html.dark .test-list-item.active {
    background: #312e81;
}

html.dark .test-detail-header {
    border-bottom-color: #374151;
}

html.dark .test-detail-header h3 {
    color: #e5e7eb;
}

html.dark .test-meta .duration {
    color: #9ca3af;
}

html.dark .section-header {
    color: #9ca3af;
}

html.dark .collapsible-header:hover {
    color: #e5e7eb;
}

html.dark .section-content {
    background: #111827;
    color: #e5e7eb;
}

html.dark .thinking-box {
    background: #2e1065;
}

html.dark .tools-box {
    background: #1e3a5f;
}

html.dark .tool-name {
    color: #7dd3fc;
}

html.dark .tool-params-inline {
    color: #9ca3af;
}

html.dark .eval-box code {
    background: #374151;
    color: #e5e7eb;
}

html.dark .status-badge-passed {
    background: #064e3b;
    color: #6ee7b7;
}

html.dark .status-badge-failed {
    background: #7f1d1d;
    color: #fca5a5;
}

html.dark .score-passed {
    color: #34d399;
}

html.dark .score-failed {
    color: #f87171;
}

html.dark .modal-test-select-mobile {
    background: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
}

html.dark .response-box {
    background: #1c1917 !important;
}

html.dark .prompt-box {
    background: #111827;
}

html.dark .section-content[style*="background"] {
    background: #111827 !important;
}

/* Dark mode: override JS-generated inline styles */
html.dark [style*="background: #fefce8"] { background: #451a03 !important; }
html.dark [style*="background:#fefce8"] { background: #451a03 !important; }
html.dark [style*="background:#f1f5f9"] { background: #1e293b !important; }
html.dark [style*="background:#e0e7ff"] { background: #312e81 !important; }
html.dark [style*="background:#fafafa"] { background: #1f2937 !important; }
html.dark [style*="border:1px solid #e5e7eb"] { border-color: #374151 !important; }
html.dark [style*="border-top:1px solid #e5e7eb"] { border-top-color: #374151 !important; }
html.dark [style*="border-top: 2px dashed #e5e7eb"] { border-top-color: #374151 !important; }
html.dark [style*="color: #9ca3af"] { color: #9ca3af !important; }
html.dark [style*="color: #999"] { color: #9ca3af !important; }
html.dark [style*="color:#999"] { color: #9ca3af !important; }
html.dark [style*="color: #dc2626"] { color: #f87171 !important; }
html.dark [style*="color:#6b7280"] { color: #9ca3af !important; }
html.dark [style*="color: #6b7280"] { color: #9ca3af !important; }
html.dark [style*="color: #666"] { color: #d1d5db !important; }
html.dark [style*="color:#666"] { color: #d1d5db !important; }
html.dark .bg-blue-50 { background-color: #1e3a5f !important; }
html.dark .bg-green-50 { background-color: #14532d !important; }
html.dark .text-gray-700 { color: #d1d5db !important; }
html.dark .text-green-600 { color: #4ade80 !important; }
html.dark .text-green-800 { color: #4ade80 !important; }
html.dark .border-blue-200 { border-color: #1e40af !important; }
html.dark .border-green-200 { border-color: #065f46 !important; }
</style>
