/* ====================================
   АллоМам - Современный стиль
   ==================================== */

/* CSS Variables */
:root {
  --primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --primary-solid: #667eea;
  --secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --secondary-solid: #f093fb;
  --accent: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --accent-solid: #4facfe;
  --danger: #ef4444;
  --success: #10b981;
  --background: #0a0e1a;
  --surface: #151b2e;
  --card: rgba(255, 255, 255, 0.03);
  --card-hover: rgba(255, 255, 255, 0.06);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: rgba(0, 0, 0, 0.5);
  --glow: rgba(102, 126, 234, 0.3);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.2s ease;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 20% 30%, rgba(102, 126, 234, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(240, 147, 251, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(79, 172, 254, 0.1) 0%, transparent 50%);
  animation: gradientShift 15s ease infinite;
  z-index: -1;
  pointer-events: none;
}

@keyframes gradientShift {
  0%, 100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: scale(1.1) rotate(5deg);
    opacity: 0.8;
  }
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Для landing страницы убираем ограничение ширины */
.container:has(#startScreen.active) {
  max-width: none;
  padding: 0;
}

/* Remove padding when call is active */
.container.call-active {
  padding: 0;
  max-width: none;
}

/* Header - Simple centered title */
header {
  text-align: center;
  padding: 40px 0 20px;
}

/* Для landing страницы уменьшаем padding header */
.container:has(#startScreen.active) header {
  padding: 30px 20px 20px;
}

/* Hide header when call is active */
.call-active header {
  display: none;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 8px 0;
  letter-spacing: -1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

header h1::before {
  content: '📹';
  font-size: 2.2rem;
}

header .subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
}

/* Main Content */
main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}

/* Full screen main when call is active */
.call-active main {
  padding: 0;
}

/* Screen Container */
.screen {
  display: none;
  width: 100%;
  animation: fadeIn 0.4s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Card */
.card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 56px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  max-width: 620px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  opacity: 0.6;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 0 0 1px rgba(102, 126, 234, 0.3);
  border-color: rgba(102, 126, 234, 0.3);
}

.card h2 {
  text-align: center;
  color: var(--text);
  margin-bottom: 40px;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
}

/* Buttons */
.buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn {
  padding: 18px 36px;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transform: translate(-50%, -50%);
  transition: width 0.5s ease, height 0.5s ease;
}

.btn:hover::before {
  width: 400px;
  height: 400px;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  padding: 2px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), transparent);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn:hover::after {
  opacity: 1;
}

.btn-primary {
  background: var(--primary);
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow:
    0 8px 24px rgba(102, 126, 234, 0.5),
    0 4px 12px rgba(118, 75, 162, 0.3);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-secondary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow:
    0 8px 24px rgba(240, 147, 251, 0.5),
    0 4px 12px rgba(245, 87, 108, 0.3);
}

.btn-small {
  padding: 10px 20px;
  font-size: 0.9rem;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Divider */
.divider {
  text-align: center;
  color: var(--text-muted);
  position: relative;
  margin: 20px 0;
  font-size: 0.9rem;
}

.divider::before,
.divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.divider::before { left: 0; }
.divider::after { right: 0; }

/* Input Fields */
input[type="text"] {
  width: 100%;
  padding: 18px 20px;
  font-size: 1.05rem;
  background: rgba(255, 255, 255, 0.02);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  transition: var(--transition);
  font-family: inherit;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="text"]:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-solid);
  background: rgba(255, 255, 255, 0.05);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.2),
    0 0 0 4px rgba(102, 126, 234, 0.1),
    0 0 20px rgba(102, 126, 234, 0.2);
}

input[readonly] {
  cursor: default;
  user-select: all;
  background: rgba(255, 255, 255, 0.03);
}

/* Waiting Screen Layout */
#waitingScreen .card {
  max-width: 100%;
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 40px;
  align-items: stretch;
}

#waitingScreen .room-info-section {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

#waitingScreen .video-preview {
  position: relative;
  width: 100%;
  background: linear-gradient(135deg, rgba(10, 14, 26, 0.95) 0%, rgba(21, 27, 46, 0.95) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

#waitingScreen .video-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-xl);
}

