/* ==========================================================================
   Villa Scheme Studio - Modern Architectural Design System
   Zero-dependency CSS3 with Custom Properties, Light/Dark Modes & High-Contrast Typography
   ========================================================================== */

:root {
  /* Color Palette - Dark Architectural Studio (Default) */
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-elevated: #282e36;
  --bg-input: #0b0e14;
  
  --border-subtle: #30363d;
  --border-strong: #484f58;
  --border-focus: #38bdf8;
  
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --text-inverse: #0d1117;

  /* Accent & Architectural Blueprint Tones */
  --accent-cyan: #38bdf8;
  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;
  --accent-glow: rgba(56, 189, 248, 0.15);
  
  /* Status Colors (Thai Villa G0-G9 Standard) */
  --status-pass: #10b981;
  --status-pass-bg: rgba(16, 185, 129, 0.15);
  --status-review: #f59e0b;
  --status-review-bg: rgba(245, 158, 11, 0.15);
  --status-fail: #f43f5e;
  --status-fail-bg: rgba(244, 63, 94, 0.15);
  --status-running: #6366f1;
  --status-running-bg: rgba(99, 102, 241, 0.18);
  --status-idle: #6e7681;
  --status-idle-bg: rgba(110, 118, 129, 0.12);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

  /* Elevation Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.25);
  --shadow-code: 0 8px 24px rgba(0, 0, 0, 0.6);

  /* Layout */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  --header-height: 64px;
  --tabbar-height: 50px;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-elevated: #e2e8f0;
  --bg-input: #ffffff;
  
  --border-subtle: #cbd5e1;
  --border-strong: #94a3b8;
  --border-focus: #0284c7;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #f8fafc;

  --accent-cyan: #0284c7;
  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;
  --accent-glow: rgba(2, 132, 199, 0.12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-code: 0 8px 24px rgba(0, 0, 0, 0.1);
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* App Shell Layout */
#app-root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Navigation Bar */
.top-header {
  height: var(--header-height);
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

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

.brand-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: 0 0 12px var(--accent-glow);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background-color: var(--bg-tertiary);
  color: var(--accent-cyan);
  border: 1px solid var(--border-subtle);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  margin-left: 0.5rem;
}

.header-status-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--status-idle);
}
.status-dot.active { background-color: var(--status-pass); box-shadow: 0 0 8px var(--status-pass); }
.status-dot.connecting { background-color: var(--status-review); animation: pulse 1.5s infinite; }
.status-dot.offline { background-color: var(--status-fail); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background-color: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover {
  background-color: var(--accent-blue-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.btn-secondary:hover {
  background-color: var(--bg-elevated);
  border-color: var(--border-strong);
}

.btn-outline {
  background-color: transparent;
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.btn-outline:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--border-strong);
}

.btn-success {
  background-color: var(--status-pass);
  color: #ffffff;
}
.btn-success:hover {
  filter: brightness(1.1);
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Navigation Tabs */
.tabs-navigation {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  overflow-x: auto;
  gap: 0.5rem;
  scrollbar-width: none;
}
.tabs-navigation::-webkit-scrollbar { display: none; }

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background-color: var(--bg-elevated);
}

.tab-badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* Main Content Area */
.main-container {
  flex: 1;
  padding: 1.5rem;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

.tab-pane {
  display: none;
  animation: fadeIn var(--transition-normal);
}
.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Card System */
.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

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

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

/* Form Controls & Grid */
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-group .field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Toggle Switch */
.switch-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
  font-weight: 500;
}

.switch-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  transition: var(--transition-fast);
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  transition: var(--transition-fast);
}

.switch-input:checked + .switch-slider {
  background-color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.switch-input:checked + .switch-slider::before {
  transform: translateX(18px);
  background-color: #ffffff;
}

/* Checklist Pill Grid */
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.check-item:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-elevated);
}

