/* ============================================================
   QA Dashboard - Design System CSS
   Premium Dark Theme with Glassmorphism Effects
   ============================================================ */

/* --- CSS Variables (Design Tokens) --- */
:root {
    /* Backgrounds */
    --bg-main: #0f172a;
    --bg-surface: rgba(30, 41, 59, 0.7);
    --bg-elevated: #334155;
    --bg-hover: rgba(51, 65, 85, 0.5);
    --bg-input: rgba(15, 23, 42, 0.6);

    /* Accents */
    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-primary-glow: rgba(59, 130, 246, 0.25);
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;

    /* Text */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Border */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(59, 130, 246, 0.3);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Sidebar */
    --sidebar-width: 260px;

    /* Transition */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
}

a {
    text-decoration: none;
    color: inherit;
}

input,
select,
button {
    font-family: inherit;
    font-size: inherit;
}

/* --- Glass Panel Mixin --- */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.15);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s var(--ease);
}

.sidebar-logo {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all 0.25s var(--ease);
    cursor: pointer;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent-primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--accent-primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
}

.version-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--bg-elevated);
}

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 0 32px 32px;
}

/* --- Top Header --- */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 0;
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    margin: 0 -32px;
    padding: 24px 32px;
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    margin-bottom: 24px;
    border-radius: var(--radius-md);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.filter-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-group select {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 6px 12px;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.3s var(--ease);
    cursor: pointer;
}

.filter-group select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-glow);
}

.filter-group select option {
    background: var(--bg-main);
    color: var(--text-primary);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
}

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

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: border-color 0.3s var(--ease);
}

.search-box:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    width: 200px;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* --- Buttons --- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--accent-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s var(--ease);
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
    box-shadow: 0 0 20px var(--accent-primary-glow);
    transform: translateY(-1px);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s var(--ease);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ============================================================
   STATS GRID
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
    animation: fadeInUp 0.5s var(--ease);
}

.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s var(--ease);
}

.stat-card:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
}

.stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.stat-icon.bg-blue {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-primary);
}

.stat-icon.bg-green {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-success);
}

.stat-icon.bg-red {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-danger);
}

.stat-icon.bg-amber {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-warning);
}

.stat-icon.bg-purple {
    background: rgba(167, 139, 250, 0.15);
    color: #a78bfa;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.25rem;
}

/* ============================================================
   PAGES
   ============================================================ */
.page {
    display: none;
    animation: fadeInUp 0.4s var(--ease);
}

.page.active {
    display: block;
}

/* ============================================================
   TEST RUNS LIST
   ============================================================ */
.runs-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.run-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.3s var(--ease);
    animation: fadeInUp 0.4s var(--ease);
}

.run-card:hover {
    transform: translateY(-2px);
    background: var(--bg-hover);
    border-color: var(--border-accent);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.run-status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.run-status-dot.pass {
    background: var(--accent-success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.run-status-dot.fail {
    background: var(--accent-danger);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    animation: pulse-error 2s infinite;
}

.run-status-dot.fatal {
    background: #b91c1c;
    box-shadow: 0 0 8px rgba(185, 28, 28, 0.8);
    animation: pulse-error 1s infinite;
}

.run-status-dot.running {
    background: var(--accent-warning);
    animation: pulse-running 1.5s infinite;
}

.run-status-dot.queued {
    background: var(--text-muted);
    border: 1px dashed var(--border-subtle);
}

.run-info {
    flex: 1;
}

.run-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.run-url {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'Fira Code', monospace;
    max-width: 500px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.run-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.run-score {
    font-weight: 700;
    font-size: 1rem;
}

.run-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- Status Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-pass {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-success);
}

.badge-fail {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-danger);
}

.badge-fatal {
    background: rgba(185, 28, 28, 1);
    color: #fff;
    box-shadow: 0 0 8px rgba(185, 28, 28, 0.5);
}

.badge-skip {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.badge-running {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-warning);
}

.badge-queued {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border: 1px dashed var(--border-subtle);
}

.badge-review {
    background: rgba(167, 139, 250, 0.2); /* Purple/Violet for Review */
    color: #a78bfa;
    border: 1px solid rgba(167, 139, 250, 0.3);
}

.badge-decision {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
}

/* ============================================================
   TEST CASES GRID
   ============================================================ */
.test-cases-grid {
    display: grid;
    gap: 16px;
}

.test-case-card {
    padding: 20px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    transition: all 0.3s var(--ease);
    animation: fadeInUp 0.4s var(--ease);
}

.test-case-card:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.test-case-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.test-case-card .card-title {
    font-weight: 600;
    font-size: 1rem;
}

.test-case-card .card-url {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'Fira Code', monospace;
    word-break: break-all;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.test-case-card .card-actions {
    display: flex;
    gap: 8px;
}

/* --- Test Case Table Layout --- */
.tc-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    animation: fadeInUp 0.4s var(--ease);
}

.tc-table th {
    text-align: left;
    padding: 14px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-subtle);
}

.tc-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    transition: background 0.2s var(--ease);
}

