/* EgoLink DevBench Modern Technical Console Styles */
:root {
  --bg-base: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: #243247;
  --bg-card-hover: #2b3b54;
  --border-subtle: #334155;
  --border-focus: #38bdf8;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-cyan: #06b6d4;
  --accent-blue: #38bdf8;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #a855f7;

  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

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

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Header & Top Bar */
.devbench-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.5px;
}

.brand-badge {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 600;
}

.header-device-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-device-selector select {
  background: var(--bg-base);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: var(--font-mono);
  outline: none;
  cursor: pointer;
}
.header-device-selector select:focus {
  border-color: var(--border-focus);
}

.header-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-family: var(--font-mono);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
}
.status-dot.online {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}
.status-dot.warn {
  background-color: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
}
.status-dot.offline {
  background-color: var(--accent-rose);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-cyan);
  color: #000;
  border-color: var(--accent-cyan);
  font-weight: 600;
}
.btn-primary:hover {
  background: #22d3ee;
  border-color: #22d3ee;
}

.btn-danger {
  background: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.4);
}
.btn-danger:hover {
  background: rgba(244, 63, 94, 0.3);
}

.btn-sm {
  padding: 3px 8px;
  font-size: 12px;
}

/* Nav Tabs */
.nav-tabs {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 20px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.nav-tab {
  padding: 10px 16px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s, border-color 0.15s;
}
.nav-tab:hover {
  color: var(--text-primary);
}
.nav-tab.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

/* Main Container */
.main-container {
  flex: 1;
  padding: 20px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* Cards & Grid Layout */
.grid-stack {
  display: grid;
  gap: 16px;
}
.grid-2col {
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
}
.grid-3col {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.grid-4col {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* Metric Display */
.metric-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.metric-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.metric-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-top: 4px;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}
.metric-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Data Tables */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

table.data-table th {
  background-color: var(--bg-card);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

table.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

table.data-table tr:hover td {
  background-color: var(--bg-card-hover);
}

/* Badges & Tags */
.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
}
.badge-ok {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-warn {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.badge-bad {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}
.badge-info {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

/* Oscilloscope Canvas & 3D Spatial Twin */
.oscilloscope-container {
  position: relative;
  background-color: #090d16;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  height: 285px;
  min-height: 285px;
  max-height: 285px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  contain: strict;
}
.oscilloscope-canvas {
  width: 100%;
  height: 240px;
  min-height: 240px;
  max-height: 240px;
  flex: 0 0 240px;
  display: block;
  box-sizing: border-box;
}
.oscilloscope-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  height: 45px;
  max-height: 45px;
  flex: 0 0 45px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  font-family: var(--font-mono);
  box-sizing: border-box;
  overflow: hidden;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-color {
  width: 12px;
  height: 3px;
  border-radius: 1px;
}

/* Map Containers */
.map-container {
  height: 480px;
  width: 100%;
  background: #090d16;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
}
#devbenchAmapContainer {
  width: 100%;
  height: 100%;
}
.vector-map-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.map-overlay-info {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(30, 41, 59, 0.9);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-family: var(--font-mono);
  z-index: 10;
  max-width: 380px;
}

/* Photo Gallery & Studio */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.photo-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.photo-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
}
.photo-thumb {
  width: 100%;
  height: 160px;
  background: #090d16;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-info {
  padding: 10px;
}
.photo-meta-line {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

/* Modal Dialogs */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-backdrop.active {
  display: flex;
}
.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: grid;
  gap: 14px;
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-group {
  display: grid;
  gap: 6px;
}
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.form-input {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
}
.form-input:focus {
  border-color: var(--border-focus);
}
.form-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* Pre / Code Blocks */
pre.code-view {
  background: #090d16;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #38bdf8;
  overflow-x: auto;
  max-height: 300px;
}

@media (max-width: 768px) {
  .devbench-header {
    flex-direction: column;
    align-items: stretch;
  }
  .grid-2col, .grid-3col, .grid-4col {
    grid-template-columns: 1fr;
  }
}

.imu-ch-btn {
  opacity: 0.45;
  transition: opacity 0.15s, background-color 0.15s;
}
.imu-ch-btn.active {
  opacity: 1.0;
  background-color: var(--bg-card-hover);
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.2);
}


