/* ==========================================================================
   TalkWide Web - Free4Talk Exact In-Room View & Audio/Video Stage
   100% Professional, Zero Overlap, Perfect 16:9 Synced Video, Full Responsiveness
   ========================================================================== */

/* Fullscreen In-Room Root */
body.in-room-mode {
  overflow: hidden !important;
  height: 100vh !important;
}

body.in-room-mode .app-header {
  display: none !important;
}

.f4t-room-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: #080c13;
  color: #f8fafc;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  position: relative;
}

/* --------------------------------------------------------------------------
   1. Main Audio / Video Stage (Left Area)
   -------------------------------------------------------------------------- */
.f4t-audio-stage {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
  padding: 12px 18px 14px 18px;
  background: radial-gradient(circle at 50% 45%, #0f1826 0%, #070b10 100%);
  gap: 8px;
}

/* Top Stage Bar: Brand Info (Left) | Call Pill (Center) | Stage Actions (Right) */
.f4t-stage-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 44px;
  flex-shrink: 0;
  z-index: 50;
  gap: 12px;
}

/* Room Brand Pill (Left) */
.f4t-stage-brand-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 36, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  padding: 3px 12px 3px 5px;
  max-width: 320px;
}

.stage-brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.stage-room-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
}

.stage-room-topic {
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.stage-room-lang-tag {
  font-size: 11px;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  padding: 2px 7px;
  border-radius: 9999px;
  flex-shrink: 0;
}

/* Center Floating Call Controls Pill */
.f4t-call-controls-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(13, 20, 31, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.f4t-pill-btn {
  width: 42px;
  height: 34px;
  border-radius: 5px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  transition: all 0.15s ease;
}

.f4t-pill-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.f4t-pill-btn.active-blue {
  background: #0284c7;
  color: #ffffff;
}

.f4t-pill-btn.active-blue:hover {
  background: #0369a1;
}

.f4t-pill-btn.is-muted {
  background: #1e293b;
  color: #ef4444;
}

.f4t-pill-btn.btn-leave-red {
  background: #ef4444;
  color: #ffffff;
}

.f4t-pill-btn.btn-leave-red:hover {
  background: #dc2626;
}

.f4t-pill-icon {
  width: 18px;
  height: 18px;
}

/* Stage Actions (Right) */
.f4t-stage-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.f4t-btn-stage-yt {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.f4t-btn-stage-yt:hover {
  background: rgba(239, 68, 68, 0.28);
  color: #ffffff;
  border-color: #ef4444;
}

.f4t-btn-stage-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s ease;
}

.f4t-btn-stage-icon:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   2. Main Stage Canvas Area (Auto-fits Spotlight OR Synced YouTube)
   -------------------------------------------------------------------------- */
.f4t-stage-main-canvas {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 6px 0;
}

/* A. Spotlight Speaker (Audio Mode) */
.f4t-spotlight-speaker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: fadeIn 0.3s ease;
}

.spotlight-avatar-outer {
  width: clamp(160px, 20vw, 220px);
  height: clamp(160px, 20vw, 220px);
  border-radius: 50%;
  border: 3.5px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: #141f2d;
}

.spotlight-avatar-outer.speaking {
  border-color: #0284c7;
  box-shadow: 0 0 0 6px rgba(2, 132, 199, 0.4), 0 0 35px rgba(2, 132, 199, 0.7);
  animation: spotlightPulse 1.6s infinite;
}

@keyframes spotlightPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.7), 0 0 20px rgba(2, 132, 199, 0.5);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(2, 132, 199, 0), 0 0 40px rgba(2, 132, 199, 0.7);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(2, 132, 199, 0), 0 0 20px rgba(2, 132, 199, 0.5);
  }
}

.spotlight-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.spotlight-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 52px;
  font-weight: 800;
  color: #ffffff;
  background: #6366f1;
}

.spotlight-speaker-label {
  background: rgba(14, 22, 33, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  padding: 4px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* B. Synced YouTube Stage Box (Video Mode: 100% Responsive 16:9) */
.f4t-youtube-stage-box {
  width: 100%;
  max-width: min(940px, calc((100vh - 200px) * 16 / 9 + 20px));
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85);
  position: relative;
  animation: fadeIn 0.25s ease;
}

.yt-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: #0f1724;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.yt-stage-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
}

.yt-stage-dot {
  font-size: 10px;
  font-weight: 800;
  color: #ef4444;
  letter-spacing: 0.5px;
}

