/* =============================================
   TECHMEET — Écran d'appel (CallScreen.js)
   Tout est limité à #tm-call et .tmc-pill : aucun style global
   (contrairement au CSS d'origine de CallManager, qui réinitialisait
   html/body/* et aurait cassé le reste de l'app).
   ============================================= */

#tm-call {
  /* Au-dessus de tous les éléments flottants de l'app (bulle assistant
     999998, partage…) ; seuls les toasts et les feuilles d'action passent devant */
  position: fixed; inset: 0; z-index: 999997;
  display: none; flex-direction: column; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 22px);
  background: radial-gradient(circle at 50% 30%, #1d3b66 0%, #0e1a2e 55%, #070d18 100%);
  color: #fff; overflow: hidden; touch-action: manipulation;
  font-family: inherit;
}
#tm-call.tmc-visible { display: flex; }
#tm-call button { font-family: inherit; }

/* Vidéos */
#tm-call .tmc-remote {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000; display: none; z-index: 0;
}
#tm-call[data-mode="video"] .tmc-remote { display: block; }
#tm-call .tmc-shade { display: none; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,.6) 0%, transparent 22%, transparent 70%, rgba(0,0,0,.65) 100%); }
#tm-call[data-mode="video"] .tmc-shade { display: block; }
#tm-call[data-mode="video"] { background: #000; }

#tm-call .tmc-local {
  position: absolute; top: calc(env(safe-area-inset-top) + 86px); right: 14px; z-index: 4;
  width: clamp(96px, 27vw, 150px); aspect-ratio: 3 / 4;
  border-radius: 14px; overflow: hidden; background: #1a2533;
  border: 2px solid rgba(255,255,255,.85); box-shadow: 0 6px 20px rgba(0,0,0,.5);
  display: none; touch-action: none;
}
#tm-call[data-mode="video"] .tmc-local { display: block; }
#tm-call .tmc-local video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
#tm-call .tmc-local-off { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: #26343d; color: #cfd8dc; }
#tm-call .tmc-local.tmc-off .tmc-local-off { display: flex; }

/* En-tête */
#tm-call .tmc-top { position: relative; z-index: 3; width: 100%; display: flex; align-items: flex-start; gap: 8px; }
#tm-call .tmc-icon { width: 40px; height: 40px; border: none; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; }
#tm-call .tmc-who { flex: 1; min-width: 0; text-align: center; padding-top: 2px; }
#tm-call .tmc-name { font-size: clamp(18px, 5vw, 22px); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tm-call .tmc-status { font-size: 13px; color: #c3cfdb; margin-top: 3px; font-variant-numeric: tabular-nums; }
#tm-call .tmc-brand { width: 40px; font-size: 9px; font-weight: 800; letter-spacing: .5px; color: rgba(255,255,255,.45); text-align: right; padding-top: 12px; }
#tm-call .tmc-badges { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
#tm-call .tmc-badge { display: none; align-items: center; gap: 5px; margin-top: 6px; padding: 3px 9px; border-radius: 999px; background: rgba(239,68,68,.22); color: #fecaca; font-size: 11px; font-weight: 700; }
#tm-call .tmc-badge.show { display: inline-flex; }

/* Avatar */
#tm-call .tmc-center { position: relative; z-index: 2; flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; }
#tm-call[data-mode="video"] .tmc-center { visibility: hidden; }
#tm-call .tmc-avatar {
  width: clamp(140px, 42vw, 210px); aspect-ratio: 1; border-radius: 50%; overflow: hidden;
  background: linear-gradient(160deg, #2b4a78, #1b2a42); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 8px rgba(255,255,255,.05), 0 12px 34px rgba(0,0,0,.45);
}
#tm-call .tmc-avatar img { width: 100%; height: 100%; object-fit: cover; }
#tm-call .tmc-avatar span { font-size: clamp(56px, 16vw, 84px); font-weight: 700; color: #c9d6e6; }
#tm-call[data-state="incoming"] .tmc-avatar,
#tm-call[data-state="ringing"] .tmc-avatar { animation: tmcPulse 1.6s ease-in-out infinite; }
@keyframes tmcPulse { 0%,100% { box-shadow: 0 0 0 8px rgba(255,255,255,.05), 0 12px 34px rgba(0,0,0,.45); } 50% { box-shadow: 0 0 0 22px rgba(59,130,246,.12), 0 12px 34px rgba(0,0,0,.45); } }

