/* InvitedIn Prototype — Styles
   Thinking environment, not a chat app. */

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

:root {
  --bg: #FAF8F4;
  --ink: #1A1A1A;
  --secondary: #6B6258;
  --accent: #4F5B93;
  --amber: #B8956A;
  --border: #D6CFC4;
  --consumer-bg: #EFEAE4;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-reading: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#root { height: 100%; }

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 740px;
  margin: 0 auto;
}

/* ── Top bar ───────────────────────────────────────── */

.top-bar {
  flex-shrink: 0;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.top-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.logo {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  user-select: none;
}

.top-bar-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  user-select: none;
  transition: color 0.4s ease;
}

.state-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.state-badge.pulse .state-dot {
  animation: dotPulse 0.5s ease;
}

@keyframes dotPulse {
  0%   { transform: scale(1); }
  35%  { transform: scale(2.2); }
  100% { transform: scale(1); }
}

.reset-btn {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--secondary);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: color 0.2s, border-color 0.2s;
  user-select: none;
}

.reset-btn:hover {
  color: var(--ink);
  border-color: var(--secondary);
}

.scenario-tabs {
  display: flex;
  gap: 6px;
}

.scenario-tab {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--secondary);
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
}

.scenario-tab:hover {
  color: var(--ink);
  background: rgba(107, 98, 88, 0.04);
}

.scenario-tab.active {
  color: var(--ink);
  border-color: var(--border);
  background: rgba(79, 91, 147, 0.04);
}

/* ── Conversation surface ──────────────────────────── */

.conversation {
  flex: 1;
  overflow-y: auto;
  padding: 36px 24px 48px;
}

.conversation::-webkit-scrollbar {
  width: 3px;
}

.conversation::-webkit-scrollbar-track {
  background: transparent;
}

.conversation::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.message {
  margin-bottom: 28px;
  animation: messageIn 300ms ease-out both;
}

.message:last-child {
  margin-bottom: 0;
}

/* AI messages — left-aligned, serif, reading column */

.message-ai {
  max-width: 560px;
}

.message-ai p {
  font-family: var(--font-reading);
  font-size: 16px;
  line-height: 1.72;
  color: var(--ink);
  margin-bottom: 14px;
}

.message-ai p:last-child {
  margin-bottom: 0;
}

.message-ai strong {
  font-weight: 600;
}

/* Consumer messages — right-aligned, soft bubble */

.message-consumer {
  display: flex;
  justify-content: flex-end;
}

.consumer-bubble {
  max-width: 480px;
  background: var(--consumer-bg);
  border-radius: 16px 16px 4px 16px;
  padding: 14px 18px;
}

.consumer-bubble p {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  margin: 0;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.scroll-anchor {
  height: 1px;
}

/* ── Bottom bar ────────────────────────────────────── */

.bottom-bar {
  flex-shrink: 0;
  padding: 16px 24px 28px;
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--border);
}

.continue-btn {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 12px 56px;
  cursor: pointer;
  transition: opacity 0.15s;
  user-select: none;
}

.continue-btn:hover:not(:disabled) {
  opacity: 0.88;
}

.continue-btn:active:not(:disabled) {
  opacity: 0.76;
}

.continue-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.complete-state {
  display: flex;
  align-items: center;
  gap: 12px;
}

.complete-label {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--secondary);
  letter-spacing: 0.01em;
}

.complete-hint {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--secondary);
  opacity: 0.6;
}

/* ── Layout: main + huddle split ──────────────────── */

.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.main-chat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-right 0.4s ease;
}

.main-chat.huddle-open {
  margin-right: 50%;
}

/* ── Huddle surface ───────────────────────────────── */

.huddle-surface {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  background: #F7F3EE;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.4s ease;
  z-index: 10;
}

.huddle-surface.open {
  transform: translateX(0);
}

/* ── Huddle header ────────────────────────────────── */

.huddle-header {
  flex-shrink: 0;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.huddle-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.huddle-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 6px;
}

.huddle-title {
  font-family: var(--font-reading);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  font-weight: 400;
}

