/* PhyCyber Studio Core App Styles */

:root {
  --bg-darker: #050508;
  --bg-dark: #0f172a;
  --bg-panel: rgba(30, 41, 59, 0.95);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --brand-primary: #8b5cf6;
  --brand-secondary: #06b6d4;
  --brand-danger: #ef4444;
  --brand-success: #10b981;
  
  --border-color: rgba(255, 255, 255, 0.1);
  --sidebar-width: 320px;
}

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, sans-serif;
  background-color: var(--bg-darker);
  color: var(--text-main);
}

#app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* ================== Viewport ================== */
#viewport-container {
  flex: 1;
  position: relative;
  background-color: #000;
  height: 100%;
}

canvas {
  display: block;
  outline: none;
}

#viewport-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hud-item {
  position: absolute;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--brand-secondary);
  background: rgba(0, 0, 0, 0.5);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.hud-left-top { top: 1rem; left: 1rem; }
.hud-left-mid { top: 4rem; left: 1rem; }
.hud-right-top { top: 1rem; right: 1rem; }

/* Telemetry HUD Panel */
#telemetry-hud {
  position: absolute;
  top: 4rem;
  left: 1rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 6px;
  padding: 1rem;
  min-width: 240px;
  backdrop-filter: blur(8px);
  font-family: 'JetBrains Mono', monospace;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.hud-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
}

.hud-data-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

.state-idle { color: var(--text-muted); }
.state-moving { color: var(--brand-success); text-shadow: 0 0 5px var(--brand-success); }
.state-auto { color: var(--brand-secondary); text-shadow: 0 0 5px var(--brand-secondary); }

.fleet-row-card {
  display: grid;
  grid-template-columns: 2fr 3fr 2fr;
  gap: 0.5rem;
  align-items: center;
  padding: 0.7rem 0.6rem;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.fleet-agent-cell,
.fleet-status-cell,
.fleet-action-cell {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.fleet-agent-cell strong,
.fleet-action-cell strong {
  font-size: 0.72rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fleet-agent-cell span,
.fleet-action-cell span,
.fleet-target {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fleet-state-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: fit-content;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  color: #fff;
  background: rgba(148, 163, 184, 0.2);
}

.fleet-state-pill::before {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.fleet-state-pill--idle {
  color: #cbd5e1;
}

.fleet-state-pill--moving {
  color: #34d399;
}

.fleet-state-pill--waiting {
  color: #fbbf24;
}

.fleet-state-pill--task {
  color: #38bdf8;
}

.fleet-empty-state {
  padding: 0.8rem 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255,255,255,0.7);
  font-size: 24px;
  font-weight: 300;
}

/* ================== Sidebar ================== */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background-color: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  box-shadow: -5px 0 25px rgba(0,0,0,0.5);
  z-index: 10;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-logo {
  height: 24px;
  width: auto;
}

.sidebar-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.studio-lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.studio-lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.45rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.studio-lang-btn:hover {
  color: var(--text-main);
}

.studio-lang-btn.active {
  color: #fff;
  background: rgba(6, 182, 212, 0.18);
  box-shadow: inset 0 0 0 1px rgba(6, 182, 212, 0.32);
}

.app-status-banner {
  margin: 1rem 1.5rem 0;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(56, 189, 248, 0.24);
  background: rgba(14, 165, 233, 0.12);
  box-shadow: 0 16px 36px rgba(2, 8, 23, 0.22);
}

.app-status-banner__eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #67e8f9;
}

.app-status-banner__message {
  margin-top: 0.45rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #e2e8f0;
}

.app-status-banner--info {
  border-color: rgba(56, 189, 248, 0.24);
  background: rgba(14, 165, 233, 0.12);
}

.app-status-banner--success {
  border-color: rgba(16, 185, 129, 0.24);
  background: rgba(16, 185, 129, 0.12);
}

.app-status-banner--warning {
  border-color: rgba(245, 158, 11, 0.24);
  background: rgba(245, 158, 11, 0.12);
}

.app-status-banner--error {
  border-color: rgba(239, 68, 68, 0.24);
  background: rgba(239, 68, 68, 0.12);
}

.sidebar-section {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.sidebar-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.sidebar-section__header h3 {
  margin-bottom: 0;
}

.section-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.25rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: #67e8f9;
  font-size: 0.68rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-section--scenario {
  background:
    radial-gradient(circle at top right, rgba(34, 211, 238, 0.18), transparent 46%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.78));
}

.scenario-eyebrow,
.scenario-card__eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #67e8f9;
}

.scenario-card {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.94), rgba(30, 41, 59, 0.88)),
    rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(103, 232, 249, 0.14);
  box-shadow: 0 18px 40px rgba(2, 8, 23, 0.35);
}

