/* ASI Réunions — styles v27 : écran d'attente, agenda, arrière-plans, adaptation à tous les écrans */

/* ---------- Socle responsive : rien ne déborde, hauteurs fiables sur mobile, zones sûres (encoche) ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { max-width: 100%; overflow-x: hidden; }
img, video, canvas, svg { max-width: 100%; }
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.room-overlay { height: 100vh; height: 100dvh; padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.call-topbar { padding-top: calc(8px + env(safe-area-inset-top)); }
.call-controls { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
button, .cta-button, .control-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* Salle : cadrage intelligent des vidéos — caméras remplies avec le visage plutôt vers le haut, écrans partagés jamais rognés */
html body #call-grid .tile video { object-fit: cover; object-position: 50% 28%; }
html body #call-grid .tile video.is-screen, html body #call-grid .tile.is-screen video, html body #call-grid .tile.sharing video { object-fit: contain; object-position: center; background: #05070f; }
#share-preview-video, #share-main video, .share-stage video { object-fit: contain; max-width: 100%; max-height: 100%; background: #05070f; }
#lobby-video { object-fit: cover; object-position: 50% 28%; width: 100%; }

/* Fond de salle (image choisie dans l'administration / par l'utilisateur) */
#call-view.zx-has-bg .call-body {
  background: linear-gradient(rgba(6, 10, 28, .42), rgba(6, 10, 28, .55)), var(--zx-room-bg) center / cover no-repeat !important;
}
#call-view.zx-has-bg #call-grid { background: transparent !important; }