/* Boutons ronds */
#tm-call .tmc-round {
  width: clamp(54px, 15vw, 64px); height: clamp(54px, 15vw, 64px); border-radius: 50%; border: none;
  background: rgba(255,255,255,.14); color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform .12s, background-color .2s;
}
#tm-call .tmc-round:active { transform: scale(.94); }
#tm-call .tmc-round:disabled { opacity: .4; pointer-events: none; }
#tm-call .tmc-round.tmc-on { background: #fff; color: #0e1a2e; }
#tm-call .tmc-red { background: #ef4444 !important; color: #fff !important; }
#tm-call .tmc-green { background: #22c55e; }
#tm-call .tmc-dark { background: rgba(255,255,255,.12); }

/* Contrôles en appel */
#tm-call .tmc-controls {
  position: relative; z-index: 3; width: 100%; max-width: 480px;
  display: none; grid-template-columns: repeat(5, 1fr); gap: 10px 4px; justify-items: center;
  padding: 16px 6px; border-radius: 26px; background: rgba(8,14,26,.72); backdrop-filter: blur(10px);
}
#tm-call[data-mode="audio"] .tmc-controls,
#tm-call[data-mode="video"] .tmc-controls { display: grid; }
#tm-call .tmc-ctl { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
#tm-call .tmc-ctl span { font-size: 10.5px; color: #c3cfdb; text-align: center; line-height: 1.2; }

/* Appel entrant */
#tm-call .tmc-incoming { position: relative; z-index: 3; width: 100%; max-width: 420px; display: none; justify-content: space-around; align-items: flex-end; padding-bottom: 8px; }
#tm-call[data-mode="incoming"] .tmc-incoming { display: flex; }
#tm-call .tmc-in-btn { display: flex; flex-direction: column; align-items: center; gap: 10px; position: relative; }
#tm-call .tmc-in-btn span { font-size: 12px; color: #c3cfdb; }
#tm-call .tmc-accept { width: 70px; height: 70px; touch-action: none; position: relative; z-index: 2; }
#tm-call .tmc-arrows { position: absolute; top: -58px; display: flex; flex-direction: column; align-items: center; color: #22c55e; pointer-events: none; }
#tm-call .tmc-arrows svg { opacity: 0; animation: tmcArrow 1.5s infinite ease-in-out; margin-top: -6px; }
#tm-call .tmc-arrows svg:nth-child(2) { animation-delay: .3s; }
#tm-call .tmc-arrows svg:nth-child(3) { animation-delay: .6s; }
@keyframes tmcArrow { 0% { transform: translateY(10px); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(-10px); opacity: 0; } }

/* Menu routes audio */
#tm-call .tmc-routes {
  position: absolute; z-index: 6; left: 16px; bottom: calc(env(safe-area-inset-bottom) + 130px);
  min-width: 210px; padding: 6px; border-radius: 16px; background: #182235; box-shadow: 0 10px 28px rgba(0,0,0,.5); display: none;
}
#tm-call .tmc-routes.open { display: block; }
#tm-call .tmc-route-item { width: 100%; display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: none; border-radius: 12px; background: none; color: #fff; font-size: 15px; text-align: left; cursor: pointer; }
#tm-call .tmc-route-item:active { background: rgba(255,255,255,.08); }
#tm-call .tmc-route-item i { margin-left: auto; color: #22c55e; display: flex; }

/* Bandeau d'appel réduit */
.tmc-pill {
  position: fixed; z-index: 999996; left: 50%; top: calc(env(safe-area-inset-top) + 8px); transform: translate(-50%, -150%);
  display: flex; align-items: center; gap: 8px; max-width: calc(100% - 24px);
  padding: 8px 14px; border: none; border-radius: 999px; background: #16a34a; color: #fff;
  font-size: 13px; font-weight: 700; box-shadow: 0 6px 18px rgba(0,0,0,.35); transition: transform .25s ease; cursor: pointer;
}
/* Masqué = invisible et intouchable (pas seulement poussé hors écran : son ombre dépassait) */
.tmc-pill:not(.show) { visibility: hidden; pointer-events: none; }
.tmc-pill.show { transform: translate(-50%, 0); }
.tmc-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.tmc-pill em { font-style: normal; font-weight: 600; opacity: .8; font-size: 12px; flex-shrink: 0; }

/* Écran d'appel ouvert : la bulle de l'assistant (et ses fenêtres) est masquée —
   elle recouvrait le bouton « Raccrocher » */
body.tm-call-open #assistant-bubble,
body.tm-call-open #assistant-overlay,
body.tm-call-open .asst-panel { display: none !important; }

@media (max-width: 360px) {
  #tm-call .tmc-controls { gap: 8px 2px; padding: 12px 4px; }
  #tm-call .tmc-ctl span { font-size: 9.5px; }
}
@media (orientation: landscape) {
  #tm-call .tmc-local { top: 14px; width: 130px; aspect-ratio: 4 / 3; }
}

