:root {
  --bg: #0f1113;
  --panel: #181b1e;
  --panel-2: #202428;
  --panel-3: #262a2e;
  --hover: #2a2e33;
  --border: #292c30;
  --text: #f1f3f4;
  --text-dim: #9aa0a6;
  --text-faint: #6c7176;
  --green: #19c463;
  --green-hover: #22d871;
  --green-soft: rgba(25, 196, 99, 0.14);
  --blue: #4285f4;
  --danger: #ea4335;
  --danger-hover: #d93025;
  --warn: #f5a623;
  --peer-color: #ffb454;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.screen { height: 100%; }
.hidden { display: none !important; }

/* ---------- Shared brand mark ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-img {
  height: 52px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.logo-img-lobby { height: 72px; }

/* ---------- Lobby ---------- */
#lobby {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, rgba(25, 196, 99, 0.10), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(25, 196, 99, 0.08), transparent 40%),
    var(--bg);
}

.back-home {
  position: fixed;
  top: 24px;
  left: 24px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 9px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  z-index: 5;
}

.back-home:hover {
  background: var(--panel-3);
  color: var(--text);
  border-color: rgba(25, 196, 99, 0.35);
}

.back-home .icon { width: 16px; height: 16px; }

.lobby-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 40px 32px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  text-align: center;
}

.lobby-card .brand { margin-bottom: 20px; justify-content: center; }

.lobby-card h1 {
  font-size: 17.5px;
  line-height: 1.3;
  margin: 0 0 28px;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.field { margin-bottom: 16px; text-align: left; }

.lobby-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-align: left;
}

.label-hint {
  font-weight: 400;
  color: var(--text-faint);
}

.lobby-card input[type="text"] {
  width: 100%;
  text-align: left;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}

.lobby-card input[type="text"]:focus {
  outline: none;
  border-color: var(--green);
  background: var(--panel-3);
}

.room-row {
  display: flex;
  gap: 8px;
}

.room-row input { flex: 1; }

.room-row button {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 16px;
}

.room-row button:hover { background: var(--panel-3); }

button.primary {
  margin-top: 8px;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: var(--green);
  color: #06210f;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

button.primary:hover { background: var(--green-hover); }
button.primary:active { transform: scale(0.99); }

.error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 12px 0 0;
}

/* =====================================================
   CALL SCREEN — DeltaMeet layout
===================================================== */

#call {
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.header {
  height: 76px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #101214;
  border-bottom: 1px solid var(--border);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.separator {
  width: 1px;
  height: 28px;
  background: #444;
  margin-left: 4px;
  flex-shrink: 0;
}

.meeting-title {
  font-size: 15px;
  color: #e8eaed;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.meeting-time {
  color: #bdc1c6;
  font-size: 14px;
  white-space: nowrap;
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.conn-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-dim);
  margin-right: 4px;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.status-dot.connecting { background: var(--warn); box-shadow: 0 0 0 3px rgba(245,166,35,0.18); }
.status-dot.connected { background: var(--green); box-shadow: 0 0 0 3px rgba(25,196,99,0.18); }
.status-dot.failed { background: var(--danger); box-shadow: 0 0 0 3px rgba(229,72,77,0.18); }

.header-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: white;
  font-size: 18px;
  cursor: pointer;
}