.check-item input[type="checkbox"] {
  accent-color: var(--accent-blue);
  width: 16px;
  height: 16px;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-pass { background-color: var(--status-pass-bg); color: var(--status-pass); border: 1px solid var(--status-pass); }
.badge-review { background-color: var(--status-review-bg); color: var(--status-review); border: 1px solid var(--status-review); }
.badge-fail { background-color: var(--status-fail-bg); color: var(--status-fail); border: 1px solid var(--status-fail); }
.badge-running { background-color: var(--status-running-bg); color: var(--status-running); border: 1px solid var(--status-running); }
.badge-idle { background-color: var(--status-idle-bg); color: var(--status-idle); border: 1px solid var(--border-subtle); }

/* ==========================================================================
   Tab 3: G0-G9 Stepper & Workflow Workbench
   ========================================================================== */

/* Workbench Two-Column Layout */
.workbench-layout {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  width: 100%;
}

/* Workbench Sticky Sidebar Navigation */
.workbench-sidebar {
  flex: 0 0 280px;
  width: 280px;
  min-width: 280px;
  position: sticky;
  top: calc(var(--header-height) + 1rem);
  max-height: calc(100vh - var(--header-height) - 2rem);
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1rem;
  z-index: 20;
  scrollbar-width: thin;
}

.workbench-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Sidebar Header Toolbar */
.sidebar-header {
  padding-bottom: 0.85rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-title-block {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sidebar-title-icon {
  font-size: 1.1rem;
}

.sidebar-title-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-toggle-all-btn {
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-toggle-all-btn:hover {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--accent-cyan);
}

.sidebar-summary-badge {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  background-color: var(--bg-tertiary);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  margin-top: 0.6rem;
  display: inline-block;
  border: 1px solid var(--border-subtle);
  font-weight: 600;
}

/* Sidebar Stage List */
.sidebar-stage-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidebar-stage-group,
.sidebar-stage-item {
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
}

/* Primary Stage Item Header */
.sidebar-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  background-color: transparent;
  border: 1px solid transparent;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  color: var(--text-primary);
  font-size: 0.85rem;
}

.sidebar-stage-header:hover {
  background-color: var(--bg-tertiary);
}

.sidebar-stage-item.active > .sidebar-stage-header,
.sidebar-stage-item.is-active-stage > .sidebar-stage-header {
  background-color: var(--bg-elevated);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 600;
  box-shadow: 0 0 8px var(--accent-glow);
}

.sidebar-stage-item-main {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-stage-num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--text-muted);
  width: 14px;
  flex-shrink: 0;
}

.sidebar-stage-item.active .sidebar-stage-num {
  color: var(--accent-cyan);
}

.sidebar-stage-sep {
  color: var(--text-muted);
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-stage-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  background-color: var(--bg-input);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  color: var(--accent-cyan);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-stage-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.sidebar-stage-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  margin-left: 0.35rem;
}

/* Status Indicator Dots */
.sidebar-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background-color: var(--status-idle);
  flex-shrink: 0;
  transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.sidebar-status-dot.status-pass,
.sidebar-status-dot.dot-pass {
  background-color: var(--status-pass);
  box-shadow: 0 0 6px var(--status-pass);
}

.sidebar-status-dot.status-running,
.sidebar-status-dot.dot-running {
  background-color: var(--status-running);
  box-shadow: 0 0 6px var(--status-running);
  animation: pulse 1.5s infinite;
}

.sidebar-status-dot.status-review,
.sidebar-status-dot.dot-review {
  background-color: var(--status-review);
  box-shadow: 0 0 6px var(--status-review);
}

.sidebar-status-dot.status-fail,
.sidebar-status-dot.dot-fail {
  background-color: var(--status-fail);
  box-shadow: 0 0 6px var(--status-fail);
}

.sidebar-status-dot.status-idle,
.sidebar-status-dot.status-not_started,
.sidebar-status-dot.dot-idle {
  background-color: var(--status-idle);
}

/* Chevron Toggle Button */
.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.15rem 0.25rem;
  font-size: 0.75rem;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), transform var(--transition-fast);
}

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

/* Collapsible Submenu Container */
.sidebar-sub-menu {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-left: 1.5rem;
  padding-top: 0.25rem;
  padding-bottom: 0.35rem;
  transition: max-height var(--transition-normal), opacity var(--transition-normal);
  overflow: hidden;
}

.sidebar-sub-menu.collapsed,
.sidebar-sub-menu.is-collapsed,
.sidebar-stage-item.is-collapsed .sidebar-sub-menu,
.sidebar-stage-group.is-collapsed .sidebar-sub-menu {
  display: none !important;
}

