/* ==================================================
   R&D WORKSPACE — FORMULATION DEPENDENCY EXPLORER
   FILE: /clients/css/workspaces/rd.css

   Three-pane operational relationship explorer:
     LEFT   — BOM navigator
     CENTER — BOM dependency intelligence
     RIGHT  — Item/component navigator

   Color palette aligned to TWMD dark operational
   conventions: charcoal surfaces, #5cff72 green accent,
   soft borders, readable typography.
================================================== */

/* ==================================================
   DESIGN TOKENS
================================================== */

:root {
  --rd-bg:           #111418;
  --rd-surface:      rgba(255, 255, 255, 0.04);
  --rd-surface-lift: rgba(255, 255, 255, 0.06);
  --rd-panel-dark:   #0e1117;
  --rd-border:       rgba(255, 255, 255, 0.07);
  --rd-border-focus: rgba(92, 255, 114, 0.4);
  --rd-text:         #f0f4f8;
  --rd-muted:        rgba(240, 244, 248, 0.45);
  --rd-green:        #5cff72;
  --rd-green-dim:    rgba(92, 255, 114, 0.1);
  --rd-yellow:       #fbbf24;
  --rd-red:          #f87171;
  --rd-blue:         #93c5fd;
}

*,
*::before,
*::after { box-sizing: border-box; }

/* ==================================================
   PAGE
================================================== */

.rd-page {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--rd-bg);
  color: var(--rd-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ==================================================
   MAIN
================================================== */

.rd-main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ==================================================
   TOP BAR
================================================== */

.rd-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 50px;
  flex-shrink: 0;
  background: #1a1e27;
  border-bottom: 1px solid var(--rd-border);
}

.rd-topbar-left  { display: flex; flex-direction: column; justify-content: center; }
.rd-topbar-right { flex-shrink: 0; }

.rd-eyebrow {
  color: var(--rd-green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 2px;
}

.rd-topbar-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--rd-text);
  line-height: 1;
}

.rd-status-pill {
  border: 1px solid rgba(92, 255, 114, 0.22);
  background: rgba(92, 255, 114, 0.07);
  color: var(--rd-green);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ==================================================
   TRI-PANE WORKSPACE BODY
================================================== */

.rd-workspace-body {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr) 232px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ==================================================
   SHARED PANEL CONVENTIONS
================================================== */

.rd-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px 8px;
  border-bottom: 1px solid var(--rd-border);
  flex-shrink: 0;
}

.rd-nav-header-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rd-muted);
}

.rd-nav-count {
  font-size: 11px;
  color: var(--rd-muted);
}

.rd-nav-empty {
  color: var(--rd-muted);
  font-size: 12px;
  padding: 16px 10px;
  text-align: center;
  line-height: 1.55;
}

/* ==================================================
   LEFT — BOM NAVIGATOR
================================================== */

.rd-bom-nav-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--rd-border);
  background: var(--rd-panel-dark);
  overflow: hidden;
}

/* BOM NAME FILTER */

.rd-bom-filter-wrap {
  padding: 7px 8px;
  border-bottom: 1px solid var(--rd-border);
  flex-shrink: 0;
}

.rd-bom-filter-input {
  width: 100%;
  border: 1px solid var(--rd-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--rd-text);
  border-radius: 6px;
  padding: 6px 9px;
  font: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color 0.12s;
}

.rd-bom-filter-input::placeholder { color: var(--rd-muted); }
.rd-bom-filter-input:focus {
  border-color: var(--rd-border-focus);
  background: rgba(92, 255, 114, 0.04);
}

/* FILTER BANNER */

