/* ==========================================================================
   玻璃立式理片系统 3D数字孪生与工艺演示系统 - 样式表 (CSS)
   Anhui Techong Glass Vertical Sorting & Buffering System Digital Twin
   ========================================================================== */

:root {
  --bg-primary: #0a0e17;
  --bg-panel: rgba(15, 23, 42, 0.78);
  --bg-panel-hover: rgba(30, 41, 59, 0.88);
  --bg-card: rgba(30, 41, 59, 0.65);
  --border-color: rgba(56, 189, 248, 0.22);
  --border-color-glow: rgba(56, 189, 248, 0.55);
  --border-subtle: rgba(148, 163, 184, 0.15);
  
  --accent-cyan: #00f0ff;
  --accent-blue: #0284c7;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #a855f7;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-cyan: #38bdf8;
  
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", Consolas, Menlo, monospace;

  --shadow-panel: 0 10px 30px -5px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.12);
  --shadow-glow: 0 0 20px rgba(0, 240, 255, 0.35);
  --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#app-container,
#app-container * {
  box-sizing: border-box;
}

body.standalone-app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  font-family: var(--font-main);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.standalone-app #app-container {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  border: none;
  box-shadow: none;
  margin: 0;
}

#app-container {
  position: relative;
  width: 100%;
  height: 720px;
  border-radius: 14px;
  overflow: hidden;
  background-color: var(--bg-primary);
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 0 20px rgba(56, 189, 248, 0.15);
  font-family: var(--font-main);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  margin: 18px 0;
}

#app-container:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
  box-shadow: none !important;
}

#webgl-canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#webgl-canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
}

/* ================= HUD LAYER ================= */
.hud-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 340px 1fr 340px;
  grid-template-areas:
    "header header header"
    "left-hud center-view right-hud"
    "dock dock dock";
  padding: 14px 18px 18px 18px;
  gap: 14px;
}

.interactive {
  pointer-events: auto;
}

/* Glassmorphism panel base */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-panel);
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.glass-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.6), transparent);
}

/* Corner industrial brackets */
.corner-bracket {
  position: relative;
}
.corner-bracket::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--accent-cyan);
  border-right: 2px solid var(--accent-cyan);
  pointer-events: none;
}

/* ================= TOP HEADER ================= */
.header-bar {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  height: 60px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.company-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(2, 132, 199, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 4px 10px;
  border-radius: 4px;
}

.company-logo-text {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
}

.company-sub {
  font-size: 11px;
  color: var(--text-secondary);
  border-left: 1px solid var(--border-subtle);
  padding-left: 8px;
}

.title-group {
  display: flex;
  flex-direction: column;
}

.system-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-primary);
  background: linear-gradient(90deg, #ffffff, #bbf2f6, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.system-subtitle {
  font-size: 10.5px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  font-family: var(--font-mono);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-emerald);
}

.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 12px var(--accent-emerald); }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.header-clock {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-cyan);
  padding: 4px 10px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.header-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.header-btn:hover {
  background: var(--bg-panel-hover);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: var(--shadow-glow);
}

.header-btn.active {
  background: rgba(56, 189, 248, 0.25);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* ================= LEFT HUD ================= */
.left-hud-panel {
  grid-area: left-hud;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 14px;
}

.panel-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-cyan);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-icon {
  margin-right: 6px;
  font-size: 14px;
}

/* 5-Step Process Timeline */
.process-timeline {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.timeline-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  transition: var(--transition-fast);
  position: relative;
}

.timeline-step.active {
  background: rgba(2, 132, 199, 0.25);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.timeline-step.completed {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.08);
}

.step-number {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.timeline-step.active .step-number {
  background: var(--accent-cyan);
  color: #000;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

.timeline-step.completed .step-number {
  background: var(--accent-emerald);
  color: #fff;
  border-color: var(--accent-emerald);
}

.step-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.step-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
}

.step-desc {
  font-size: 10px;
  color: var(--text-secondary);
}

.step-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.6);
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.timeline-step.active .step-badge {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
}

.timeline-step.completed .step-badge {
  color: var(--accent-emerald);
}

/* KPI Telemetry Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  transition: var(--transition-fast);
}

.kpi-card:hover {
  border-color: var(--border-color);
  background: rgba(30, 41, 59, 0.8);
}

.kpi-label {
  font-size: 10px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-val-group {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-top: 3px;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.kpi-unit {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Current Glass Sheet Info */
.glass-info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.info-row .label {
  color: var(--text-secondary);
}

.info-row .val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

.info-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  background: rgba(2, 132, 199, 0.2);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