.huddle-close-affordance {
  font-family: var(--font-ui);
  font-size: 18px;
  color: var(--secondary);
  background: none;
  border: none;
  cursor: default;
  opacity: 0.4;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
  margin-left: 12px;
  margin-top: 2px;
}

.huddle-participants {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.huddle-participant {
  display: flex;
  align-items: center;
  gap: 6px;
}

.participant-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  transition: box-shadow 0.3s ease;
}

.participant-avatar.consumer-avatar {
  background: var(--accent);
}

.participant-avatar.human-avatar {
  background: #7B8F6B;
}

.participant-avatar.professional-avatar {
  background: var(--amber);
}

.participant-avatar.highlight {
  box-shadow: 0 0 0 3px rgba(184, 149, 106, 0.5);
  animation: avatarHighlight 1s ease forwards;
}

@keyframes avatarHighlight {
  0%   { box-shadow: 0 0 0 3px rgba(184, 149, 106, 0.5); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

.participant-name {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--secondary);
}

.participant-role {
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--secondary);
  opacity: 0.7;
}

/* ── Scoped context panel ─────────────────────────── */

.scoped-context {
  flex-shrink: 0;
  margin: 0 16px;
  padding: 14px 16px;
  background: #F0EBE3;
  border: 1px solid #DDD5C9;
  border-radius: 8px;
  margin-top: 16px;
}

.scoped-context-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--secondary);
  margin-bottom: 8px;
}

.scoped-context-list {
  list-style: none;
  padding: 0;
}

.scoped-context-list li {
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink);
  padding-left: 14px;
  position: relative;
  margin-bottom: 3px;
}

.scoped-context-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--amber);
}

/* ── Huddle conversation ──────────────────────────── */

.huddle-conversation {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 24px;
}

.huddle-conversation::-webkit-scrollbar {
  width: 3px;
}

.huddle-conversation::-webkit-scrollbar-track {
  background: transparent;
}

.huddle-conversation::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.huddle-msg {
  margin-bottom: 20px;
  animation: messageIn 300ms ease-out both;
}

.huddle-msg:last-child {
  margin-bottom: 0;
}

.huddle-msg-sender {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.huddle-msg-sender .sender-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.huddle-msg-sender.sender-ai {
  color: var(--secondary);
}

.huddle-msg-sender.sender-ai .sender-dot {
  background: var(--accent);
}

.huddle-msg-sender.sender-consumer {
  color: var(--accent);
}

.huddle-msg-sender.sender-consumer .sender-dot {
  background: var(--accent);
}

.huddle-msg-sender.sender-human {
  color: #7B8F6B;
}

.huddle-msg-sender.sender-human .sender-dot {
  background: #7B8F6B;
}

.huddle-msg-sender.sender-professional {
  color: var(--amber);
}

.huddle-msg-sender.sender-professional .sender-dot {
  background: var(--amber);
}

.huddle-msg-body p {
  font-family: var(--font-reading);
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
  margin-bottom: 10px;
}

.huddle-msg-body p:last-child {
  margin-bottom: 0;
}

/* ── Huddle-closed inline note ────────────────────── */

.huddle-closed-note {
  margin-bottom: 28px;
  padding: 10px 16px;
  background: #F0EBE3;
  border-left: 3px solid var(--amber);
  border-radius: 0 6px 6px 0;
  animation: messageIn 300ms ease-out both;
}

.huddle-closed-note p {
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.5;
  color: var(--secondary);
  margin: 0;
}

/* ── Project Timer (below nav bar) ───────────────── */

.project-timer {
  flex-shrink: 0;
  height: 4px;
  background: var(--border);
  position: relative;
  cursor: default;
}

.project-timer-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.6s ease;
}

.project-timer-fill.past-target {
  background: #9B9BAA;
}

.project-timer-popover {
  display: none;
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  white-space: nowrap;
  z-index: 20;
}

.project-timer:hover .project-timer-popover {
  display: block;
}

