/* =====================================================
   QA Reporter — Design System
   ===================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Colors */
  --bg: #0d0f16;
  --bg-2: #13161f;
  --bg-3: #1a1e2e;
  --bg-4: #222638;
  --border: rgba(255,255,255,0.07);
  --border-focus: rgba(124,92,252,0.6);
  --text: #e8eaf0;
  --text-2: #9ea3b8;
  --text-3: #5c6180;

  --accent: #7C5CFC;
  --accent-2: #4FA3FF;
  --accent-glow: rgba(124,92,252,0.25);

  --success: #22c55e;
  --success-bg: rgba(34,197,94,0.12);
  --fail: #ef4444;
  --fail-bg: rgba(239,68,68,0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245,158,11,0.12);
  --progress: #3b82f6;
  --progress-bg: rgba(59,130,246,0.12);
  --na: #6b7280;
  --na-bg: rgba(107,114,128,0.12);

  /* Spacing */
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-width: 300px;
  --header-height: 62px;

  /* Typography */
  --font: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* =====================================================
   SCROLLBAR
   ===================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 99px; }

/* =====================================================
   APP HEADER
   ===================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(13,15,22,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 24px;
  max-width: 100%;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.app-logo-text span {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* =====================================================
   PROJECT SELECTOR
   ===================================================== */
.project-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-left: 20px;
}

.project-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  padding-left: 10px;
}

.project-icon {
  color: var(--accent-2);
  margin-right: 8px;
}

.project-select {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 24px 4px 0;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c6180' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  min-width: 140px;
  max-width: 240px;
  text-overflow: ellipsis;
}

.btn-icon-sm {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon-sm:hover {
  background: var(--accent-glow);
  color: var(--accent-2);
  border-color: var(--accent-2);
}

.btn-icon-sm.btn-danger-soft:hover {
  background: var(--fail-bg);
  color: var(--fail);
  border-color: var(--fail);
}

/* =====================================================
   LAYOUT
   ===================================================== */
.app-layout {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--header-height));
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar-section {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-title svg { opacity: 0.6; }

/* =====================================================
   FORMS
   ===================================================== */
.form-group {
  margin-bottom: 12px;
}

.label {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px;
}

.input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

.input::placeholder { color: var(--text-3); }

.textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

input[type="date"].input {
  color-scheme: dark;
}

/* =====================================================
   URL INPUT GROUP
   ===================================================== */
.url-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.url-input-group .input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
}

/* =====================================================
   SITE PREVIEW
   ===================================================== */
.site-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: fadeIn 0.3s ease;
}

.site-favicon {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  object-fit: contain;
  flex-shrink: 0;
}

.site-preview-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.site-preview-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-preview-url {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}

/* =====================================================
   LOGO UPLOAD
   ===================================================== */
.logo-upload-area {
  position: relative;
  cursor: pointer;
}

.logo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.logo-placeholder:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}

.logo-placeholder svg { opacity: 0.5; transition: opacity 0.2s; }
.logo-placeholder:hover svg { opacity: 1; }

.logo-preview {
  width: 100%;
  max-height: 80px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  padding: 8px;
}

.logo-remove {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 4px;
  background: transparent;
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  color: var(--fail);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.2s;
}

.logo-remove:hover { background: var(--fail-bg); }

/* =====================================================
   STATS
   ===================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  transition: border-color 0.2s;
}

.stat-num {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
}

.stat-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.stat-total .stat-num { color: var(--text); }
.stat-pass .stat-num { color: var(--success); }
.stat-fail .stat-num { color: var(--fail); }
.stat-warn .stat-num { color: var(--warning); }

.progress-bar-wrap {
  height: 6px;
  background: var(--bg-4);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 99px;
  width: 0%;
  transition: width 0.5s cubic-bezier(0.16,1,0.3,1);
}

.progress-label {
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
}

.mobile-only-actions { display: none; }

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.table-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.test-count {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--font-mono);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  gap: 6px;
}

.select-filter {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 12.5px;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.select-filter:focus { border-color: var(--border-focus); }

/* =====================================================
   TABLE
   ===================================================== */
.table-wrapper {
  flex: 1;
  overflow: auto;
  padding: 16px 24px 24px;
}

.test-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.test-table th {
  position: sticky;
  top: 0;
  background: var(--bg-2);
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 1;
}

.test-table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.test-table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

.test-row {
  transition: background 0.15s;
}