.rd-filter-banner {
  padding: 6px 12px;
  font-size: 11px;
  line-height: 1.5;
  background: rgba(92, 255, 114, 0.06);
  border-bottom: 1px solid rgba(92, 255, 114, 0.1);
  color: var(--rd-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.rd-filter-banner strong { color: var(--rd-green); }

.rd-filter-banner-empty {
  background: rgba(248, 113, 113, 0.05);
  border-bottom-color: rgba(248, 113, 113, 0.1);
  color: var(--rd-red);
}

.rd-filter-banner-empty strong { color: var(--rd-red); }

.rd-banner-clear {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--rd-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 1px 4px;
  flex-shrink: 0;
  border-radius: 4px;
  transition: color 0.1s;
}

.rd-banner-clear:hover { color: var(--rd-text); }

/* BOM LIST */

.rd-bom-nav {
  flex: 1;
  overflow-y: auto;
  padding: 5px;
}

/* BOM LIST ITEM */

.rd-bom-item {
  padding: 8px 9px 7px;
  border-radius: 7px;
  cursor: pointer;
  margin-bottom: 2px;
  border: 1px solid transparent;
  outline: none;
  transition: background 0.1s, opacity 0.12s;
}

.rd-bom-item:hover { background: var(--rd-surface-lift); }

.rd-bom-item.active {
  background: var(--rd-green-dim);
  border-color: rgba(92, 255, 114, 0.18);
}

.rd-bom-item.matches {
  border-left: 2px solid var(--rd-yellow);
  padding-left: 8px;
}

.rd-bom-item.dimmed { opacity: 0.2; pointer-events: none; }

.rd-bom-item-main {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 3px;
  overflow: hidden;
}

.rd-bom-item-icon { color: var(--rd-muted); font-size: 10px; flex-shrink: 0; }
.rd-bom-item.active .rd-bom-item-icon { color: var(--rd-green); }

.rd-bom-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.rd-bom-item-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--rd-muted);
  padding-left: 16px;
}

.rd-dot-active {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--rd-green); flex-shrink: 0;
}

.rd-dot-draft {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--rd-yellow); flex-shrink: 0;
}

.rd-bom-item-code {
  font-family: monospace;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
}

.rd-bom-item-count { margin-left: auto; white-space: nowrap; flex-shrink: 0; }

/* ==================================================
   CENTER — INTELLIGENCE SURFACE
================================================== */

.rd-bom-detail {
  overflow-y: auto;
  padding: 20px 24px 32px;
  min-width: 0;
  border-right: 1px solid var(--rd-border);
}

/* PROMPT */

.rd-detail-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  text-align: center;
  color: var(--rd-muted);
}

.rd-detail-prompt-icon { font-size: 28px; margin-bottom: 12px; opacity: 0.2; }

.rd-detail-prompt-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--rd-text);
  opacity: 0.55;
  margin-bottom: 8px;
}

.rd-detail-prompt-subtitle {
  font-size: 13px;
  max-width: 300px;
  line-height: 1.65;
}

/* DETAIL HEADER */

.rd-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rd-border);
}

.rd-detail-eyebrow {
  color: var(--rd-green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.rd-detail-title {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 5px;
}

.rd-detail-meta {
  color: var(--rd-muted);
  font-size: 12px;
  line-height: 1.7;
}

.rd-detail-header-right {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  flex-shrink: 0;
  padding-top: 2px;
}

/* SECTION HEADERS */

.rd-section-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--rd-muted);
  margin: 20px 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--rd-border);
}

/* ==================================================
   RIGHT — ITEM NAVIGATOR
================================================== */

.rd-item-nav-panel {
  display: flex;
  flex-direction: column;
  background: var(--rd-panel-dark);
  overflow: hidden;
}

.rd-item-filter-wrap {
  padding: 7px 8px;
  border-bottom: 1px solid var(--rd-border);
  flex-shrink: 0;
}

.rd-item-filter-input {
  width: 100%;
  border: 1px solid var(--rd-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--rd-text);
  border-radius: 6px;
  padding: 6px 9px;
  font: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color 0.12s;
}