.scenario-card__title {
  margin-top: 0.7rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.scenario-card__description {
  margin-top: 0.65rem;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.help-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.4;
}

.help-text--compact {
  margin-bottom: 0;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.section-header h3 {
  margin-bottom: 0.35rem;
}

.ops-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.ops-summary-card {
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.ops-summary-card__label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.ops-summary-card strong {
  display: block;
  margin-top: 0.4rem;
  font-size: 1.1rem;
  color: #fff;
}

.ops-task-list,
.ops-alert-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  max-height: 260px;
  overflow-y: auto;
}

.ops-task-card,
.ops-alert-card,
.ops-empty-state {
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.ops-empty-state {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.ops-task-card__top,
.ops-alert-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.ops-task-card__id,
.ops-alert-card__time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: #67e8f9;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ops-task-card__title,
.ops-alert-card__message {
  margin-top: 0.45rem;
  font-size: 0.84rem;
  line-height: 1.45;
  color: #fff;
}

.ops-task-card__meta,
.ops-alert-card__meta {
  margin-top: 0.55rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.ops-status-pill,
.ops-priority-pill,
.ops-alert-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ops-status-pill--pending {
  color: #f8fafc;
  background: rgba(59, 130, 246, 0.18);
}

.ops-status-pill--active {
  color: #ecfccb;
  background: rgba(16, 185, 129, 0.18);
}

.ops-status-pill--completed {
  color: #d1fae5;
  background: rgba(5, 150, 105, 0.2);
}

.ops-status-pill--blocked {
  color: #fef3c7;
  background: rgba(245, 158, 11, 0.2);
}

.ops-status-pill--cancelled {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.18);
}

.ops-priority-pill {
  margin-top: 0.55rem;
}

.ops-priority-pill--high {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.18);
}

.ops-priority-pill--normal {
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.16);
}

.ops-priority-pill--low {
  color: #d1fae5;
  background: rgba(16, 185, 129, 0.16);
}

.ops-alert-pill--info {
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.16);
}

.ops-alert-pill--success {
  color: #d1fae5;
  background: rgba(16, 185, 129, 0.18);
}

.ops-alert-pill--warning {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.18);
}

.ops-alert-pill--error {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.18);
}

.ops-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.ops-summary-card {
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 23, 42, 0.5);
}

.ops-summary-card--wide {
  grid-column: 1 / -1;
}

.ops-summary-card span {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ops-summary-card strong {
  display: block;
  font-size: 0.95rem;
  color: #fff;
  line-height: 1.35;
}

.ops-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 17rem;
  overflow-y: auto;
}

.ops-record-card {
  padding: 0.8rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(2, 6, 23, 0.46);
}

.ops-record-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ops-record-card__header strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: #fff;
}

.ops-record-card__detail {
  margin-top: 0.6rem;
  font-size: 0.84rem;
  line-height: 1.45;
  color: #e2e8f0;
}

.ops-record-card__meta {
  margin-top: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.ops-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ops-status-pill--info {
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
}

.ops-status-pill--warning {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

.ops-status-pill--success {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
}

.ops-status-pill--error {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

.ops-empty-state {
  padding: 0.9rem;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  text-align: center;
  font-size: 0.78rem;
}

.control-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.control-group.button-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn:hover { background: rgba(255,255,255,0.1); }

.btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.btn.is-busy {
  box-shadow: inset 0 0 0 1px rgba(103, 232, 249, 0.28);
}

.btn.active {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--brand-primary);
  color: #fff;
}

/* UI Controls */
input[type=range] {
  flex: 1;
  margin: 0 1rem;
  accent-color: var(--brand-secondary);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255,255,255,0.1);
  transition: .3s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}
input:checked + .slider { background-color: var(--brand-primary); }
input:checked + .slider:before { transform: translateX(20px); }

.toggle-label {
  cursor: pointer;
}

/* Terminal */
.terminal-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: 1rem;
  border-bottom: none;
}

.terminal-log {
  flex: 1;
  min-height: 10rem;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--brand-secondary);
  overflow-y: auto;
  line-height: 1.5;
}

.terminal-log div { margin-bottom: 4px; }

/* ================== A.I. Vision PiP ================== */
#vision-pip-container {
  position: absolute;
  bottom: 2rem;
  right: 2rem;
  width: 320px;
  height: 240px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(6, 182, 212, 0.5);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.pip-header {
  background: rgba(0,0,0,0.6);
  padding: 0.5rem 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.vision-status {
  color: var(--brand-success);
  text-shadow: 0 0 5px var(--brand-success);
  animation: pulseBox 2s infinite;
}

#pip-viewport {
  flex: 1;
  position: relative;
  background: #000;
}

/* Simulated CV Bounding Boxes overlaying the PiP Viewport */
.cv-bounding-box {
  position: absolute;
  border: 2px solid #ef4444; /* Default red */
  pointer-events: none;
  display: none;
  box-sizing: border-box;
  z-index: 60;
}

.cv-label {
  position: absolute;
  top: -20px; /* Right above the box */
  left: -2px; /* Align with left border */
  background: rgba(239, 68, 68, 0.8);
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 2px 6px;
  white-space: nowrap;
  pointer-events: none;
}

@media (max-width: 1100px) {
  :root {
    --sidebar-width: 290px;
  }

  #vision-pip-container {
    width: 280px;
    height: 210px;
    right: 1rem;
    bottom: 1rem;
  }

  #telemetry-hud {
    width: 290px;
  }
}

@media (max-width: 900px) {
  #app-container {
    flex-direction: column;
  }

  #sidebar {
    width: 100%;
    min-width: 100%;
    height: 44vh;
    overflow-y: auto;
    border-left: none;
    border-top: 1px solid var(--border-color);
  }

  #viewport-container {
    height: 56vh;
  }

  #telemetry-hud,
  #vision-pip-container {
    transform: scale(0.9);
    transform-origin: bottom right;
  }

  .app-status-banner {
    margin: 1rem;
  }

  .ops-summary-grid {
    grid-template-columns: 1fr;
  }
}
