/* =====================================================
   MKP DeviceFarm · UI v2
   Theme matches MKP WebHub (Dark + Orange accent #EA8623)
   Inter font · Material Symbols Rounded · 220px sidebar
   ===================================================== */

@font-face {
  font-family: 'Material Symbols Rounded';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('../fonts/material-symbols-rounded.ttf') format('truetype');
}
.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  display: inline-block;
  white-space: nowrap;
  -webkit-font-feature-settings: 'liga';
  font-feature-settings: 'liga';
  vertical-align: middle;
}

:root {
  --bg-primary: #0C0C0C;
  --bg-secondary: #161616;
  --bg-card: #1E1E1E;
  --bg-hover: #2A2A2A;
  --text-primary: #F0F0F0;
  --text-secondary: #B4B4B4;   /* WCAG AA pass · was #888 · now 9.3:1 on bg-primary */
  --text-muted: #8A8A8A;        /* WCAG AA pass body · was #555 · now 5.0:1 on bg-primary */
  --accent: #EA8623;
  --accent-hover: #F5A040;
  --accent-focus: #FFB766;      /* high-contrast focus ring */
  /* Standardised single-source colours · replaces #22c55e/#f59e0b/#ef4444 used inline */
  --success: #22C55E;
  --success-bg: rgba(34,197,94,0.18);
  --error:   #EF4444;
  --error-bg: rgba(239,68,68,0.18);
  --warning: #F59E0B;
  --warning-bg: rgba(245,158,11,0.18);
  --info:    #3B82F6;
  --info-bg: rgba(59,130,246,0.18);
  --border: #333;
  --sidebar-width: 220px;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 12px;
  --radius-pill: 9999px;
  /* Comfort spacing scale · was 4/8/12/16/24 · bumped to 6/10/16/22/32 for readability */
  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 16px;
  --space-lg: 22px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.4);
  --shadow-accent: 0 4px 16px rgba(234,134,35,.25);
  --transition: 0.18s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  /* Bigger base font · 13→14 · line-height bumped to 1.6 for comfort */
  font-size: 14px;
  line-height: 1.6;
}

/* ─── LAYOUT ─── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 22px 22px;       /* breathing */
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}
.sidebar-logo-text {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
}
.sidebar-logo-text small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 2px;
}
.sidebar-nav {
  flex: 1;
  padding: 18px 12px;
  overflow-y: auto;
}
.sidebar-section {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 18px 14px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;       /* was 10·12 · taller hit area */
  margin-bottom: 4px;       /* gap between items */
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;          /* was 13 */
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  line-height: 1.4;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: rgba(234,134,35,0.15);
  color: var(--accent);
}
.nav-item .material-symbols-rounded { font-size: 20px; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  min-width: 18px;
  text-align: center;
}
.nav-item .nav-badge.muted {
  background: var(--bg-hover);
  color: var(--text-secondary);
}
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}
.sidebar-firstrun {
  margin: 12px;
  padding: 10px 12px;
  background: rgba(234,134,35,0.08);
  border: 1px solid rgba(234,134,35,0.25);
  border-radius: var(--radius-md);
}

/* ─── MAIN CONTENT ─── */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

/* ─── TOP BAR ─── */
.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 20px 28px;             /* was 12·24 · much more room */
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 24px;
}
.topbar-title {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 18px;                /* was 16 */
  font-weight: 700;
  line-height: 1.3;
}
.topbar-title .material-symbols-rounded {
  color: var(--accent);
  font-size: 30px;                /* was 26 */
}
.topbar-title-block { display: flex; flex-direction: column; }
.topbar-title-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 2px;
}
.topbar-stats {
  display: flex;
  gap: 32px;                      /* was 24 · more breathing */
  font-size: 13px;
}
.topbar-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.topbar-stat-label {
  color: var(--text-secondary);   /* was muted · darker for readability */
  font-size: 11px;
  font-weight: 500;
  text-transform: none;           /* was uppercase · friendlier */
  letter-spacing: 0;
}
.topbar-stat-value {
  font-size: 18px;                /* was 14 · KPI prominent */
  font-weight: 700;
  line-height: 1.2;
}
.topbar-stat-value.success { color: var(--success); }
.topbar-stat-value.warning { color: var(--warning); }
.topbar-stat-value.error { color: var(--error); }

/* ─── TOOLBAR ─── */
.toolbar {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: 18px 28px;          /* was 12·24 */
  display: flex;
  gap: 12px;                   /* was 8 */
  align-items: center;
  flex-wrap: wrap;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;                    /* was 6 */
  padding: 10px 18px;          /* was 8·14 · bigger hit area */
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;             /* was 13 */
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  line-height: 1.4;
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.btn:active { transform: translateY(1px); }
.btn .material-symbols-rounded { font-size: 18px; }
.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-accent);
}
.btn-success {
  background: var(--success);
  color: #000;
  border-color: var(--success);
  font-weight: 600;
}
.btn-success:hover { background: #5cbf60; }
.btn-danger {
  background: transparent;
  color: var(--error);
  border-color: var(--error);
}
.btn-danger:hover { background: var(--error); color: #fff; }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
  justify-content: center;
}

/* ─── SELECT / DROPDOWN ─── */
.select {
  padding: 8px 12px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ─── BADGES / CHIPS ─── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(234,134,35,0.15);
  color: var(--accent);
  border: 1px solid rgba(234,134,35,0.3);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
}
.chip.muted {
  background: var(--bg-card);
  color: var(--text-secondary);
  border-color: var(--border);
}
.chip.success {
  background: rgba(76,175,80,0.15);
  color: var(--success);
  border-color: rgba(76,175,80,0.3);
}

.toolbar-spacer { flex: 1; }

/* ─── DEVICE GRID ─── */
.grid {
  padding: 16px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* ─── DEVICE TILE ─── */
.tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.tile.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), var(--shadow-md);
}
.tile.offline { opacity: 0.4; cursor: not-allowed; }
.tile.error { border-color: var(--error); }

