/* WatchParty — Premium Cinema Theme Phase 3 */
:root {
  --bg-color: #0b0d14;
  --surface-color: #141724;
  --surface-hover: #1f2336;
  --surface-card: #181b2a;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.3);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --accent-color: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.4);
  --danger-color: #ef4444;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
}

.container {
  width: 90%;
  max-width: 460px;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.1);
  margin: auto;
  backdrop-filter: blur(12px);
}

h1, h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  text-align: center;
  background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

p.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  background: rgba(11, 13, 20, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 16px; /* Защита от зума на iOS */
  outline: none;
  transition: all 0.2s ease;
}

input[type="text"]:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* 3D Avatar System & Badges */
.avatar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  position: relative;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  user-select: none;
  flex-shrink: 0;
  vertical-align: middle;
}

.avatar-badge:hover {
  transform: scale(1.15) rotate(4deg);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.7);
}

.avatar-badge .avatar-emoji {
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  display: inline-block;
}

.avatar-xs { width: 22px; height: 22px; font-size: 13px; }
.avatar-sm { width: 32px; height: 32px; font-size: 18px; }
.avatar-md { width: 44px; height: 44px; font-size: 26px; }
.avatar-lg { width: 56px; height: 56px; font-size: 34px; }
.avatar-xl { width: 72px; height: 72px; font-size: 44px; }

/* Grid of Emoji Card Buttons */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 20px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}

.emoji-card-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 64px;
}

.emoji-card-btn:hover {
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.emoji-card-btn.selected {
  border-color: var(--accent-color);
  background: rgba(99, 102, 241, 0.25);
  box-shadow: 0 0 16px var(--accent-glow);
}

.avatar-card-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.btn {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-color), #4338ca);
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
}

.btn:hover {
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  width: auto;
  min-height: 38px;
}

/* Карточка истории комнат */
.room-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  transition: all 0.2s ease;
}

.room-card:hover {
  background: var(--surface-hover);
  border-color: var(--accent-glow);
}

.room-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.room-card-info strong {
  font-size: 14px;
  color: #a5b4fc;
  letter-spacing: 1px;
}

.room-card-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Шапка комнаты */
.app-header {
  min-height: 60px;
  background: rgba(20, 23, 36, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.brand-badge {
  background: var(--accent-color);
  color: white;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

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

.code-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-family: monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #a5b4fc;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.code-chip:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-color);
}

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

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-badge.online .status-dot {
  background: var(--success-color);
  box-shadow: 0 0 8px var(--success-color);
}

.status-badge.connecting .status-dot {
  background: var(--warning-color);
  animation: pulse 1s infinite;
}

.status-badge.offline .status-dot {
  background: var(--danger-color);
}

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

/* Главный макет комнаты */
.room-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  padding: 16px 20px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* Кинозал и Плеер */
.cinema-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7), 0 0 30px rgba(99, 102, 241, 0.1);
}

.player-embed {
  width: 100%;
  height: 100%;
  border: none;
}

/* Анимированный слой реакции (Floating Emojis) */
.reactions-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 20;
}

.floating-emoji {
  position: absolute;
  bottom: 20px;
  font-size: 34px;
  animation: floatUp 2.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.6) rotate(0deg);
  }
  50% {
    opacity: 0.9;
    transform: translateY(-110px) scale(1.2) rotate(-10deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-240px) scale(1) rotate(15deg);
  }
}

/* Нижняя панель управления видео */
.controls-bar {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  flex-wrap: wrap;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.play-btn-large {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-color);
  color: white;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 4px 14px var(--accent-glow);
  flex-shrink: 0;
}

.play-btn-large:hover {
  transform: scale(1.08);
  background: var(--accent-hover);
}

.reaction-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 12px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
  overflow-x: auto;
  max-width: 100%;
}

.reaction-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
  min-width: 38px;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.reaction-btn:hover {
  transform: scale(1.35) translateY(-3px);
  background: rgba(99, 102, 241, 0.3);
  border-color: var(--accent-color);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.platform-badge {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.host-badge-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

/* Боковая панель */
.side-panel {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: calc(100vh - 96px);
  position: sticky;
  top: 80px;
}

.tab-header {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn.active {
  color: var(--text-primary);
  border-bottom: 2px solid var(--accent-color);
  background: rgba(99, 102, 241, 0.08);
}

.pane {
  display: none;
  flex-direction: column;
  flex: 1;
  height: calc(100% - 44px);
}

.pane.active {
  display: flex;
}

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

.chat-msg {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.msg-author {
  font-size: 13px;
  font-weight: 700;
  color: #a5b4fc;
}

.msg-body {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
  padding-left: 2px;
}

.system-msg-badge {
  font-size: 13px;
  margin-right: 4px;
}

.chat-msg.system-msg {
  background: transparent;
  border: none;
  font-size: 12px;
  font-style: italic;
  color: var(--text-secondary);
  text-align: center;
  padding: 4px 8px;
}

.chat-input-area {
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  gap: 8px;
}

.chat-input-area input {
  flex: 1;
  padding: 10px 12px;
  font-size: 16px;
}

.users-list {
  list-style: none;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
}

.user-info-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.host-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 13, 20, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 30;
  padding: 20px;
  text-align: center;
}

.hidden {
  display: none !important;
}

/* Адаптивность для мобильных */
@media (max-width: 900px) {
  .room-layout {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 16px;
  }

  .side-panel {
    height: 380px;
    position: static;
  }

  .app-header {
    padding: 10px 14px;
  }

  .brand-title {
    font-size: 15px;
  }

  .code-chip {
    font-size: 12px;
    padding: 4px 8px;
  }

  .controls-bar {
    justify-content: center;
  }
}

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

  .emoji-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .app-header {
    justify-content: center;
  }

  .header-right {
    margin-top: 4px;
  }
}
