/* ==========================================
   nivoMeet — Design System
   Light theme aligned with nivoLive brand
   ========================================== */

/* ---------- Google Fonts: Baloo Thambi 2 (match nivoLive) ---------- */
@import url('https://fonts.googleapis.com/css2?family=Baloo+Thambi+2:wght@400;500;600;700;800&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Backgrounds (Light, clean, WhatsApp-like) */
  --bg-primary: #ffffff;
  --bg-secondary: #f7f5f1;
  --bg-surface: #f0ede8;
  --bg-elevated: #eae7e1;
  --bg-video: #1a1a2e;
  --bg-glass: rgba(255, 255, 255, 0.88);
  --bg-page: linear-gradient(160deg, #f7f5f1 0%, #eef1f7 40%, #f0f4ff 100%);

  /* Brand — nivoLive palette */
  --navy: #263765;
  --navy-light: #2d4a8a;
  --blue: #264cb6;
  --blue-light: #EBF2FB;
  --gold: #ffc845;
  --gold-hover: #f5bc30;

  /* Accent */
  --accent: #264cb6;
  --accent-hover: #1e3a8a;
  --accent-light: rgba(38, 76, 182, 0.08);
  --accent-glow: rgba(38, 76, 182, 0.15);
  --accent-gradient: linear-gradient(135deg, #264cb6, #1e3a8a);

  /* Status */
  --success: #389537;
  --success-light: #e8f5e8;
  --danger: #ea4335;
  --danger-hover: #d33426;
  --danger-light: #fef2f2;
  --warning: #f59e0b;

  /* Text */
  --text-primary: #263765;
  --text-secondary: #6b7a99;
  --text-muted: #9eabbf;
  --text-on-accent: #ffffff;

  /* Borders & Effects */
  --border: #dbe1eb;
  --border-hover: #c5cdd9;
  --border-active: rgba(38, 76, 182, 0.4);
  --shadow-xs: 0 1px 2px rgba(38, 55, 101, 0.04);
  --shadow-sm: 0 2px 8px rgba(38, 55, 101, 0.06);
  --shadow-md: 0 4px 16px rgba(38, 55, 101, 0.08);
  --shadow-lg: 0 8px 32px rgba(38, 55, 101, 0.10);
  --shadow-xl: 0 12px 48px rgba(38, 55, 101, 0.12);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Timing */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Baloo Thambi 2', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ---------- Animated Background (Light, subtle) ---------- */
.animated-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  background: var(--bg-page);
}

.animated-bg .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  animation: float 25s ease-in-out infinite;
}

.animated-bg .orb:nth-child(1) {
  width: 500px;
  height: 500px;
  background: #dce8ff;
  top: -150px;
  left: -80px;
  animation-delay: 0s;
}

.animated-bg .orb:nth-child(2) {
  width: 400px;
  height: 400px;
  background: #fff3d0;
  bottom: -150px;
  right: -80px;
  animation-delay: -8s;
}

.animated-bg .orb:nth-child(3) {
  width: 350px;
  height: 350px;
  background: #d4f0d4;
  top: 40%;
  left: 60%;
  animation-delay: -16s;
}

@keyframes float {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  25% {
    transform: translate(40px, -60px) scale(1.05);
  }

  50% {
    transform: translate(-20px, 40px) scale(0.95);
  }

  75% {
    transform: translate(50px, 20px) scale(1.02);
  }
}

/* ---------- Layout Utilities ---------- */
.page-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

/* ==========================================
   HOME PAGE
   ========================================== */
.home-container {
  text-align: center;
  max-width: 860px;
  width: 100%;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-icon {
  width: 52px;
  height: 52px;
  background: var(--accent-gradient);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #fff;
  box-shadow: 0 4px 14px rgba(38, 76, 182, 0.25);
}

.brand h1 {
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--navy);
}

.home-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 44px;
  font-weight: 400;
}

.home-actions {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.home-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 36px 32px;
  width: 370px;
  transition: var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.home-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.home-card h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}

.home-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
  font-weight: 400;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  user-select: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gold);
  color: var(--navy);
  box-shadow: 0 4px 14px rgba(255, 200, 69, 0.3);
}

.btn-primary:hover {
  background: var(--gold-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 200, 69, 0.35);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.btn-accent {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(38, 76, 182, 0.25);
}

.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(38, 76, 182, 0.3);
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--navy);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--border-hover);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-icon {
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.3rem;
}

.btn-icon.active {
  background: var(--bg-primary);
  color: var(--navy);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-icon.muted {
  background: var(--danger);
  color: #fff;
  border: none;
}

.btn-icon:hover {
  transform: scale(1.08);
}

.btn-sm {
  padding: 10px 20px;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 16px 40px;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* ---------- Inputs ---------- */
.input-group {
  position: relative;
  width: 100%;
}

.text-input {
  width: 100%;
  padding: 14px 20px;
  background: var(--bg-primary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition-fast);
  outline: none;
}

.text-input::placeholder {
  color: var(--text-muted);
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.separator {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.separator::before,
.separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- Time Display ---------- */
.time-display {
  margin-top: 44px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.time-display .clock {
  font-size: 3rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 2px;
}

/* ==========================================
   LOBBY PAGE
   ========================================== */
.lobby-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  max-width: 1000px;
  width: 100%;
  flex-wrap: wrap;
}

.lobby-preview {
  flex: 1;
  min-width: 400px;
  max-width: 560px;
}

.video-preview-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--bg-video);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.video-preview-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.video-preview-wrapper .no-camera {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #8888aa;
}

.no-camera .avatar-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #aaa;
}

.preview-controls {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
}

.preview-controls .btn-icon.active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
}

.preview-controls .btn-icon.muted {
  background: var(--danger);
  color: #fff;
}

.lobby-config {
  flex: 0 0 320px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.lobby-header {
  text-align: center;
  margin-bottom: 8px;
}

.lobby-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

.lobby-header .room-code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--accent);
  font-size: 1rem;
  letter-spacing: 1px;
  font-weight: 600;
}