/* Submenu Items */
.sidebar-sub-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

.sidebar-sub-item:hover {
  color: var(--accent-cyan);
  background-color: var(--bg-tertiary);
  transform: translateX(2px);
}

.sidebar-sub-item.active,
.sidebar-sub-item.is-active-sub {
  color: var(--accent-cyan);
  font-weight: 600;
  background-color: var(--bg-elevated);
}

.sub-item-icon {
  font-size: 0.82rem;
  flex-shrink: 0;
}

.sub-item-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub-item-count,
.sub-item-badge {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
}

.stepper-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.stepper-progress-track {
  display: flex;
  align-items: center;
  width: 100%;
  overflow-x: auto;
  padding: 1rem 0;
  scrollbar-width: thin;
}

.step-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-width: 105px;
  cursor: pointer;
  user-select: none;
}

.step-node:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 16px;
  left: 50%;
  width: 100%;
  height: 2px;
  background-color: var(--border-subtle);
  z-index: 1;
}

.step-node.completed:not(:last-child)::after {
  background-color: var(--status-pass);
}

.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--bg-tertiary);
  border: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-secondary);
  z-index: 2;
  transition: all var(--transition-fast);
}

.step-node.active .step-circle {
  border-color: var(--accent-cyan);
  background-color: var(--accent-blue);
  color: #fff;
  box-shadow: 0 0 10px var(--accent-glow);
}

.step-node.pass .step-circle {
  border-color: var(--status-pass);
  background-color: var(--status-pass);
  color: #fff;
}

.step-node.review .step-circle {
  border-color: var(--status-review);
  background-color: var(--status-review);
  color: #fff;
}

.step-node.fail .step-circle {
  border-color: var(--status-fail);
  background-color: var(--status-fail);
  color: #fff;
}

.step-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 0.4rem;
  text-align: center;
}
.step-node.active .step-label { color: var(--accent-cyan); }

/* Stage Card Layout in Workbench */
.stage-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.stage-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  scroll-margin-top: calc(var(--header-height) + 1.25rem);
}

.stage-card.is-active-focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px var(--accent-glow);
}

.stage-card-header {
  padding: 1rem 1.25rem;
  background-color: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stage-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stage-code {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  background-color: var(--bg-elevated);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--accent-cyan);
  border: 1px solid var(--border-subtle);
}

.stage-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stage-body {
  padding: 1.25rem;
}

.stage-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.gate-requirements {
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

.gate-title {
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.stage-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Stage Card Standard Sections (Inputs, Trigger, Artifacts) */
.stage-section {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 1rem;
  scroll-margin-top: calc(var(--header-height) + 1.25rem);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.stage-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.stage-section-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.stage-section-title {
  font-weight: 600;
}

.stage-section-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Visual Focus and Pulse Animation */
@keyframes highlightPulseAnim {
  0% {
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.65);
    border-color: var(--accent-cyan);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(56, 189, 248, 0.25);
    border-color: var(--accent-cyan);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0);
  }
}

.highlight-pulse {
  animation: highlightPulseAnim 1.4s ease-out;
  border-color: var(--accent-cyan) !important;
}

/* ==========================================================================
   Tab 4: Real-time ANSI Log Terminal
   ========================================================================== */
.terminal-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 480px;
  background-color: #0b0e14;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-code);
}

