/* Support chat, calls and the operator console. Builds on the tokens in style.css. */
:root{
  --chat-mine:#1d2f27;
  --chat-theirs:#141c19;
  --chat-mine-border:rgba(185,243,206,.22);
  --call-bg:#050807;
  --call-danger:#e5484d;
  --call-accept:#2fbf71;
}
:root[data-theme="light"]{
  --chat-mine:#e3f1e9;
  --chat-theirs:#ffffff;
  --chat-mine-border:rgba(23,106,67,.25);
}

/* Floating entry point on the install site. */
.support-fab{
  position:fixed;right:20px;bottom:20px;z-index:40;
  display:inline-flex;align-items:center;gap:10px;width:auto;margin:0;
  padding:13px 18px;border-radius:999px;font-size:14px;
}
.support-fab svg{width:20px;height:20px;flex:none}
.support-fab .support-dot{width:9px;height:9px;border-radius:50%;background:var(--call-danger);box-shadow:0 0 0 3px var(--bg)}
.support-panel{
  position:fixed;right:20px;bottom:20px;z-index:41;
  width:min(420px,calc(100vw - 32px));height:min(640px,calc(100dvh - 40px));
  display:flex;flex-direction:column;
  background:var(--bg-elevated);border:1px solid var(--border);border-radius:var(--radius-lg);
  box-shadow:var(--shadow-lg);overflow:hidden;
}
.support-head{display:flex;align-items:center;gap:6px;padding:14px 14px 12px 20px;border-bottom:1px solid var(--border)}
.support-head>div{flex:1;min-width:0}
.support-head h2{font-size:16px;margin:0}
.support-sub{font-size:12px;margin:2px 0 0;color:var(--text-faint);line-height:1.4}
/* justify/align-content: the site-wide button rule sets space-between, which shrinks
   the grid track to the icon and pins it to the left edge. */
.support-head-button,.chat-icon{
  display:grid;place-items:center;justify-content:center;align-content:center;flex:none;width:40px;height:40px;margin:0;padding:0;
  border-radius:50%;background:transparent;color:var(--text-muted);border:1px solid var(--border);box-shadow:none;
}
.support-head-button:hover,.chat-icon:hover{color:var(--text);border-color:var(--border-strong);transform:none;filter:none}
.support-head-button svg,.chat-icon svg{width:19px;height:19px}
.support-head-button:focus-visible,.chat-icon:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.support-login{padding:4px 20px 20px;overflow:auto}
.support-login p{font-size:14px;margin-top:16px}
.support-error{color:var(--danger)!important;font-size:13px;margin:10px 0 0}
#supportChat{flex:1;min-height:0}
@media(max-width:560px){
  .support-fab{right:14px;bottom:14px}
  .support-panel{inset:0;width:100%;height:100dvh;border-radius:0;border:0}
}