.config-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-md);
}

.config-card .form-group {
  margin-bottom: 20px;
}

.config-card label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.device-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.device-toggle:last-child {
  border-bottom: none;
}

.device-toggle-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.device-toggle-info .material-icons-round {
  color: var(--text-secondary);
  font-size: 1.3rem;
}

.device-toggle-info span {
  font-size: 0.95rem;
  color: var(--text-primary);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle-switch input {
  display: none;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 12px;
  transition: var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.toggle-switch input:checked+.toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* ==========================================
   ROOM PAGE (keeps dark bg for video)
   ========================================== */
.room-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-video);
}

/* Top Bar — dark (Google Meet style) */
.room-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #1e2433;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-brand {
  font-size: 1rem;
  font-weight: 700;
  color: #f0f0f8;
}

.topbar-room-code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  color: #9eabbf;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar-room-code:hover {
  color: var(--gold);
  border-color: rgba(255, 200, 69, 0.3);
  background: rgba(255, 200, 69, 0.08);
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-timer {
  font-size: 0.9rem;
  font-weight: 600;
  color: #9eabbf;
  font-variant-numeric: tabular-nums;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.participants-count {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #9eabbf;
  background: rgba(255, 255, 255, 0.06);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Video Grid */
.video-grid {
  flex: 1;
  display: grid;
  gap: 6px;
  padding: 6px;
  overflow: hidden;
  transition: var(--transition-normal);
}

.video-grid[data-count="1"] {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.video-grid[data-count="2"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}

.video-grid[data-count="3"] {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr;
}

.video-grid[data-count="4"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.video-grid[data-count="5"],
.video-grid[data-count="6"] {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.video-grid[data-count="7"],
.video-grid[data-count="8"],
.video-grid[data-count="9"] {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
}

/* Video Tile */
.video-tile {
  position: relative;
  background: #1e2433;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid transparent;
  transition: var(--transition-normal);
  animation: tileAppear 0.4s ease forwards;
}

.video-tile.speaking {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(255, 200, 69, 0.3);
}

@keyframes tileAppear {
  from {
    opacity: 0;
    transform: scale(0.92);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-tile .tile-avatar {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e2433;
}

.tile-avatar .avatar-big {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--blue-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
}

.tile-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tile-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tile-indicators {
  display: flex;
  gap: 4px;
}

.indicator {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  background: rgba(0, 0, 0, 0.5);
}

.indicator.muted {
  color: var(--danger);
}

/* Control Bar — dark (Google Meet style) */
.control-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  background: #1e2433;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 10;
  gap: 12px;
}

.control-bar .controls-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-bar .controls-right {
  position: absolute;
  right: 24px;
}

.control-bar .btn-icon.active {
  background: #3c4043;
  color: #e8eaed;
  border: none;
  box-shadow: none;
}

.control-bar .btn-icon.active:hover {
  background: #4a4d52;
}

.control-bar .btn-icon.muted {
  background: #ea4335;
  color: #fff;
  border: none;
}

.control-bar .btn-icon.muted:hover {
  background: #d33426;
}

.control-bar .btn-leave {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: #ea4335;
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
}

.control-bar .btn-leave:hover {
  background: var(--danger-hover);
  transform: scale(1.03);
}

/* ==========================================
   TOASTS
   ========================================== */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 12px 24px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease forwards;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.leaving {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* ==========================================
   LOADING / CONNECTING STATES
   ========================================== */
.connecting-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  z-index: 100;
  transition: opacity 0.4s ease;
}

.connecting-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.connecting-text {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 768px) {
  .home-actions {
    flex-direction: column;
    align-items: center;
  }

  .home-card {
    width: 100%;
    max-width: 380px;
  }

  .brand h1 {
    font-size: 2rem;
  }

  .lobby-container {
    flex-direction: column;
  }

  .lobby-preview {
    min-width: unset;
    width: 100%;
  }

  .lobby-config {
    flex: 1;
    width: 100%;
  }

  .video-grid[data-count="2"],
  .video-grid[data-count="3"] {
    grid-template-columns: 1fr;
  }

  .control-bar .controls-right {
    position: static;
  }

  .control-bar {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .page-wrapper {
    padding: 16px;
  }

  .home-card {
    padding: 24px 20px;
  }

  .btn-icon {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }

  .time-display .clock {
    font-size: 2rem;
  }
}

/* ---------- Material Icons Fix ---------- */
.material-icons-round {
  font-size: inherit;
  vertical-align: middle;
}