/* Blend Demo Styles - Table-based allocation view */

/* ============================================
   Blend Demo Container
   ============================================ */

.blend-demo {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 500px;
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  background: var(--sd-background);
  border-radius: 0 0 10px 10px;
  overflow: hidden;
}

.blend-demo * {
  font-family: inherit;
}

/* ============================================
   Table Container
   ============================================ */

.blend-table-container {
  flex: 1;
  overflow: auto;
  background: var(--sd-background);
  padding: 0;
}

/* ============================================
   Blend Table
   ============================================ */

.blend-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

.blend-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--sd-muted);
}

.blend-table th {
  padding: 10px 8px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--sd-soft-foreground);
  border-bottom: 2px solid var(--sd-border);
  white-space: nowrap;
}

.blend-table th.col-week {
  width: 70px;
}

.blend-table th.col-vessel {
  width: 140px;
}

.blend-table th.col-qty {
  width: 70px;
  text-align: right;
}

.blend-table th.col-silica {
  width: 70px;
  text-align: right;
}

.blend-table th.col-margin {
  width: 70px;
  text-align: right;
}

.blend-table th.col-alloc {
  width: 80px;
  text-align: right;
}

.blend-table th.col-total {
  width: 70px;
  text-align: right;
  border-left: 2px solid var(--sd-border);
}

/* ============================================
   Table Body
   ============================================ */

.blend-table tbody tr {
  transition: background-color 0.15s ease;
}

.blend-table tbody tr:hover {
  background-color: var(--sd-muted);
}

.blend-table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--sd-border);
  vertical-align: middle;
}

.blend-table td.col-week {
  font-weight: 500;
  color: var(--sd-soft-foreground);
}

.blend-table td.col-vessel {
  font-weight: 600;
  color: var(--sd-foreground);
}

.blend-table td.col-qty {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.blend-table td.col-silica {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.blend-table td.col-margin {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.blend-table td.col-alloc {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.blend-table td.col-total {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-left: 2px solid var(--sd-border);
}

/* ============================================
   Cell Status Colors
   ============================================ */

.blend-table td.cell-good {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.blend-table td.cell-warning {
  background-color: #fff3e0;
  color: #e65100;
}

.blend-table td.cell-bad {
  background-color: #ffebee;
  color: #c62828;
}

/* ============================================
   Demurrage Cost Styling
   ============================================ */

.outcome-value.demurrage-high {
  color: #c62828 !important;
}

.outcome-value.demurrage-low {
  color: #238551 !important;
}

/* ============================================
   Row Grouping (Week headers)
   ============================================ */

.blend-table tr.week-header td {
  background-color: var(--sd-muted);
  font-weight: 700;
  padding: 8px;
  border-top: 2px solid var(--sd-border);
}

/* ============================================
   Demo Toggle (in topbar)
   ============================================ */

/* Toolbar optimize button - hidden on desktop, shown on mobile */
.blend-demo .toolbar-optimize-btn {
  display: none;
}

.demo-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.demo-label {
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.4);
}

/* Responsive text: show full name on desktop, short name on mobile */
.demo-text-mobile {
  display: none;
}

.demo-text-desktop {
  display: inline;
}

@media (max-width: 768px) {
  .demo-label {
    display: none;
  }
}

/* When window dots are hidden, move toggle to the left */
@media (max-width: 500px) {
  .demo-toggle-wrapper {
    margin-left: 0;
    margin-right: auto;
  }
}

.demo-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  padding: 3px;
}

.demo-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: rgba(0, 0, 0, 0.4);
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.demo-toggle-btn:hover {
  color: rgba(0, 0, 0, 0.7);
  background: rgba(255, 255, 255, 0.5);
}

.demo-toggle-btn.active {
  background: #ffffff;
  color: #0a0a0a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Responsive Adjustments
   ============================================ */

/* ============================================
   Mobile / Simplified Layout (< 900px)
   ============================================ */

@media (max-width: 900px) {
  /* Hide workflow sections (Graph, Inputs, Plan, Outcomes) */
  .blend-demo .workflow-sections {
    display: none;
  }

  /* Hide avatar stack on mobile */
  .blend-demo .avatar-stack {
    display: none;
  }

  /* Compact toolbar */
  .blend-demo .schedule-toolbar {
    height: 40px;
    padding: 0 8px;
  }

  .blend-demo .toolbar-dropdown {
    font-size: 12px;
    padding: 4px 6px;
  }

  /* Show optimize button in toolbar on mobile */
  .blend-demo .toolbar-optimize-btn {
    display: inline-flex;
  }

  /* Hide optimize button in subheader on mobile */
  .blend-demo .schedule-subheader > .optimize-btn {
    display: none;
  }

  /* Subheader: fixed height, tabs only */
  .blend-demo .schedule-subheader {
    height: 40px;
    padding: 0 12px;
    gap: 8px;
    flex-shrink: 0;
  }

  .blend-demo .subheader-tabs {
    flex: 1;
    height: 100%;
  }

  .blend-demo .subheader-tab {
    padding: 0 10px;
    font-size: 12px;
  }

  .blend-demo .subheader-spacer {
    display: none;
  }

  /* Hide metrics from subheader on mobile (they move to bottom bar) */
  .blend-demo .schedule-subheader .subheader-metrics {
    display: none;
  }

  /* Table adjustments */
  .blend-table {
    font-size: 11px;
    min-width: 500px; /* Prevent columns from smushing on narrow screens */
  }

  /* Hide quantity (3rd col) and target S (4th col) on mobile, keep Est S (5th col) */
  .blend-table th:nth-child(3),
  .blend-table td:nth-child(3),
  .blend-table th:nth-child(4),
  .blend-table td:nth-child(4) {
    display: none;
  }

  .blend-table th,
  .blend-table td {
    padding: 8px 6px;
  }

  .blend-table th {
    font-size: 10px;
  }

  .blend-table th.col-vessel {
    width: 100px;
  }

  .blend-table th.col-alloc,
  .blend-table td.col-alloc {
    width: 70px;
    min-width: 70px; /* Ensure supplier columns don't get compressed */
  }

  /* Operator panel */
  .blend-demo .operator-panel {
    width: 32px;
  }

  .blend-demo .operator-icon {
    width: 14px;
    height: 14px;
  }

  .blend-demo .operator-label {
    font-size: 9px;
  }
}

/* ============================================
   Mobile Bottom Bar (shared with schedule-demo)
   ============================================ */

.blend-demo .mobile-bottom-bar {
  display: none;
}

@media (max-width: 900px) {
  .blend-demo .mobile-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 36px;
    padding: 0 10px;
    background: var(--sd-background);
    border-top: 1px solid var(--sd-border);
    flex-shrink: 0;
    gap: 8px;
  }

  .blend-demo .mobile-bottom-bar .subheader-metrics {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
  }

  .blend-demo .mobile-bottom-bar .outcome-card {
    padding: 3px 6px;
    min-width: 0;
    gap: 4px;
    flex-shrink: 0;
  }

  .blend-demo .mobile-bottom-bar .outcome-label {
    font-size: 8px;
    white-space: nowrap;
  }

  .blend-demo .mobile-bottom-bar .outcome-value {
    font-size: 11px;
  }

  /* Hide optimize button from bottom bar (stays in subheader) */
  .blend-demo .mobile-bottom-bar .optimize-btn {
    display: none;
  }
}
