/* Calls in chat (static/js/calls.js): the floating call window, incoming-call cards, the chat banner and notices.
   The call window is dark in both themes, like Meet; the chat parts use the tokens from app.css. */

/* ---------------------------------------------------------------- call window */
.call-win {
  --call-bg: #1b1e23; --call-tile: #2a2f37; --call-text: #f1f3f5; --call-dim: #a9b0bb; --call-ok: #1e9e5a; --call-bad: #e0473b;
  position: fixed; right: 24px; bottom: 24px; z-index: 850; width: 440px; height: 340px; min-width: 300px; min-height: 220px;
  max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); display: flex; flex-direction: column;
  background: var(--call-bg); color: var(--call-text); border-radius: 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  resize: both; overflow: hidden;
}
.call-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; cursor: move; user-select: none;
  touch-action: none; flex: none; }
.call-head .icon { color: var(--call-ok); }
.call-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.call-clock { color: var(--call-dim); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.call-head .icon-btn { color: var(--call-dim); width: 30px; height: 30px; }
.call-head .icon-btn:hover { background: rgba(255, 255, 255, .08); color: var(--call-text); }
.call-notice { padding: 0 14px 6px; color: var(--call-dim); font-size: 12.5px; flex: none; }
.call-notice[hidden] { display: none; }
.call-grid { flex: 1; min-height: 0; display: grid; gap: 6px; padding: 0 8px; --cols: 1;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.call-tile { position: relative; min-height: 0; border-radius: 10px; overflow: hidden; background: var(--call-tile);
  display: grid; place-items: center; outline: 2px solid transparent; outline-offset: -2px; transition: outline-color .12s; }
.call-tile.speaking { outline-color: var(--call-ok); }
.call-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; background: #000; }
.call-tile.has-video video { display: block; }
.call-tile.has-video .call-face { visibility: hidden; }
.call-tile.mirror video { transform: scaleX(-1); }
.call-tile.screen video { object-fit: contain; }
.call-face .avatar.xl { width: 64px; height: 64px; font-size: 24px; }
.call-grid[data-count="5"] .call-face .avatar.xl, .call-grid[data-count="6"] .call-face .avatar.xl,
.call-grid[data-count="7"] .call-face .avatar.xl, .call-grid[data-count="8"] .call-face .avatar.xl { width: 44px; height: 44px; font-size: 17px; }
.call-tile-foot { position: absolute; left: 6px; bottom: 6px; display: flex; align-items: center; gap: 4px; max-width: calc(100% - 12px);
  padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .5); font-size: 12px; }
.call-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-mic-off { display: inline-flex; color: #ff8f86; }
.call-mic-off[hidden] { display: none; }
.call-mic-off .icon { width: 14px; height: 14px; }
.call-badge { position: absolute; top: 6px; left: 6px; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .55);
  color: var(--call-dim); font-size: 11.5px; }
.call-badge[hidden] { display: none; }
.call-bar { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 8px 12px; flex: none; flex-wrap: wrap; }
.call-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; display: inline-grid; place-items: center; cursor: pointer;
  background: #3a404a; color: var(--call-text); flex: none; }
.call-btn:hover { background: #4a515d; }
.call-btn:focus-visible { outline: 2px solid #8ab4ff; outline-offset: 2px; }
.call-btn:disabled { opacity: .45; cursor: default; }
.call-btn[hidden] { display: none; }
.call-btn.off { background: #ea4335; }
.call-btn.off:hover { background: #f05a4d; }
.call-btn.on { background: #8ab4ff; color: #0d1424; }
.call-btn.danger { background: var(--call-bad); width: 52px; border-radius: 999px; }
.call-btn.danger:hover { background: #ef5b4f; }
.call-btn.ok { background: var(--call-ok); }
.call-btn.ok:hover { background: #24b468; }
.call-btn .icon { width: 20px; height: 20px; }
.call-settings { position: absolute; left: 10px; right: 10px; bottom: 70px; padding: 12px; border-radius: 12px; display: grid; gap: 10px;
  background: #262a31; box-shadow: 0 8px 26px rgba(0, 0, 0, .5); }
.call-settings-head { display: flex; align-items: center; justify-content: space-between; }
.call-settings .field { color: var(--call-dim); font-size: 12.5px; }
.call-settings select { width: 100%; background: #1b1e23; color: var(--call-text); border-color: #444b56; }
.call-settings .icon-btn { color: var(--call-dim); font-size: 18px; }

/* minimized: a pill with the title, the clock and the essentials */
.call-win.min { width: auto !important; height: auto !important; min-height: 0; min-width: 0; resize: none; flex-direction: row;
  align-items: center; border-radius: 999px; padding-right: 6px; }
.call-win.min .call-grid, .call-win.min .call-notice, .call-win.min .call-settings { display: none; }
.call-win.min .call-head { padding-right: 0; }
.call-win.min .call-title { max-width: 180px; }
.call-win.min .call-bar { padding: 4px; gap: 6px; flex-wrap: nowrap; }
.call-win.min .call-bar .call-btn { width: 34px; height: 34px; }
.call-win.min .call-bar .call-btn.danger { width: 42px; }
.call-win.min .call-bar .call-btn:not(:first-child):not(.danger) { display: none; }
.call-win.min .call-head > .grow { display: none; }

/* ---------------------------------------------------------------- incoming calls */
.call-rings { position: fixed; top: 16px; right: 16px; z-index: 1080; display: flex; flex-direction: column; gap: 10px;
  width: 380px; max-width: calc(100vw - 32px); }
.call-ring { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 16px; color: #f1f3f5;
  background: #1b1e23; box-shadow: 0 14px 40px rgba(0, 0, 0, .35); animation: call-ring-in .18s ease-out; }
.call-ring .avatar { width: 40px; height: 40px; font-size: 15px; animation: call-pulse 1.4s ease-in-out infinite; }
.call-ring-text { display: flex; flex-direction: column; min-width: 0; }
.call-ring-text b, .call-ring-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-ring-text span { color: #a9b0bb; font-size: 12.5px; }
.call-ring .call-btn { --call-ok: #1e9e5a; --call-bad: #e0473b; }
.call-ring .call-btn.ok { background: #1e9e5a; }
.call-ring .call-btn.danger { background: #e0473b; width: 42px; border-radius: 50%; }
@keyframes call-ring-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes call-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(30, 158, 90, .55); } 50% { box-shadow: 0 0 0 8px rgba(30, 158, 90, 0); } }

/* ---------------------------------------------------------------- in chat */
.chat-head .call-start { color: var(--text-2); }
.chat-head .call-start:hover { color: var(--accent); }
.chat-call-slot:empty { display: none; }
.call-banner { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 16px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--ok) 10%, var(--surface)); font-size: 13.5px; }
.call-banner.mine { background: var(--accent-weak); }
.call-banner-ico { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--ok); color: #fff; }
.call-banner.mine .call-banner-ico { background: var(--accent); }
.call-banner-ico .icon { width: 16px; height: 16px; }
.call-banner .grow { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-banner .btn .icon.sm { width: 15px; height: 15px; }
.msg.call-notice-row { display: flex; align-items: center; gap: 10px; padding: 6px 20px; color: var(--text-2); font-size: 13px; }
.call-notice-ico { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--surface-2); color: var(--ok); }
.call-notice-row.missed .call-notice-ico { color: var(--danger); }
.call-notice-ico .icon { width: 14px; height: 14px; }
.call-notice-row .msg-text { display: inline; }

/* ---------------------------------------------------------------- phones */
@media (max-width: 860px) {
  .call-win { left: 8px; right: 8px; bottom: 8px; width: auto; height: min(60vh, 420px); resize: none; }
  .call-win.min { left: auto; }
  .call-rings { top: 8px; right: 8px; left: 8px; width: auto; max-width: none; }
  .call-bar { gap: 6px; }
  .call-btn { width: 40px; height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .call-ring, .call-ring .avatar { animation: none; }
}
