/* =========================================================================
   O³ ENGINE DESIGN SYSTEM — METAMODEL & SAFe CATALOG EXPLORER STYLES
   Directly adapted from apps/metamodel_explorer/styles.css
   ========================================================================= */

:root {
  --bg-base: #070a0f;
  --bg-surface: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-panel: rgba(11, 19, 36, 0.95);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --border-glow: rgba(56, 189, 248, 0.4);
  --accent-cyan: #38bdf8;
  --accent-purple: #c084fc;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #64748b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* =========================================================================
   TOP APPLICATION HEADER & WORKSPACE SWITCHER
   ========================================================================= */
header {
  height: 52px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 50;
  flex-shrink: 0;
}

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

.logo-badge {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.04em;
  border: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.3);
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.nav-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.7);
  padding: 3px 4px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.nav-tab {
  padding: 5px 12px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  color: #f8fafc;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.3), rgba(147, 51, 234, 0.25));
  border: 1px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.2);
}

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

.ribbon-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ribbon-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.level-toggles {
  display: flex;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  gap: 2px;
}

.level-btn {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.level-btn.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(192, 132, 252, 0.2));
  color: #fff;
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.25);
}

.status-pill {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: var(--accent-emerald);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.btn-micro {
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-micro:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-medium);
}

/* =========================================================================
   MAIN VIEWPORT: LEFT CONTAINER + RIGHT INSPECTOR DRAWER
   ========================================================================= */
#viewport-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  width: 100%;
  height: calc(100vh - 52px);
}

/* Left Main Container */
.main-left-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

/* Sub-toolbar (View selector + Quick search + Tools) */
.tbox-toolbar {
  padding: 8px 16px;
  background: #0b1324;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
  flex-shrink: 0;
}

.tbox-layout-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chip-btn {
  padding: 4px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chip-btn:hover {
  color: var(--text-main);
  border-color: var(--border-medium);
  background: rgba(255, 255, 255, 0.08);
}

.chip-btn.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: var(--accent-cyan);
  font-weight: 700;
}

.tbox-search {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.72rem;
  padding: 5px 12px;
  width: 240px;
  outline: none;
  transition: border-color 0.2s;
}

.tbox-search:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

.tbox-tool-btn {
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s;
}

.tbox-tool-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-medium);
}

.tbox-tool-btn.active-inspector {
  border-color: #38bdf8;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  font-weight: 700;
}

/* Screen Panels */
.screen-panel {
  display: none;
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.screen-panel.active {
  display: flex;
}

/* 1. Graph Workspace */
#panel-graph {
  background: radial-gradient(circle at 50% 50%, #0d1527 0%, #070a0f 100%);
  position: relative;
}

#cy-container {
  width: 100%;
  height: 100%;
}

.canvas-controls-floating {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 10;
  display: flex;
  gap: 8px;
}

.ribbon-select {
  background: #0f172a;
  border: 1px solid var(--border-medium);
  color: var(--text-main);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}

.graph-legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 14px;
  z-index: 10;
  font-size: 0.72rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.legend-header {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--accent-cyan);
}

.legend-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.legend-tiers {
  display: flex;
  gap: 12px;
  margin: 6px 0;
  font-size: 0.68rem;
}

.tier-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}
.tier-indicator.portfolio { color: #38bdf8; }
.tier-indicator.essential { color: #c084fc; }

.tier-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.tier-dot.portfolio {
  background: #38bdf8;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.6);
}
.tier-dot.essential {
  background: #c084fc;
  box-shadow: 0 0 6px rgba(192, 132, 252, 0.6);
}

.legend-hint {
  color: var(--text-sub);
  font-size: 0.65rem;
}

/* 2 & 3. Tables & Validation Panels */
.panel-inner-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: 16px 20px;
}

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

.sub-header-bar h3 {
  font-size: 1rem;
  font-weight: 700;
}

.sub-header-bar p {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.sub-header-bar code {
  color: var(--accent-cyan);
  font-family: var(--font-mono);
}

.table-search-input {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.72rem;
  padding: 5px 12px;
  width: 220px;
  outline: none;
}

.table-scroll-container {
  flex: 1;
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.5);
}

.tbox-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.tbox-data-table th {
  background: #0b1324;
  text-align: left;
  padding: 10px 12px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 5;
}

.tbox-data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: top;
}