.terminal-header {
  height: 44px;
  background-color: #161b22;
  border-bottom: 1px solid #30363d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

.terminal-title-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.window-dots {
  display: flex;
  gap: 6px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-red { background-color: #ff5f56; }
.dot-yellow { background-color: #ffbd2e; }
.dot-green { background-color: #27c93f; }

.terminal-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: #8b949e;
}

.terminal-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.terminal-screen {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.45;
  color: #c9d1d9;
  background-color: #0b0e14;
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal-line {
  display: flex;
  gap: 0.75rem;
  padding: 0.05rem 0;
}

.terminal-time {
  color: #6e7681;
  user-select: none;
  font-size: 0.75rem;
}

.terminal-text {
  flex: 1;
}

/* ANSI Color Classes */
.ansi-black { color: #484f58; }
.ansi-red { color: #ff7b72; }
.ansi-green { color: #7ee787; }
.ansi-yellow { color: #f2cc60; }
.ansi-blue { color: #58a6ff; }
.ansi-magenta { color: #bc8cff; }
.ansi-cyan { color: #39c5cf; }
.ansi-white { color: #d2a8ff; }
.ansi-bold { font-weight: 700; }
.ansi-dim { opacity: 0.65; }
.ansi-underline { text-decoration: underline; }

/* Terminal Footer Info */
.terminal-footer {
  height: 28px;
  background-color: #161b22;
  border-top: 1px solid #30363d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  font-size: 0.75rem;
  color: #8b949e;
  font-family: var(--font-mono);
}

/* ==========================================================================
   Tab 5: Interactive Artifact Viewers & Downloads
   ========================================================================== */
.artifact-layout-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

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

/* Interactive SVG Viewer Container */
.svg-viewer-container {
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 580px;
  position: relative;
}

.svg-viewer-toolbar {
  padding: 0.6rem 1rem;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  z-index: 10;
}

.svg-layer-toggles {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.layer-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  user-select: none;
}
.layer-chip.active {
  background-color: var(--accent-glow);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.svg-canvas-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  background: 
    radial-gradient(circle, var(--border-subtle) 1px, transparent 1px);
  background-size: 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.svg-canvas-viewport:active {
  cursor: grabbing;
}

.svg-canvas-content {
  transform-origin: 0 0;
  transition: transform 50ms linear;
  display: flex;
  align-items: center;
  justify-content: center;
}

.svg-canvas-content svg {
  max-width: none;
  display: block;
}

/* Floating Zoom Widget inside SVG Viewer */
.svg-float-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 4px;
  box-shadow: var(--shadow-md);
  z-index: 10;
}

/* DXF Download Cards */
.dxf-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
}

.dxf-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.dxf-filename {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dxf-hash {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* 16:9 Presentation Board Container */
.board-viewer-card {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #0b0e14;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  cursor: pointer;
}

.board-viewer-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal);
}
.board-viewer-card:hover .board-viewer-img {
  transform: scale(1.02);
}

.board-overlay-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background-color: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(4px);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-cyan);
  border: 1px solid var(--border-subtle);
}

/* Structured JSON Tree Inspector */
.json-tree-container {
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  max-height: 480px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
}

.json-node {
  margin-left: 1.25rem;
  position: relative;
}

.json-key {
  color: var(--accent-cyan);
  cursor: pointer;
  user-select: none;
}
.json-key:hover { text-decoration: underline; }

.json-string { color: #7ee787; }
.json-number { color: #79c0ff; }
.json-boolean { color: #ff7b72; }
.json-null { color: #8b949e; }

.json-toggle-icon {
  display: inline-block;
  width: 12px;
  font-size: 0.65rem;
  margin-right: 4px;
  color: var(--text-secondary);
}

/* Modal Dialogs */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
}

.modal-backdrop.active {
  display: flex;
}

.modal-content {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 90vw;
  max-height: 90vh;
  width: 1200px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

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

.modal-body {
  padding: 1.5rem;
  overflow: auto;
  flex: 1;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  animation: slideInRight 200ms ease;
  min-width: 280px;
}

.toast-success { border-left: 4px solid var(--status-pass); }
.toast-error { border-left: 4px solid var(--status-fail); }
.toast-info { border-left: 4px solid var(--accent-cyan); }
.toast-warning { border-left: 4px solid var(--status-review); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  .form-grid-2, .form-grid-3 {
    grid-template-columns: 1fr;
  }
  .header-status-area {
    display: none;
  }
  .top-header {
    padding: 0 1rem;
  }
  .tabs-navigation {
    padding: 0 0.5rem;
  }
  .tab-btn {
    padding: 0.75rem 0.85rem;
    font-size: 0.82rem;
  }
}

/* Tablet & Mobile Workbench Responsive Fallback */
@media (max-width: 1024px) {
  .workbench-layout {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .workbench-sidebar {
    width: 100%;
    min-width: 100%;
    position: static;
    max-height: none;
    box-shadow: none;
  }

  .workbench-main-content {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
}