.rd-item-filter-input::placeholder { color: var(--rd-muted); }
.rd-item-filter-input:focus {
  border-color: var(--rd-border-focus);
  background: rgba(92, 255, 114, 0.04);
}

.rd-item-nav {
  flex: 1;
  overflow-y: auto;
  padding: 5px;
}

/* ITEM ROW */

.rd-item-row {
  padding: 8px 9px;
  border-radius: 7px;
  cursor: pointer;
  margin-bottom: 2px;
  border: 1px solid transparent;
  outline: none;
  transition: background 0.1s;
}

.rd-item-row:hover { background: var(--rd-surface-lift); }

.rd-item-row.active {
  background: var(--rd-green-dim);
  border-color: rgba(92, 255, 114, 0.18);
}

.rd-item-row-name {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rd-item-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--rd-muted);
}

.rd-item-sku {
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
}

.rd-item-bom-count {
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

.rd-item-supplier {
  font-size: 10px;
  color: var(--rd-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==================================================
   TABLES
================================================== */

.rd-table-wrap { overflow-x: auto; margin-bottom: 2px; }

table.rd-table {
  width: 100%;
  border-collapse: collapse;
}

table.rd-table th,
table.rd-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
  font-size: 12px;
}

table.rd-table th {
  color: var(--rd-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.03);
  white-space: nowrap;
}

table.rd-table tr:hover td { background: rgba(255, 255, 255, 0.025); }

tr.rd-row-highlight td {
  background: rgba(251, 191, 36, 0.05) !important;
  border-bottom-color: rgba(251, 191, 36, 0.1);
}

.rd-assess-table .rd-assess-domain {
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  color: var(--rd-text);
}

.rd-assess-table .rd-assess-text {
  color: var(--rd-muted);
  font-size: 12px;
  line-height: 1.55;
}

/* ==================================================
   TAGS
================================================== */

.rd-tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--rd-border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--rd-muted);
  background: var(--rd-surface);
  white-space: nowrap;
}

.rd-tag.green {
  color: var(--rd-green);
  border-color: rgba(92, 255, 114, 0.22);
  background: rgba(92, 255, 114, 0.07);
}

.rd-tag.yellow {
  color: var(--rd-yellow);
  border-color: rgba(251, 191, 36, 0.22);
  background: rgba(251, 191, 36, 0.06);
}

.rd-tag.red {
  color: var(--rd-red);
  border-color: rgba(248, 113, 113, 0.22);
  background: rgba(248, 113, 113, 0.06);
}

.rd-tag.blue {
  color: var(--rd-blue);
  border-color: rgba(147, 197, 253, 0.22);
  background: rgba(147, 197, 253, 0.06);
}

/* ==================================================
   LOADING / EMPTY
================================================== */

.rd-loading-state {
  color: var(--rd-green);
  padding: 16px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  animation: rd-pulse 1.5s ease-in-out infinite;
}

@keyframes rd-pulse {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 0.9; }
}

.rd-empty-state {
  color: var(--rd-muted);
  padding: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.06);
  border-radius: 7px;
  text-align: center;
  font-size: 12px;
  margin: 6px 0;
}

/* ==================================================
   RESPONSIVE
================================================== */

@media (max-width: 1100px) {

  .rd-workspace-body {
    grid-template-columns: 240px minmax(0, 1fr) 210px;
  }

}

@media (max-width: 820px) {

  .rd-workspace-body {
    grid-template-columns: 1fr;
    grid-template-rows: 200px minmax(300px, 1fr) 200px;
    overflow-y: auto;
  }

  .rd-bom-nav-panel,
  .rd-item-nav-panel {
    border-right: none;
    border-bottom: 1px solid var(--rd-border);
  }

  .rd-bom-detail {
    border-right: none;
    padding: 14px 16px;
  }

}

@media (max-width: 480px) {

  .rd-topbar { padding: 0 12px; }
  .rd-status-pill { display: none; }

}