.project-timer-popover-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--secondary);
  margin-bottom: 2px;
}

.project-timer-popover-detail {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink);
}

/* ── Huddle Timer (in huddle header) ─────────────── */

.huddle-timer {
  height: 4px;
  background: #DDD5C9;
  border-radius: 2px;
  margin-top: 12px;
  position: relative;
  cursor: default;
}

.huddle-timer-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--amber);
  transition: width 0.6s ease;
}

.huddle-timer-fill.past-target {
  background: #A8A098;
}

.huddle-timer-popover {
  display: none;
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  white-space: nowrap;
  z-index: 20;
}

.huddle-timer:hover .huddle-timer-popover {
  display: block;
}

.huddle-timer-popover-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--secondary);
  margin-bottom: 2px;
}

.huddle-timer-popover-detail {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink);
}

/* ── State badge: pressure states ────────────────── */

.state-badge.pressure .state-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 91, 147, 0.2);
  animation: pressurePulse 2s ease-in-out infinite;
}

@keyframes pressurePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(79, 91, 147, 0.15); }
  50%      { box-shadow: 0 0 0 5px rgba(79, 91, 147, 0.3); }
}

.state-badge.pressure {
  color: var(--accent);
  font-weight: 600;
}

/* ── Escalation panel (inline, after AI message) ─── */

.escalation-panel {
  max-width: 560px;
  margin-bottom: 28px;
  padding: 20px 22px;
  background: #F0EBE3;
  border: 1px solid #DDD5C9;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  animation: messageIn 300ms ease-out both;
}

.escalation-panel-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.escalation-panel-reason {
  font-family: var(--font-reading);
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
  margin-bottom: 14px;
}

.escalation-panel-prepared {
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.5;
  color: var(--secondary);
  padding-left: 14px;
  position: relative;
  margin-bottom: 16px;
}

.escalation-panel-prepared::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.escalation-panel-actions {
  display: flex;
  gap: 10px;
}

.escalation-action-primary {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  cursor: default;
  letter-spacing: 0.01em;
}

.escalation-action-secondary {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--secondary);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 18px;
  cursor: default;
  letter-spacing: 0.01em;
}

/* ── Professional invitation note (main chat) ────── */

.escalation-note {
  margin-bottom: 28px;
  padding: 12px 16px;
  background: rgba(79, 91, 147, 0.06);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  animation: messageIn 300ms ease-out both;
}

.escalation-note p {
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.5;
  color: var(--accent);
  margin: 0;
  font-weight: 500;
}

/* ── Professional message tint in huddle ─────────── */

.huddle-msg.professional-msg {
  padding: 10px 12px;
  background: rgba(79, 91, 147, 0.04);
  border-radius: 6px;
  margin-left: -12px;
  margin-right: -12px;
  padding-left: 12px;
  padding-right: 12px;
}

/* ── Licensed credential mark ────────────────────── */

.licensed-mark {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(79, 91, 147, 0.1);
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Pro Binded mark ─────────────────────────────── */

.pro-binded-mark {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--amber);
  background: rgba(184, 149, 106, 0.12);
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Pro Binded header (above conversation) ──────── */

.pro-binded-header {
  flex-shrink: 0;
  padding: 10px 24px;
  background: rgba(184, 149, 106, 0.08);
  border-bottom: 1px solid rgba(184, 149, 106, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: messageIn 300ms ease-out both;
}

.pro-binded-header-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
}

.pro-binded-header-text {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  color: var(--amber);
  letter-spacing: 0.02em;
}

/* ── Narrow viewport: full-screen huddle ──────────── */

@media (max-width: 899px) {
  .main-chat.huddle-open {
    margin-right: 100%;
  }

  .huddle-surface {
    width: 100%;
  }

  .huddle-back-btn {
    display: inline-flex;
  }
}

@media (min-width: 900px) {
  .huddle-back-btn {
    display: none;
  }
}

.huddle-back-btn {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--secondary);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
  letter-spacing: 0.02em;
  margin-right: auto;
  margin-top: 8px;
}
