/* CSS Variables */
:root {
    --bg-primary: #FAFBFC;
    --bg-secondary: #F5F6F8;
    --bg-card: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --accent: #0D9488;
    --accent-hover: #0F766E;
    --success: #10B981;
    --success-bg: #ECFDF5;
    --failure: #EF4444;
    --failure-bg: #FEF2F2;
    --warning: #F59E0B;
    --warning-bg: #FFFBEB;
    --border: #E5E7EB;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    padding: 16px 0 24px;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.logo.spinning {
    animation: spin 2s linear infinite;
}

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

.header-text {
    flex: 1;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 2px;
}

.header-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Main Content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Progress Section */
.progress-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.progress-bar-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
}

.progress-bar-track {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 100px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), #14B8A6, var(--accent));
    background-size: 200% 100%;
    border-radius: 100px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.progress-section.complete .progress-bar,
.progress-section.has-failures .progress-bar,
.progress-section.has-warnings .progress-bar {
    animation: none;
    background-size: 100% 100%;
}

.progress-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.progress-percent {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 48px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.restart-icon-button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.restart-icon-button:hover {
    background: var(--accent);
    color: white;
}

.restart-icon-button:active {
    transform: scale(0.95);
}

.restart-icon-button svg {
    width: 18px;
    height: 18px;
}

/* Section Titles */
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* Results Section */
.results-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

/* Running state - show as list */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.test-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.25s ease;
    order: 2; /* Default order for pending */
}

.test-row.running {
    order: 0;
    background: linear-gradient(90deg, rgba(13, 148, 136, 0.1), rgba(13, 148, 136, 0.05));
    border-left: 3px solid var(--accent);
    margin-left: -3px;
}

.test-row.fail {
    order: 1;
}

.test-row.soft {
    order: 1;
}

.test-row.pass {
    order: 3;
    opacity: 0.5;
}

.test-row.pending {
    opacity: 0.35;
}

.test-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.test-icon svg {
    width: 16px;
    height: 16px;
}

.test-icon.pending svg {
    color: var(--text-muted);
}

.test-icon.running svg {
    color: var(--accent);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.test-icon.pass svg {
    color: var(--success);
}

.test-icon.soft svg {
    color: var(--warning);
}

.test-icon.fail svg {
    color: var(--failure);
}

.test-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
    flex: 1;
}

.test-row.running .test-name {
    color: var(--accent);
    font-weight: 600;
}

.test-row.fail .test-name {
    color: var(--failure);
    font-weight: 500;
}

.test-row.soft .test-name {
    color: var(--warning);
    font-weight: 500;
}

/* Completed state */
.results-complete {
    animation: fadeIn 0.3s ease;
}

.results-summary-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 8px 0;
    flex-wrap: wrap;
}

.summary-stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-stat-icon {
    width: 20px;
    height: 20px;
}

.summary-stat-icon svg {
    width: 20px;
    height: 20px;
}

.summary-stat-icon.pass svg { color: var(--success); }
.summary-stat-icon.soft svg { color: var(--warning); }
.summary-stat-icon.fail svg { color: var(--failure); }

.summary-stat-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.summary-stat-text strong {
    font-weight: 600;
    color: var(--text-primary);
}

/* Issues list in completion view */
.results-issues-list {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.results-issues-list:empty {
    display: none;
}

.issue-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--failure);
}

.issue-card:last-child {
    margin-bottom: 0;
}

.issue-card.soft {
    border-left-color: var(--warning);
}

.issue-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.issue-card-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.issue-card-icon svg {
    width: 20px;
    height: 20px;
    color: var(--failure);
}

.issue-card.soft .issue-card-icon svg {
    color: var(--warning);
}

.issue-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.issue-card-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--failure);
}

.issue-card.soft .issue-card-badge {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.issue-card-errors {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.issue-card-error {
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding-left: 30px;
    line-height: 1.5;
}

/* All passed state */
.all-passed-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    color: var(--success);
}

.all-passed-message svg {
    width: 24px;
    height: 24px;
}

.all-passed-message span {
    font-size: 1rem;
    font-weight: 500;
}


/* Export Section */
.export-section {
    animation: fadeIn 0.3s ease;
}

.export-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.export-container {
    position: relative;
}

.export-textarea {
    width: 100%;
    height: 100px;
    padding: 16px;
    padding-right: 100px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    resize: none;
    color: var(--text-primary);
    line-height: 1.5;
    word-break: break-all;
}

.export-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.copy-button {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-button:hover {
    background: var(--accent-hover);
}

.copy-button:active {
    transform: scale(0.98);
}

.copy-button.copied {
    background: var(--success);
}

.copy-icon {
    width: 16px;
    height: 16px;
}


/* Footer */
.footer {
    padding: 24px 0 8px;
    text-align: center;
}

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

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

    .header-content {
        gap: 12px;
    }

    .header-title {
        font-size: 1.1rem;
    }

    .header-description {
        font-size: 0.85rem;
    }

    .progress-bar-wrapper {
        flex-direction: column;
        gap: 8px;
    }

    .progress-info {
        width: 100%;
        justify-content: flex-end;
    }

    .export-textarea {
        padding-right: 16px;
        padding-bottom: 60px;
    }

    .copy-button {
        top: auto;
        bottom: 12px;
        right: 12px;
        left: 12px;
        justify-content: center;
    }

    .results-summary-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .issue-card-header {
        flex-wrap: wrap;
    }

    .issue-card-badge {
        margin-left: auto;
    }
}

/* Completion States */
.progress-section.complete .progress-bar {
    background: var(--success);
}

.progress-section.complete .progress-percent {
    color: var(--success);
}

.progress-section.has-failures .progress-bar {
    background: var(--failure);
}

.progress-section.has-failures .progress-percent {
    color: var(--failure);
}

.progress-section.has-warnings .progress-bar {
    background: var(--warning);
}

.progress-section.has-warnings .progress-percent {
    color: var(--warning);
}