/* Room Info */
.room-info {
  margin: 32px 0;
}

.room-info p {
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.room-id-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 24px 0 40px;
  padding: 24px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(102, 126, 234, 0.2);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.15);
}

.room-id-display span {
  font-size: 3rem;
  font-weight: 900;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 12px;
  text-shadow: 0 0 40px var(--glow);
  animation: pulseGlow 2s ease-in-out infinite;
  filter: drop-shadow(0 0 10px rgba(102, 126, 234, 0.3));
}

@keyframes pulseGlow {
  0%, 100% {
    filter: drop-shadow(0 0 10px rgba(102, 126, 234, 0.3));
  }
  50% {
    filter: drop-shadow(0 0 20px rgba(102, 126, 234, 0.5));
  }
}

.btn-icon {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
  border: 2px solid var(--border);
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.btn-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn-icon:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.08) 100%);
  transform: scale(1.1) rotate(5deg);
  border-color: var(--primary-solid);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.3),
    0 0 0 3px rgba(102, 126, 234, 0.2);
}

.btn-icon:hover::before {
  opacity: 0.1;
}

.btn-icon:active {
  transform: scale(0.95);
}

.btn-icon svg {
  width: 22px;
  height: 22px;
  position: relative;
  z-index: 1;
}

.room-link {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.room-link input {
  flex: 1;
}

.help-text {
  margin-top: 24px;
  font-weight: 500;
  color: var(--text);
}

/* Video Grid */
#callScreen {
  max-width: 100%;
  padding: 0;
  width: 100%;
  height: 100%;
  position: relative;
}

/* Только когда callScreen активен, показываем его как flex */
#callScreen.active {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
}

/* Home Button - в info-panel */
.info-panel .home-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.info-panel .home-button:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.info-panel .home-button svg {
  width: 18px;
  height: 18px;
}

.video-grid {
  position: absolute;
  top: 54px; /* Высота info-panel (padding 12px * 2 + content ~30px) */
  left: 0;
  right: 0;
  bottom: 0;
  display: none; /* Скрыт по умолчанию */
  gap: 16px;
  padding: 16px;
  background: var(--background);
  overflow: hidden;
}

/* Grid layouts для разного количества участников */
/* Показываем grid только когда есть участники */
.video-grid.participants-1,
.video-grid.participants-2,
.video-grid.participants-3,
.video-grid.participants-4 {
  display: grid; /* Показываем когда есть участники */
}

.video-grid.participants-1 {
  grid-template-columns: 1fr;
}

.video-grid.participants-2 {
  grid-template-columns: repeat(2, 1fr);
}

.video-grid.participants-3,
.video-grid.participants-4 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

/* Video wrapper */
.video-wrapper {
  position: relative;
  background: #000;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  transition: var(--transition);
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.video-wrapper:hover {
  border-color: var(--primary-solid);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(102, 126, 234, 0.3);
  transform: scale(1.01);
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-xl);
}

