/* LabTools Studio - Design System */
/* Scientific, Minimalistic, Clean */

:root {
  /* Primary Colors - Scientific Blue/Cyan */
  --primary: #00B4D8;
  --primary-light: #48CAE4;
  --primary-dark: #0077B6;
  --primary-glow: rgba(0, 180, 216, 0.3);
  
  /* Backgrounds */
  --bg-primary: #0D1117;
  --bg-secondary: #161B22;
  --bg-tertiary: #21262D;
  --bg-card: #1C2128;
  
  /* Text */
  --text-primary: #E6EDF3;
  --text-secondary: #8B949E;
  --text-muted: #6E7681;
  
  /* Accents */
  --accent: #00B4D8;
  --success: #3FB950;
  --warning: #D29922;
  --error: #F85149;
  
  /* Borders */
  --border: #30363D;
  --border-light: #3D444D;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--primary-glow);
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
  color: var(--text-secondary);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-light);
}

/* Navigation Bar */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.navbar-brand:hover {
  color: var(--primary);
}

.navbar-brand .icon {
  font-size: 1.5rem;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.nav-item {
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-item.active {
  color: var(--primary);
  background: rgba(0, 180, 216, 0.1);
}

/* Main Content */
.main-content {
  padding-top: 80px;
  padding-bottom: 40px;
  min-height: 100vh;
  background: var(--bg-primary);
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 80px var(--space-xl) var(--space-xl);
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-normal);
}

.card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-icon {
  font-size: 1.5rem;
}

.card-desc {
  margin: 12px 0;
  font-size: 0.9rem;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  min-height: 30px;
}

.card-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.card-disabled {
  opacity: 0.6;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  background: var(--primary);
  color: var(--bg-primary);
}

.btn:hover {
  background: var(--primary-light);
  box-shadow: var(--shadow-glow);
}

.btn-primary {
  background: var(--primary);
  color: var(--bg-primary);
}

.btn-primary:hover {
  background: var(--primary-light);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: none;
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: #ff6b63;
  box-shadow: 0 0 20px rgba(248, 81, 73, 0.3);
}

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

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
  box-shadow: none;
}

.btn-lg {
  padding: var(--space-md) var(--space-lg);
  font-size: 1rem;
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.8rem;
}

/* Inputs */
.input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-size: 0.9rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

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

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

.input-narrow {
  width: 100px;
}

.input-medium {
  width: 150px;
}

.input-auto {
  width: auto;
}

/* Status Indicators */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.gray { background: var(--text-muted); }
.status-dot.green { background: var(--success); }
.status-dot.orange { background: var(--warning); }
.status-dot.red { background: var(--error); }

/* Utility Classes */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary-color { color: var(--primary); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-end { align-items: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.grid { display: grid; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); }

.cursor-pointer { cursor: pointer; }
.hidden { display: none; }

@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .navbar { padding: 0 var(--space-md); }
  .container { padding: var(--space-lg) var(--space-md); }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

.fade-in-delay-1 { animation-delay: 0.1s; opacity: 0; }
.fade-in-delay-2 { animation-delay: 0.2s; opacity: 0; }
.fade-in-delay-3 { animation-delay: 0.3s; opacity: 0; }

/* Code/Technical Elements */
.code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--primary);
}

/* Section Headers */
.section-header {
  margin-bottom: var(--space-xl);
}

.section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

/* Navigation Dropdown */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.nav-dropdown-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-width: 200px;
  padding: 8px 0;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
}

.nav-dropdown-menu.show {
  display: block;
}