/* =============================================
   Appel de groupe (GroupCallScreen.js) — limité à #tm-gcall
   ============================================= */
#tm-gcall {
  position: fixed; inset: 0; z-index: 999997; display: none; flex-direction: column; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 12px calc(env(safe-area-inset-bottom) + 18px);
  background: radial-gradient(circle at 50% 25%, #1d3b66 0%, #0e1a2e 55%, #070d18 100%);
  color: #fff; overflow: hidden; touch-action: manipulation; font-family: inherit;
}
#tm-gcall.tmg-visible { display: flex; }
#tm-gcall button { font-family: inherit; }
#tm-gcall .tmg-top { display: flex; align-items: center; gap: 10px; }
#tm-gcall .tmc-icon { width: 40px; height: 40px; border: none; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; }
#tm-gcall .tmg-who { flex: 1; min-width: 0; text-align: center; }
#tm-gcall .tmg-name { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tm-gcall .tmg-status { font-size: 12.5px; color: #c3cfdb; margin-top: 2px; font-variant-numeric: tabular-nums; }
#tm-gcall .tmg-count { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: #c3cfdb; padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,.1); flex-shrink: 0; }
/* Grille : 1 → plein écran, 2 → l'un sous l'autre, 3-4 → 2×2, 5-8 → 2 colonnes */
#tm-gcall .tmg-grid { flex: 1; min-height: 0; display: grid; gap: 8px; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
#tm-gcall .tmg-grid[data-n="3"], #tm-gcall .tmg-grid[data-n="4"],
#tm-gcall .tmg-grid[data-n="5"], #tm-gcall .tmg-grid[data-n="6"],
#tm-gcall .tmg-grid[data-n="7"], #tm-gcall .tmg-grid[data-n="8"] { grid-template-columns: 1fr 1fr; }
#tm-gcall .tmg-tile { position: relative; min-height: 0; border-radius: 16px; overflow: hidden; background: rgba(255,255,255,.07); display: flex; align-items: center; justify-content: center; }
#tm-gcall .tmg-tile.tmg-wait { opacity: .7; }
#tm-gcall .tmg-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; display: none; }
#tm-gcall .tmg-me .tmg-video { transform: scaleX(-1); }
#tm-gcall .tmg-tile.tmg-has-video .tmg-video { display: block; }
#tm-gcall .tmg-tile.tmg-has-video .tmg-av { display: none; }
#tm-gcall .tmg-av { width: clamp(56px, 22vw, 96px); aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: linear-gradient(135deg, #2563eb, #0891b2); display: flex; align-items: center; justify-content: center; font-size: clamp(22px, 8vw, 36px); font-weight: 800; }
#tm-gcall .tmg-av img { width: 100%; height: 100%; object-fit: cover; }
#tm-gcall .tmg-label { position: absolute; left: 8px; bottom: 8px; right: 8px; display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.7); white-space: nowrap; overflow: hidden; }
#tm-gcall .tmg-mic { color: #fca5a5; display: inline-flex; }
#tm-gcall .tmg-n { overflow: hidden; text-overflow: ellipsis; }
#tm-gcall .tmg-audio { display: none; }
#tm-gcall .tmg-controls { display: flex; justify-content: space-around; gap: 6px; padding: 14px 6px; border-radius: 26px; background: rgba(8,14,26,.72); backdrop-filter: blur(10px); }
#tm-gcall .tmc-ctl { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; flex: 1; }
#tm-gcall .tmc-ctl span { font-size: 10.5px; color: #c3cfdb; text-align: center; line-height: 1.2; }
#tm-gcall .tmc-round { width: clamp(52px, 15vw, 62px); height: clamp(52px, 15vw, 62px); border-radius: 50%; border: none; background: rgba(255,255,255,.14); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .12s, background-color .2s; }
#tm-gcall .tmc-round:active { transform: scale(.94); }
#tm-gcall .tmc-round.tmc-on { background: #fff; color: #0e1a2e; }
#tm-gcall .tmc-red { background: #ef4444 !important; color: #fff !important; }
body.tm-call-open #tm-gcall ~ #assistant-bubble { display: none !important; }

/* Bandeau « Appel en cours · Rejoindre » dans le groupe */
.gc-callband { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: rgba(34,197,94,.12); border-bottom: 1px solid rgba(34,197,94,.3); color: var(--text-1); font-size: 13px; }
.gc-callband b { color: #16a34a; }
.gc-callband button { margin-left: auto; border: none; border-radius: 999px; padding: 7px 14px; background: #16a34a; color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; flex-shrink: 0; }
