/* ============================================
   06-dealroom.css — Rooms list, chat, escrow sidebar
   ============================================ */

/* ---------- ROLE TOGGLE (create form) ---------- */
.role-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.role-opt {
  padding: var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  text-align: center;
}

.role-opt:hover {
  border-color: var(--border-2);
}

.role-opt i {
  font-size: 24px;
  display: block;
  margin-bottom: 5px;
  color: var(--muted-2);
}

.role-opt h5 {
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--text);
}

.role-opt p {
  font-size: var(--fs-xs);
  color: var(--muted);
}

.role-opt.on.buyer {
  border-color: var(--blue);
  background: rgba(59, 130, 246, 0.06);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.role-opt.on.buyer i { color: var(--blue); }

.role-opt.on.seller {
  border-color: var(--accent);
  background: rgba(16, 185, 129, 0.06);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.role-opt.on.seller i { color: var(--accent); }

/* ---------- FEE PREVIEW ---------- */
.fee-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-4);
  margin: var(--space-4) 0;
}

.fee-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: var(--fs-sm);
  color: var(--muted-2);
}

.fee-row span:last-child {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text);
}

.fee-row.fee-total {
  padding-top: var(--space-3);
  margin-top: 5px;
  border-top: 1px dashed var(--border-2);
  font-weight: 600;
  color: var(--text);
}

.fee-row.fee-total span:last-child {
  color: var(--accent);
}

/* ---------- DEAL ROOMS GRID (list page) ---------- */
.deal-rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-4);
}

.deal-room-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  cursor: pointer;
  transition: all var(--t-base);
}