.tc-table tr:last-child td {
    border-bottom: none;
}

.tc-table tr:hover td {
    background: var(--bg-hover);
}

.td-url {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--accent-primary);
    font-size: 0.85rem;
    font-family: 'Fira Code', monospace;
}

.td-url a {
    color: inherit;
    opacity: 0.8;
}

.td-url a:hover {
    opacity: 1;
    text-decoration: underline;
}

.status-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.table-actions {
    display: flex;
    gap: 6px;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 4px;
}

.badge-ready {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.badge-finished {
    background: rgba(59, 130, 246, 0.1);
    color: var(--text-secondary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* --- Phase 0.3 Explainability Elements --- */
.reason-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reason-tag {
    font-size: 0.65rem;
    padding: 1px 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-container {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.score-raw {
    font-size: 0.7rem;
    opacity: 0.5;
    text-decoration: line-through;
}

/* ============================================================
   HISTORY TIMELINE
   ============================================================ */
.history-timeline {
    position: relative;
}

.history-timeline::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-subtle);
}

.timeline-item {
    position: relative;
    padding-left: 52px;
    padding-bottom: 24px;
    animation: fadeInUp 0.4s var(--ease);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 3px solid var(--bg-main);
}

.timeline-item.pass::before {
    background: var(--accent-success);
}

.timeline-item.fail::before {
    background: var(--accent-danger);
}

.timeline-item.running::before {
    background: var(--accent-warning);
}

.timeline-content {
    padding: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s var(--ease);
}

.timeline-content:hover {
    border-color: var(--border-accent);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.timeline-content h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.timeline-content p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================================
   DETAIL MODAL - Step Timeline Visualization
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s var(--ease);
}

.modal {
    width: 100%;
    max-width: 560px;
    max-height: 95vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s var(--ease);
}

.modal-large {
    max-width: 1240px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
    font-size: 1.15rem;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s var(--ease);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
}

/* --- Step Timeline inside Detail --- */
.step-timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 650px;
    overflow-y: auto;
    padding-right: 12px;
}

.step-timeline::-webkit-scrollbar {
    width: 6px;
}

.step-timeline::-webkit-scrollbar-track {
    background: transparent;
}

.step-timeline::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.step-timeline::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.step-card {
    padding: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all 0.3s var(--ease);
}

.step-card:hover {
    border-color: var(--border-accent);
}

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

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.step-number.pass {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-success);
}

.step-number.fail {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-danger);
}

.step-action {
    font-weight: 600;
    font-size: 0.9rem;
    flex: 1;
    margin-left: 12px;
}

.step-images {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
}

.step-img-container {
    text-align: center;
}

.step-img-container img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.step-img-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.step-arrow {
    font-size: 1.5rem;
    color: var(--text-muted);
}

.step-arrow-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 60px;
}

.step-option-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.step-diff {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-family: 'Fira Code', monospace;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
}

.step-message {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    font-family: 'Fira Code', monospace;
}

/* --- Final Evaluation Card --- */
.eval-card {
    padding: 20px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.05));
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-md);
    margin-top: 20px;
}

.eval-card h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--accent-primary);
}

.eval-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.eval-stat {
    text-align: center;
}

.eval-stat-value {
    font-size: 1.2rem;
    font-weight: 700;
}

.eval-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.eval-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

