/* ══════════════════════════════════════════
   BÁC SĨ MÁY — Light Theme v5
   Đồng bộ design system Tiệm Đồ Số
   ══════════════════════════════════════════ */

.check-app {
  --ck-bg: var(--bg-primary, #faf9f6);
  --ck-surface: var(--surface, #ffffff);
  --ck-surface2: var(--surface-2, #f3f1ec);
  --ck-surface3: var(--surface-3, #ece9e2);
  --ck-border: var(--border, rgba(28, 25, 23, 0.08));
  --ck-border-hover: rgba(28, 25, 23, 0.16);
  --ck-text: var(--text-primary, #1c1917);
  --ck-text2: var(--text-secondary, #57534e);
  --ck-text3: var(--text-muted, #a8a29e);
  --ck-accent: var(--accent, #0d9488);
  --ck-accent2: var(--accent-strong, #0f766e);
  --ck-accent-soft: var(--accent-soft, #e7f3f1);
  --ck-green: var(--green, #059669);
  --ck-yellow: #ca8a04;
  --ck-orange: #ea580c;
  --ck-red: var(--danger, #e11d48);
  --ck-radius: var(--radius-xs, 12px);
  --ck-radius-sm: 8px;
  --ck-shadow: var(--shadow-sm, 0 1px 2px rgba(28,25,23,0.04), 0 1px 3px rgba(28,25,23,0.06));
  --ck-shadow-md: var(--shadow-md, 0 2px 6px rgba(28,25,23,0.05), 0 10px 24px rgba(28,25,23,0.07));

  min-height: 100vh;
  background: var(--ck-bg);
  color: var(--ck-text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  padding: 88px 16px 48px; /* 72px navbar + 16px gap */
}

/* ── Layout Grid ── */
.check-container { max-width: 1100px; margin: 0 auto; }
.check-layout-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
}

/* ── Sidebar ── */
.check-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 88px; /* dưới navbar 72px + khoảng đệm */
  align-self: start;
}

.sidebar-card {
  background: var(--ck-surface);
  border: 1px solid var(--ck-border);
  border-radius: var(--ck-radius);
  padding: 18px;
  box-shadow: var(--ck-shadow);
}

.sidebar-card-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ck-text3);
  margin: 0 0 14px;
}

/* Device badge */
.device-badge { display: flex; align-items: center; gap: 12px; }
.device-icon-box {
  width: 42px; height: 42px;
  background: var(--ck-accent-soft);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.device-icon-box svg { width: 22px; height: 22px; stroke: var(--ck-accent); }
.device-name { font-size: 0.95rem; font-weight: 700; margin: 0; line-height: 1.3; color: var(--ck-text); }
.device-specs { font-size: 0.75rem; color: var(--ck-text2); margin: 2px 0 0; }

/* Health ring */
.health-card { text-align: center; }
.health-ring-container { position: relative; width: 110px; height: 110px; margin: 0 auto 10px; }
.health-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { stroke: var(--ck-surface2); }
.ring-fill { stroke: var(--ck-accent); transition: stroke-dashoffset 1s ease, stroke 0.5s ease; }
.health-score-box {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  text-align: center;
}
.health-score { font-size: 1.8rem; font-weight: 800; display: block; line-height: 1; color: var(--ck-text); }
.health-label { font-size: 0.6rem; letter-spacing: 0.12em; color: var(--ck-text3); font-weight: 700; }
.health-verdict { font-size: 0.85rem; font-weight: 700; margin: 4px 0 6px; }
.health-desc { font-size: 0.72rem; color: var(--ck-text2); margin: 0; line-height: 1.5; }

/* Khối điểm sức mạnh (benchmark) trong thẻ sức khoẻ */
.bench-total {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  margin: 8px 0 10px; padding: 9px 10px;
  background: var(--ck-surface2);
  border: 1px solid var(--ck-border);
  border-radius: var(--ck-radius-sm);
}
.bench-total-cap { font-size: 0.58rem; letter-spacing: 0.08em; color: var(--ck-text3); font-weight: 700; }
.bench-total-val { font-size: 1.5rem; font-weight: 800; line-height: 1.1; color: var(--ck-text); }
.bench-total-tier { font-size: 0.72rem; font-weight: 700; }

/* Start button */
.action-card { padding: 14px; }
.start-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 16px;
  background: var(--gradient-accent, linear-gradient(135deg, #14b8a6, #0d9488));
  color: #fff; font-weight: 700; font-size: 0.85rem;
  border: none; border-radius: 10px; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.2);
}
.start-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(13, 148, 136, 0.3); }
.start-btn:active { transform: scale(0.98); }
.start-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.start-btn-icon { display: flex; align-items: center; }

/* ── Main Content ── */
.check-main-content { min-width: 0; }

/* Tabs */
.check-tabs {
  background: var(--ck-surface);
  border: 1px solid var(--ck-border);
  border-radius: var(--ck-radius);
  padding: 5px;
  margin-bottom: 16px;
  box-shadow: var(--ck-shadow);
}
.tabs-scroll {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs-scroll::-webkit-scrollbar { display: none; }

.check-tab {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: inherit;
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px;
  font-size: 0.8rem; font-weight: 600;
  color: var(--ck-text3);
  background: transparent;
  border: none; border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.check-tab svg { width: 15px; height: 15px; flex-shrink: 0; }
.check-tab:hover { color: var(--ck-text); background: var(--ck-surface2); }
.check-tab.active {
  color: #fff;
  background: var(--gradient-accent, linear-gradient(135deg, #14b8a6, #0d9488));
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
}
.check-tab.active svg { stroke: #fff; }

/* Panels */
.check-panel { display: none; }
.check-panel.active { display: block; animation: panelIn 0.25s ease; }
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel-header { margin-bottom: 16px; }
.panel-header h2 { font-size: 1.1rem; font-weight: 700; margin: 0 0 3px; color: var(--ck-text); }
.panel-header p { font-size: 0.75rem; color: var(--ck-text2); margin: 0; }

/* ── Peripherals sub-nav ── */
.periph-section {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding: 5px;
  background: var(--ck-surface);
  border: 1px solid var(--ck-border);
  border-radius: var(--ck-radius);
  box-shadow: var(--ck-shadow);
}
.periph-toggle {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: inherit;
  padding: 9px 18px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ck-text2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  text-align: center;
  min-width: 0;
  white-space: nowrap;
}
.periph-toggle:hover {
  color: var(--ck-text);
  background: var(--ck-surface2);
}
.periph-toggle.active {
  color: #fff;
  background: var(--gradient-accent, linear-gradient(135deg, #14b8a6, #0d9488));
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
}
.periph-content { display: none; }
.periph-content.active { display: block; animation: panelIn 0.2s ease; }

/* ── Info Grid (Overview) ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.info-item {
  background: var(--ck-surface);
  border: 1px solid var(--ck-border);
  border-radius: var(--ck-radius-sm);
  padding: 12px 14px;
  box-shadow: var(--ck-shadow);
  transition: box-shadow 0.2s;
}
.info-item:hover { box-shadow: var(--ck-shadow-md); }
.info-item--full { grid-column: 1 / -1; }
.info-label {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 0.65rem; color: var(--ck-text3);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
}
.info-value {
  font-size: 0.82rem; font-weight: 600; margin-top: 5px;
  overflow-wrap: anywhere; word-break: normal; line-height: 1.45;
  color: var(--ck-text);
}
/* Nhãn loại GPU: rời (d) · tích hợp (i) · SoC (s) */
.info-pill {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 0.56rem; font-weight: 700; letter-spacing: 0.02em;
  text-transform: none; line-height: 1.55; white-space: nowrap;
}
.info-pill--d { background: rgba(5, 150, 105, 0.14); color: var(--ck-green); }
.info-pill--i { background: rgba(202, 138, 4, 0.16); color: var(--ck-yellow); }
.info-pill--s { background: var(--ck-accent-soft); color: var(--ck-accent2); }
.info-pill--x { background: var(--ck-surface2); color: var(--ck-text3); }

.overview-guide {
  background: var(--ck-accent-soft);
  border: 1px solid rgba(13, 148, 136, 0.12);
  border-radius: var(--ck-radius);
  padding: 16px 18px;
}
.overview-guide h4 { margin: 0 0 8px; font-size: 0.85rem; color: var(--ck-accent2); }
.overview-guide ul { margin: 0; padding-left: 18px; }
.overview-guide li { font-size: 0.78rem; color: var(--ck-text2); line-height: 1.8; }

/* ── Bench Cards: lưới 2 cột trên màn rộng (4 thẻ xếp 2×2) ── */
#perfTests {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}
#perfTests .bench-card { margin-bottom: 0; }

.bench-card {
  background: var(--ck-surface);
  border: 1px solid var(--ck-border);
  border-radius: var(--ck-radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: var(--ck-shadow);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.bench-card:hover { box-shadow: var(--ck-shadow-md); }
.bench-card.running { border-color: var(--ck-accent); box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.1); }
.bench-card.done { border-color: var(--ck-border-hover); }

.bench-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.bench-title { font-size: 0.85rem; font-weight: 700; color: var(--ck-text); min-width: 0; }
.bench-head-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.bench-score { font-size: 1.05rem; font-weight: 800; white-space: nowrap; }
.bench-wear {
  font-size: 0.7rem; font-weight: 700; white-space: nowrap;
  padding: 2px 8px; border-radius: 999px;
  background: var(--ck-surface2);
}
.bench-wear:empty { display: none; }

.bench-bar {
  height: 5px;
  background: var(--ck-surface2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}
.bench-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  transition: width 0.8s ease;
}

.card-desc { font-size: 0.74rem; color: var(--ck-text3); margin: 0 0 10px; }

.bench-details { display: flex; flex-direction: column; gap: 2px; }
.bench-detail {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.76rem;
  padding: 5px 0;
  border-bottom: 1px solid var(--ck-border);
}
.bench-detail:last-child { border-bottom: none; }
.bench-detail-label { color: var(--ck-text2); }
.bench-detail-value { font-weight: 600; text-align: right; color: var(--ck-text); }

.bench-actions { margin-top: 12px; }

/* ── Diag cards ── */
.diag-card {
  background: var(--ck-surface);
  border: 1px solid var(--ck-border);
  border-radius: var(--ck-radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: var(--ck-shadow);
}
.card-title { font-size: 0.88rem; font-weight: 700; margin: 0 0 8px; color: var(--ck-text); }

/* ── Buttons ── */
.test-action-btn {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 18px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--ck-surface);
  color: var(--ck-text);
  border: 1px solid var(--ck-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.2;
  box-shadow: var(--ck-shadow);
}
.test-action-btn:hover {
  border-color: var(--ck-accent);
  color: var(--ck-accent);
  background: var(--ck-accent-soft);
  box-shadow: 0 2px 10px rgba(13, 148, 136, 0.12);
  transform: translateY(-1px);
}
.test-action-btn:active { transform: scale(0.97); }
.test-action-btn:disabled {
  opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none;
}
.test-action-btn.small { padding: 5px 12px; font-size: 0.72rem; border-radius: 6px; }
.test-action-btn.recording {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-color: transparent; color: #fff;
  box-shadow: 0 2px 14px rgba(239, 68, 68, 0.3);
  animation: recPulse 1.2s ease infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 2px 14px rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 2px 22px rgba(239, 68, 68, 0.5); }
}

/* Speaker */
.speaker-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.speaker-status, .mic-status {
  font-size: 0.76rem; color: var(--ck-text2);
  margin-top: 8px; padding: 8px 12px;
  background: var(--ck-accent-soft);
  border-radius: 8px;
  border-left: 3px solid var(--ck-accent);
}

/* Mic */
#micWaveform {
  width: 100%; height: 80px;
  background: var(--ck-surface2);
  border: 1px solid var(--ck-border);
  border-radius: 8px;
  margin-bottom: 10px;
}
.mic-controls { display: flex; gap: 8px; }

/* Dead pixel colors */
.color-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.color-btn {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 42px; height: 42px;
  border-radius: 10px;
  border: 2px solid var(--ck-border);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--ck-shadow);
}
.color-btn:hover {
  transform: scale(1.15);
  border-color: var(--ck-accent);
  box-shadow: 0 4px 16px rgba(13, 148, 136, 0.2);
}
.color-btn[data-color="#ff0000"] { background: #ef4444; }
.color-btn[data-color="#00ff00"] { background: #22c55e; }
.color-btn[data-color="#0000ff"] { background: #3b82f6; }
.color-btn[data-color="#ffffff"] { background: #ffffff; border-color: #d4d4d4; }
.color-btn[data-color="#000000"] { background: #1c1917; }

/* Touch canvas */
#touchCanvas {
  width: 100%; height: 160px;
  background: var(--ck-surface2);
  border: 1px solid var(--ck-border);
  border-radius: 8px;
  touch-action: none;
  cursor: crosshair;
}
.touch-info { font-size: 0.72rem; color: var(--ck-text3); margin: 6px 0 0; }

/* Camera */
.camera-preview-wrapper {
  position: relative; width: 100%;
  aspect-ratio: 16/9;
  background: #1c1917;
  border-radius: var(--ck-radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}
#cameraPreview { width: 100%; height: 100%; object-fit: cover; }
.camera-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(28, 25, 23, 0.75);
  font-size: 0.82rem; color: #e7e5e4;
  transition: opacity 0.3s;
}
.camera-overlay.hidden { opacity: 0; pointer-events: none; }
.camera-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.snapshot-preview { width: 100%; border-radius: var(--ck-radius-sm); margin-top: 12px; }

/* Keyboard */
.kb-stats {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; font-size: 0.8rem; color: var(--ck-text2);
}
.kb-layout { overflow-x: auto; padding-bottom: 4px; }
.kb-row { display: flex; gap: 3px; margin-bottom: 3px; }
.kb-key {
  min-width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 600;
  background: var(--ck-surface);
  border: 1px solid var(--ck-border);
  border-radius: 6px;
  color: var(--ck-text2);
  transition: all 0.12s;
  flex-shrink: 0;
  user-select: none;
  box-shadow: 0 1px 2px rgba(28,25,23,0.05);
}
.kb-key.pressed {
  background: var(--ck-accent); border-color: var(--ck-accent); color: #fff;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
}
.kb-key.active-press { transform: scale(0.9); }
.kb-hint { font-size: 0.72rem; color: var(--ck-text3); margin: 6px 0 0; }

/* Fullscreen overlay */
.fullscreen-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  z-index: 9999; cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 30px;
}
.fs-hint {
  background: rgba(28, 25, 23, 0.7); padding: 8px 20px;
  border-radius: 20px; font-size: 0.75rem; color: #fff;
}

/* ══════════════════════════════════════════
   RESPONSIVE — Tablet 769–960px: sidebar hẹp hơn
   ══════════════════════════════════════════ */
@media (min-width: 769px) and (max-width: 960px) {
  .check-layout-grid { grid-template-columns: 232px 1fr; gap: 16px; }
  .sidebar-card { padding: 15px; }
  #perfTests { gap: 10px; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — Mobile / Tablet dọc ≤ 768px
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
  .check-app { padding: 82px 10px 36px; }
  .check-layout-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  /* Sidebar không sticky, xếp dọc, mỗi thẻ full-width */
  .check-sidebar {
    position: static;
    flex-direction: column;
    gap: 10px;
  }
  .device-header-card { padding: 14px; }
  .action-card { padding: 12px; }
  .start-btn { font-size: 0.82rem; padding: 12px 14px; }

  /* Thẻ Sức khoẻ & Sức mạnh: bố cục NGANG cho gọn — vòng tròn | chỉ số */
  .health-card {
    text-align: left;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "title title" "ring stats" "desc desc";
    align-items: center;
    gap: 6px 14px;
    padding: 14px 16px;
  }
  .health-card .sidebar-card-title { grid-area: title; margin: 0 0 2px; }
  .health-card .health-ring-container { grid-area: ring; width: 88px; height: 88px; margin: 0; }
  .health-card .health-stats { grid-area: stats; min-width: 0; }
  .health-card .health-desc { grid-area: desc; }
  .health-score { font-size: 1.5rem; }
  .health-verdict { margin: 0 0 6px; }
  .bench-total { margin: 0; align-items: flex-start; text-align: left; }
  .bench-total-cap { font-size: 0.55rem; }
  .bench-total-val { font-size: 1.3rem; }

  .check-tab { padding: 8px 10px; font-size: 0.74rem; gap: 4px; }
  .check-tab svg { width: 13px; height: 13px; }

  .info-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .info-item { padding: 10px 12px; }

  .periph-section { gap: 4px; padding: 4px; }
  .periph-toggle { padding: 7px 12px; font-size: 0.74rem; }

  /* Thẻ benchmark về 1 cột cho dễ đọc trên mobile */
  #perfTests { grid-template-columns: 1fr; }
  .bench-card { padding: 14px; }
  .bench-title { font-size: 0.8rem; }
  .bench-score { font-size: 0.95rem; }

  .kb-key { min-width: 24px; height: 26px; font-size: 0.58rem; }
  .kb-row { gap: 2px; margin-bottom: 2px; }
}

@media (max-width: 420px) {
  .check-app { padding: 78px 8px 32px; }
  .tabs-scroll { gap: 1px; }
  .check-tab { padding: 7px 6px; font-size: 0.7rem; }
  .check-tab svg { display: none; }
  .info-grid { grid-template-columns: 1fr; }
  .periph-toggle { font-size: 0.7rem; padding: 6px 8px; }
  /* Vòng tròn nhỏ lại chút trên màn rất hẹp */
  .health-card .health-ring-container { width: 76px; height: 76px; }
  .health-score { font-size: 1.3rem; }
}
