/**
 * Tema `reindal`: meet.reindal.cloud — palette reindal.com
 * Tema `during`: meet.during.group — chiaro come [during.group](https://during.group/), logo Gruppo During, primario #e8641c
 * `data-theme` è impostato in config.js dall’hostname.
 */
:root,
[data-theme="reindal"] {
  /* RealtimeKit: brand (RGB separati da spazio) — il JS riapplica dopo il tema preset */
  --rtk-colors-brand-300: 255 235 100;
  --rtk-colors-brand-400: 255 229 17;
  --rtk-colors-brand-500: 240 216 24;
  --rtk-colors-brand-600: 212 192 21;
  --rtk-colors-brand-700: 184 166 18;
  --rtk-colors-text-on-brand-1000: 48 48 48;

  --reindal-yellow: #f0d818;
  --reindal-yellow-bright: #ffe511;
  --reindal-cream: #faf8e8;
  --reindal-charcoal: #303030;
  --reindal-gray-700: #3c3c3c;
  --reindal-gray-600: #646464;
  --reindal-gray-500: #929294;
  --reindal-line: #e8e8e8;
  --reindal-green: #61ce70;
  --reindal-magenta: #e1306c;

  --bg: #252525;
  --surface: var(--reindal-gray-700);
  --surface2: var(--reindal-charcoal);
  --border: var(--reindal-gray-600);
  --text: var(--reindal-cream);
  --muted: var(--reindal-gray-500);
  --accent: var(--reindal-yellow);
  --accent-bright: var(--reindal-yellow-bright);
  --accent-dim: #c9b012;
  --accent-on-brand: var(--reindal-charcoal);
  --accent-glow: rgba(240, 216, 24, 0.25);
  --accent-glow-strong: rgba(255, 229, 17, 0.35);
  --accent-border-soft: rgba(240, 216, 24, 0.35);
  --danger: #c42d4a;
  --ok: var(--reindal-green);
  --radius: 12px;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  --font-ui: "Work Sans", system-ui, sans-serif;
  --font-display: "Roboto Slab", Georgia, serif;
}

[data-theme="during"] {
  --rtk-colors-brand-300: 255 150 95;
  --rtk-colors-brand-400: 255 120 55;
  --rtk-colors-brand-500: 232 100 28;
  --rtk-colors-brand-600: 200 82 22;
  --rtk-colors-brand-700: 168 65 18;
  --rtk-colors-text-on-brand-1000: 255 255 255;

  --during-orange: #e8641c;
  --during-orange-bright: #ff8a45;
  --during-navy: #192a3d;
  --during-slate: #3a4f66;
  --reindal-yellow: #e8641c;
  --reindal-yellow-bright: #ff8a45;
  --reindal-cream: #faf8e8;
  --reindal-charcoal: #ffffff;
  --reindal-gray-700: #ffffff;
  --reindal-gray-600: #cfd8e0;
  --reindal-gray-500: #6b7c8c;
  --reindal-green: #2d8a47;
  --reindal-magenta: #c43d5c;

  --bg: #f2f5f7;
  --surface: #ffffff;
  --surface2: #f7f9fb;
  --border: #e1e8ed;
  --text: #192a3d;
  --muted: #5c6b7a;
  --accent: var(--during-orange);
  --accent-bright: var(--during-orange-bright);
  --accent-dim: #c55516;
  --accent-on-brand: #ffffff;
  --accent-glow: rgba(232, 100, 28, 0.22);
  --accent-glow-strong: rgba(232, 100, 28, 0.32);
  --accent-border-soft: rgba(232, 100, 28, 0.38);
  --shadow: 0 12px 40px rgba(25, 42, 61, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

body {
  background: radial-gradient(
      1000px 520px at 12% -8%,
      rgba(240, 216, 24, 0.08) 0%,
      transparent 55%
    ),
    radial-gradient(
      800px 480px at 96% 4%,
      rgba(225, 48, 108, 0.06) 0%,
      transparent 45%
    ),
    linear-gradient(180deg, #2d2d2d 0%, var(--bg) 45%);
}

html[data-theme="during"] body {
  background: radial-gradient(
      900px 420px at 8% 0%,
      rgba(232, 100, 28, 0.09) 0%,
      transparent 52%
    ),
    radial-gradient(
      800px 380px at 100% 12%,
      rgba(58, 79, 102, 0.06) 0%,
      transparent 50%
    ),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 55%);
}

.app-root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shell {
  width: min(1120px, 100% - 2rem);
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.brand h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text);
}

.brand--during {
  align-items: center;
  gap: 1rem 1.25rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.brand--during .brand-logo {
  height: 48px;
  width: auto;
  display: block;
}

.brand--during .brand-title-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text);
}

