/* ===============================
   RESET & BASE
================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

/* ===============================
   ROOT VARIABLES
================================= */
:root {
  /* Status colors */
  --passed: #10B981;
  --passed-bg: #ECFDF5;
  --passed-light: #D1FAE5;

  --failed: #EF4444;
  --failed-bg: #FEF2F2;
  --failed-light: #FECACA;

  --broken: #F59E0B;
  --broken-bg: #FFFBEB;
  --broken-light: #FEF3C7;

  --skipped: #6B7280;
  --skipped-bg: #F9FAFB;
  --skipped-light: #F3F4F6;

  --print: #8B5CF6;
  --print-bg: #F5F3FF;
  --print-light: #E0E7FF;

  /* Base colors */
  --primary: #0F172A;
  --primary-dark: #1D4ED8;

  --bg: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-light: #e6ebed;
  --bg-strong: #ced3d9;

  --text: #0F172A;
  --text-light: #475569;
  --text-muted: #64748B;

  --border: #E2E8F0;
  --border-light: #F1F5F9;

  /* Misc */
  --shadow: 0px 0px 15px rgba(0, 0, 0, 0.3);
  --radius: 10px;
  --radius-sm: 5px;
}

/* ===============================
   TYPOGRAPHY
================================= */
h1, h2, h3, h4 { font-weight: 600; }
h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; }
a { text-decoration: underline; }

/* ===============================
   UTILITIES & SHARED PATTERNS
================================= */
.hidden { display: none !important; }
.main-icon { width: 69px; height: 69px; }
.level-0 { --level: 0; }

.header {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 0.75rem;
    padding-left: 1rem;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 1rem;
}

.header h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Shared hover feedback for clickable blocks */
.header:hover,
.test-header:hover,
.step-header:hover,
.attachment:hover {
    background: var(--bg-light);
    opacity: 0.6;
}

.header.expanded {
    background: var(--bg-light);
    border-radius: var(--radius) var(--radius) 0px 0px;
}

/* Toggle icon animations */
.header .toggle-icon,
.test-header .toggle-icon,
.step-header .toggle-icon { transition: transform 0.2s ease; }

.header.expanded .toggle-icon,
.test-header.expanded .toggle-icon,
.step-header.expanded .toggle-icon { transform: rotate(180deg); }

/* Unified show/hide API via .active */
.content,
.test-content,
.step-content,
.step-body,
.attachment-body,
.download-link { display: none; }

.content.active,
.test-content.active,
.step-content.active,
.step-body.active,
.attachment-body.active,
.download-link.active,
.test-run-content.active { display: block; }

/* ===============================
   LAYOUT
================================= */
.container { max-width: 100%; margin: 0; padding: 0; }

.layout-wrapper { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 350px;
  background: var(--bg);
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar .card { margin: 1rem; margin-top: 0; }
.sidebar .card .header { padding: 0.75rem; padding-left: 1rem; }
.sidebar .card h1 { font-size: 1.25rem; line-height: 1.5rem; }
.sidebar .meta-grid { grid-template-columns: 1fr; }

.main-content { flex: 1; overflow-y: auto; padding: 1rem; background: var(--bg); }
.main-content .card:first-child { margin-top: 0; }

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
    transition: 0.5s;
}

/* ===============================
   SIDEBAR
================================= */
.sidebar .search-filter {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.sidebar .search-filter > div:first-child {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar .search-container {
    position: relative;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.sidebar .search-container:hover {
    border-color: var(--primary);
	transition: all 0.2s ease;
}
.sidebar .search-container i {
    position: absolute; left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text);
}
.sidebar .search-container input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    font-size: 1rem;
    border: none;
    border-radius: var(--radius-sm);
}

.sidebar .search-filter select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}
.sidebar .search-filter select:hover {
	border-color: var(--primary);
	transition: all 0.2s ease;
}

.sidebar .filter-buttons { width: 100%; flex-wrap: wrap; display: flex; gap: 1rem; }
.sidebar .filter-buttons button { flex: 1 1 45%; }
.sidebar .filter-buttons .filter-btn {
	padding: 0.5rem 1rem;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg-light);
	cursor: pointer;
	transition: all 0.2s ease;
	font-size: 0.875rem;
}
.sidebar .filter-buttons .filter-btn:hover {
	background: var(--primary);
	color: white;
	border-color: var(--primary);
}
.sidebar .filter-buttons .filter-btn.active {
	background: var(--primary);
	color: white;
	border-color: var(--primary);
}

/* ===============================
   CARDS & SUMMARY
================================= */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.content { padding: 1rem; }