.test-row:hover { background: rgba(255,255,255,0.025); }

.test-row.drag-over { background: var(--accent-glow); }

.test-row td {
  padding: 0;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* Column widths */
.col-select { width: 40px; text-align: center; vertical-align: middle !important; }
.col-id { width: 40px; }
.col-category { width: 130px; }
.col-description { width: 220px; }
.col-page { width: 130px; }
.col-expected { width: 180px; }
.col-actual { width: 180px; }
.col-status { width: 150px; }
.col-notes { width: 160px; }
.col-actions { width: 44px; }

/* Custom Checkbox Styling */
.col-select input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  display: inline-block;
  vertical-align: middle;
}

.col-select input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.col-select input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.col-select input[type="checkbox"]:hover {
  border-color: var(--accent-2);
}

/* Vertical centering for cells without inputs */
th.col-select, td.col-select, .row-id, .col-actions {
  text-align: center;
}

.row-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
}

/* =====================================================
   CELL EDITABLE
   ===================================================== */
.cell-editable {
  min-height: 38px;
  padding: 8px 10px;
  outline: none;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  transition: background 0.15s;
  white-space: pre-wrap;
  word-break: break-word;
}

.cell-editable:empty::before {
  content: attr(data-placeholder);
  color: var(--text-3);
  pointer-events: none;
}

.cell-editable:focus {
  background: rgba(124,92,252,0.06);
  box-shadow: inset 0 0 0 1px var(--border-focus);
}

/* =====================================================
   CELL SELECT
   ===================================================== */
.cell-select {
  width: 100%;
  height: 100%;
  min-height: 38px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c6180' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.status-select { font-size: 12px; }

/* Status row tints */
.test-row[data-status="success"] td { border-left: none; }
.test-row[data-status="success"] td:first-child { border-left: 3px solid var(--success); }
.test-row[data-status="fail"] td:first-child { border-left: 3px solid var(--fail); }
.test-row[data-status="warning"] td:first-child { border-left: 3px solid var(--warning); }
.test-row[data-status="progress"] td:first-child { border-left: 3px solid var(--progress); }
.test-row[data-status="na"] td:first-child { border-left: 3px solid var(--na); }

/* =====================================================
   ROW ACTIONS
   ===================================================== */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin: 6px auto;
}

.btn-delete:hover { background: var(--fail-bg); color: var(--fail); }

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 80px 20px;
  color: var(--text-3);
  text-align: center;
}

.empty-state svg { opacity: 0.25; margin-bottom: 8px; }
.empty-sub { font-size: 13px; color: var(--text-3) !important; margin-bottom: 12px; }
.empty-state p { font-size: 15px; color: var(--text-2); }

.table-footer-actions {
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  border-radius: var(--radius);
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
}

.w-full { width: 100%; }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6040e0);
  color: #fff;
  box-shadow: 0 2px 8px rgba(124,92,252,0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #8d6ffe, var(--accent));
  box-shadow: 0 4px 16px rgba(124,92,252,0.5);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

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

.btn-danger {
  background: var(--fail-bg);
  color: var(--fail);
  border: 1px solid rgba(239,68,68,0.3);
}

.btn-danger:hover { background: rgba(239,68,68,0.25); }

/* =====================================================
   SPINNER
   ===================================================== */
.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 280px;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: slideUp 0.2s ease;
}

.modal-message { font-size: 14px; color: var(--text); margin-bottom: 18px; line-height: 1.5; }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

.magic-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-magic {
  background: linear-gradient(135deg, #FF3CAC 0%, #784BA0 50%, #2B86C5 100%);
  color: #fff;
  border: none;
  box-shadow: 0 4px 15px rgba(120, 75, 160, 0.4);
}

.btn-magic:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 6px 20px rgba(120, 75, 160, 0.6);
}

.w-full { width: 100%; }

.recorder-box {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 12px;
  text-align: left;
}