/* --- Settings Form --- */
.settings-form {
    padding: 24px;
    max-width: 500px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.3s var(--ease);
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
    gap: 12px;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pulse-error {

    0%,
    100% {
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    }

    50% {
        box-shadow: 0 0 16px rgba(239, 68, 68, 0.8);
    }
}

.loading-spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

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

    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse-running {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

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

    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, rgba(148, 163, 184, 0.1) 50%, var(--bg-elevated) 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
        padding: 0 16px 16px;
    }

    .top-header {
        margin: 0 -16px;
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .header-right {
        flex-wrap: wrap;
    }

    .search-box input {
        width: 120px;
    }

    .modal {
        width: 95%;
    }

    .step-images {
        grid-template-columns: 1fr;
    }

    .step-arrow {
        transform: rotate(90deg);
        text-align: center;
    }

    .eval-stats {
        grid-template-columns: 1fr;
    }
}

/* Premium Tabs & Footer Logs */
.case-tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
}

.case-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.case-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.case-tab.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.run-footer-logs {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 2px dashed rgba(255, 255, 255, 0.05);
}

.error-log-card {
    background: rgba(18, 18, 18, 0.4) !important;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
}

.error-item {
    padding: 6px 0;
    font-size: 0.75rem;
    opacity: 0.8;
}

.error-item:last-child {
    border-bottom: none;
}

/* Biography-style Vertical Timeline & AI Vision */
.step-timeline {
    position: relative;
    padding-left: 20px;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.step-timeline::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--accent-primary), rgba(99, 102, 241, 0.1));
}

.step-item {
    position: relative;
    padding-bottom: 20px;
}

.step-marker {
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    transition: all 0.3s ease;
    width: 30px;
    height: 30px;
    line-height: 26px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 2px solid var(--border-subtle);
}

.step-item.pass .step-marker {
    border-color: var(--accent-success);
    color: var(--accent-success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.step-item.fail .step-marker {
    border-color: var(--accent-danger);
    color: var(--accent-danger);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.step-content {
    margin-left: 25px;
    padding: 15px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.step-item:hover .step-content {
    border-color: var(--border-accent);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.step-item:hover .step-marker {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 0 15px var(--accent-primary);
}

/* Collapsible Sections */
.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.collapsible-header:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-accent);
}

.collapsible-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-icon {
    transition: transform 0.3s var(--ease);
    color: var(--text-muted);
}

.collapsible-header.active .toggle-icon {
    transform: rotate(180deg);
    color: var(--accent-primary);
}

.collapsible-content {
    max-height: 10000px;
    overflow: hidden;
    transition: max-height 0.4s var(--ease), opacity 0.3s ease, margin 0.3s ease;
    opacity: 1;
    margin-bottom: 24px;
}

.collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 24px;
    /* Keep margin for flow if needed, or set to 0 */
    pointer-events: none;
}

.ai-insight-box {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
    position: relative;
    overflow: hidden;
}

.ai-insight-box::before {
    content: 'AI ANALYSIS';
    position: absolute;
    top: 0;
    right: 0;
    background: var(--accent-primary);
    color: white;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 2px 8px;
    border-bottom-left-radius: 8px;
    letter-spacing: 0.5px;
}

.ai-reason-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0;
}

.ai-vision-view {
    margin-top: 20px;
    background: #000;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.ai-vision-header {
    background: #1a1a1a;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-vision-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent-primary);
    letter-spacing: 1px;
}

.ai-annotated-img {
    width: 100%;
    display: block;
    cursor: zoom-in;
    max-height: 600px;
    object-fit: contain;
}

/* Boxed Step Internals */
.step-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.step-title-area {
    flex: 1;
}

.step-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
    letter-spacing: 1px;
    font-weight: 700;
}

.step-action-title {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
    text-transform: capitalize;
}

.step-name {
    color: var(--accent-primary);
}

.step-selection-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.step-val-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.step-val-badge {
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-family: 'Fira Code', monospace;
    font-family: 'Fira Code', monospace;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
}

/* Pagination Styles */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
    padding: 16px;
}

.pagination-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s var(--ease);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-width: 100px;
    text-align: center;
}

/* History Scroll */
.history-timeline {
    max-height: 800px;
    overflow-y: auto;
    padding-right: 12px;
}

.history-timeline::-webkit-scrollbar {
    width: 6px;
}

.history-timeline::-webkit-scrollbar-track {
    background: transparent;
}

.history-timeline::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.history-timeline::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}