.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.meta-item { display: flex; flex-direction: column; gap: 0.25rem; }
.meta-item span { font-size: 0.875rem; color: var(--text-muted); text-transform: uppercase; font-weight: 500; }
.meta-item strong {
    font-size: 1rem; font-weight: 600;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
}
.summary-card {
    text-align: center;
    padding: 1rem;
    border-radius: var(--radius);
    border: 2px solid;
    position: relative;
}
.summary-card:first-child {
    grid-column: 1 / -1;
}
.summary-card.passed { border-color: var(--passed); background: var(--passed-bg); }
.summary-card.failed { border-color: var(--failed); background: var(--failed-bg); }
.summary-card.broken { border-color: var(--broken); background: var(--broken-bg); }
.summary-card.skipped { border-color: var(--skipped); background: var(--skipped-bg); }
.summary-card .number { font-size: 2.5rem; font-weight: 700; line-height: 1; }
.summary-card .label { font-weight: 600; margin: 0.5rem 0; }
.summary-card .percentage { font-size: 0.875rem; }

.badge {
  display: block;
  text-align: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge.passed { background: var(--passed-light); color: var(--passed); }
.badge.failed { background: var(--failed-light); color: var(--failed); }
.badge.broken { background: var(--broken-light); color: var(--broken); }
.badge.skipped { background: var(--skipped-light); color: var(--skipped); }
.badge.print { background: var(--print-light); color: var(--print); }

/* ===============================
   MODULES
================================= */
.module {
    border-radius: var(--radius);
    transition: 0.2s ease;
}
.module-stats { display: flex; align-items: center; gap: 0.5rem; }

/* ===============================
   TESTS
================================= */
.test {
  border-left: 4px solid;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 0.75rem;
}

.test.passed { border-left-color: var(--passed); }
.test.failed { border-left-color: var(--failed); }
.test.broken { border-left-color: var(--broken); }
.test.skipped { border-left-color: var(--skipped); }

.test-header {
    display: flex;
    background: var(--bg-card);
    padding: 0.5rem;
    padding-left: 0.75rem;
    border-radius: 7px var(--radius) var(--radius) 7px;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.test-header.expanded {
    background: var(--bg-light);
    border-radius: 7px var(--radius) 0px 0px;
}

.test-name { font-weight: 600; }

.test.test-multi {
    border-left: 4px solid var(--primary);
    border-bottom: 1px solid var(--bg-strong);
}
.test-header-multi {
    display: flex;
    padding: 0.5rem;
    padding-left: 0.75rem;
    border-radius: var(--radius);
    align-items: center;
    background: var(--bg-card);
}
.test.test-sub {
    margin: 0.75rem;
    margin-top: 0.5rem;
}

/* Test info band */
.test-info { display: grid; grid-template-columns: max-content 1fr auto; align-items: center; gap: 1rem; }

.test-results { display: grid; grid-auto-flow: column; column-gap: 0.5rem; align-items: center; }

.test-status.passed { background-color: #d4edda; color: var(--passed); background: var(--passed-light); }
.test-status.failed { background-color: #f8d7da; color: var(--failed); background: var(--failed-light); }
.test-status.skipped { background-color: #fff3cd; color: var(--skipped); background: var(--skipped-light); }

.test-duration { color: var(--text-muted); font-size: 0.875rem; background: var(--bg-card); padding: 0.25rem 0.5rem; border-radius: var(--radius-sm); text-align: center; }
.test-steps li { padding: 0.75rem; margin-bottom: 0.5rem; border-radius: var(--radius-sm); background: var(--bg-light); }

/* ===============================
   TABS
================================= */
.tab-nav {
    background: var(--bg-light);
    display: flex;
}
.tab-btn {
    padding: 0.75rem;
    border: none;
    background: var(--bg-light);
    cursor: pointer;
    font-weight: 550;
    font-size: 0.875rem;
    color: var(--text);
    transition: all 0.2s ease;
}
.tab-btn:hover {
    background: var(--bg);
    opacity: 0.6;
    transition: all 0.2s ease;
}
.tab-btn.active {
    background: var(--bg-card);
}
.tab-btn.error { color: var(--failed); }

.tab-content {
	display: none;
	padding: 0.75rem;
}

.tab-content.active {
	display: block;
}

/* ===============================
   SECTIONS & INFO
================================= */
.section { margin-bottom: 0.5rem; }
.section h4 { margin-bottom: 0.5rem; }

.description {
    background: var(--bg-light);
    padding: 1rem;
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    font-size: 0.875rem;
}

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.info-item { background: var(--bg-light); padding: 1rem; border-radius: var(--radius-sm); }
.info-key { font-weight: 600; margin-bottom: 0.5rem; color: var(--text-muted); text-transform: uppercase; font-size: 0.875rem; }
.info-value {
    font-size: 0.875rem;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* ===============================
   BUGS AND ERRORS
================================= */
.bug-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.bug-item { background: var(--failed-bg); padding: 1rem; border-radius: var(--radius-sm); }
.bug-desc { font-weight: 600; color: var(--failed); }
.bug-item a { color: var(--failed); font-size: 1rem; }

.error-icon { color: var(--failed); font-size: 0.875rem; }

.error-section {
    background: var(--failed-bg);
    border: 1px solid var(--failed-light);
    padding: 0.75rem;
    border-radius: var(--radius);
}
.error-section .card {
    margin-bottom: 0.25rem;
}
.error-section .header {
    padding: 0.75rem;
}
.error-section h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.error-message {
    font-weight: 600;
    color: var(--failed);
    margin-bottom: 0.75rem;
    white-space: pre-wrap;
}
.stacktrace {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    font-weight: 550;
    overflow-x: auto;
    white-space: pre-wrap;
}

.no-results { text-align: center; padding: 3rem; color: var(--text-muted); }
.no-steps { text-align: center; padding: 2rem; color: var(--text-muted); font-style: italic; }

/* ===============================
   STEPS
================================= */
.steps { margin: 0.5rem 0; }
.step {
  margin-bottom: 0.75rem;
  border-radius: var(--radius);
  border-left: 3px solid;
  padding-left: 1.25rem;
  margin-left: calc(var(--level, 0) * 1rem);
}
.step.print { padding: 0.5rem; background: var(--print-bg); border-left: 3px solid var(--print); border-top: none; }
.step.passed { border-left-color: var(--passed); border-top-color: var(--passed); }
.step.failed { border-left-color: var(--failed); border-top-color: var(--failed); }
.step.broken { border-left-color: var(--broken); border-top-color: var(--broken); }
.step.skipped { border-left-color: var(--skipped); border-top-color: var(--skipped); }

.step-header {
    padding: 0.5rem;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}
.step-header-no-addons {
    padding: 0.5rem;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.step-info { display: flex; align-items: center; gap: 0.5rem; }

.step .info-item { padding: 0.75rem; }
.step .bug-item { padding: 0.75rem; }

.step-badge { font-size: 0.875rem; padding: 0.25rem; align-items: center; display: flex; gap: 0.5rem; }
.step-title { font-weight: 550; white-space: pre-wrap; }
.step-content { margin-top: 0.5rem; padding: 0rem; background: var(--bg-card); border-radius: var(--radius-sm); }

.step-children { margin-top: 0.5rem; }

.step-error { background: var(--failed-bg); padding: 0.75rem; border-radius: var(--radius-sm); margin-top: 0.5rem; white-space: pre-wrap; }
.step-error pre { background: var(--bg-card); padding: 0.75rem; border-radius: var(--radius-sm); font-size: 0.875rem; overflow-x: auto; }

/* ===============================
   ATTACHMENTS
================================= */
.attachments { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1rem 0; }
.attachment {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
    width: 150px;
    transition: all 0.2s ease;
}
.attachment img { max-width: 125px; max-height: 125px; border-radius: var(--radius-sm); }
.attachment i { font-size: 2rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.attachment span { font-size: 0.75rem; margin-top: 0.5rem; word-break: break-word; }

/* Attachment modal */
.modal { display: none; position: fixed; z-index: 999; inset: 0; background: rgba(0, 0, 0, 0.8); overflow: auto; padding: 2vh 2vw; }
.modal-content { position: relative; margin: auto; background: #fff; border-radius: 8px; max-width: 90vw; max-height: 90vh; padding: 1rem; box-sizing: border-box; }
.attachment-body { max-height: 80vh; overflow: auto; margin-top: 1rem; text-align: center; }
.download-link { margin-top: 1rem; padding: 0.5rem 1rem; background: #007bff; color: #fff; border-radius: 5px; text-decoration: none; }
.download-link:hover { background: #0056b3; }
.close { position: absolute; top: 0.5rem; right: 1rem; font-size: 1.5rem; background: none; border: none; color: #888; cursor: pointer; }
.close:hover { color: #000; }

#modalImage {
  max-width: 100%;
  max-height: 100%;
  transition: transform 0.2s ease;
  transform-origin: center;
  cursor: grab;
}

#modalPDF {
  width: 100%;
  height: 70vh;
  border: none;
}

#modalText {
    background: #f9f9f9;
    text-align: left;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 1rem;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.95rem;
}

/* ===============================
   RESPONSIVE
================================= */
@media (max-width: 992px) {
  .layout-wrapper { flex-direction: column; height: auto; }
  .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); overflow-y: visible; }
  .sidebar .search-filter { padding: 1rem; }
  .main-content { padding: 1rem; }
}

@media (max-width: 768px) {
  .container { padding: 1rem; }
  .search-filter { grid-template-columns: 1fr; }
  .filter-buttons { flex-wrap: wrap; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .meta-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .tab-nav { flex-wrap: wrap; }
  .tab-btn { flex: 1; min-width: 100px; }
  .sidebar .filter-buttons { flex-direction: column; }
  .sidebar .filter-buttons button { flex: 1 1 100%; width: 100%; }
}

@media (max-width: 480px) {
  .test-info { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .summary-grid { grid-template-columns: 1fr; }
  .main-content { padding: 0.5rem; }
}
