/* ═══════════════════════════════════════════════════════════
   P59.6 — Test Dashboard Panel
   Model testing results, health score, category sections,
   expert test editor, trend sparkline.
   ═══════════════════════════════════════════════════════════ */

/* ── Panel Container ────────────────────────────────────── */
.test-dashboard {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: var(--status-bar-height);
  width: var(--panel-width, 340px);
  max-width: 100vw;
  display: none;
  flex-direction: column;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
  z-index: 190;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.test-dashboard.open {
  display: flex;
  transform: translateX(0);
}

/* Docking handled by layout.css .app.side-open rules (P60) */

/* ── Header ─────────────────────────────────────────────── */
.test-dashboard__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}

.test-dashboard__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.test-dashboard__title-icon {
  display: flex;
  align-items: center;
  color: var(--info);
}

.test-dashboard__header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Buttons ────────────────────────────────────────────── */
.test-dashboard__btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.test-dashboard__btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.test-dashboard__btn:active {
  transform: scale(0.97);
}

.test-dashboard__btn--primary {
  background: var(--info);
  color: #ffffff;
  border-color: var(--info);
}

.test-dashboard__btn--primary:hover {
  filter: brightness(1.1);
  background: var(--info);
  color: #ffffff;
  border-color: var(--info);
}

.test-dashboard__btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.test-dashboard__btn--danger {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
  padding: 4px 6px;
}

.test-dashboard__btn--danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.test-dashboard__btn--close {
  border: none;
  background: transparent;
  padding: 4px;
  color: var(--text-tertiary);
}

.test-dashboard__btn--close:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

/* ── Scrollable Body ────────────────────────────────────── */
.test-dashboard__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px;
}

/* ── Health Score Section ───────────────────────────────── */
.test-dashboard__health-score {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.test-dashboard__health-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.test-dashboard__health-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.test-dashboard__health-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.test-dashboard__health-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s ease-out, background-color 0.3s ease;
  min-width: 2px;
}

.test-dashboard__health-fill--red {
  background: var(--danger);
}

.test-dashboard__health-fill--orange {
  background: var(--warning);
}

.test-dashboard__health-fill--green {
  background: var(--success);
}

.test-dashboard__health-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 48px;
  text-align: right;
}

.test-dashboard__health-summary {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.test-dashboard__health-chip {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.test-dashboard__health-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* ── Category Section ───────────────────────────────────── */
.test-dashboard__body > * + * {
  margin-top: 12px;
}

.test-dashboard__category {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.test-dashboard__category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-base);
}

.test-dashboard__category-header:hover {
  background: var(--surface-hover);
}

.test-dashboard__category-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.test-dashboard__category-chevron {
  display: flex;
  align-items: center;
  color: var(--text-tertiary);
  transition: transform var(--transition-base);
}

.test-dashboard__category.expanded .test-dashboard__category-chevron {
  transform: rotate(90deg);
}

.test-dashboard__category-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.test-dashboard__category-count--pass {
  background: var(--success-bg);
  color: var(--success);
}

.test-dashboard__category-count--fail {
  background: var(--danger-bg);
  color: var(--danger);
}

.test-dashboard__category-body {
  display: none;
  border-top: 1px solid var(--border);
}

.test-dashboard__category.expanded .test-dashboard__category-body {
  display: block;
}

/* ── Test Item ──────────────────────────────────────────── */
.test-dashboard__test-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-base);
}

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

.test-dashboard__test-item:hover {
  background: var(--surface-hover);
}

.test-dashboard__test-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  margin-top: 1px;
}

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

.test-dashboard__test-icon--fail {
  color: var(--danger);
}

.test-dashboard__test-icon--warn {
  color: var(--warning);
}

.test-dashboard__test-icon--info {
  color: var(--info);
}

.test-dashboard__test-icon--skipped {
  color: var(--text-tertiary);
}

.test-dashboard__test-content {
  flex: 1;
  min-width: 0;
}

.test-dashboard__test-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.test-dashboard__test-message {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}

.test-dashboard__test-duration {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Test Details (expandable) ──────────────────────────── */
.test-dashboard__details {
  display: none;
  padding: 6px 12px 8px 36px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.test-dashboard__test-item.expanded + .test-dashboard__details {
  display: block;
}

.test-dashboard__detail-row {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 3px 0;
  line-height: 1.4;
}

.test-dashboard__detail-element {
  font-weight: 600;
  color: var(--text-primary);
}

.test-dashboard__detail-suggestion {
  font-style: italic;
  color: var(--text-tertiary);
  margin-top: 1px;
}

/* ── Expert Tests Section ───────────────────────────────── */
.test-dashboard__expert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 8px;
}

/* ── Expert Test Form ───────────────────────────────────── */
.test-dashboard__expert-form {
  display: none;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.test-dashboard__expert-form.visible {
  display: block;
}

.test-dashboard__form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: flex-end;
}

.test-dashboard__form-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.test-dashboard__form-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.test-dashboard__form-input,
.test-dashboard__form-select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  outline: none;
  transition: border-color var(--transition-base);
}

.test-dashboard__form-input:focus,
.test-dashboard__form-select:focus {
  border-color: var(--info);
  box-shadow: 0 0 0 2px var(--info-bg);
}

.test-dashboard__form-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* ── Trend Section ──────────────────────────────────────── */
.test-dashboard__trend {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-width: 0;
}

.test-dashboard__trend-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.test-dashboard__trend-canvas {
  width: 100%;
  max-width: 100%;
  height: 60px;
  display: block;
}

.test-dashboard__trend-empty {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 10px 0;
}

/* ── Empty State ────────────────────────────────────────── */
.test-dashboard__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 40px 20px;
  color: var(--text-tertiary);
}

.test-dashboard__empty svg {
  width: 40px;
  height: 40px;
  opacity: 0.35;
}

.test-dashboard__empty-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.test-dashboard__empty-hint {
  font-size: 11px;
  opacity: 0.7;
  max-width: 240px;
}

/* ── Loading State ──────────────────────────────────────── */
.test-dashboard__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 16px;
  color: var(--text-secondary);
  font-size: 12px;
}

.test-dashboard__spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--info);
  border-radius: 50%;
  animation: td-spin 0.7s linear infinite;
}

@keyframes td-spin {
  to { transform: rotate(360deg); }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .test-dashboard {
    width: 100vw;
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  .test-dashboard {
    width: 360px;
  }
}
