/* rootwork-ui.css
   Chat widget + MERCO callout styles for RootWork portal pages.
   Adapted from the Tipao UI pattern. Loaded after base page styles.
   Version: 20260302a
*/

/* ============================================================
   MERCO ANCHORS (inline content hooks)
   ============================================================ */
.merco-anchor {
  position: relative;
  cursor: pointer;
  border-bottom: 1px dashed rgba(56, 189, 248, 0.55);
  transition: border-color .18s;
}
.merco-anchor:hover { border-color: rgba(56, 189, 248, 0.9); }

.merco-chat-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
  cursor: pointer;
  transition: transform .18s;
}
.merco-chat-indicator:hover { transform: scale(1.2); }
.merco-chat-indicator svg {
  width: 11px; height: 11px;
  fill: currentColor;
}
.merco-chat-indicator.mentor    { background: rgba(96,165,250,.25); color: #93c5fd; }
.merco-chat-indicator.evaluator { background: rgba(74,222,128,.22); color: #86efac; }
.merco-chat-indicator.recommender { background: rgba(251,191,36,.2); color: #fde68a; }
.merco-chat-indicator.coordinator { background: rgba(251,146,60,.2); color: #fed7aa; }
.merco-chat-indicator.optimizer  { background: rgba(167,139,250,.2); color: #ddd6fe; }

/* ============================================================
   MERCO CALLOUT BOXES (in-content role components)
   ============================================================ */
.rw-callout {
  margin: 18px 0;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  padding: 14px 16px;
  background: rgba(0,0,0,0.22);
}
.rw-callout-badge {
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  font-weight: 800; margin-bottom: 8px;
}
.rw-callout-title { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.rw-callout-body  { font-size: 13px; line-height: 1.55; opacity: .9; }
.rw-callout-cta   {
  display: inline-block; margin-top: 10px;
  font-size: 12px; font-weight: 700; cursor: pointer;
  color: var(--rw-accent, #38bdf8);
}

/* Role colours */
.rw-callout.mentor     { border-color: rgba(96,165,250,.3); }
.rw-callout.mentor .rw-callout-badge { color: #93c5fd; }
.rw-callout.evaluator  { border-color: rgba(74,222,128,.28); }
.rw-callout.evaluator .rw-callout-badge { color: #86efac; }
.rw-callout.recommender { border-color: rgba(251,191,36,.28); }
.rw-callout.recommender .rw-callout-badge { color: #fde68a; }
.rw-callout.coordinator { border-color: rgba(251,146,60,.28); }
.rw-callout.coordinator .rw-callout-badge { color: #fed7aa; }
.rw-callout.optimizer  { border-color: rgba(167,139,250,.28); }
.rw-callout.optimizer .rw-callout-badge { color: #ddd6fe; }

/* ============================================================
   FLOATING CHAT WIDGET
   ============================================================ */
:root {
  --rw-accent: #38bdf8;
  --rw-bg-panel: rgba(7, 10, 17, 0.93);
  --rw-border: rgba(255,255,255,0.12);
}

.rw-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
  font-family: Inter, system-ui, -apple-system, sans-serif;
}

/* FAB */
.rw-chat-fab {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 10px 15px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.16);
  background: linear-gradient(160deg, rgba(14,22,38,.92), rgba(8,13,24,.86));
  color: rgba(255,255,255,0.95);
  box-shadow: 0 8px 28px rgba(0,0,0,0.40);
  cursor: pointer; user-select: none;
}
.rw-chat-fab .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--rw-accent);
  box-shadow: 0 0 0 4px rgba(56,189,248,0.20);
  animation: rwPulse 2.4s ease-in-out infinite;
}
.rw-chat-fab .label { font-size: 12px; font-weight: 800; letter-spacing: .04em; }

@keyframes rwPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(56,189,248,0.18); }
  50%       { box-shadow: 0 0 0 7px rgba(56,189,248,0.08); }
}

/* Panel */
.rw-chat-panel {
  width: min(440px, calc(100vw - 40px));
  height: min(600px, calc(100dvh - 120px));
  position: absolute; right: 0; bottom: 56px;
  border-radius: 18px;
  border: 1px solid var(--rw-border);
  background: var(--rw-bg-panel);
  backdrop-filter: blur(14px);
  box-shadow: 0 22px 64px rgba(0,0,0,0.60);
  display: none; flex-direction: column; overflow: hidden;
}
.rw-chat-panel.open { display: flex; }

/* Header */
.rw-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rw-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), transparent);
  flex-shrink: 0;
}
.rw-chat-head .left  { display: flex; flex-direction: column; gap: 2px; }
.rw-chat-head .right { display: flex; align-items: center; gap: 8px; }
.rw-chat-head .title { font-size: 13px; font-weight: 800; color: rgba(255,255,255,0.95); }
.rw-chat-head .sub   { font-size: 11px; color: rgba(255,255,255,0.62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }

.rw-iconbtn {
  height: 28px; min-width: 28px; padding: 0 9px;
  border-radius: 9px; border: 1px solid var(--rw-border);
  background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.84);
  font-size: 11px; cursor: pointer;
}
.rw-iconbtn:hover { background: rgba(255,255,255,0.12); }

/* Body (quick prompts + heatmap + thread) */
.rw-chat-body {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px; overflow: hidden; flex: 1;
}

/* Quick chips */
.rw-quick { display: flex; flex-wrap: wrap; gap: 7px; flex-shrink: 0; }
.rw-chip {
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.4);
  background: rgba(15,23,42,0.9);
  color: rgba(241,245,249,0.94);
  padding: 7px 11px; font-size: 11px; line-height: 1;
  cursor: pointer; transition: background .15s, border-color .15s, transform .15s;
}
.rw-chip:hover {
  transform: translateY(-1px);
  background: rgba(30,41,59,.95);
  border-color: rgba(56,189,248,0.5);
}

/* Heatmap */
.rw-heatmap { flex-shrink: 0; }
.rw-heatmap-card {
  border: 1px solid rgba(148,163,184,0.2);
  border-radius: 12px;
  background: radial-gradient(circle at top right, rgba(56,189,248,0.14), transparent 60%),
              linear-gradient(180deg, rgba(8,13,24,0.9), rgba(6,9,18,0.86));
  padding: 9px 10px 7px;
}
.rw-heatmap-head   { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.rw-heatmap-title  { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: rgba(186,230,253,.9); font-weight: 800; }
.rw-heatmap-score  { font-size: 10px; color: rgba(224,242,254,.8); font-weight: 700; }
.rw-heatmap-focus  { font-size: 11px; color: rgba(241,245,249,.86); margin-bottom: 6px; line-height: 1.35; }
.rw-heatmap-grid   { display: flex; flex-direction: column; gap: 5px; }
.rw-heatmap-row    { display: grid; grid-template-columns: 90px 1fr 36px; align-items: center; gap: 7px; }
.rw-heatmap-row.active .rw-heatmap-label { color: #f8fafc; }
.rw-heatmap-label  { font-size: 10px; color: rgba(203,213,225,.88); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rw-heatmap-track  { position: relative; height: 7px; border-radius: 999px; background: rgba(30,41,59,0.88); overflow: hidden; }
.rw-heatmap-fill   { height: 100%; border-radius: inherit; transition: width .22s ease; }
.rw-heatmap-fill.cool { background: linear-gradient(90deg, #1e293b, #334155); }
.rw-heatmap-fill.warm { background: linear-gradient(90deg, #0f766e, #14b8a6); }
.rw-heatmap-fill.hot  { background: linear-gradient(90deg, #0369a1, #0ea5e9); }
.rw-heatmap-pct    { text-align: right; font-size: 10px; color: rgba(226,232,240,.9); font-variant-numeric: tabular-nums; }

/* Thread */
.rw-thread {
  flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 9px;
  padding-right: 2px; scrollbar-width: none;
}
.rw-thread::-webkit-scrollbar { display: none; }

.rw-msg {
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,0.2);
  background: rgba(15,23,42,0.55);
  padding: 9px 12px;
}
.rw-msg.user   { background: rgba(14,165,233,0.13); border-color: rgba(56,189,248,0.3); }
.rw-msg.agent  { background: rgba(8,13,24,0.84); border-color: rgba(96,165,250,0.2); }
.rw-msg.system { background: rgba(255,255,255,0.02); border-color: rgba(148,163,184,0.14); }

.rw-msg .who  { font-size: 11px; font-weight: 800; color: rgba(255,255,255,0.86); margin-bottom: 4px; }
.rw-msg .body { font-size: 13px; color: rgba(241,245,249,0.88); line-height: 1.55; }
.rw-msg .meta { margin-top: 5px; font-size: 11px; color: rgba(203,213,225,0.65); }

/* Agent card */
.rw-agent-card    { display: flex; flex-direction: column; gap: 9px; }
.rw-agent-kicker  { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #7dd3fc; font-weight: 700; }
.rw-agent-summary { font-size: 13px; line-height: 1.52; color: #f8fafc; }
.rw-agent-row     { border-top: 1px solid rgba(148,163,184,0.2); padding-top: 7px; }
.rw-agent-label   { font-size: 10px; letter-spacing: .04em; color: rgba(186,230,253,.9); font-weight: 700; text-transform: uppercase; margin-bottom: 3px; }
.rw-agent-value   { font-size: 12px; line-height: 1.5; color: rgba(241,245,249,0.9); }
.rw-agent-details summary { cursor: pointer; font-size: 11px; font-weight: 600; color: rgba(203,213,225,.88); }
.rw-agent-details ul { margin: 6px 0 0; padding-left: 16px; }
.rw-agent-details li { margin: 3px 0; font-size: 12px; color: rgba(226,232,240,.9); line-height: 1.42; }

.rw-followups { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
.rw-followup {
  border-radius: 999px; border: 1px solid rgba(125,211,252,.38);
  background: rgba(8,47,73,0.44); color: #e0f2fe;
  font-size: 11px; line-height: 1; padding: 6px 10px; cursor: pointer;
}
.rw-followup:hover { background: rgba(14,116,144,0.44); }

/* Footer */
.rw-chat-foot {
  padding: 9px 12px; border-top: 1px solid var(--rw-border);
  display: flex; align-items: center; gap: 8px;
  background: rgba(2,6,23,0.7); flex-shrink: 0;
}
.rw-input {
  flex: 1; height: 38px; border-radius: 11px;
  border: 1px solid rgba(148,163,184,0.3);
  background: rgba(15,23,42,0.92); color: rgba(248,250,252,.95);
  padding: 0 11px; outline: none; font-size: 13px;
}
.rw-input::placeholder { color: rgba(203,213,225,0.58); }
.rw-input:disabled { opacity: .65; }
.rw-send-btn {
  height: 38px; border-radius: 11px;
  border: 1px solid rgba(56,189,248,0.4);
  background: rgba(14,165,233,0.22); color: rgba(255,255,255,.95);
  font-weight: 800; padding: 0 14px; cursor: pointer;
}
.rw-send-btn:hover   { background: rgba(14,165,233,0.34); }
.rw-send-btn:disabled { opacity: .7; cursor: default; }

/* Mobile adjustments */
@media (max-width: 520px) {
  .rw-chat { right: 12px; bottom: 12px; }
  .rw-chat-panel {
    width: calc(100vw - 24px); height: calc(100dvh - 90px);
    bottom: 52px; right: 0;
  }
}