.recorder-steps {
  list-style: none;
  font-size: 12.5px;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recorder-steps li {
  display: flex;
  gap: 10px;
}

.step-num {
  background: var(--accent);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.code-block {
  background: #000;
  color: #22c55e;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin-top: 8px;
  white-space: pre;
  border: 1px solid var(--border);
}

.bookmarklet-btn {
  display: inline-block;
  background: var(--bg-4);
  border: 1px solid var(--accent);
  color: var(--accent-2);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: move;
  margin: 5px 0;
}

.bookmarklet-btn:hover {
  background: var(--accent-glow);
}

/* =====================================================
   TOAST
   ===================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 10px 16px;
  z-index: 1000;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  animation: slideUp 0.25s ease;
}

.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--fail); }

/* =====================================================
   UTILITIES
   ===================================================== */
.hidden { display: none !important; }

/* =====================================================
   ANIMATIONS
   ===================================================== */
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.test-row {
  animation: fadeIn 0.2s ease;
}

/* =====================================================
   PRINT STYLES
   ===================================================== */
@media print {
  @page {
    size: A4 landscape;
    margin: 15mm 12mm;
  }

  body {
    background: #fff !important;
    color: #111 !important;
    font-size: 11pt !important;
  }

  .app-header,
  .sidebar,
  .table-toolbar .toolbar-right,
  .btn,
  .col-actions,
  .empty-state { display: none !important; }

  .app-layout { display: block !important; }
  .main-content { width: 100% !important; }

  .table-toolbar {
    border-bottom: 2px solid #ddd;
    padding: 0 0 10px;
    margin-bottom: 10px;
  }

  .table-title { color: #111 !important; font-size: 16pt !important; }

  .test-table { border: 1px solid #ddd !important; }

  .test-table th {
    background: #f4f4f8 !important;
    color: #444 !important;
    border-bottom: 2px solid #ccc !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .test-row td {
    border-bottom: 1px solid #e5e7eb !important;
  }

  .cell-editable, .cell-select { color: #111 !important; }

  .test-row[data-status="success"] td:first-child { border-left: 4px solid #22c55e !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .test-row[data-status="fail"] td:first-child { border-left: 4px solid #ef4444 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .test-row[data-status="warning"] td:first-child { border-left: 4px solid #f59e0b !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .test-row[data-status="progress"] td:first-child { border-left: 4px solid #3b82f6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* =====================================================
   RESPONSIVE — SIDEBAR TOGGLE BUTTON
   ===================================================== */
.btn-sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.btn-sidebar-toggle:hover {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--accent);
}

/* Overlay behind sidebar on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  z-index: 199;
}

.sidebar-overlay.active {
  display: block;
}

/* =====================================================
   RESPONSIVE — TABLETTE (≤ 1080px)
   ===================================================== */
@media (max-width: 1080px) {
  :root {
    --sidebar-width: 260px;
  }

  .project-select {
    min-width: 100px;
    max-width: 160px;
  }

  .app-header-actions .btn-ghost {
    display: none;
  }
}

/* =====================================================
   RESPONSIVE — MOBILE/TABLETTE (≤ 768px)
   ===================================================== */
@media (max-width: 768px) {
  :root {
    --header-height: 54px;
  }

  /* Show hamburger button */
  .btn-sidebar-toggle {
    display: flex;
    margin-right: 4px;
  }

  /* Sidebar becomes an off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
    padding-top: var(--header-height);
    width: 280px;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
  }

  /* Main content takes full width */
  .main-content {
    width: 100%;
  }

  /* Header: compact project selector */
  .project-selector {
    margin-left: 8px;
  }

  .project-select {
    min-width: 80px;
    max-width: 130px;
    font-size: 12px;
  }



  /* Hide desktop header actions on mobile */
  .app-header-actions {
    display: none;
  }

  /* Show mobile actions in sidebar */
  .mobile-only-actions {
    display: block;
  }

  .mobile-only-actions .btn {
    justify-content: flex-start;
  }

  .mobile-only-actions {
    display: block;
    padding: 20px 0; /* Standard sidebar section padding */
  }

  .mobile-only-actions .section-title {
    padding: 0;
    margin-bottom: 14px;
  }

  .btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  #btn-export-html > svg ~ *,
  #btn-reset > svg ~ * {
    display: none;
  }

  /* Toolbar layout for mobile */
  .table-toolbar {
    padding: 12px 16px;
    gap: 8px;
  }

  .toolbar-right {
    width: 100%;
    justify-content: flex-start;
  }

  .filter-group {
    flex: 1;
  }

  .select-filter {
    flex: 1;
    font-size: 12px;
    padding: 5px 8px;
  }

  /* ── TABLE → CARD LAYOUT ── */

  /* Wrapper: padding around the cards */
  .table-wrapper {
    padding: 16px 16px 24px;
    overflow-x: hidden;
  }

  /* Make table elements behave as blocks to allow margins and full width */
  .test-table,
  .test-table tbody,
  .test-table td {
    display: block;
    width: 100%;
    border-collapse: collapse;
  }

  /* Hide the header row */
  .test-table thead tr {
    display: none;
  }

  /* Each row = a card */
  .test-row {
    display: block;
    background: var(--bg-2);
    border: 1px solid var(--border);
    margin: 0 0 32px 0 !important; /* Force margin between blocks */
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    animation: none;
  }

  /* Card top color stripe by status */
  .test-row[data-status="success"] { border-top: 3px solid var(--success); }
  .test-row[data-status="fail"]    { border-top: 3px solid var(--fail); }
  .test-row[data-status="warning"] { border-top: 3px solid var(--warning); }
  .test-row[data-status="progress"]{ border-top: 3px solid var(--progress); }
  .test-row[data-status="na"]      { border-top: 3px solid var(--na); }

  /* Clear the desktop left-status border */
  .test-row td:first-child { border-left: none !important; }

  /* Clearfix removal and structural cleanup */
  .test-row td {
    display: flex !important;
    align-items: stretch; /* Keep labels full height */
    justify-content: flex-start;
    border-bottom: 1px solid var(--border);
    padding: 0 !important;
    min-height: 48px;
    width: 100% !important;
    box-sizing: border-box;
  }

  .test-row td:last-child {
    border-bottom: none;
  }

  /* Label pseudo-element on left with consistent fixed width */
  .test-row td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 120px; /* SAME WIDTH FOR EVERY LABEL */
    display: flex;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    background: var(--bg-3);
    padding: 12px 15px;
    border-right: 1px solid var(--border);
    line-height: 1.2;
    box-sizing: border-box;
  }

  /* Content area on the right */
  .test-row .cell-editable,
  .test-row .cell-select {
    flex: 1;
    margin: 0;
    height: 100%;
    min-height: 48px;
    padding: 12px 15px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
  }

  /* Refined alignment for non-text inputs */
  .test-row .col-select,
  .test-row .col-actions {
    justify-content: flex-start;
  }

  .test-row .row-checkbox,
  .test-row .btn-icon {
    flex: none;
    align-self: center;
    margin: 0 0 0 15px !important; /* Force exact same horizontal start as text padding */
    padding: 0;
    width: 16px; /* Consistency */
    height: 16px; 
    border: 1px solid var(--border);
  }

  .test-row .btn-icon {
    width: 32px;
    height: 32px;
    margin-left: 7px !important; /* Adjust for icon button width to align the actual icon center? No, user wants the "row" aligned. */
  }
  
  /* Actually, let's just make sure the left edge aligns */
  .test-row .btn-icon {
    margin-left: 8px !important; /* (15px padding - (32px btn - 18px icon)/2 ) ... roughly */
    /* Let's be precise: if padding is 15px, and btn is 32px with 15px icon inside, 
       the icon starts at margin + (32-15)/2. 
       We want the icon start (or the focus box start) to look aligned. 
       Usually 15px is the target. */
    margin-left: 15px !important;
  }

  .test-row .cell-select {
    padding-right: 35px;
  }

  /* Modal adapts to mobile */
  .modal {
    min-width: 0;
    width: calc(100vw - 32px);
    max-width: 360px;
  }

  /* Toast adapts */
  .toast {
    bottom: 16px;
    right: auto;
    left: 16px;
    width: calc(100vw - 32px);
    font-size: 12.5px;
  }

  .table-footer-actions {
    border-radius: var(--radius);
    margin-top: 0;
    border: 1px solid var(--border);
    padding: 12px 16px;
  }
}

/* =====================================================
   RESPONSIVE — PETIT MOBILE (≤ 480px)
   ===================================================== */
@media (max-width: 480px) {
  .app-logo-text {
    font-size: 14px;
  }

  .project-selector {
    margin-left: 4px;
    padding: 3px;
  }

  .project-select {
    min-width: 60px;
    max-width: 100px;
    font-size: 11px;
  }

  .btn-icon-sm {
    width: 26px;
    height: 26px;
  }

  /* Hide project rename/delete buttons to save space */
  #btn-rename-project,
  #btn-delete-project {
    display: none;
  }

  .table-toolbar {
    padding: 10px 10px;
  }

  .table-title {
    font-size: 14px;
  }

  .table-wrapper {
    padding: 8px 12px 16px;
  }

  .sidebar {
    width: 100vw;
    max-width: 320px;
  }
}
