/* Test Runner Overlay Styles */

.test-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--scrim);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.test-overlay.active {
    display: flex;
}

.test-modal {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 1200px;
    height: 85%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1rem 0.9rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elev);
}

.test-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-strong);
    margin: 0;
}

.test-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.test-close:hover {
    background: var(--bg-hover);
    color: var(--text-strong);
}

.test-toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.test-stats {
    margin-left: auto;
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
}

.test-stats span {
    color: var(--text);
}

.stat-passed {
    color: var(--teal) !important;
}

.stat-failed {
    color: var(--red) !important;
}

.stat-running {
    color: var(--yellow) !important;
}

.test-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.test-sidebar {
    width: 300px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.test-search {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.test-search input {
    width: 100%;
    height: 32px;
    padding: 0 0.65rem;
    background: var(--control-bg);
    border: 1px solid var(--border-strong);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.test-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.test-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 0.25rem;
}

/* Tree directory nodes */
.test-tree-dir {
    user-select: none;
}

.test-dir-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
    color: var(--text);
    font-size: 0.9rem;
}

.test-dir-header:hover {
    background: var(--bg-hover);
}

.test-dir-toggle {
    font-size: 0.7rem;
    width: 12px;
    text-align: center;
    color: var(--text-faint);
    flex-shrink: 0;
    transition: transform 0.15s;
}

.test-dir-icon {
    font-size: 0.85rem;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.test-dir-header.test-passed .test-dir-icon { color: var(--teal); }
.test-dir-header.test-failed .test-dir-icon { color: var(--red); }
.test-dir-header.test-running .test-dir-icon { color: var(--yellow); }

.test-dir-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-strong);
}

.test-dir-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--badge-bg);
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    min-width: 20px;
    text-align: center;
}

/* Test items — compact rows within the tree */
.test-item {
    display: flex;
    flex-direction: column;
    border-left: 2px solid transparent;
    border-radius: 3px;
    padding: 0.25rem 0.5rem;
    margin-bottom: 1px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.test-item:hover {
    background: var(--bg-hover);
    border-left-color: var(--accent);
}

.test-item.test-passed {
    border-left-color: var(--teal);
}

.test-item.test-failed {
    border-left-color: var(--red);
}

.test-item.test-running {
    border-left-color: var(--yellow);
}

.test-item-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 22px;
}

.test-status-icon {
    font-size: 0.8rem;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}

.test-item.test-passed .test-status-icon {
    color: var(--teal);
}

.test-item.test-failed .test-status-icon {
    color: var(--red);
}

.test-item.test-running .test-status-icon {
    color: var(--yellow);
    animation: spin 1s linear infinite;
}

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

.test-name {
    flex: 1;
    color: var(--text);
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.test-run-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.test-item:hover .test-run-btn {
    opacity: 1;
}

.test-run-btn:hover {
    background: var(--accent);
    color: white;
}

.test-item-result {
    margin-top: 0.2rem;
    padding-left: 18px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.test-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    overflow: hidden;
}

.test-view {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.test-view.active {
    display: flex;
    flex-direction: column;
}

.test-welcome {
    text-align: center;
    padding: 3rem 2rem;
}

.test-welcome h3 {
    color: var(--text-strong);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.test-welcome p {
    color: var(--text);
    font-size: 1rem;
    line-height: 1.6;
}

.test-detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.btn-back {
    background: var(--control-bg);
    color: var(--text-strong);
    border: 1px solid var(--border-strong);
    height: 34px;
    padding: 0 0.85rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.btn-back:hover {
    background: var(--control-hover);
}

.test-detail-header h3 {
    flex: 1;
    color: var(--text-strong);
    font-size: 1.2rem;
    margin: 0;
}

.test-detail-actions {
    display: flex;
    gap: 0.5rem;
}

.test-detail-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.test-output-section,
.test-source-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.test-output-section h4,
.test-source-section h4 {
    color: var(--text-strong);
    font-size: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-copy {
    background: var(--control-bg);
    border: 1px solid var(--border-strong);
    color: var(--text-strong);
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12.5px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: var(--control-hover);
    border-color: var(--accent);
}

.btn-copy.copied {
    background: var(--teal);
    border-color: var(--teal);
    color: var(--bg);
}

.btn-copy.copied::before {
    content: '✓ ';
}

.test-output,
.test-source {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.5;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.test-output.success {
    border-left: 3px solid var(--teal);
}

.test-output.error {
    border-left: 3px solid var(--red);
}

.test-loading,
.test-empty,
.test-error {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.test-error {
    color: var(--red);
}

.test-summary {
    flex: 1;
    overflow-y: auto;
}

.test-summary h3 {
    color: var(--text-strong);
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-stat {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
}

.summary-stat.success {
    border-color: var(--teal);
}

.summary-stat.failed {
    border-color: var(--red);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.summary-stat.success .stat-value {
    color: var(--teal);
}

.summary-stat.failed .stat-value {
    color: var(--red);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.test-results-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-item {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.result-item:hover {
    background: var(--bg-elev2);
    border-color: var(--accent);
}

.result-item.success {
    border-left: 3px solid var(--teal);
}

.result-item.failed {
    border-left: 3px solid var(--red);
}

.result-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.result-item.success .result-icon {
    color: var(--teal);
}

.result-item.failed .result-icon {
    color: var(--red);
}

.result-name {
    flex: 1;
    color: var(--text);
    font-size: 0.95rem;
}

.result-summary {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Scrollbar styling */
.test-list::-webkit-scrollbar,
.test-main::-webkit-scrollbar,
.test-output::-webkit-scrollbar,
.test-source::-webkit-scrollbar {
    width: 8px;
}

.test-list::-webkit-scrollbar-track,
.test-main::-webkit-scrollbar-track,
.test-output::-webkit-scrollbar-track,
.test-source::-webkit-scrollbar-track {
    background: var(--bg);
}

.test-list::-webkit-scrollbar-thumb,
.test-main::-webkit-scrollbar-thumb,
.test-output::-webkit-scrollbar-thumb,
.test-source::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.test-list::-webkit-scrollbar-thumb:hover,
.test-main::-webkit-scrollbar-thumb:hover,
.test-output::-webkit-scrollbar-thumb:hover,
.test-source::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}