.deal-room-card:hover {
  border-color: var(--border-3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.deal-room-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.deal-room-id {
  font-family: 'IBM Plex Mono', monospace;
  font-size: var(--fs-xs);
  color: #4338ca;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.deal-room-title {
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: var(--space-3);
  line-height: 1.4;
  color: var(--text);
}

.deal-room-parties {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.dr-mini-av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  border: 1.5px solid var(--surface);
}

.dr-mini-av.b { background: linear-gradient(135deg, #3b82f6, #1d4ed8); margin-left: -6px; }
.dr-mini-av.s { background: linear-gradient(135deg, #10b981, #0891b2); margin-left: -6px; }
.dr-mini-av.d { background: linear-gradient(135deg, #a855f7, #7e22ce); margin-left: -6px; }

.deal-room-parties .dr-mini-av:first-child { margin-left: 0; }

.deal-room-amount {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.deal-room-amount .v {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--accent);
  font-family: 'IBM Plex Mono', monospace;
}

.deal-room-amount .l {
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* ---------- DEAL CHAT PAGE ---------- */
.deal-page {
  position: relative;
  z-index: 2;
  display: none;
  height: calc(100vh - 64px);
  max-width: 1280px;
  margin: 0 auto;
}

.deal-page.active {
  display: block;
}

.deal-chat-wrap {
  display: grid;
  grid-template-columns: 1fr 340px;
  height: 100%;
  background: var(--bg);
}

/* Chat main */
.chat-main {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-2);
  min-height: 0;
}

.chat-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-2);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  min-height: 64px;
}

.chat-header-info { flex: 1; min-width: 0; }

.chat-deal-id {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: #4338ca;
  font-weight: 700;
  margin-bottom: 2px;
  letter-spacing: 0.5px;
}

.chat-deal-title {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text);
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.chat-parties {
  display: flex;
  align-items: center;
}

.chat-parties .av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  border: 2px solid var(--surface);
  margin-left: -8px;
}

.chat-parties .av:first-child { margin-left: 0; }
.chat-parties .av.b { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.chat-parties .av.s { background: linear-gradient(135deg, #10b981, #0891b2); }
.chat-parties .av.d { background: linear-gradient(135deg, #a855f7, #7e22ce); }

/* Chat body */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--bg);
}

.system-msg {
  align-self: center;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: var(--r-sm);
  padding: 7px 13px;
  font-size: var(--fs-xs);
  color: var(--purple-text);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 85%;
  text-align: center;
}

.system-msg i { font-size: 13px; }

.msg {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
  max-width: 75%;
}

.msg.me {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 1.5px solid var(--surface);
}

.msg-av.b { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.msg-av.s { background: linear-gradient(135deg, #10b981, #0891b2); }
.msg-av.d { background: linear-gradient(135deg, #a855f7, #7e22ce); }

.msg-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.msg.me .msg-content {
  align-items: flex-end;
}

.msg-name {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  padding: 0 5px;
}

.msg-name.dealer {
  color: var(--purple-text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.msg-name.dealer i { font-size: 10px; }

.msg-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 14px;
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text);
}

.msg.me .msg-bubble {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.25);
  border-bottom-right-radius: 3px;
}

.msg-bubble.dealer {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.25);
  border-bottom-left-radius: 3px;
}

.msg-bubble.seller {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.2);
  border-bottom-left-radius: 3px;
}

.msg-time {
  font-size: 9px;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  padding: 0 5px;
}

/* Chat footer */
.chat-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-2);
  background: var(--surface);
  flex-shrink: 0;
}

.chat-quick-actions {
  display: flex;
  gap: 5px;
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.qa-btn {
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted-2);
  transition: all var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.qa-btn:hover {
  border-color: var(--border-3);
  color: var(--text);
}

.qa-btn i { font-size: 13px; }

.qa-btn.qa-success:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.qa-btn.qa-danger:hover {
  border-color: var(--red);
  color: var(--red);
}

.chat-input-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.chat-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 0 var(--space-4);
  height: 40px;
  color: var(--text);
  font-size: var(--fs-sm);
  outline: none;
}

.chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.chat-send {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: all var(--t-fast);
}

.chat-send:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* ---------- ESCROW SIDEBAR ---------- */
.escrow-sidebar {
  background: var(--bg);
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.es-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: var(--space-4);
}

.es-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: var(--space-3);
}

.es-amount {
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: -1px;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.es-amount small {
  font-size: var(--fs-sm);
  color: var(--muted);
  font-weight: 500;
}

.es-status-row {
  display: flex;
  gap: 5px;
  margin-top: var(--space-3);
  flex-wrap: wrap;
}

.es-badge {
  font-size: 10px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-weight: 600;
}

.es-bdg-blue   { background: var(--blue-soft);   color: var(--blue-text);   border: 1px solid rgba(59, 130, 246, 0.2); }
.es-bdg-purple { background: var(--purple-soft); color: var(--purple-text); border: 1px solid rgba(168, 85, 247, 0.2); }
.es-bdg-green  { background: var(--accent-soft); color: var(--accent-text); border: 1px solid rgba(16, 185, 129, 0.2); }
.es-bdg-red    { background: var(--red-soft);    color: var(--red-text);    border: 1px solid rgba(239, 68, 68, 0.2); }

.es-progress {
  margin-top: var(--space-4);
}

.es-progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 5px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
}

.es-progress-bar {
  height: 5px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
}

.es-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  border-radius: var(--r-full);
  transition: width 0.5s;
}

.milestones {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.milestone {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  transition: all var(--t-fast);
}

.milestone.done {
  border-color: rgba(16, 185, 129, 0.2);
  background: rgba(16, 185, 129, 0.05);
}

.milestone.active {
  border-color: rgba(59, 130, 246, 0.25);
  background: rgba(59, 130, 246, 0.05);
}

.ms-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ms-dot.done    { background: var(--accent); }
.ms-dot.active  { background: var(--blue); animation: ms-pulse 1.2s infinite; }
.ms-dot.pending { background: var(--border-3); }

@keyframes ms-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.3); }
}

.ms-text {
  font-size: var(--fs-xs);
  flex: 1;
  font-weight: 500;
  color: var(--text);
}

.ms-text.muted {
  color: var(--muted);
  font-weight: 400;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted-2);
}

.breakdown-row:last-child {
  border-bottom: none;
}

.breakdown-row.breakdown-total {
  font-size: var(--fs-sm);
  font-weight: 600;
  padding-top: var(--space-2);
  color: var(--text);
  border-bottom: none;
}

.fee-amber { color: var(--amber); }
.fee-green { color: var(--accent); }