.video-wrapper .video-label {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.video-wrapper.local .video-label {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 4px 12px rgba(102, 126, 234, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Fullscreen video */
.video-wrapper:fullscreen,
.video-wrapper:-webkit-full-screen {
  aspect-ratio: auto;
  border-radius: 0;
  border: none;
  cursor: default;
  width: 100vw !important;
  height: 100vh !important;
}

.video-wrapper:fullscreen video,
.video-wrapper:-webkit-full-screen video {
  object-fit: contain;
  border-radius: 0;
}

.video-wrapper:fullscreen .video-label,
.video-wrapper:-webkit-full-screen .video-label {
  top: 32px;
  left: 32px;
  font-size: 1.1rem;
  padding: 12px 20px;
}

/* Chat Panel */
.chat-panel {
  position: fixed;
  right: -420px;
  top: 0;
  width: 420px;
  height: 100vh;
  background: linear-gradient(180deg, rgba(21, 27, 46, 0.98) 0%, rgba(15, 20, 36, 0.98) 100%);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-left: 1px solid rgba(102, 126, 234, 0.2);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  z-index: 100;
  box-shadow:
    -20px 0 60px rgba(0, 0, 0, 0.6),
    inset 1px 0 0 rgba(255, 255, 255, 0.05);
}

.chat-panel.open {
  right: 0;
}

.chat-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.chat-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.chat-header svg {
  width: 20px;
  height: 20px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 75%;
  animation: slideInMessage 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInMessage {
  from {
    opacity: 0;
    transform: translateX(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.chat-message.own {
  align-self: flex-end;
}

.chat-message .sender {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-left: 4px;
}

.chat-message .content {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.03) 100%);
  padding: 12px 16px;
  border-radius: 16px 16px 16px 4px;
  word-wrap: break-word;
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: var(--transition-fast);
}

.chat-message .content:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.chat-message.own .content {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 16px 16px 4px 16px;
  box-shadow:
    0 4px 12px rgba(102, 126, 234, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.chat-message.own .content:hover {
  box-shadow:
    0 6px 16px rgba(102, 126, 234, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.chat-input {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  background: var(--card);
}

.chat-input input {
  flex: 1;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 16px; /* 16px чтобы iOS не зумил при фокусе */
  -webkit-appearance: none; /* Отключить стандартное оформление iOS */
}

.chat-input input:focus {
  outline: none;
  border-color: var(--primary-solid);
}

.chat-input .btn {
  padding: 12px 16px;
  width: auto;
}

/* Controls - Floating over video */
.controls {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 20px 32px;
  /* Полупрозрачный фон вместо solid */
  background: linear-gradient(135deg, rgba(21, 27, 46, 0.75) 0%, rgba(15, 20, 36, 0.8) 100%);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-xl);
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 10;
  /* Плавная анимация появления при загрузке */
  animation: slideUpInitial 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  /* Плавный переход для показа/скрытия (работает в обе стороны) */
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
}

/* Скрытое состояние панели - плавная анимация */
.controls.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(30px);
  pointer-events: none;
}

/* Анимация начального появления панели управления */
@keyframes slideUpInitial {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(100px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.btn-control {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  position: relative;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-control::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, var(--primary-solid), var(--accent-solid));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn-control:hover::before {
  opacity: 1;
}

.btn-control svg {
  width: 26px;
  height: 26px;
  position: relative;
  z-index: 1;
}

.btn-control:hover {
  transform: scale(1.15);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.08) 100%);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 0 20px rgba(102, 126, 234, 0.3);
}

.btn-control:active {
  transform: scale(0.95);
}

.btn-control.disabled {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.9) 0%, rgba(220, 38, 38, 0.9) 100%);
  color: white;
  border-color: var(--danger);
  box-shadow:
    0 4px 16px rgba(239, 68, 68, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-control.disabled:hover {
  box-shadow:
    0 6px 20px rgba(239, 68, 68, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-control.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  color: white;
  border-color: var(--danger);
  box-shadow:
    0 4px 16px rgba(239, 68, 68, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-control.btn-danger::before {
  background: linear-gradient(135deg, #ff6b6b, #ff4757);
}

.btn-control.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow:
    0 8px 28px rgba(239, 68, 68, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 0 30px rgba(239, 68, 68, 0.4);
}

/* Badge */
.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  color: white;
  font-size: 0.75rem;
  font-weight: 800;
  min-width: 24px;
  height: 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 2px solid var(--surface);
  box-shadow:
    0 4px 12px rgba(239, 68, 68, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      0 4px 12px rgba(239, 68, 68, 0.5),
      inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }
  50% {
    transform: scale(1.1);
    box-shadow:
      0 6px 16px rgba(239, 68, 68, 0.7),
      inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }
}

.badge.hidden {
  display: none;
}

/* Footer - Hidden */
footer {
  display: none;
}

/* Notifications */
.notification {
  position: fixed;
  top: 32px;
  right: 32px;
  background: linear-gradient(135deg, rgba(21, 27, 46, 0.98) 0%, rgba(15, 20, 36, 0.98) 100%);
  border: 1px solid var(--border);
  padding: 20px 28px;
  border-radius: var(--radius-lg);
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  z-index: 10000;
  animation: slideInNotification 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  max-width: 420px;
  overflow: hidden;
}

.notification::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary);
}

.notification.success::before {
  background: linear-gradient(180deg, var(--success) 0%, #059669 100%);
  box-shadow: 0 0 20px var(--success);
}

.notification.error::before {
  background: linear-gradient(180deg, var(--danger) 0%, #dc2626 100%);
  box-shadow: 0 0 20px var(--danger);
}

.notification.info::before {
  background: var(--primary);
  box-shadow: 0 0 20px var(--primary-solid);
}

@keyframes slideInNotification {
  from {
    transform: translateX(500px) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  header {
    padding: 30px 0 16px;
  }

  header h1 {
    font-size: 2rem;
  }

  header h1::before {
    font-size: 1.8rem;
  }

  header .subtitle {
    font-size: 0.9rem;
  }

  .card {
    padding: 40px 28px;
    border-radius: var(--radius-lg);
  }

  .card h2 {
    font-size: 1.8rem;
  }

  /* Waiting screen responsive */
  #waitingScreen .card {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 32px;
  }

  #waitingScreen .video-preview {
    order: -1; /* Move video preview to top */
    max-width: 100%;
    aspect-ratio: 4/3;
    margin: 0;
    width: 100%;
  }

  .btn {
    padding: 16px 28px;
    font-size: 1rem;
  }

  .chat-panel {
    width: 100%;
    right: -100%;
    /* Добавляем padding-bottom чтобы .chat-input не был скрыт за панелью управления */
    padding-bottom: 120px;
  }

  /* Фиксированное позиционирование поля ввода на мобильных */
  .chat-input {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: var(--card);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
  }

  .video-grid {
    gap: 10px;
    padding: 10px;
  }

  .video-grid.participants-2,
  .video-grid.participants-3,
  .video-grid.participants-4 {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .info-panel .home-button {
    width: 32px;
    height: 32px;
  }

  .info-panel .home-button svg {
    width: 16px;
    height: 16px;
  }

  .controls {
    gap: 16px;
    padding: 16px 24px;
    bottom: 20px;
  }

  .btn-control {
    width: 56px;
    height: 56px;
  }

  .btn-control svg {
    width: 22px;
    height: 22px;
  }

  .notification {
    top: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
  }

  .room-id-display span {
    font-size: 2.2rem;
    letter-spacing: 8px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 12px;
  }

  header {
    padding: 24px 0 12px;
  }

  header h1 {
    font-size: 1.6rem;
  }

  header h1::before {
    font-size: 1.5rem;
  }

  header .subtitle {
    font-size: 0.85rem;
  }

  .card {
    padding: 32px 20px;
  }

  .card h2 {
    font-size: 1.5rem;
  }

  .btn {
    padding: 14px 24px;
    font-size: 0.95rem;
  }

  .room-link {
    flex-direction: column;
  }

  .room-id-display {
    padding: 20px;
  }

  .room-id-display span {
    font-size: 2rem;
    letter-spacing: 6px;
  }

  .btn-icon {
    width: 48px;
    height: 48px;
  }

  .btn-control {
    width: 52px;
    height: 52px;
  }

  .btn-control svg {
    width: 20px;
    height: 20px;
  }

  .controls {
    gap: 12px;
    padding: 14px 20px;
    bottom: 16px;
  }

  .chat-header {
    padding: 20px;
  }

  .chat-header h3 {
    font-size: 1.1rem;
  }

  input[type="text"] {
    padding: 16px 18px;
    font-size: 1rem;
  }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--surface);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(102, 126, 234, 0.5) 0%, rgba(118, 75, 162, 0.5) 100%);
  border-radius: 5px;
  border: 2px solid var(--surface);
  transition: var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--primary-solid) 0%, #764ba2 100%);
  box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

/* Selection Styling */
::selection {
  background: rgba(102, 126, 234, 0.3);
  color: var(--text);
}

::-moz-selection {
  background: rgba(102, 126, 234, 0.3);
  color: var(--text);
}

/* Focus Visible */
*:focus-visible {
  outline: 2px solid var(--primary-solid);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Loading Animation */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.loading {
  animation: shimmer 2s infinite linear;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0.03) 0%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.03) 100%
  );
  background-size: 1000px 100%;
}

/* Loading Screen */
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 48px 32px;
  text-align: center;
}

.loading-content h2 {
  margin: 0;
  font-size: 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.loading-content .help-text {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Spinner */
.spinner {
  width: 64px;
  height: 64px;
  border: 4px solid rgba(102, 126, 234, 0.1);
  border-top-color: var(--primary-solid);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ====================================
   Profile Modal & Header
   ==================================== */

/* Header Layout */
.header-content {
  text-align: center;
}

/* Profile Button */
.profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: var(--transition);
  height: auto;
  width: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.profile-btn:hover {
  background: var(--card-hover);
  border-color: var(--primary-solid);
  transform: translateY(-2px);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(102, 126, 234, 0.2);
}

.profile-btn svg {
  width: 20px;
  height: 20px;
}

.display-name-preview {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Modal Backdrop */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.modal.active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Modal Content */
.modal-content {
  background: linear-gradient(135deg, rgba(21, 27, 46, 0.98) 0%, rgba(15, 20, 36, 0.98) 100%);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  width: 90%;
  max-width: 500px;
  padding: 0;
  animation: slideInModal 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInModal {
  from {
    transform: scale(0.9) translateY(-30px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Modal Header */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 32px 20px 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: transparent;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header h3 svg {
  width: 22px;
  height: 22px;
}

.modal-header .btn-icon {
  width: 40px;
  height: 40px;
  background: var(--card);
  border: 1px solid var(--border);
  transition: var(--transition-fast);
}

.modal-header .btn-icon:hover {
  background: var(--card-hover);
  border-color: var(--danger);
  color: var(--danger);
}

/* Modal Body */
.modal-body {
  padding: 24px 32px;
}

.modal-body label {
  display: block;
  margin-bottom: 12px;
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.modal-body input {
  width: 100%;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 1rem;
  transition: var(--transition-fast);
}

.modal-body input:focus {
  outline: none;
  border-color: var(--primary-solid);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modal-body .help-text {
  margin-top: 12px;
  margin-bottom: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-body .error-message {
  margin-top: 12px;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 500;
  display: none;
}

.modal-body .error-message:not(:empty) {
  display: block;
}

/* Modal Footer */
.modal-footer {
  padding: 20px 32px 28px 32px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: transparent;
}

.modal-footer .btn {
  min-width: 140px;
}

/* Responsive Modal */
@media (max-width: 768px) {
  .profile-btn {
    padding: 8px 14px;
  }

  .display-name-preview {
    max-width: 200px;
    font-size: 0.9rem;
  }

  .modal-content {
    width: 95%;
    margin: 20px;
  }

  .modal-header {
    padding: 20px 24px;
  }

  .modal-header h3 {
    font-size: 1.1rem;
  }

  .modal-body {
    padding: 24px;
  }

  .modal-footer {
    padding: 20px 24px;
  }

  .modal-footer .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .profile-btn {
    padding: 8px 12px;
    gap: 8px;
  }

  .display-name-preview {
    max-width: 160px;
    font-size: 0.85rem;
  }

  .header-content {
    gap: 12px;
    flex-wrap: wrap;
  }

  .header-left {
    width: 100%;
  }

  .profile-btn {
    width: 100%;
    justify-content: center;
  }

  .modal-header {
    padding: 18px 20px;
  }

  .modal-body {
    padding: 20px;
  }

  .modal-footer {
    padding: 18px 20px;
  }

  .modal-footer .btn {
    width: 100%;
    font-size: 0.9rem;
  }
}

/* ============================================
   FULLSCREEN UI - PARTICIPANT NAVIGATION
   ============================================ */

/* Fullscreen UI Container */
.fullscreen-ui {
  position: absolute;
  inset: 0;
  pointer-events: none; /* Клики проходят через контейнер */
  z-index: 100;
}

/* ============================================
   THUMBNAILS BAR (нижняя полоса с миниатюрами)
   ============================================ */

.fullscreen-thumbnails-bar {
  position: absolute;
  bottom: 80px; /* Над controls */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: calc(100vw - 40px); /* Не выходим за границы */
  overflow-x: auto; /* Скролл если не помещается */
  overflow-y: hidden;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  pointer-events: auto;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 101;
}

.fullscreen-thumbnails-bar::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.fullscreen-thumbnails-bar.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

/* Миниатюра */
.fs-thumbnail {
  width: 120px;
  height: 80px;
  flex-shrink: 0; /* Не сжимаются */
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

.fs-thumbnail.active {
  border-color: #667eea;
  box-shadow: 0 0 16px rgba(102, 126, 234, 0.6);
}

.fs-thumbnail:hover {
  border-color: #667eea;
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.5);
}

/* Видео в миниатюре */
.fs-thumbnail video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.fs-thumbnail .video-label {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  font-size: 0.65rem;
  padding: 3px 6px;
  text-align: center;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Специальный стиль для label в миниатюрах - очень компактный */
.fs-thumbnail .fs-thumbnail-label {
  font-size: 0.45rem;
  padding: 2px 4px;
  font-weight: 600;
  letter-spacing: 0;
}

/* ============================================
   NAVIGATION ARROWS (стрелки)
   ============================================ */

.fullscreen-nav-arrows {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.fullscreen-nav-arrows.hidden {
  opacity: 0;
  pointer-events: none;
}

.fs-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.3s ease;
  color: white;
}

.fs-arrow:hover {
  background: rgba(102, 126, 234, 0.8);
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.5);
}

.fs-arrow:active {
  transform: translateY(-50%) scale(0.95);
}

.fs-arrow.left {
  left: 20px;
}

.fs-arrow.right {
  right: 20px;
}

.fs-arrow svg {
  width: 24px;
  height: 24px;
}

/* ============================================
   SWIPE INDICATOR (визуальный feedback при свайпе)
   ============================================ */

.fullscreen-swipe-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 102;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.fullscreen-swipe-indicator.show {
  opacity: 1;
}

/* ============================================
   PARTICIPANT COUNTER (счетчик "2 / 4")
   ============================================ */

.fullscreen-participant-counter {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  pointer-events: none;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.fullscreen-participant-counter.hidden {
  opacity: 0;
}

/* ============================================
   RESPONSIVE DESIGN - FULLSCREEN UI
   ============================================ */

/* Планшеты */
@media (max-width: 768px) {
  .fullscreen-thumbnails-bar {
    bottom: 100px; /* Выше controls */
    gap: 10px;
    padding: 10px 16px;
    max-width: calc(100vw - 32px);
  }

  .fs-thumbnail {
    width: 100px;
    height: 66px;
  }

  .fs-arrow {
    width: 52px;
    height: 52px;
  }

  .fs-arrow svg {
    width: 26px;
    height: 26px;
  }
}

/* Мобильные */
@media (max-width: 480px) {
  .fullscreen-thumbnails-bar {
    bottom: 120px; /* Еще выше */
    gap: 8px;
    padding: 8px 12px;
    max-width: calc(100vw - 24px);
  }

  .fs-thumbnail {
    width: 80px;
    height: 53px;
  }

  .fs-thumbnail .video-label {
    font-size: 0.55rem;
    padding: 2px 4px;
  }

  .fs-thumbnail .fs-thumbnail-label {
    font-size: 0.4rem;
    padding: 1px 3px;
  }

  /* Стрелки крупнее для touch */
  .fs-arrow {
    width: 60px;
    height: 60px;
  }

  .fs-arrow svg {
    width: 28px;
    height: 28px;
  }

  .fs-arrow.left {
    left: 12px;
  }

  .fs-arrow.right {
    right: 12px;
  }

  /* Счетчик компактнее */
  .fullscreen-participant-counter {
    top: 16px;
    right: 16px;
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  /* Индикатор свайпа крупнее */
  .fullscreen-swipe-indicator {
    font-size: 4rem;
  }
}

/* Очень маленькие экраны */
@media (max-width: 360px) {
  /* Миниатюры еще меньше */
  .fs-thumbnail {
    width: 60px;
    height: 40px;
  }

  .fs-thumbnail .video-label {
    font-size: 0.5rem;
    padding: 2px 3px;
  }

  .fs-thumbnail .fs-thumbnail-label {
    font-size: 0.38rem;
    padding: 1px 2px;
  }
}

/* Landscape на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
  .fullscreen-thumbnails-bar {
    bottom: 60px; /* Ближе к низу */
  }

  .fs-thumbnail {
    width: 90px;
    height: 60px;
  }

  .fullscreen-participant-counter {
    top: 12px;
    right: 12px;
  }
}