.yt-stage-title {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.yt-stage-close-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.yt-stage-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* Exact 16:9 Viewport */
.yt-player-viewport {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.yt-player-viewport iframe,
.yt-player-viewport #yt-player-target {
  width: 100% !important;
  height: 100% !important;
  position: absolute;
  top: 0;
  left: 0;
  border: none;
  display: block;
}

/* Listener Sync Lock Overlay */
.youtube-listener-lock {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 10;
  pointer-events: none;
}

.youtube-sync-pill {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
}

/* Active Speaker PiP Badge while Video Plays */
.yt-speaker-pip {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 10;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
  padding: 3px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.yt-speaker-pip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

/* Host Controls Bar */
.yt-stage-host-bar {
  padding: 8px 12px;
  background: #0b121c;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.yt-stage-form {
  display: flex;
  gap: 8px;
}

.yt-stage-input {
  flex: 1;
  background: #141e2b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  padding: 6px 10px;
  color: #ffffff;
  font-size: 12px;
  outline: none;
}
.yt-stage-input:focus {
  border-color: #0284c7;
}

.yt-stage-preset-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.yt-preset-chip {
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  color: #94a3b8;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.yt-preset-chip:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

/* --------------------------------------------------------------------------
   3. Bottom Participant Tiles Dock (Exact to Free4Talk)
   -------------------------------------------------------------------------- */
.f4t-bottom-dock-wrapper {
  width: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 40;
  padding-top: 4px;
}

.f4t-participants-tiles-dock {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  padding: 2px 8px;
  margin: 0 auto;
  scrollbar-width: thin;
}

.f4t-dock-tile {
  width: 72px;
  height: 72px;
  min-width: 72px;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  background: #131d2a;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  flex-shrink: 0;
}

.f4t-dock-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.f4t-dock-tile.speaking {
  border-color: #0284c7;
  box-shadow: 0 0 14px rgba(2, 132, 199, 0.7);
}

.tile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Initials Tile for Unverified Users (Free4Talk Exact) */
.tile-initial-box {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  user-select: none;
}

.tile-initial-letters {
  font-size: 23px;
  line-height: 1;
}

.tile-unverified-tag {
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.6px;
  opacity: 0.85;
  margin-top: 2px;
  text-transform: uppercase;
}

/* Small Gear Icon Button in Top-Right of Tile */
.tile-gear-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 5;
  padding: 0;
}

.tile-gear-btn:hover {
  background: #0284c7;
  color: #ffffff;
}

/* Bottom Blue Role Badge */
.tile-role-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0284c7;
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 700;
  text-align: center;
  height: 16px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 4;
}

/* Tiny Mute Mic Icon in Bottom-Right */
.tile-mute-icon {
  position: absolute;
  bottom: 18px;
  right: 4px;
  font-size: 10px;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  z-index: 5;
}

/* Floating Mini Actions Pill below tiles */
.f4t-dock-mini-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(18, 28, 42, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  padding: 3px 12px;
  position: relative;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.f4t-mini-btn {
  background: transparent;
  border: none;
  font-size: 15px;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 5px;
  color: #e2e8f0;
  transition: transform 0.15s ease;
}

.f4t-mini-btn:hover {
  transform: scale(1.25);
}

/* Popups for reactions & more menu */
.f4t-reactions-popup,
.f4t-more-popup {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.85);
  padding: 6px;
  z-index: 1000;
  display: flex;
}

.f4t-reactions-popup {
  gap: 6px;
}
.f4t-reactions-popup button {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: transform 0.15s ease;
}
.f4t-reactions-popup button:hover {
  transform: scale(1.3);
}

.f4t-more-popup {
  flex-direction: column;
  min-width: 190px;
  gap: 2px;
}
.f4t-more-popup button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: #e2e8f0;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
}
.f4t-more-popup button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   4. Free4Talk Live Chat Drawer (Right Sidebar)
   -------------------------------------------------------------------------- */
.f4t-chat-sidebar {
  width: 320px;
  min-width: 290px;
  max-width: 340px;
  height: 100%;
  background: #090e15;
  border-left: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  transition: width 0.2s ease;
}

/* Top Action Tabs */
.f4t-chat-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid #1e293b;
  background: #0c131d;
  flex-shrink: 0;
}

.f4t-chat-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
}

.f4t-tab-icon-btn {
  background: transparent;
  border: none;
  padding: 6px 8px;
  border-radius: 4px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.f4t-tab-icon-btn:hover {
  color: #cbd5e1;
}

.f4t-tab-icon-btn.active {
  color: #38bdf8;
}

.tab-svg {
  width: 17px;
  height: 17px;
}

.f4t-chat-toggle-collapse {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}
.f4t-chat-toggle-collapse:hover {
  color: #ffffff;
}

/* Room Info Card */
.f4t-chat-room-info-card {
  background: #111a26;
  border: 1px solid #1e2d3d;
  border-radius: 4px;
  margin: 8px 10px;
  padding: 8px 12px;
  flex-shrink: 0;
}

.f4t-chat-info-label {
  font-size: 11px;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 2px;
}

.f4t-chat-info-value {
  font-size: 11px;
  color: #94a3b8;
}

/* Chat Messages Container */
.f4t-chat-sidebar .chat-messages-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Chat Bottom Input & Toolbar */
.f4t-chat-bottom-dock {
  padding: 8px 10px 12px 10px;
  background: #090e15;
  border-top: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.f4t-chat-tools-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.f4t-tool-icon-btn {
  background: transparent;
  border: none;
  font-size: 15px;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: transform 0.15s ease;
}
.f4t-tool-icon-btn:hover {
  transform: scale(1.15);
  color: #ffffff;
}

.f4t-tool-text-btn {
  border: 1px solid #334155;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  color: #94a3b8;
  background: transparent;
  cursor: pointer;
  line-height: 1.2;
}
.f4t-tool-text-btn:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}

.mic-tool-btn {
  margin-left: auto;
}

.f4t-chat-form-box {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: #0d1520;
  border: 1px solid #1e2d3f;
  border-radius: 6px;
  padding: 6px 8px;
  transition: border-color 0.15s ease;
}

.f4t-chat-form-box:focus-within {
  border-color: #0284c7;
}

.f4t-chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #f1f5f9;
  font-family: inherit;
  font-size: 12.5px;
  resize: none;
  min-height: 36px;
  max-height: 80px;
  line-height: 1.35;
}

.f4t-chat-textarea::placeholder {
  color: #475569;
}

.f4t-chat-send-btn {
  background: transparent;
  border: none;
  color: #0284c7;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.f4t-chat-send-btn:hover {
  color: #38bdf8;
  transform: scale(1.1);
}

/* Floating Reactions */
.emoji-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 99;
}

.floating-emoji {
  position: absolute;
  bottom: 80px;
  font-size: 32px;
  animation: floatUp 2.2s forwards cubic-bezier(0.1, 0.8, 0.3, 1);
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.6);
  }
  100% {
    opacity: 0;
    transform: translateY(-280px) scale(1.3);
  }
}
