* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: #1f1f1f;
  background: #fff;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.icon { width: 24px; height: 24px; fill: currentColor; flex: none; }

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 24px;
  border: 0; border-radius: 24px;
  font-size: 15px; font-weight: 500;
  transition: background .15s, box-shadow .15s;
}
.btn.primary { background: #0b57d0; color: #fff; }
.btn.primary:hover { background: #0a4fbd; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.btn.text { background: transparent; color: #0b57d0; padding: 0 16px; }
.btn.text:hover:not(:disabled) { background: #e8f0fe; }
.btn.text:disabled { color: #a0a0a0; cursor: default; }
.btn.tonal { background: #c2e7ff; color: #001d35; width: 100%; }
.btn.tonal:hover { background: #b0dcf7; }

.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  border: 0; border-radius: 50%;
  background: transparent; color: inherit;
}
.icon-btn:hover { background: rgba(128,128,128,.2); }
.icon-btn.active { color: #8ab4f8; }

/* ---------- Home ---------- */
.home-header {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; padding: 0 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #444746; font-size: 22px; text-decoration: none; }
.home-now { color: #444746; font-size: 16px; }
.home-main {
  display: flex; align-items: center;
  min-height: calc(100% - 64px);
  padding: 24px clamp(24px, 8vw, 120px) 96px;
}
.home-hero { max-width: 640px; }
.home-hero h1 { margin: 0 0 16px; font-size: clamp(32px, 5vw, 45px); line-height: 1.15; font-weight: 400; }
.home-hero p { margin: 0 0 40px; font-size: 20px; line-height: 1.4; color: #444746; }
.home-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; }
.home-join { display: flex; align-items: center; gap: 8px; }
.home-join input {
  height: 48px; width: 260px; padding: 0 16px;
  border: 1px solid #747775; border-radius: 8px; outline: 0;
  font-size: 15px;
}
.home-join input:focus { border-color: #0b57d0; box-shadow: inset 0 0 0 1px #0b57d0; }
.home-hero p.home-error { margin: 16px 0 0; font-size: 14px; color: #b3261e; }

/* ---------- Stanza ---------- */
body.room { background: #202124; color: #e8eaed; overflow: hidden; }

.ctl {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  border: 0; border-radius: 50%;
  background: #3c4043; color: #e8eaed;
  transition: background .15s;
}
.ctl:hover { background: #4a4e52; }
.ctl.off { background: #ea4335; color: #fff; }
.ctl.off:hover { background: #d93025; }
.ctl.on { background: #8ab4f8; color: #202124; }
.ctl.on:hover { background: #a1c2fa; }
.ctl.hangup { width: 64px; border-radius: 24px; background: #ea4335; color: #fff; }
.ctl.hangup:hover { background: #d93025; }

/* Sala d'attesa */
.prejoin {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 48px;
  min-height: 100%; padding: 24px;
  background: #fff; color: #1f1f1f;
}
.pj-preview {
  position: relative;
  width: min(740px, 100%); aspect-ratio: 16 / 9;
  border-radius: 16px; overflow: hidden;
  background: #202124;
}
.pj-preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.pj-off {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; background: #202124;
}
.pj-controls { position: absolute; left: 0; right: 0; bottom: 16px; display: flex; justify-content: center; gap: 16px; }
.pj-controls .ctl { width: 56px; height: 56px; background: rgba(60,64,67,.6); border: 1px solid #fff; }
.pj-controls .ctl.off { background: #ea4335; border-color: #ea4335; }
.pj-side { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 300px; text-align: center; }
.pj-side h1 { margin: 0; font-size: 28px; font-weight: 400; }
.pj-code { margin: 0; color: #444746; }
.pj-side input {
  width: 100%; height: 48px; padding: 0 16px;
  border: 1px solid #747775; border-radius: 8px; outline: 0;
  font-size: 15px; text-align: center;
}
.pj-side input:focus { border-color: #0b57d0; box-shadow: inset 0 0 0 1px #0b57d0; }

/* Chiamata */
.call { display: flex; flex-direction: column; height: 100%; }
.call-body { flex: 1; min-height: 0; display: flex; gap: 16px; padding: 16px 16px 0; }
.stage { position: relative; flex: 1; min-width: 0; }

.grid {
  display: grid; gap: 12px;
  width: 100%; height: 100%;
  justify-content: center; align-content: center;
  grid-template-columns: repeat(var(--cols, 1), var(--tile-w, 100%));
  grid-auto-rows: var(--tile-h, 100%);
}

.tile { position: relative; border-radius: 12px; overflow: hidden; background: #3c4043; }
.tile video { width: 100%; height: 100%; object-fit: cover; background: #202124; }
.tile.mirror video { transform: scaleX(-1); }
.tile.screen video { object-fit: contain; }
.tile.no-video video { visibility: hidden; }
.tile .avatar {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: none; align-items: center; justify-content: center;
  width: min(30%, 160px); aspect-ratio: 1; border-radius: 50%;
  color: #fff; font-size: clamp(24px, 5vw, 64px); font-weight: 500;
}
.tile.no-video .avatar { display: flex; }
.tile .label {
  position: absolute; left: 12px; bottom: 10px;
  display: flex; align-items: center; gap: 6px;
  max-width: calc(100% - 24px);
  font-size: 14px; font-weight: 500; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.8);
}
.tile .label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .label .icon { display: none; width: 18px; height: 18px; padding: 2px; border-radius: 50%; background: #ea4335; }
.tile.muted .label .icon { display: block; }

.captions {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(820px, calc(100% - 32px));
  padding: 12px 20px; border-radius: 12px;
  background: rgba(0,0,0,.78); color: #fff;
  font-size: 20px; line-height: 1.4;
}
.captions:empty::before { content: "In attesa di qualcuno che parli…"; color: #9aa0a6; font-size: 16px; }
.cap-line + .cap-line { margin-top: 6px; }
.cap-name { margin-right: 8px; color: #8ab4f8; font-size: 15px; font-weight: 600; }

/* Pannello laterale */
.panel {
  display: flex; flex-direction: column;
  width: 360px; flex: none;
  border-radius: 16px; overflow: hidden;
  background: #fff; color: #1f1f1f;
}
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 4px 24px; }
.panel-header h2 { margin: 0; font-size: 18px; font-weight: 400; }
.panel-section { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 16px; padding: 12px 24px 16px; overflow-y: auto; }
.panel-note { margin: 0; padding: 12px; border-radius: 8px; background: #f1f3f4; color: #444746; font-size: 12px; line-height: 1.4; }
.panel-note.status:empty { display: none; }
.panel-note.status { background: #fef7e0; color: #5f4b00; }

.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.people li { display: flex; align-items: center; gap: 12px; }
.people .dot-avatar { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; color: #fff; font-weight: 500; flex: none; }
.people .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .icon { width: 20px; height: 20px; color: #444746; }

.chat-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.chat-msg .meta { font-size: 13px; font-weight: 600; }
.chat-msg .meta time { margin-left: 8px; font-weight: 400; color: #5f6368; font-size: 12px; }
.chat-msg .text { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-form { display: flex; align-items: center; padding-left: 16px; border-radius: 24px; background: #f1f3f4; }
.chat-form input { flex: 1; min-width: 0; height: 48px; border: 0; outline: 0; background: transparent; }
.chat-form .icon-btn { color: #0b57d0; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #444746; }
.field select { height: 44px; padding: 0 12px; border: 1px solid #747775; border-radius: 8px; background: #fff; color: #1f1f1f; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: 18px; height: 18px; accent-color: #0b57d0; }

/* Barra inferiore */
.bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 80px; padding: 0 16px; }
.bar-left { display: flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 500; white-space: nowrap; }
.bar-left .sep { color: #9aa0a6; }
.bar-center { display: flex; align-items: center; gap: 12px; }
.bar-right { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.count {
  position: absolute; top: 4px; right: 2px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #5f6368; color: #fff; font-size: 11px; line-height: 16px; text-align: center;
}
.dot { position: absolute; top: 10px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: #8ab4f8; }

/* Notifiche */
.toasts { position: fixed; left: 24px; top: 24px; z-index: 10; display: flex; flex-direction: column; gap: 8px; }
.toast { max-width: 360px; padding: 14px 18px; border-radius: 8px; background: #303134; color: #e8eaed; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.toast.clickable { cursor: pointer; text-decoration: underline; }

@media (max-width: 800px) {
  .bar { grid-template-columns: auto 1fr auto; gap: 8px; }
  .bar-left { display: none; }
  .bar-center { gap: 8px; }
  .call-body { padding: 8px 8px 0; }
  .panel { position: fixed; inset: 8px 8px 88px; width: auto; z-index: 5; }
  .pj-side { width: 100%; }
}