.brand span {
  color: var(--muted);
  font-size: 0.95rem;
}

.card {
  background: linear-gradient(
    155deg,
    var(--surface) 0%,
    var(--surface2) 100%
  );
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text);
}

.lead {
  color: var(--muted);
  margin: 0 0 1.25rem;
  line-height: 1.55;
  font-size: 0.98rem;
}

.field {
  margin-bottom: 1.1rem;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="datetime-local"],
select {
  width: 100%;
  max-width: 420px;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--reindal-charcoal);
  color: var(--text);
  font: inherit;
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

.row-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease,
    box-shadow 0.15s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(
    180deg,
    var(--accent-bright) 0%,
    var(--accent) 100%
  );
  color: var(--accent-on-brand);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--reindal-gray-500);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-bright);
}

.btn-danger {
  background: linear-gradient(180deg, #9d1f3c 0%, var(--reindal-magenta) 100%);
  color: #fff;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
}

.result-box {
  margin-top: 1.25rem;
  padding: 1rem;
  border-radius: 10px;
  background: var(--reindal-charcoal);
  border: 1px dashed var(--reindal-gray-600);
  font-size: 0.9rem;
  word-break: break-all;
}

.result-box strong {
  color: var(--accent-bright);
}

.meet-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 900px) {
  .meet-layout {
    grid-template-columns: 1fr 320px;
    align-items: start;
  }
}

.video-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.tile {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16/10;
  border: 1px solid var(--border);
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile .label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: rgba(48, 48, 48, 0.85);
  font-size: 0.75rem;
  color: #fff;
}

[data-theme="reindal"] .tile.local {
  outline: 2px solid rgba(240, 216, 24, 0.55);
}

[data-theme="during"] .tile.local {
  outline: 2px solid rgba(232, 100, 28, 0.55);
}

.side-panel .card + .card {
  margin-top: 1rem;
}

.meter-wrap {
  height: 6px;
  background: var(--reindal-charcoal);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.35rem;
}

.meter {
  height: 100%;
  width: 0%;
  background: linear-gradient(
    90deg,
    var(--accent),
    var(--ok)
  );
  border-radius: 99px;
  transition: width 0.08s linear;
}

.status-ok {
  color: var(--ok);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.status-warn {
  color: var(--accent);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.status-err {
  color: #ff8a9a;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.wait-screen {
  text-align: center;
  padding: 3rem 1.5rem;
}

.wait-screen h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-glow);
  color: var(--accent-bright);
  border: 1px solid var(--accent-border-soft);
}

/* Riunione: massimo spazio orizzontale e altezza esplicita per rtk-meeting mode="fill" */
.shell.shell--meet {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 0.75rem 0 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  box-sizing: border-box;
}

.shell.shell--meet .brand {
  padding: 0 1rem;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.shell.shell--meet .brand--during .brand-logo {
  height: 40px;
}

/* spazio per header brand sopra al video */
.shell.shell--meet #room-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 4.75rem);
}

/**
 * Altezza esplicita in vh: dentro lo shadow, rtk-grid usa flex:1 1 0% e serve un antenato
 * con altezza calcolata; height:% spesso fallisce nella catena flex.
 */
.rtk-host {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  height: calc(100vh - 4.75rem);
  min-height: 520px;
  max-height: min(960px, 100vh);
  box-sizing: border-box;
}

/**
 * Con mode="fill" lo stylesheet interno imposta solo position:relative ma lascia
 * top/right/bottom/left:0 del preset "fixed". Resettiamo inset sull’host.
 * height:100% ora risolve rispetto a .rtk-host con altezza in vh.
 */
.rtk-host rtk-meeting {
  position: relative !important;
  inset: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  display: flex !important;
  flex-direction: column !important;
  box-sizing: border-box;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  flex: 1 1 auto !important;
  --rtk-brand-color: var(--accent);
  --rtk-brand-text-color: var(--accent-on-brand);
}

.room-loading-lead {
  text-align: center;
  margin: 2rem auto 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.hidden {
  display: none !important;
}