.tile-screen {
  aspect-ratio: 9 / 16;
  background: #000;
  position: relative;
  overflow: hidden;
}
.tile-screen img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.tile-screen .placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px;
  flex-direction: column;
  gap: 8px;
}
.tile-screen .placeholder .material-symbols-rounded {
  font-size: 32px; color: var(--text-muted);
}

/* Status badge */
.tile-status {
  position: absolute; top: 8px; right: 8px;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  backdrop-filter: blur(8px);
}
.tile-status.ready   { background: rgba(76,175,80,0.9);  color: #000; }
.tile-status.idle    { background: rgba(136,136,136,0.9); color: #fff; }
.tile-status.degraded { background: rgba(255,193,7,0.9);  color: #000; }
.tile-status.needs_attention { background: rgba(244,67,54,0.9); color: #fff; }
.tile-status.offline { background: rgba(244,67,54,0.9); color: #fff; }
.tile-status.error   { background: rgba(244,67,54,0.9); color: #fff; }
.tile-status.unknown { background: rgba(33,150,243,0.9); color: #fff; }

/* Issue dot indicators */
.tile-issues {
  position: absolute; bottom: 8px; left: 8px;
  display: flex; gap: 4px;
}
.tile-issues .issue-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--error);
  border: 1px solid #000;
  position: relative;
  cursor: help;
}
.tile-issues .issue-dot.warning { background: var(--warning); }

/* Checkbox */
.tile-checkbox {
  position: absolute; top: 8px; left: 8px;
  width: 24px; height: 24px;
  background: rgba(0,0,0,0.7);
  border: 2px solid var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
  font-size: 16px;
  color: #fff;
  transition: var(--transition);
}
.tile-checkbox:hover { border-color: var(--accent); }
.tile.selected .tile-checkbox {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* Tile info */
.tile-info {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tile-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.tile-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.tile-meta {
  font-size: 11px;
  color: var(--text-secondary);
}
.tile-battery {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-secondary);
}
.tile-battery.low { color: var(--error); }
.tile-battery .material-symbols-rounded { font-size: 14px; }

.tile-serial {
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'SF Mono', Consolas, monospace;
}

/* ─── STATUS PILL (bottom right) ─── */
.status-pill {
  position: fixed;
  bottom: 16px; right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
}
.status-pill.success { border-color: var(--success); color: var(--success); }
.status-pill.error { border-color: var(--error); color: var(--error); }
.status-pill .material-symbols-rounded { font-size: 16px; }

/* ─── TOAST ─── */
.toast-container {
  position: fixed;
  bottom: 60px; right: 16px;
  z-index: 10500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  animation: toast-in 0.3s ease;
  pointer-events: auto;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--error); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toast-in {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toast-out {
  to { transform: translateX(120%); opacity: 0; }
}

/* ─── EMPTY STATE ─── */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}
.empty .material-symbols-rounded {
  font-size: 64px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.empty h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.empty p { font-size: 13px; }

/* ─── FOCUS RINGS (a11y · keyboard nav) ─── */
*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--accent-focus, var(--accent));
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.btn:focus-visible,
.nav-item:focus-visible,
.select:focus-visible,
input:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent-focus, var(--accent));
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(234,134,35,0.18);
}

/* ─── SKIP LINK (a11y) ─── */
.skip-link {
  position: fixed;
  top: -100px;
  left: 12px;
  z-index: 10000;
  background: var(--accent);
  color: #000;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  text-decoration: none;
  transition: top var(--transition);
}
.skip-link:focus { top: 12px; }

/* ─── SIDEBAR TOGGLE (mobile/tablet) ─── */
.sidebar-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
}
.sidebar-toggle:hover { background: var(--bg-hover); border-color: var(--accent); }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 90;
}
.sidebar-backdrop.show { display: block; }

/* ─── RESPONSIVE ─── */
/* Laptop · 12-13" · stats wrap · table scroll */
@media (max-width: 1280px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topbar-stats { gap: 12px; flex-wrap: wrap; }
  .toolbar { gap: 6px; }
}

/* Tablet · sidebar collapses · stats hidden (use sidebar menu instead) */
@media (max-width: 1024px) {
  .sidebar-toggle { display: inline-flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar-title { font-size: 14px; }
  .topbar-stats {
    width: 100%;
    margin-top: 6px;
    border-top: 1px solid var(--border);
    padding-top: 6px;
  }
}

/* Mobile · everything compact */
@media (max-width: 640px) {
  .topbar { padding: 10px 12px; }
  .topbar-stats { gap: 8px; }
  .topbar-stat-value { font-size: 13px; }
  .toolbar { padding: 8px 12px; flex-wrap: wrap; }
  .btn { font-size: 12px; padding: 6px 10px; }
  .grid { padding: 12px; gap: 12px; grid-template-columns: 1fr 1fr; }
  table { font-size: 11px; }
}

/* Reduced motion · respect OS preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast · respect OS preference */
@media (prefers-contrast: more) {
  :root {
    --text-secondary: #E0E0E0;
    --text-muted: #BBBBBB;
    --border: #555;
  }
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg-secondary);
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