.nav-dropdown-item {
  display: block;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.nav-dropdown-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.nav-dropdown-header {
  padding: 8px 16px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* Form elements */
select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238B949E' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

input[type="number"].input {
  width: 100px;
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 10px;
}

th {
  color: var(--text-secondary);
}

tr {
  border-bottom: 1px solid var(--border);
}

/* ==========================================================================
   Page-specific component styles
   ========================================================================== */

/* Hero Section (Home) */
.hero {
  padding: 60px 0;
}

.hero-subtitle {
  max-width: 600px;
  margin: 20px auto 0;
  font-size: 1.1rem;
}

/* App Grid (Home) */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

/* Badge */
.badge {
  font-size: 0.75rem;
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-left: var(--space-sm);
}

/* Footer */
.footer {
  margin-top: 60px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}

/* Session Code Display */
.code-display {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  margin-bottom: 20px;
}

.code-display .label {
  font-size: 14px;
  color: var(--text-secondary);
}

.code-display .code {
  color: var(--primary);
  font-size: 48px;
  font-weight: bold;
  letter-spacing: 8px;
  background: none;
  padding: 0;
}

.code-display .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* Lookup (for viewer pages) */
.lookup {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 30px;
  border-radius: var(--radius-lg);
  text-align: center;
  margin-bottom: var(--space-lg);
}

.lookup input {
  background: var(--bg-tertiary);
  border: 2px solid var(--primary);
  color: var(--text-primary);
  font-size: 32px;
  padding: 15px;
  border-radius: var(--radius-md);
  width: 200px;
  text-align: center;
  letter-spacing: 8px;
  margin-right: 10px;
}

.lookup input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Video/Canvas */
.video-wrapper {
  position: relative;
  overflow: auto;
  max-height: 70vh;
  background: var(--bg-primary);
}

.video-wrapper video {
  display: block;
  background: var(--bg-primary);
}

.video-wrapper canvas {
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
}

/* Window Card */
.window-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  overflow: hidden;
}

.window-header {
  background: var(--bg-tertiary);
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.window-title {
  color: var(--primary);
  font-weight: bold;
}

.window-controls {
  display: flex;
  gap: 10px;
}

.window-id-badge {
  background: var(--primary);
  color: var(--bg-primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  margin-left: 10px;
}

/* Regions */
.regions {
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.region-item {
  background: var(--bg-tertiary);
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.region-item .coords {
  font-size: 12px;
  color: var(--text-muted);
}

.region-item .value {
  color: var(--primary);
  font-weight: bold;
  min-width: 100px;
}

.region-item .remove {
  background: var(--error);
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
}

.region-name-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--primary);
  color: var(--text-primary);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 14px;
  width: 120px;
}

/* Instructions */
.instructions {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 15px;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
}

.instructions ol {
  margin-left: 20px;
  margin-top: 10px;
  color: var(--text-secondary);
}

.instructions li {
  margin-bottom: 8px;
  color: var(--text-secondary);
}

/* Data Preview */
.data-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 15px;
  border-radius: var(--radius-lg);
}

.data-preview h3 {
  color: var(--primary);
  margin-bottom: 10px;
}

.data-preview pre {
  background: var(--bg-tertiary);
  padding: 10px;
  border-radius: 5px;
  overflow-x: auto;
  font-size: 12px;
}

/* Status */
.status {
  text-align: center;
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 10px;
}

.status.error {
  background: var(--error);
}

.status.success {
  background: var(--success);
  color: var(--bg-primary);
}

.status.info {
  background: var(--bg-tertiary);
}

/* Data Display (Viewer) */
.data-display {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 20px;
  border-radius: var(--radius-lg);
}

.data-display h2 {
  color: var(--primary);
  margin-bottom: 15px;
}

.data-row {
  background: var(--bg-tertiary);
  padding: 15px;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.data-row .label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.data-row .value {
  font-size: 18px;
  color: var(--primary);
  font-weight: bold;
  word-break: break-all;
}

.last-updated {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 10px;
}

/* Status Bar (Viewer) */
.status-bar {
  text-align: center;
  margin-bottom: 20px;
}

.status-bar .status-text {
  color: var(--text-muted);
}

.status-bar .status-text.connected {
  color: var(--primary);
}

.status-bar .status-text.waiting {
  color: var(--warning);
}

/* Status Indicators (large) */
.status-indicator {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 10px;
  vertical-align: middle;
}

.status-indicator.gray {
  background: var(--text-muted);
}

.status-indicator.green {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

.status-indicator.orange {
  background: var(--warning);
  box-shadow: 0 0 10px var(--warning);
}

/* Controls */
.controls-center {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
}

/* Data list (scrollable) */
.data-list-scroll {
  max-height: 200px;
  overflow-y: auto;
}

.data-list-item {
  padding: var(--space-sm);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

.data-list-item .value {
  color: var(--primary);
}

/* Chart container */
.chart-container {
  height: 400px;
}

/* Table wrapper (scrollable) */
.table-scroll {
  max-height: 300px;
  overflow-y: auto;
}

/* Chart/Table cards */
#chart-card,
#table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
}

/* Small text helper */
.text-xs {
  font-size: 0.8rem;
}
