/* ═══════════════════════════════════════════════════════════════
   TradeForge — Unified System Flow & Cross-Module Navigation
   OS-level flow bar, module route context, opportunity previews,
   operational tool cards, and continuity links.
   ═══════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────────────────────
   1. System Flow Bar
   Horizontal breadcrumb-style bar showing the unified route:
   Design > Opportunity > Action > Project > Execution > Result
   ────────────────────────────────────────────────────────────── */
.tf-system-flow {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  padding: 10px 20px;
  background: rgba(15, 17, 20, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(140, 106, 62, 0.18);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: var(--tf-system-flow-top, 0);
  z-index: 44;
}
.tf-system-flow::-webkit-scrollbar {
  display: none;
}

.ucmd-env .tf-system-flow {
  --tf-system-flow-top: 56px;
}

.tf-os .tf-system-flow {
  --tf-system-flow-top: 60px;
}

/* ──────────────────────────────────────────────────────────────
   2. System Flow Steps
   ────────────────────────────────────────────────────────────── */
.tf-system-flow-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, rgba(181, 183, 185, 0.72));
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 6px 0;
  position: relative;
  flex-shrink: 0;
  transition: color 0.2s ease;
}
.tf-system-flow-step svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
}

/* Arrow connector between steps */
.tf-system-flow-step + .tf-system-flow-step::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238C6A3E' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
  opacity: 0.45;
}

/* ──────────────────────────────────────────────────────────────
   3. Active Flow Step
   ────────────────────────────────────────────────────────────── */
.tf-system-flow-step.active {
  color: #fff;
  font-weight: 700;
}
.tf-system-flow-step.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--bronze, #8C6A3E);
  border-radius: 2px 2px 0 0;
}
.tf-system-flow-step.active svg {
  color: var(--bronze, #8C6A3E);
  opacity: 1;
}

/* Completed steps (upstream of active) */
.tf-system-flow-step.completed {
  color: rgba(181, 183, 185, 0.55);
}
.tf-system-flow-step.completed svg {
  opacity: 0.5;
}

/* ──────────────────────────────────────────────────────────────
   4. Flow Step Links
   ────────────────────────────────────────────────────────────── */
.tf-system-flow-step a {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}
.tf-system-flow-step a:hover {
  color: #fff;
  background: rgba(140, 106, 62, 0.12);
}
.tf-system-flow-step.active a {
  color: #fff;
}
.tf-system-flow-step.active a:hover {
  background: rgba(140, 106, 62, 0.18);
}

/* ──────────────────────────────────────────────────────────────
   5. Module Route Bar
   Thin contextual bar showing where the user is in the system
   ────────────────────────────────────────────────────────────── */
.tf-module-route {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 20px;
  background: rgba(15, 17, 20, 0.6);
  border-bottom: 1px solid rgba(181, 183, 185, 0.08);
  font-size: 12px;
  min-height: 36px;
}

/* ──────────────────────────────────────────────────────────────
   6. Module Route Breadcrumb
   ────────────────────────────────────────────────────────────── */
.tf-module-route-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted, rgba(181, 183, 185, 0.72));
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.tf-module-route-breadcrumb a {
  color: var(--muted, rgba(181, 183, 185, 0.72));
  text-decoration: none;
  transition: color 0.15s ease;
  flex-shrink: 0;
}
.tf-module-route-breadcrumb a:hover {
  color: #fff;
}
.tf-module-route-breadcrumb span.sep {
  color: rgba(140, 106, 62, 0.4);
  font-size: 10px;
  flex-shrink: 0;
}
.tf-module-route-breadcrumb .current {
  color: var(--ash, #B5B7B9);
  font-weight: 650;
}

/* ──────────────────────────────────────────────────────────────
   7. Module Route Quick-Jump Links
   ────────────────────────────────────────────────────────────── */
.tf-module-route-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.tf-module-route-links a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, rgba(181, 183, 185, 0.72));
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(181, 183, 185, 0.1);
  background: transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.tf-module-route-links a:hover {
  color: #fff;
  border-color: rgba(140, 106, 62, 0.35);
  background: rgba(140, 106, 62, 0.08);
}
.tf-module-route-links a svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .tf-system-flow {
    position: static;
  }
}

/* ──────────────────────────────────────────────────────────────
   8. Opportunity Preview Overlay
   Inline structured preview card for opportunities
   ────────────────────────────────────────────────────────────── */
