/**
 * PR339 — Lily Cash Flow Prediction Engine
 * TradeRail Field Portal — Cash Flow Panel Styles
 * TradeRail orange: #FF6B00
 * Lily bar: border-left 4px solid #7C3AED, background #f5f0ff
 */

/* ── Main Container ──────────────────────────────────────────────────────── */
.cash-flow-panel {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  background: #ffffff;
  color: #1a1a1a;
}

/* ── Lily Insight Bar ────────────────────────────────────────────────────── */
.lily-insight-bar {
  border-left: 4px solid #7C3AED;
  background: #f5f0ff;
  padding: 14px 18px;
  margin-bottom: 24px;
  border-radius: 0 6px 6px 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.lily-insight-label {
  font-weight: 700;
  color: #7C3AED;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  min-width: 130px;
}

.lily-insight-message {
  font-size: 14px;
  color: #3d2a6e;
  line-height: 1.5;
}

.lily-insight-bar.tier-healthy .lily-insight-label { color: #16a34a; }
.lily-insight-bar.tier-healthy { border-left-color: #16a34a; background: #f0fdf4; }
.lily-insight-bar.tier-watch .lily-insight-label { color: #d97706; }
.lily-insight-bar.tier-watch { border-left-color: #d97706; background: #fffbeb; }
.lily-insight-bar.tier-risk .lily-insight-label { color: #FF6B00; }
.lily-insight-bar.tier-risk { border-left-color: #FF6B00; background: #fff7f0; }
.lily-insight-bar.tier-critical .lily-insight-label { color: #dc2626; }
.lily-insight-bar.tier-critical { border-left-color: #dc2626; background: #fef2f2; }

/* ── Section Titles ──────────────────────────────────────────────────────── */
.section-title {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid #f0f0f0;
}

/* ── Scenario Rows ───────────────────────────────────────────────────────── */
.scenario-rows {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.scenario-best {
  font-size: 13px;
  color: #16a34a;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 4px;
  padding: 6px 12px;
  font-weight: 600;
}

.scenario-likely {
  font-size: 13px;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 6px 12px;
  font-weight: 600;
}

/* ── Forecast Chart ──────────────────────────────────────────────────────── */
.forecast-section {
  margin-bottom: 32px;
}

.forecast-chart {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  overflow-x: auto;
  padding: 12px 4px 8px;
  background: #fafafa;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  min-height: 140px;
}

/* ── Week Bars ───────────────────────────────────────────────────────────── */
.forecast-week-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  flex: 1;
  padding: 8px 4px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  position: relative;
}

.forecast-week-bar.gap-week {
  background: #fff3e0;
  border-color: #FF6B00;
}

.week-label {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.bar-container {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  height: 90px;
  width: 100%;
  justify-content: center;
}

.bar-inflow {
  width: 18px;
  background: #16a34a;
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  transition: height 0.3s ease;
}

.bar-outflow {
  width: 18px;
  background: #dc2626;
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  transition: height 0.3s ease;
}

.bar-role-gated {
  color: #9ca3af;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  width: 100%;
}

.bar-net {
  font-size: 10px;
  color: #6b7280;
  margin-top: 4px;
  text-align: center;
}

.gap-badge {
  font-size: 10px;
  font-weight: 800;
  color: #ffffff;
  background: #FF6B00;
  border-radius: 3px;
  padding: 2px 5px;
  margin-top: 4px;
  letter-spacing: 0.05em;
}

/* ── Heat Map ────────────────────────────────────────────────────────────── */
.heat-map-section {
  margin-bottom: 32px;
}

.heat-map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.heat-map-card {
  padding: 16px;
  border-radius: 8px;
  border: 2px solid #e5e7eb;
  background: #ffffff;
  position: relative;
}

.heat-map-card.status-green {
  border-color: #16a34a;
  background: #f0fdf4;
}

.heat-map-card.status-yellow {
  border-color: #d97706;
  background: #fffbeb;
}

.heat-map-card.status-red {
  border-color: #dc2626;
  background: #fef2f2;
}

.status-green { color: #16a34a; }
.status-yellow { color: #d97706; }
.status-red { color: #dc2626; }

.hm-project-id {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hm-project-name {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 8px;
  line-height: 1.3;
}

.hm-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-bottom: 8px;
}

.hm-status-dot.status-green { background: #16a34a; }
.hm-status-dot.status-yellow { background: #d97706; }
.hm-status-dot.status-red { background: #dc2626; }

.hm-risk-note {
  font-size: 12px;
  color: #4b5563;
  margin-bottom: 8px;
  line-height: 1.4;
}

.hm-ar {
  font-size: 12px;
  color: #374151;
  margin-bottom: 8px;
  font-weight: 600;
}

.hm-action-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: #FF6B00;
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
}

.hm-action-link:hover {
  border-bottom-color: #FF6B00;
}

/* ── Action List ─────────────────────────────────────────────────────────── */
.action-section {
  margin-bottom: 32px;
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.action-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  transition: border-color 0.2s;
}

.action-item:hover {
  border-color: #FF6B00;
}

.action-item[data-priority="1"] {
  border-left: 4px solid #dc2626;
}

.action-item[data-priority="2"] {
  border-left: 4px solid #d97706;
}

.action-item[data-priority="3"] {
  border-left: 4px solid #2563eb;
}

.action-priority {
  font-size: 13px;
  font-weight: 800;
  color: #6b7280;
  min-width: 28px;
  text-align: center;
  padding-top: 2px;
}

.action-content {
  flex: 1;
  min-width: 0;
}

.action-title {
  font-size: 14px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.action-desc {
  font-size: 13px;
  color: #4b5563;
  line-height: 1.5;
  margin-bottom: 6px;
}

.action-impact {
  font-size: 12px;
  color: #16a34a;
  font-weight: 700;
}

.action-cta-btn {
  background: #FF6B00;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.action-cta-btn:hover {
  background: #e05e00;
}

.action-cta-btn[data-confirmed="true"] {
  background: #dc2626;
}

/* ── Refresh Button ──────────────────────────────────────────────────────── */
.refresh-section {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.refresh-btn {
  background: #FF6B00;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.refresh-btn:hover {
  background: #e05e00;
}

.refresh-btn[data-confirmed="true"] {
  background: #dc2626;
}

/* ── Role Gating: dollar amounts hidden for field_tech and foreman ─────── */
body.role-field-tech .dollar-amount,
body.role-foreman .dollar-amount {
  display: none;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .cash-flow-panel {
    padding: 12px;
  }

  .heat-map-grid {
    grid-template-columns: 1fr 1fr;
  }

  .scenario-rows {
    flex-direction: column;
  }

  .action-item {
    flex-direction: column;
    gap: 10px;
  }

  .action-cta-btn {
    width: 100%;
    text-align: center;
  }

  .forecast-chart {
    gap: 4px;
  }

  .forecast-week-bar {
    min-width: 56px;
  }
}
