/* PUDU Academy Brand Design System (https://academy.pudutech.com/en) */
:root {
  --bg-page: #f4f6f9;
  --bg-card: #ffffff;
  --bg-dark-navy: #0a2540;
  --border-color: #e2e8f0;

  --pudu-blue: #0052cc;
  --pudu-blue-hover: #0040a8;
  --pudu-cyan: #1890ff;
  --pudu-cyan-light: #e6f7ff;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --card-shadow: 0 4px 14px rgba(0, 82, 204, 0.06);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* PUDU Academy Header - Compact Top Navbar */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 1.5rem;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
  height: 44px;
  width: 100%;
}

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

.brand-logo {
  background: linear-gradient(135deg, var(--pudu-blue), var(--pudu-cyan));
  padding: 0.35rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 2px 6px rgba(0, 82, 204, 0.2);
}

.brand h1 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--bg-dark-navy);
  letter-spacing: -0.01em;
}

/* Dashboard Layout (30% Left Parameters Sidebar | 70% Right 3D Visualizer Workspace) */
.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(320px, 28%) 1fr;
  gap: 1.25rem;
  padding: 0.75rem 1.5rem;
  flex: 1;
  max-width: 1920px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 1100px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
}

/* Cards & Panels */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background-color: #fafbfc;
}

.card-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--bg-dark-navy);
}

.card-body {
  padding: 1.25rem;
}

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

.manifest-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }

.badge-count {
  background-color: var(--pudu-cyan-light);
  color: var(--pudu-blue);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
}

/* Forms & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.label-with-badge {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin-bottom: 0.35rem;
}

.label-with-badge label {
  margin-bottom: 0;
  font-size: 0.73rem;
  font-weight: 700;
  flex-shrink: 0;
}

.inner-dim-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--pudu-blue);
  background-color: rgba(0, 82, 204, 0.08);
  padding: 0.18rem 0.55rem;
  border-radius: 5px;
  border: 1px solid rgba(0, 82, 204, 0.2);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.form-control {
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--pudu-blue);
  box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.12);
}

.dim-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.dim-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.dim-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.manifest-action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

/* Dimension Guide Reference Panel */
.dim-guide-panel {
  margin-bottom: 0.75rem;
  border: 1px solid var(--pudu-blue);
  border-radius: 8px;
  overflow: hidden;
  background: var(--pudu-cyan-light);
  animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to   { opacity: 1; max-height: 600px; }
}

.dim-guide-img-wrap {
  padding: 0.5rem;
  text-align: center;
  background: #fff;
  cursor: pointer;
}

.dim-guide-img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  transition: transform 0.2s;
}

.dim-guide-img:hover {
  transform: scale(1.02);
}

.dim-guide-caption {
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 0.4rem 0.6rem;
  line-height: 1.6;
  text-align: center;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
}

.dim-guide-caption strong {
  color: var(--pudu-blue);
  font-weight: 700;
}

/* Dimension Guide button active state */
#btn-dim-guide.active {
  background: var(--pudu-blue);
  color: #fff;
  border-color: var(--pudu-blue);
}

/* Fullscreen overlay for zoomed image */
.dim-guide-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.dim-guide-overlay img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background-color: var(--pudu-blue);
  color: white;
  box-shadow: 0 2px 6px rgba(0, 82, 204, 0.2);
}