.tf-opp-preview {
  background: linear-gradient(180deg, rgba(46, 49, 54, 0.98), rgba(38, 41, 46, 0.92));
  border: 1px solid rgba(140, 106, 62, 0.3);
  border-radius: var(--r, 14px);
  box-shadow: 0 16px 40px rgba(10, 11, 13, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.15);
  padding: 0;
  width: 380px;
  max-width: 95vw;
  overflow: hidden;
  z-index: 60;
  position: absolute;
}

/* ──────────────────────────────────────────────────────────────
   9. Opportunity Preview Sub-elements
   ────────────────────────────────────────────────────────────── */
.tf-opp-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(181, 183, 185, 0.08);
  background: rgba(15, 17, 20, 0.3);
}
.tf-opp-preview-header h4 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.35;
}
.tf-opp-preview-header .tf-opp-preview-status {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  flex-shrink: 0;
}
.tf-opp-preview-header .tf-opp-preview-id {
  font-size: 11px;
  color: var(--muted, rgba(181, 183, 185, 0.72));
  margin-top: 3px;
}

.tf-opp-preview-section {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(181, 183, 185, 0.06);
}
.tf-opp-preview-section:last-of-type {
  border-bottom: none;
}
.tf-opp-preview-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted, rgba(181, 183, 185, 0.72));
  margin: 0 0 6px;
}
.tf-opp-preview-section p {
  font-size: 13px;
  color: var(--ash, #B5B7B9);
  line-height: 1.5;
  margin: 0;
}

.tf-opp-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(181, 183, 185, 0.06);
}
.tf-opp-preview-grid-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tf-opp-preview-grid-item .label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, rgba(181, 183, 185, 0.72));
}
.tf-opp-preview-grid-item .value {
  font-size: 13px;
  font-weight: 650;
  color: #fff;
}
.tf-opp-preview-grid-item .value.bronze {
  color: var(--bronze, #8C6A3E);
}

.tf-opp-preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: rgba(15, 17, 20, 0.25);
  border-top: 1px solid rgba(181, 183, 185, 0.06);
}
.tf-opp-preview-actions a,
.tf-opp-preview-actions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 650;
  padding: 7px 14px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}
.tf-opp-preview-actions .tf-opp-preview-action-primary {
  background: var(--bronze, #8C6A3E);
  color: var(--ink, #0f1114);
  border: 1px solid rgba(140, 106, 62, 0.65);
}
.tf-opp-preview-actions .tf-opp-preview-action-primary:hover {
  opacity: 0.9;
}
.tf-opp-preview-actions .tf-opp-preview-action-secondary {
  background: rgba(140, 106, 62, 0.08);
  color: var(--bronze, #8C6A3E);
  border: 1px solid rgba(140, 106, 62, 0.22);
}
.tf-opp-preview-actions .tf-opp-preview-action-secondary:hover {
  background: rgba(140, 106, 62, 0.16);
  border-color: rgba(140, 106, 62, 0.35);
}
.tf-opp-preview-actions svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* ──────────────────────────────────────────────────────────────
   10. Operational Tool Card
   Card style for modules (Bins, Haulage, etc.) shown as tools
   within the project flow
   ────────────────────────────────────────────────────────────── */
.tf-ops-tool-card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(46, 49, 54, 0.96), rgba(38, 41, 46, 0.82));
  border: 1px solid rgba(181, 183, 185, 0.1);
  border-radius: var(--r, 14px);
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
  position: relative;
}
.tf-ops-tool-card:hover {
  border-color: rgba(140, 106, 62, 0.38);
  box-shadow: 0 14px 34px rgba(10, 11, 13, 0.28);
  transform: translateY(-1px);
}
.tf-ops-tool-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(140, 106, 62, 0.12);
  border: 1px solid rgba(140, 106, 62, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.tf-ops-tool-card-icon svg {
  width: 20px;
  height: 20px;
  color: var(--bronze, #8C6A3E);
}
.tf-ops-tool-card-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.tf-ops-tool-card-desc {
  font-size: 12px;
  color: var(--muted, rgba(181, 183, 185, 0.72));
  line-height: 1.5;
  margin: 0 0 12px;
}
.tf-ops-tool-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(181, 183, 185, 0.06);
}
.tf-ops-tool-card-stat {
  font-size: 11px;
  color: var(--muted, rgba(181, 183, 185, 0.72));
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tf-ops-tool-card-stat svg {
  width: 12px;
  height: 12px;
}
.tf-ops-tool-card-stat .value {
  color: var(--bronze, #8C6A3E);
  font-weight: 700;
}
.tf-ops-tool-card-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 5px;
}
.tf-ops-tool-card-badge.active {
  background: rgba(106, 191, 105, 0.14);
  color: #6abf69;
  border: 1px solid rgba(106, 191, 105, 0.3);
}
.tf-ops-tool-card-badge.pending {
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.25);
}
.tf-ops-tool-card-badge.required {
  background: rgba(140, 106, 62, 0.14);
  color: var(--bronze, #8C6A3E);
  border: 1px solid rgba(140, 106, 62, 0.3);
}

/* ──────────────────────────────────────────────────────────────
   11. Continuity Link
   "Next step" links that visually connect to the next module
   ────────────────────────────────────────────────────────────── */
.tf-continuity-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
  color: var(--bronze, #8C6A3E);
  text-decoration: none;
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(140, 106, 62, 0.06);
  border: 1px solid rgba(140, 106, 62, 0.2);
  transition: all 0.18s ease;
  position: relative;
  letter-spacing: 0.01em;
}
.tf-continuity-link:hover {
  background: rgba(140, 106, 62, 0.14);
  border-color: rgba(140, 106, 62, 0.4);
  color: #fff;
  transform: translateX(2px);
}
.tf-continuity-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}
.tf-continuity-link:hover svg {
  transform: translateX(3px);
}
.tf-continuity-link-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted, rgba(181, 183, 185, 0.72));
  display: block;
  margin-bottom: 2px;
}
.tf-continuity-link-module {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

/* Connector line variant -- visual connection to the next module */
.tf-continuity-link.with-connector::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -20px;
  width: 20px;
  height: 2px;
  background: rgba(140, 106, 62, 0.3);
}

