/* ── Old Header (hidden — replaced by Constellation Bar) ── */
header { display: none !important; }

/* ── Constellation Bar ─────────────────────── */
.cbar {
  background: var(--card-bg, #fffdf8);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}
.cbar--hidden { display: none; }

.cbar__row1 {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 44px;
}

.cbar__phase-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.cbar__phase-icon--intake { color: var(--accent); animation: cbar-pulse 2s ease infinite; }
.cbar__phase-icon--outreach { color: var(--accent); animation: cbar-send 1.5s ease infinite; }
.cbar__phase-icon--matching { color: var(--gold); animation: cbar-pulse 2s ease infinite; }
.cbar__phase-icon--avatar {
  width: 28px; height: 28px; border-radius: 50%;
  overflow: hidden; font-size: 11px; font-weight: 600;
  background: var(--chip-bg); color: var(--text);
}
.cbar__phase-icon--avatar img { width: 100%; height: 100%; object-fit: cover; }

.cbar__primary {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.cbar__context {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  overflow-x: auto;
  max-width: 50%;
  scrollbar-width: none;
}
.cbar__context::-webkit-scrollbar { display: none; }

/* Category pills (intake mode) */
.cbar__pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: transparent;
}
.cbar__pill--complete { background: #e8f5e9; border-color: #4caf50; color: #2e7d32; }
.cbar__pill--active { border-color: var(--accent); color: var(--accent); border-width: 2px; }
.cbar__pill--pending { color: var(--text-muted); border-style: dashed; }

/* Deal phase badges (job mode) */
.cbar__deal-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.cbar__deal-badge--scoping { background: var(--chip-bg); color: var(--text-muted); }
.cbar__deal-badge--quote { background: var(--gold-light); color: #8B6914; }
.cbar__deal-badge--payment { background: #e8f5e9; color: #2e7d32; }
.cbar__deal-badge--booked { background: var(--gold-light); color: #8B6914; }

.cbar__financial {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.cbar__summary-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; font-size: 14px; color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.2s ease, background 0.15s;
}
.cbar__summary-btn:hover { background: var(--chip-bg); }
.cbar__summary-btn--open { transform: rotate(180deg); }

/* Step progress bar (journey phases: Brief → Match → Book) */
.cbar__step-bar {
  display: flex;
  align-items: center;
  padding: 6px 16px;
  gap: 0;
}
.cbar__step-bar--hidden { display: none; }

.cbar__step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-muted);
}
.cbar__step--complete { color: #2e7d32; }
.cbar__step--active { color: var(--accent); font-weight: 600; }
.cbar__step--pending { opacity: 0.5; }

.cbar__step-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  background: transparent;
}
.cbar__step--complete .cbar__step-circle {
  background: #e8f5e9;
  border-color: #4caf50;
  color: #2e7d32;
}
.cbar__step--active .cbar__step-circle {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.cbar__step-connector {
  flex: 1;
  height: 2px;
  min-width: 20px;
  background: var(--border);
  margin: 0 4px;
}
.cbar__step-connector--done {
  background: #4caf50;
}

/* Progress strip (intake only) */
.cbar__progress-strip {
  height: 6px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
}
.cbar__progress-strip--hidden { display: none; }
.cbar__progress-fill-track {
  height: 3px;
  background: var(--chip-bg);
  border-radius: 2px;
  flex: 1;
  position: relative;
  overflow: hidden;
}
.cbar__progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}
.cbar__progress-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Row 2: Provider tabs (multi-job only) */
.cbar__row2 {
  display: flex;
  overflow-x: auto;
  border-top: 1px solid var(--border);
  height: 40px;
  scrollbar-width: none;
}
.cbar__row2::-webkit-scrollbar { display: none; }
.cbar__row2.hidden { display: none; }

.cbar__tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  white-space: nowrap;
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
  font-family: inherit;
}
.cbar__tab--active {
  border-bottom-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}
.cbar__tab-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  overflow: hidden; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--chip-bg); flex-shrink: 0;
}
.cbar__tab-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cbar__tab-phase {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--chip-bg);
  color: var(--text-muted);
}

/* ── Summary Panel (slide-down) ────────────── */
.summary-panel {
  overflow: hidden;
  transition: max-height 0.25s ease-out;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.summary-panel__inner {
  padding: 16px 20px;
  max-height: 55vh;
  overflow-y: auto;
}

.sp-section { margin-bottom: 16px; }
.sp-section:last-child { margin-bottom: 0; }
.sp-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.sp-section-status {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 8px;
}
.sp-section-status--complete { background: #e8f5e9; color: #2e7d32; }
.sp-section-status--active { background: var(--gold-light); color: #8B6914; }
.sp-section-status--pending { background: var(--chip-bg); color: var(--text-muted); }
.sp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}
.sp-item-label { color: var(--text-muted); }
.sp-item-value { font-weight: 500; word-break: break-word; text-align: right; max-width: 60%; }
.sp-item-needed {
  color: var(--text-muted);
  font-style: italic;
  font-size: 12px;
  padding: 2px 0;
}
.sp-item-edit {
  width: 24px; height: 24px; border: none; background: none; cursor: pointer;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px; flex-shrink: 0; margin-left: 4px;
}
.sp-item-edit:hover { background: var(--chip-bg); color: var(--accent); }

.sp-estimate {
  padding: 8px 12px;
  background: var(--chip-bg);
  border-radius: var(--radius);
  margin-top: 8px;
}
.sp-estimate-value { font-size: 18px; font-weight: 700; color: var(--primary); }
.sp-estimate-note { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sp-provider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
}
.sp-provider-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.sp-provider-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.sp-provider-info { flex: 1; min-width: 0; }
.sp-provider-name { font-weight: 600; }
.sp-provider-detail { font-size: 12px; color: var(--text-muted); }
.sp-contact-row { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.sp-deal-track {
  display: flex;
  gap: 2px;
  margin: 8px 0;
  align-items: center;
}
.sp-deal-step {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--chip-bg);
}
.sp-deal-step--done { background: var(--accent); }
.sp-deal-step--current { background: var(--gold); }
.sp-deal-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-muted);
}

/* Mobile overrides */
@media (max-width: 480px) {
  .cbar__row1 { padding: 0 12px; }
  .cbar__primary { font-size: 13px; }
  .cbar__context { max-width: 35%; }
  .cbar__pill { font-size: 10px; padding: 2px 7px; }
  .cbar__progress-strip { padding: 0 12px; }
  .cbar__step-bar { padding: 4px 12px; }
  .cbar__step-label { display: none; }
  .summary-panel__inner { padding: 12px 14px; }
}

@keyframes cbar-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes cbar-send {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(3px); }
}

/* ── Main Layout ────────────────────────────── */
.layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ── Chat Area ──────────────────────────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 20px 80px 20px;
  /* Extra bottom padding for input bar clearance */
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.agent {
  align-self: flex-start;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg.system {
  align-self: center;
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
}

.msg.error {
  align-self: center;
  background: var(--error-bg);
  color: var(--error-text);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
}