/* Contrôles : ne passent jamais à la ligne sur petit écran, défilent si besoin */
@media (max-width: 700px) {
  .call-controls { flex-wrap: nowrap !important; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .call-controls::-webkit-scrollbar { display: none; }
  .call-controls > * { flex: 0 0 auto; }
  .call-controls .leave-btn { margin-left: auto; }
}
@media (max-width: 560px) {
  .welcome-card { top: 8px; max-width: 94%; font-size: 13px; }
  .lobby-shell { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .modal { width: 100%; max-width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; margin-top: auto; }
  .modal-backdrop.is-open { align-items: flex-end; padding: 0; }
  .modal-body { max-height: calc(92dvh - 90px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .cta-row { grid-template-columns: 1fr !important; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .call-topbar { padding-top: 4px; padding-bottom: 4px; }
  .control-btn { width: 38px !important; height: 38px !important; }
  .call-controls { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  .hero-title { font-size: 1.8rem !important; }
}
@media (min-width: 1500px) { .zx-ag-body { max-width: 1500px; } }

/* Bouton Agenda à l'accueil (même famille que « Rejoindre ») */
.zx-agenda-cta { background: rgba(255, 255, 255, .12) !important; color: #fff !important; border: 1.5px solid rgba(255, 255, 255, .35) !important; box-shadow: none !important; backdrop-filter: blur(6px); }
.zx-agenda-cta:hover { background: rgba(255, 255, 255, .2) !important; }
.cta-row:has(.zx-agenda-cta) { flex-wrap: wrap; }
@media (min-width: 641px) { .cta-row:has(.zx-agenda-cta) { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); } }

/* ---------- Écran d'attente + compte à rebours ---------- */
.zx-wait {
  position: fixed; inset: 0; z-index: 99998; display: grid; place-items: center; padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto; text-align: center; color: #f3f6ff; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: radial-gradient(1000px 560px at 50% -10%, #25326f, transparent 62%), radial-gradient(700px 500px at 100% 110%, rgba(238, 129, 48, .16), transparent 60%), #080d22;
  animation: zx-fade .35s ease both;
}
@keyframes zx-fade { from { opacity: 0; } to { opacity: 1; } }
.zx-wait-card { width: min(520px, 100%); }
.zx-wait-ico { font-size: clamp(42px, 9vw, 58px); filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .4)); animation: zx-float 3.4s ease-in-out infinite; }
@keyframes zx-float { 50% { transform: translateY(-6px); } }
.zx-wait-title { font-size: clamp(22px, 5.2vw, 30px); line-height: 1.15; margin: 12px 0 8px; }
.zx-wait-name { font-size: clamp(16px, 4vw, 19px); font-weight: 700; margin: 0 0 6px; word-break: break-word; }
.zx-wait-when { color: #b3bcec; margin: 0 0 18px; line-height: 1.5; font-size: 14px; }
.zx-wait-count { font: 800 clamp(34px, 11vw, 52px)/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; margin: 4px 0 14px; font-variant-numeric: tabular-nums; }
.zx-wait-count.zx-hot { font-size: clamp(96px, 34vw, 190px); color: #ffb35e; text-shadow: 0 0 40px rgba(238, 129, 48, .55); animation: zx-pop 1s ease-out infinite; letter-spacing: 0; }
@keyframes zx-pop { 0% { transform: scale(1.18); opacity: .55; } 30% { opacity: 1; } 100% { transform: scale(1); } }
.zx-wait-bar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .12); overflow: hidden; margin: 0 auto 18px; max-width: 360px; }
.zx-wait-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #ee8130, #ffd27a); transition: width .3s linear; }
.zx-wait-note { color: #b3bcec; margin: 0 auto 22px; max-width: 430px; line-height: 1.5; font-size: 14px; }
.zx-wait-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.zx-wait-actions button { padding: 12px 20px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .08); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; min-height: 46px; }
.zx-wait-actions .zx-close { background: #ee8130; border-color: #ee8130; color: #2b1203; }
body.zx-counting { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .zx-wait-ico, .zx-wait-count.zx-hot { animation: none; } }

/* ---------- Agenda (style Google Agenda) ---------- */
.zx-ag { position: fixed; inset: 0; z-index: 9990; display: flex; flex-direction: column; background: #f6f7fb; color: #1d2433; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; outline: 0; animation: zx-fade .2s ease both; }
.zx-ag-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: #fff; border-bottom: 1px solid #e3e6ef; }
.zx-ag-logo { font-size: 24px; }
.zx-ag-title { margin: 0; font-size: clamp(17px, 4vw, 22px); font-weight: 600; text-transform: capitalize; min-width: 0; }
.zx-ag-nav { display: flex; gap: 6px; align-items: center; }
.zx-ag-sp { flex: 1; }
.zx-ag-btn, .zx-ag-ic { border: 1px solid #d5d9e6; background: #fff; color: #1d2433; border-radius: 999px; padding: 8px 16px; font: 600 14px/1 inherit; cursor: pointer; min-height: 38px; }
.zx-ag-ic { width: 38px; padding: 0; font-size: 22px; line-height: 1; }
.zx-ag-btn:hover, .zx-ag-ic:hover { background: #eef1fa; }
.zx-ag-primary { background: #1a56db; border-color: #1a56db; color: #fff; }
.zx-ag-primary:hover { background: #1747b8; }
.zx-ag-primary:disabled { opacity: .5; cursor: not-allowed; }
.zx-ag-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 0; width: 100%; margin: 0 auto; }
.zx-ag-month { display: flex; flex-direction: column; min-height: 0; padding: 12px 12px 16px; overflow: auto; }
.zx-ag-head { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; font-weight: 700; color: #5b6478; text-transform: uppercase; padding: 4px 0 8px; }
.zx-ag-grid { flex: 1; min-height: 360px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(88px, 1fr); border-top: 1px solid #e3e6ef; border-left: 1px solid #e3e6ef; background: #fff; border-radius: 10px; overflow: hidden; }
.zx-ag-cell { border-right: 1px solid #e3e6ef; border-bottom: 1px solid #e3e6ef; padding: 4px; min-width: 0; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.zx-ag-cell:hover { background: #f5f8ff; }
.zx-ag-cell.out { background: #fafbfd; color: #9aa2b5; }
.zx-ag-cell.sel { box-shadow: inset 0 0 0 2px #1a56db; }
.zx-ag-num { align-self: center; font-size: 12.5px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.zx-ag-cell.today .zx-ag-num { background: #1a56db; color: #fff; }
.zx-ag-chips { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.zx-ag-chip { display: flex; gap: 5px; align-items: center; border: 0; border-radius: 6px; padding: 2px 6px; background: #d9e5ff; color: #12306e; font-size: 11.5px; text-align: left; cursor: pointer; min-width: 0; }
.zx-ag-chip.mine { background: #1a56db; color: #fff; }
.zx-ag-chip.over { opacity: .55; text-decoration: line-through; }
.zx-ag-chip i { font-style: normal; font-weight: 700; flex: 0 0 auto; }
.zx-ag-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zx-ag-more { font-size: 11px; color: #5b6478; padding-left: 6px; font-style: normal; }
.zx-ag-dots { display: none; justify-content: center; gap: 3px; }
.zx-ag-dots i { width: 6px; height: 6px; border-radius: 50%; background: #8aa8ec; }
.zx-ag-dots i.mine { background: #1a56db; }
.zx-ag-side { border-left: 1px solid #e3e6ef; background: #fff; padding: 16px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.zx-ag-side h3 { margin: 0 0 4px; font-size: 16px; text-transform: capitalize; }
.zx-ag-empty { color: #6a7388; margin: 4px 0; font-size: 14px; }
.zx-ag-card { display: grid; gap: 2px; text-align: left; border: 1px solid #dfe4f1; border-left: 4px solid #8aa8ec; border-radius: 10px; background: #fff; padding: 10px 12px; cursor: pointer; font: inherit; color: inherit; }
.zx-ag-card.mine { border-left-color: #1a56db; }
.zx-ag-card:hover { background: #f5f8ff; }
.zx-ag-card b { color: #1a56db; font-size: 13px; }
.zx-ag-card span { font-weight: 600; word-break: break-word; }
.zx-ag-card small { color: #6a7388; }
.zx-ag-side-add { margin-top: auto; align-self: stretch; }
.zx-ag-det { display: grid; gap: 8px; color: inherit; }
.zx-ag-det p { margin: 0; }
.zx-ag-det-when { font-weight: 700; text-transform: capitalize; }
.zx-ag-det-sub { color: #6a7388; font-size: 13.5px; }
.zx-ag-det-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
@media (max-width: 860px) {
  .zx-ag-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .zx-ag-side { border-left: 0; border-top: 1px solid #e3e6ef; max-height: 42dvh; }
  .zx-ag-grid { min-height: 280px; grid-auto-rows: minmax(46px, 1fr); }
  .zx-ag-chips { display: none; }
  .zx-ag-dots { display: flex; }
  .zx-ag-cell { align-items: center; }
  .zx-ag-top .zx-ag-btn:not(.zx-ag-primary) { padding: 8px 12px; }
}
@media (max-width: 480px) { .zx-ag-top { gap: 6px; padding-left: 10px; padding-right: 10px; } .zx-ag-sp { display: none; } .zx-ag-title { flex: 1 1 100%; order: -1; } }

/* ---------- Sélecteur d'arrière-plans ---------- */
.zx-bg section { margin-bottom: 18px; }
.zx-bg h3 { margin: 0 0 2px; font-size: 16px; }
.zx-bg p { margin: 0 0 10px; opacity: .75; font-size: 13px; }
.zx-bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.zx-bg-card { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; border: 2px solid rgba(128, 138, 170, .35); background: #1d2540 center / cover no-repeat; color: #fff; cursor: pointer; overflow: hidden; padding: 0; font-size: 26px; display: grid; place-items: center; }
.zx-bg-card.zx-bg-plain { background: #2a3358; }
.zx-bg-card span { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px; font-size: 11.5px; font-weight: 700; background: linear-gradient(transparent, rgba(0, 0, 0, .7)); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zx-bg-card.is-on { border-color: #ee8130; box-shadow: 0 0 0 3px rgba(238, 129, 48, .35); }
.zx-bg-empty { padding: 10px 12px; border-radius: 10px; background: rgba(128, 138, 170, .15); }
.fiche-ov { padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
.plist-card { max-width: 100%; max-height: 92dvh; overflow: auto; -webkit-overflow-scrolling: touch; }