/* Chat view. */
.chat{display:flex;flex-direction:column;min-height:0;height:100%;position:relative}
.chat.dragging::after{
  content:'';position:absolute;inset:8px;border:2px dashed var(--accent);border-radius:var(--radius-md);
  background:color-mix(in srgb,var(--accent) 8%,transparent);pointer-events:none;
}
.chat-log{flex:1;min-height:0;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:10px;overscroll-behavior:contain}
.chat-empty{margin:auto 20px;text-align:center;font-size:14px}
.chat-older{width:auto;align-self:center;margin:10px 0 0;padding:8px 14px;font-size:12.5px;background:transparent;color:var(--text-muted);border:1px solid var(--border);box-shadow:none;border-radius:999px}
.chat-older:hover{transform:none;color:var(--text)}
.chat-message{
  max-width:86%;padding:10px 13px 8px;border-radius:16px;border:1px solid var(--border);
  background:var(--chat-theirs);color:var(--text);align-self:flex-start;
  display:flex;flex-direction:column;gap:6px;overflow-wrap:anywhere;
}
.chat-message.mine{align-self:flex-end;background:var(--chat-mine);border-color:var(--chat-mine-border)}
.chat-author{font-size:11.5px;font-weight:700;color:var(--text-muted);letter-spacing:.2px}
.chat-body{margin:0;color:var(--text);font-size:14.5px;line-height:1.5;white-space:pre-wrap}
.chat-meta{font-size:11px;color:var(--text-faint);align-self:flex-end}
.chat-image{display:block;width:auto;max-width:260px;margin:0;padding:0;border:0;border-radius:12px;overflow:hidden;background:var(--surface);box-shadow:none;cursor:zoom-in}
.chat-image:hover{transform:none;filter:none}
.chat-image img{display:block;max-width:100%;max-height:240px;min-width:80px;min-height:60px;object-fit:cover}
.chat-file,.chat-chip{
  display:flex;align-items:center;gap:10px;width:100%;margin:0;padding:9px 12px;
  background:var(--surface);color:var(--text);border:1px solid var(--border);border-radius:12px;box-shadow:none;
  font-size:13px;font-weight:500;text-align:left;
}
.chat-file:hover{transform:none;filter:none;border-color:var(--border-strong)}
.chat-file-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-file-size{flex:none;color:var(--text-faint);font-size:12px}
.chat-error{margin:0 16px 8px;color:var(--danger);font-size:13px}
.chat-chips{display:flex;flex-direction:column;gap:6px;padding:0 16px 8px}
.chat-chip.error{border-color:var(--danger)}
.chat-chip-action{width:auto;margin:0;padding:2px 8px;background:transparent;color:var(--text-muted);border:0;box-shadow:none;font-size:15px}
.chat-chip-action:hover{transform:none;color:var(--text)}
.chat-composer{display:flex;align-items:flex-end;gap:8px;padding:10px 12px 12px;border-top:1px solid var(--border)}
.chat-input{
  flex:1;min-width:0;resize:none;max-height:160px;overflow-y:hidden;padding:10px 12px;font:inherit;font-size:14.5px;line-height:20px;
  background:var(--input-bg);color:var(--text);border:1px solid var(--border);border-radius:var(--radius-sm);
}
.chat-input:focus{outline:none;border-color:var(--border-strong);box-shadow:0 0 0 4px var(--focus-ring)}
.chat-send{background:linear-gradient(180deg,var(--accent),var(--accent-2));color:var(--accent-ink);border:0}
/* Same height as the one-line input (20px line + 20px padding + 2px border). */
.chat-composer .chat-icon{width:42px;height:42px}
.chat-send:hover{color:var(--accent-ink)}
.chat-icon:disabled{opacity:.45;cursor:default}
.chat-lightbox{
  position:fixed;inset:0;z-index:60;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;
  padding:20px;background:rgba(0,0,0,.86);
}
.chat-lightbox img{max-width:100%;max-height:calc(100dvh - 110px);object-fit:contain;border-radius:8px}
.chat-lightbox-bar{display:flex;align-items:center;gap:10px;max-width:100%;color:#fff}
.chat-lightbox-button{width:auto;margin:0;padding:9px 16px;font-size:13px}

/* Call overlay. */
.call-overlay{
  position:fixed;inset:0;z-index:70;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:22px;
  padding:24px;background:var(--call-bg);color:#f3f8f5;
}
.call-stage{position:relative;width:min(900px,100%);flex:0 1 auto;display:grid;place-items:center}
.call-remote{display:none;width:100%;max-height:calc(100dvh - 240px);border-radius:18px;background:#000;object-fit:contain}
.call-overlay.video .call-remote{display:block}
.call-overlay:not(.video) .call-remote{position:absolute;width:1px;height:1px;opacity:0}
.call-avatar{
  display:grid;place-items:center;width:132px;height:132px;border-radius:50%;
  background:linear-gradient(145deg,#b9f3ce,#7be0a4);color:#07160e;font:800 54px 'Manrope',sans-serif;
  box-shadow:0 0 0 12px rgba(185,243,206,.08),0 0 0 26px rgba(185,243,206,.04);
}
.call-overlay.video .call-avatar:not([hidden]){position:absolute}
.call-local{position:absolute;right:14px;bottom:14px;width:min(28%,200px);border-radius:12px;background:#111;border:1px solid rgba(255,255,255,.25);transform:scaleX(-1)}
.call-overlay:not(.video) .call-local{display:none}
.call-info{text-align:center}
.call-title{margin:0 0 6px;color:#fff;font-size:22px}
.call-status{margin:0;color:#b8cbc1;font-size:15px;min-height:1.5em;font-variant-numeric:tabular-nums}
.call-actions{display:flex;gap:18px;flex-wrap:wrap;justify-content:center}
.call-button{
  display:flex;flex-direction:column;align-items:center;gap:8px;width:auto;margin:0;padding:0;
  background:transparent;border:0;box-shadow:none;color:#dfe9e4;font-size:12px;font-weight:600;
}
.call-button:hover{transform:none;filter:none}
.call-icon{display:grid;place-items:center;width:62px;height:62px;border-radius:50%;background:rgba(255,255,255,.12);transition:background .2s}
.call-icon svg{width:26px;height:26px}
.call-button:hover .call-icon{background:rgba(255,255,255,.2)}
.call-button:hover span{transform:none}
.call-button.off .call-icon{background:#f3f8f5;color:#07160e}
.call-button.danger .call-icon{background:var(--call-danger);color:#fff}
.call-button.accept .call-icon{background:var(--call-accept);color:#fff;animation:call-pulse 1.4s infinite}
.call-button:focus-visible{outline:none}
.call-button:focus-visible .call-icon{outline:3px solid #fff;outline-offset:3px}
@keyframes call-pulse{0%{box-shadow:0 0 0 0 rgba(47,191,113,.55)}70%{box-shadow:0 0 0 18px rgba(47,191,113,0)}100%{box-shadow:0 0 0 0 rgba(47,191,113,0)}}
@media(prefers-reduced-motion:reduce){.call-button.accept .call-icon{animation:none}}

/* Operator console (/admin/support). */
.console{max-width:1180px}
.console-layout{display:grid;grid-template-columns:320px 1fr;gap:16px;margin-top:20px;height:calc(100dvh - 150px);min-height:480px}
.console-list,.console-chat{background:var(--bg-elevated);border:1px solid var(--border);border-radius:var(--radius-lg);overflow:hidden;display:flex;flex-direction:column;min-height:0}
.console-list-head{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700}
.console-items{overflow-y:auto;flex:1}
.console-item{
  display:block;width:100%;margin:0;padding:12px 16px;text-align:left;border:0;border-bottom:1px solid var(--border);
  border-radius:0;background:transparent;color:var(--text);box-shadow:none;font-size:13.5px;font-weight:500;
}
.console-item:hover,.console-item.active{background:var(--surface);transform:none;filter:none}
.console-item.active{box-shadow:inset 3px 0 0 var(--accent)}
.console-item strong{display:flex;align-items:center;gap:8px;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.console-item small{display:block;color:var(--text-faint);font-size:12.5px;margin-top:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.console-waiting{flex:none;width:8px;height:8px;border-radius:50%;background:var(--accent)}
.console-chat-head{display:flex;align-items:center;gap:8px;padding:12px 14px 12px 18px;border-bottom:1px solid var(--border)}
.console-chat-head h2{flex:1;min-width:0;margin:0;font-size:15px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.console-placeholder{margin:auto;padding:24px;text-align:center}
.console-chat .chat{flex:1}
.console-login{margin-top:28px}
.console-bar{display:flex;align-items:center;gap:10px;margin-left:auto}
.console-bar button{width:auto;margin:0;padding:8px 14px;font-size:12.5px}
.console-back{display:none!important}
@media(max-width:820px){
  .console-layout{grid-template-columns:1fr;height:auto}
  .console-list{max-height:none}
  .console-layout.chat-open .console-list{display:none}
  .console-layout:not(.chat-open) .console-chat{display:none}
  .console-chat{height:calc(100dvh - 120px)}
  .console-back{display:grid!important}
}