/* ================= RIGHT HUD ================= */
.right-hud-panel {
  grid-area: right-hud;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 14px;
}

/* 2D 10-Slot Storage Rack Matrix */
.rack-header-stats {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.rack-capacity-bar {
  width: 100%;
  height: 6px;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
  border: 1px solid var(--border-subtle);
}

.rack-capacity-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  width: 60%;
  transition: width 0.4s ease;
}

.rack-slot-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.slot-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
}

.slot-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.slot-item.focus-highlight {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
  background: rgba(2, 132, 199, 0.25);
}

.slot-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slot-id-label {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  color: var(--text-primary);
}

.slot-status-pill {
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}

/* Slot status state styles */
.slot-item.state-idle .slot-status-pill {
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-secondary);
}
.slot-item.state-idle {
  opacity: 0.75;
}

.slot-item.state-infeed {
  border-color: var(--accent-amber);
  animation: pulse-border-amber 1.5s infinite;
}
.slot-item.state-infeed .slot-status-pill {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
}

.slot-item.state-occupied {
  border-color: rgba(56, 189, 248, 0.4);
}
.slot-item.state-occupied .slot-status-pill {
  background: rgba(14, 165, 233, 0.2);
  color: var(--accent-cyan);
}

.slot-item.state-outfeed {
  border-color: var(--accent-purple);
  animation: pulse-border-purple 1.5s infinite;
}
.slot-item.state-outfeed .slot-status-pill {
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-purple);
}

.slot-item.state-paired {
  border-color: var(--accent-emerald);
}
.slot-item.state-paired .slot-status-pill {
  background: rgba(16, 185, 129, 0.25);
  color: var(--accent-emerald);
}

@keyframes pulse-border-amber {
  0% { box-shadow: 0 0 0 rgba(245, 158, 11, 0); }
  50% { box-shadow: 0 0 8px rgba(245, 158, 11, 0.6); }
  100% { box-shadow: 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes pulse-border-purple {
  0% { box-shadow: 0 0 0 rgba(168, 85, 247, 0); }
  50% { box-shadow: 0 0 8px rgba(168, 85, 247, 0.6); }
  100% { box-shadow: 0 0 0 rgba(168, 85, 247, 0); }
}

.slot-glass-detail {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-spec-row {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-muted);
}

/* Event Logs Ticker */
.event-logs-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 140px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.log-entry {
  display: flex;
  gap: 6px;
  line-height: 1.3;
  padding: 2px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.log-time {
  color: var(--text-muted);
}

.log-type {
  font-weight: 700;
}
.log-type.info { color: var(--accent-cyan); }
.log-type.success { color: var(--accent-emerald); }
.log-type.warn { color: var(--accent-amber); }

.log-msg {
  color: var(--text-primary);
  flex: 1;
}

/* ================= BOTTOM CONTROL DOCK ================= */
.control-dock {
  grid-area: dock;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  gap: 20px;
}

.dock-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dock-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dock-btn {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.dock-btn:hover {
  background: var(--bg-panel-hover);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

.dock-btn.primary {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.8), rgba(14, 165, 233, 0.8));
  border-color: var(--accent-cyan);
  color: #fff;
}
.dock-btn.primary:hover {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  box-shadow: 0 0 15px var(--accent-cyan);
}

.dock-btn.active {
  background: rgba(56, 189, 248, 0.25);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.dock-btn.danger:hover {
  border-color: var(--accent-rose);
  color: var(--accent-rose);
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.4);
}

.speed-selector-group {
  display: flex;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow: hidden;
}

.speed-btn {
  background: transparent;
  border: none;
  padding: 5px 10px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.speed-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.speed-btn.active {
  background: var(--accent-cyan);
  color: #000;
  font-weight: 700;
}

/* Camera presets group */
.camera-presets-group {
  display: flex;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.cam-btn {
  background: transparent;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 11.5px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.cam-btn:hover {
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
}

.cam-btn.active {
  background: rgba(56, 189, 248, 0.25);
  color: var(--accent-cyan);
  font-weight: 600;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

/* ================= OVERLAYS & TOOLTIPS ================= */
.viewport-hud-overlay {
  position: absolute;
  bottom: 80px;
  left: 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.7);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  pointer-events: none;
  display: flex;
  gap: 12px;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.4);
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.5);
}

/* Media Queries for Responsive Screens */
@media (max-width: 1280px) {
  .hud-layer {
    grid-template-columns: 290px 1fr 290px;
    padding: 10px;
    gap: 10px;
  }
  .system-title {
    font-size: 16px;
  }
}