.btn-primary:hover {
  background-color: var(--pudu-blue-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: #e2e8f0;
  color: var(--bg-dark-navy);
}

.btn-secondary:hover {
  background-color: #cbd5e1;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--pudu-blue);
  color: var(--pudu-blue);
}

.btn-outline:hover {
  background: var(--pudu-cyan-light);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
}

.btn-xs {
  padding: 0.2rem 0.45rem;
  font-size: 0.7rem;
}

.btn-full {
  width: 100%;
}

/* Data Tables */
.product-table-wrapper {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

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

.data-table th {
  background-color: #f8fafc;
  padding: 0.6rem 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--border-color);
}

.color-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-tag {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.btn-icon-del {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.75rem;
}

/* Metrics Dashboard */
.card-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.card-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

@media (max-width: 1100px) {
  .card-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .card-grid-3 {
    grid-template-columns: 1fr;
  }
  .card-grid-4 {
    grid-template-columns: 1fr;
  }
}

.metric-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: var(--card-shadow);
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.metric-value {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--pudu-blue);
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.progress-bar {
  height: 6px;
  background-color: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.3rem;
}

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

.main-viewport {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Visualizer Section (Right Side 3D Viewport - Expanded Canvas Height) */
.visualizer-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 750px;
}

.visualizer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background-color: #fafbfc;
}

.view-tabs {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background-color: #ffffff;
  color: var(--pudu-blue);
  border-color: var(--border-color);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.robot-facing-badge {
  background: var(--pudu-cyan-light);
  color: var(--pudu-blue);
  border: 1px solid rgba(0, 82, 204, 0.2);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
}

.view-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  padding: 0;
  display: flex;
  min-height: 700px;
}

.tab-content {
  display: none;
  width: 100%;
  height: 100%;
  position: relative;
  flex: 1;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  flex: 1;
}

#canvas-3d-container {
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 700px;
}

.viewport-controls-overlay {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  right: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  color: var(--text-main);
  background-color: var(--bg-card);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.controls-right-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.validation-banner {
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.4;
  margin-top: 0.6rem;
}
.validation-banner.warning {
  background-color: #fffbe6;
  border: 1px solid #ffe58f;
  color: #d48806;
}
.validation-banner.success {
  background-color: #f6ffed;
  border: 1px solid #b7eb8f;
  color: #389e0d;
}

/* Top-Left 3D Model Loading Status Badge */
.model-status-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  padding: 0.4rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  z-index: 10;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #eab308;
}
.status-dot.active {
  background-color: #10b981;
}
.status-dot.fallback {
  background-color: #3b82f6;
}

/* Robot Orientation Indicator Compass Widget (Top-Right of 3D Viewport) */
.robot-orientation-widget {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  z-index: 20;
  width: 120px;
  user-select: none;
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--bg-dark-navy);
}

.front-badge {
  background: var(--pudu-blue);
  color: white;
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.compass-dial {
  width: 60px;
  height: 60px;
  border: 2px dashed #cbd5e1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #f8fafc;
}

.compass-robot-icon {
  width: 36px;
  height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s linear;
  transform-origin: center center;
}

.robot-body-shape {
  width: 26px;
  height: 30px;
  background: var(--pudu-blue);
  border-radius: 4px;
  border: 2px solid #0a2540;
  box-shadow: 0 2px 4px rgba(0, 52, 204, 0.3);
}

.robot-front-arrow {
  color: #10b981;
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 1;
  margin-top: -3px;
}

.compass-footer {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
}

.layer-slider-bar {
  padding: 0.75rem 1.25rem;
  background-color: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.85rem;
}

.layer-slider-bar input[type="range"] {
  flex: 1;
}

.canvas-2d-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f1f5f9;
  padding: 0.5rem;
  overflow: hidden;
  min-height: 700px;
}

#canvas-top-2d, #canvas-side-2d {
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  cursor: default;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.side-info-bar {
  padding: 0.5rem 1.25rem;
  background-color: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-responsive {
  padding: 1rem;
  overflow: auto;
  height: 100%;
}

.manifest-table td {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* Modal Overlay for Smart Dimension Confirmation */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(10, 37, 64, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 480px;
  max-width: 90vw;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fafbfc;
}

.modal-body {
  padding: 1.25rem;
  font-size: 0.9rem;
}

.analysis-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.analysis-box .highlight {
  color: var(--pudu-blue);
  font-weight: 700;
}

.gain-badge {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid var(--success);
  font-weight: 700;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  display: inline-block;
  text-align: center;
  margin-top: 0.5rem;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