/* ──────────────────────────────────────────────────────────────
   Responsive — Tablet (900px)
   ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .tf-system-flow {
    padding: 8px 16px;
  }
  .tf-system-flow-step {
    font-size: 11px;
  }
  .tf-system-flow-step + .tf-system-flow-step::before {
    width: 14px;
    height: 14px;
    background-size: 11px 11px;
    margin-right: 4px;
  }

  .tf-module-route {
    padding: 8px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .tf-module-route-links {
    flex-wrap: wrap;
    gap: 6px;
  }

  .tf-opp-preview {
    width: 340px;
  }
  .tf-opp-preview-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .tf-ops-tool-card {
    padding: 16px;
  }
  .tf-ops-tool-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
  }
  .tf-ops-tool-card-icon svg {
    width: 18px;
    height: 18px;
  }
}

/* ──────────────────────────────────────────────────────────────
   Responsive — Mobile (520px)
   ────────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .tf-system-flow {
    padding: 6px 12px;
    gap: 0;
  }
  .tf-system-flow-step {
    font-size: 10px;
    letter-spacing: 0.02em;
    padding: 5px 0;
  }
  .tf-system-flow-step svg {
    width: 12px;
    height: 12px;
  }
  .tf-system-flow-step a {
    padding: 3px 6px;
  }
  .tf-system-flow-step + .tf-system-flow-step::before {
    width: 12px;
    height: 12px;
    background-size: 10px 10px;
    margin-right: 2px;
  }

  .tf-module-route {
    padding: 6px 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .tf-module-route-breadcrumb {
    font-size: 11px;
    width: 100%;
  }
  .tf-module-route-links {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .tf-module-route-links::-webkit-scrollbar {
    display: none;
  }
  .tf-module-route-links a {
    font-size: 10px;
    padding: 3px 8px;
  }

  .tf-opp-preview {
    width: 100%;
    max-width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    border-radius: var(--r, 14px) var(--r, 14px) 0 0;
    max-height: 80vh;
    overflow-y: auto;
  }
  .tf-opp-preview-header {
    padding: 14px 16px 10px;
  }
  .tf-opp-preview-section {
    padding: 10px 16px;
  }
  .tf-opp-preview-grid {
    padding: 10px 16px;
    grid-template-columns: 1fr 1fr;
  }
  .tf-opp-preview-actions {
    padding: 10px 16px;
    position: sticky;
    bottom: 0;
    background: rgba(46, 49, 54, 0.98);
  }

  .tf-ops-tool-card {
    padding: 14px;
  }
  .tf-ops-tool-card-title {
    font-size: 14px;
  }
  .tf-ops-tool-card-desc {
    font-size: 12px;
  }
  .tf-ops-tool-card-meta {
    flex-wrap: wrap;
    gap: 8px;
  }

  .tf-continuity-link {
    width: 100%;
    justify-content: space-between;
    padding: 12px 16px;
  }
}