.header-button:hover { background: #2b2f33; }

.participant-count { position: relative; }

.count {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #34383d;
  color: white;
  font-size: 10px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.profile {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg,#5cff82,#08a94f);
  color: #06210f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  margin-left: 4px;
  flex-shrink: 0;
}

/* ---------- Main ---------- */
.main {
  height: calc(100vh - 76px - 88px);
  display: flex;
  gap: 12px;
  padding: 8px 20px 0;
  min-height: 0;
}

/* ---------- Video area ---------- */
.video-area {
  flex: 1;
  min-width: 0;
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  grid-auto-rows: 1fr;
  align-content: center;
  gap: 10px;
}

.video-card {
  position: relative;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 16/10;
  border-radius: 12px;
  overflow: hidden;
  background: #191d20;
  border: 1px solid #25292d;
  cursor: pointer;
  transition: width .2s ease, height .2s ease, inset .2s ease;
}

/* ---------- Maximized (focused) tile, within the video area only ---------- */
.video-area[data-focus] {
  display: block;
}

.video-area[data-focus] .video-card {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

.video-area[data-focus="local"] .video-card.remote,
.video-area[data-focus="remote"] .video-card.local {
  inset: auto;
  bottom: 16px;
  right: 16px;
  width: 240px;
  height: 135px;
  z-index: 5;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  border: 2px solid var(--panel-3);
}

@media(max-width:600px) {
  .video-area[data-focus="local"] .video-card.remote,
  .video-area[data-focus="remote"] .video-card.local {
    width: 130px;
    height: 90px;
    bottom: 10px;
    right: 10px;
  }
}

.video-frame {
  width: 100%;
  height: 100%;
  position: relative;
}

.video-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background:
    radial-gradient(circle at center, #343a40, #171a1d 70%);
}

.video-card.local video { transform: scaleX(-1); }

.avatar-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: radial-gradient(circle at center, #343a40, #171a1d 70%);
  pointer-events: none;
}

.waiting-text {
  color: var(--text-faint);
  font-size: 13px;
}

.avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 30px;
  font-weight: 600;
  background: #41464c;
}

.avatar.green { background: #278a4a; }
.avatar.purple { background: #8e44ad; }
.avatar.orange { background: #e67e22; }
.avatar.blue { background: #2874a6; }

.mic-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.15s;
}

.mic-indicator.off {
  background: rgba(234,67,53,0.75);
}

.name {
  position: absolute;
  bottom: 12px;
  left: 14px;
  font-size: 14px;
  color: white;
  text-shadow: 0 1px 4px black;
}

.name:empty { display: none; }

.unmute-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--green);
  color: #06210f;
  border: none;
  border-radius: 24px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  z-index: 5;
}

.unmute-btn:hover { background: var(--green-hover); }

/* ---------- Chat panel ---------- */
.chat-panel {
  width: 365px;
  min-width: 365px;
  height: 100%;
  background: var(--panel);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  height: 68px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.chat-title {
  font-size: 18px;
  font-weight: 500;
}

.chat-close {
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  color: white;
  border-radius: 50%;
  font-size: 27px;
  cursor: pointer;
  line-height: 1;
}

.chat-close:hover { background: #2c3034; }

.chat-info {
  padding: 12px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.5;
  border-bottom: 1px solid var(--border);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  font-size: 13.5px;
  line-height: 1.55;
}

.messages:empty::before {
  content: "A conversa aparecerá aqui assim que alguém falar ou escrever.";
  color: var(--text-faint);
  font-size: 13px;
}

.entry {
  margin-bottom: 16px;
  max-width: 100%;
}

.entry-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 3px;
}

.entry .who {
  font-weight: 700;
  font-size: 13px;
}

.entry .ts {
  color: var(--text-faint);
  font-size: 11px;
}

.entry .kind-icon {
  font-size: 11px;
  opacity: 0.7;
}

.entry .text {
  color: #e5e7e9;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.entry.self .who { color: var(--green2, #55e77e); }
.entry.peer .who { color: var(--peer-color); }

.entry.interim { opacity: 0.55; font-style: italic; }

.entry.chat .text {
  background: var(--panel-2);
  display: inline-block;
  padding: 8px 12px;
  border-radius: 10px;
  margin-top: 2px;
}

.entry.chat.self .text { background: var(--green-soft); }

.entry.system .text {
  color: var(--text-faint);
  font-size: 12.5px;
  font-style: italic;
}

.chat-input {
  padding: 12px 15px 16px;
  flex-shrink: 0;
}

.input-container {
  height: 50px;
  border-radius: 26px;
  background: var(--panel-2);
  display: flex;
  align-items: center;
  padding: 0 8px 0 17px;
}

.input-container input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: white;
  font-size: 14px;
}

.input-container input::placeholder { color: #8d949a; }

.send {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--green);
  font-size: 20px;
  cursor: pointer;
}

.send:hover { background: var(--hover); }

/* ---------- Footer ---------- */
.footer {
  height: 88px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  background: #101214;
  border-top: 1px solid var(--border);
}

.footer-left {
  width: 220px;
  display: flex;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.clock { font-size: 14px; flex-shrink: 0; }

.footer-sep { color: #555; }

.footer-title {
  font-size: 14px;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: #292d31;
  color: white;
  font-size: 19px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .15s;
}

.control:hover { background: #3a3f44; }

.control .icon { width: 22px; height: 22px; }

.control.end .icon-phone { transform: rotate(135deg); }

.control.off {
  background: rgba(234,67,53,0.85);
}

.control:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.control.end {
  width: 70px;
  border-radius: 27px;
  background: var(--danger);
  font-size: 22px;
}

.control.end:hover { background: var(--danger-hover); }

.footer-right {
  width: 220px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.footer-icon {
  width: 45px;
  height: 45px;
  border: none;
  background: transparent;
  color: white;
  font-size: 20px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.footer-icon .icon { width: 20px; height: 20px; }

.footer-icon:hover { background: #292d31; }

.footer-icon.selected { color: var(--green); }

/* =====================================================
   RESPONSIVE
===================================================== */

@media(max-width:1100px) {
  .chat-panel { width: 320px; min-width: 320px; }
}

@media(max-width:850px) {
  .main { flex-direction: column; }

  .chat-panel {
    position: fixed;
    right: 12px;
    top: 80px;
    bottom: 90px;
    left: 12px;
    width: auto;
    min-width: 0;
    height: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  }

  .chat-panel.show { display: flex; }

  .meeting-title,
  .meeting-time,
  .separator,
  .conn-status { display: none; }

  .footer-left { display: none; }

  .footer { justify-content: center; gap: 24px; }
}

@media(max-width:600px) {
  .header { height: 64px; padding: 0 12px; }

  .main {
    height: calc(100vh - 64px - 76px);
    padding: 5px;
  }

  .video-area { gap: 5px; }

  .video-card { border-radius: 8px; }

  .logo-img { height: 26px; }

  .header-right .header-button { display: none; }

  .footer { height: 76px; }

  .controls { gap: 7px; }

  .control { width: 44px; height: 44px; font-size: 16px; }

  .control.end { width: 58px; }
}