.tbox-data-table tr:hover td {
  background: rgba(56, 189, 248, 0.04);
  cursor: pointer;
}

.badge-node {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  display: inline-block;
}

.badge-rel {
  background: rgba(192, 132, 252, 0.12);
  color: #c084fc;
  border: 1px solid rgba(192, 132, 252, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  display: inline-block;
}

/* Validation Specifics */
.validation-summary-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px 20px;
  display: flex;
  gap: 36px;
  align-items: center;
  margin-bottom: 16px;
}

.val-metric {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

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

.val-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.val-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-mono);
  width: fit-content;
}

.val-badge.ready {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.val-badge.pass {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.val-badge.fail {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  overflow-y: auto;
  flex: 1;
}

.rule-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  gap: 10px;
}

.rule-num {
  width: 22px;
  height: 22px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}

.rule-info h4 {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 3px;
}

.rule-info p {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.primary-btn {
  padding: 6px 14px;
  font-size: 0.74rem;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(56, 189, 248, 0.1));
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: var(--accent-cyan);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.primary-btn:hover {
  background: rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

/* =========================================================================
   RIGHT-HAND SIDE INSPECTOR DRAWER (Exact Match to metamodel_explorer)
   ========================================================================= */
.side-widget-pane {
  width: 390px;
  min-width: 390px;
  max-width: 390px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 30;
  transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              min-width 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              max-width 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              padding 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.18s ease;
  position: relative;
}

.side-widget-pane.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border-left: none !important;
  overflow: hidden !important;
  opacity: 0;
  pointer-events: none;
}

.drawer-docked-tab {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 45;
  background: #0b1324;
  border: 1px solid #38bdf8;
  border-right: none;
  color: #38bdf8;
  font-weight: 700;
  font-size: 0.68rem;
  padding: 12px 7px;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.6);
  transition: all 0.2s ease;
  user-select: none;
}

.drawer-docked-tab:hover {
  background: #0284c7;
  color: #ffffff;
  padding-left: 11px;
  box-shadow: -6px 0 20px rgba(56, 189, 248, 0.4);
}

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

.widget-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px;
}

.widget-header {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
}

.empty-state {
  color: var(--text-sub);
  font-size: 0.75rem;
  text-align: center;
  margin-top: 50px;
  line-height: 1.6;
}

.inspector-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-cyan);
  margin-bottom: 2px;
}

.inspector-badge {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 14px;
}

.inspector-section {
  margin-bottom: 14px;
}

.inspector-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 4px;
}

.inspector-text {
  font-size: 0.75rem;
  line-height: 1.45;
  color: #e2e8f0;
}

.pattern-pill-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.pattern-pill {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Enriched Educational Styles */
.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: #94a3b8;
}

.state-pill.first {
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.state-pill.done {
  border-color: rgba(52, 211, 153, 0.4);
  color: #34d399;
}

.official-safe-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #38bdf8;
  text-decoration: none;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s ease;
  width: 100%;
  justify-content: center;
  box-sizing: border-box;
}

.official-safe-link:hover {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.5);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* =========================================================================
   EMBEDDED / IFRAME DISPLAY MODE (?embed=true)
   Hides the top suite header to provide a seamless docked viewer in LMS
   ========================================================================= */
body.is-embedded header {
  display: none !important;
}

body.is-embedded {
  background: transparent !important;
}

body.is-embedded #viewport-container,
body.is-embedded .main-layout {
  height: 100vh !important;
  max-height: 100vh !important;
}

