/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 */

:root {
  --bg-primary: #000000; /* pure black = transparent on additive display, lets real world show through */
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent-primary: #00d4ff;
  --accent-secondary: #00ff88;
  --accent-warm: #ff9f43;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --success: #00ff88;
  --warning: #ffaa00;
  --info: #00b4d8;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

/* --- Screens --- */
.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
}
.screen.hidden { display: none; }

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
}
.header h1 {
  font-size: 22px;
  font-weight: 600;
  flex: 1;
}
.header-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- Content Area --- */
.content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Focus States (critical for EMG/D-pad) --- */
.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* --- Navigation Bar --- */
.nav-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.nav-item:focus { background: var(--bg-card); }
.nav-item.primary {
  background: var(--accent-primary);
  color: #0a0a0f;
}
.nav-item.primary:focus { background: #33ddff; }
.nav-item.danger {
  background: var(--danger);
  color: white;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 2px solid transparent;
}
.card:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}
.card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}
.card-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}
.card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-primary);
}

/* --- List Items --- */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 400px;
}
.list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  text-align: left;
  gap: 12px;
}
.list-item:focus { background: var(--bg-card); }
.list-item-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}
.list-item-content { flex: 1; min-width: 0; }
.list-item-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.list-item-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

/* --- Loading States --- */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
  flex: 1;
}
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-size: 16px;
  color: var(--text-secondary);
}

/* Skeleton loading for cards/lists */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-card) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-line {
  height: 16px;
  margin-bottom: 8px;
  border-radius: 4px;
}
.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }

/* --- Error States --- */
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  text-align: center;
}
.error-icon { font-size: 48px; }
.error-message {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 400px;
}

/* --- Toast Notifications --- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  border: 1px solid var(--accent-primary);
  transition: transform 0.3s ease;
  z-index: 100;
  pointer-events: none;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

/* --- Progress Bar --- */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* --- Status Badges --- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: rgba(0, 255, 136, 0.2); color: var(--success); }
.badge-warning { background: rgba(255, 170, 0, 0.2); color: var(--warning); }
.badge-danger { background: rgba(255, 68, 102, 0.2); color: var(--danger); }
.badge-info { background: rgba(0, 180, 216, 0.2); color: var(--info); }

/* --- Data Grid (2-column) --- */
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* --- Tabs --- */
.tab-bar {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}
.tab-item {
  flex: 1;
  padding: 10px 8px;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}
.tab-item.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.tab-item:focus {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* --- Text Input --- */
.text-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
}
.text-input:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
  outline: none;
}
.text-input::placeholder { color: var(--text-muted); }

/* --- Utility --- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-accent { color: var(--accent-primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-secondary); }
.mt-auto { margin-top: auto; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.gap-lg { gap: 20px; }

/* ==================================================================
   DevDeck app-specific styles
   Layered on the Meta create-webapp template above. Overrides here
   bring the template in line with the 88dp tap target and 8dp safe
   margin required by references/display-guidelines.md.
   ================================================================== */

:root {
  --bg-secondary: #0e1014;
  --bg-tertiary: #16181c;
  --bg-card: #1f2228;
  --accent-primary: #4fd1ff;
  --focus-ring: #4fd1ff;
}

/* 8dp safe margin: interactive elements at the very edge get clipped
   by the display's rubberbanding animation. */
#app { padding: 8px; }

.header { padding: 12px 16px; border-radius: var(--radius-md); }
.header h1 { font-size: 22px; }

.content { padding: 12px 8px; position: relative; }

/* 88dp minimum tap target for anything the D-pad can land on. */
.list-item, .nav-item { min-height: 88px; }

/* Focus: only the container scales, content stays 1x so text stays legible. */
.focusable {
  transition:
    transform 475ms cubic-bezier(0.6, 0, 0.4, 1),
    background-color 300ms cubic-bezier(0.4, 0.04, 0.5, 1);
}
.focusable .list-item-content { opacity: 0.8; }
.focusable:focus { transform: scale(calc(1 - 8/88)); }
.focusable:focus .list-item-content { opacity: 1; }

/* Scrim signals more content below a scrolling list. */
.scroll-wrap { position: relative; flex: 1; min-height: 0; }
.scroll-wrap::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: linear-gradient(to top, #000000 0%, transparent 100%);
  pointer-events: none;
  z-index: 10;
}
.list-container { max-height: none; height: 100%; padding-bottom: 64px; }

/* Status dot pairs with the badge text so colour is never the only signal. */
.status-dot {
  width: 14px; height: 14px; border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.pass { background: var(--success); }
.status-dot.fail { background: var(--danger); }
.status-dot.running { background: var(--warning); animation: pulse 1.2s ease-in-out infinite; }
.status-dot.idle { background: var(--text-muted); }
@keyframes pulse { 50% { opacity: 0.35; } }

.summary-row {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  padding: 0 8px 8px;
}
.summary-tile {
  flex: 1;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  text-align: center;
}
.summary-tile .n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.summary-tile .k { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Detail screen check rows */
.check-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-size: 15px;
}
.check-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-row .dur { font-size: 13px; color: var(--text-secondary); }

.commit-line {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Monospace log excerpt, clipped to the viewport. */
.log-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
}
.log-block .err { color: var(--danger); }

/* Desktop preview: centre the 600x600 stage so framing matches the glasses.
   On-device the viewport IS 600x600 and this is a no-op. */
@media (min-width: 700px) {
  html {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #17181a;
  }
  body { outline: 1px solid #2c2f34; }
}
