/* ═══════════════════════════════════════════════════
   WatchTogether — Premium Dark Theme
   ═══════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #10102a;
  --bg-tertiary: #16163a;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.07);
  --border-light: rgba(255, 255, 255, 0.12);
  --text: #e8e8f0;
  --text-muted: #7878a0;
  --text-dim: #4a4a70;
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 58, 237, 0.25);
  --accent-gradient: linear-gradient(135deg, #7c3aed, #a855f7);
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: 200ms ease;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --glass-bg: rgba(20, 20, 50, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  overflow: hidden;
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Glass Card ── */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-light);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
  width: 100%;
  justify-content: center;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
}

.btn-icon:hover {
  color: var(--text);
  background: var(--bg-card-hover);
}

/* ── Inputs ── */
input[type="text"],
input[type="url"] {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: all var(--transition);
  outline: none;
}

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

input::placeholder {
  color: var(--text-dim);
}

/* Remove default mobile X clear button in inputs */
input[type="text"]::-ms-clear,
input[type="text"]::-ms-reveal { display: none; }
input[type="text"]::-webkit-search-decoration,
input[type="text"]::-webkit-search-cancel-button,
input[type="text"]::-webkit-search-results-button,
input[type="text"]::-webkit-search-results-decoration { display: none; }

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Progress Bar ── */
.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar.small {
  height: 4px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: var(--accent-gradient);
  transition: width 300ms ease;
}

.progress-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════
   Landing Page
   ═══════════════════════════════════════════════════ */

.landing-body {
  background: radial-gradient(ellipse at 20% 50%, rgba(124, 58, 237, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.06) 0%, transparent 50%),
    var(--bg-primary);
}

.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: var(--accent-light);
  border-radius: 50%;
  opacity: 0;
  animation: float linear infinite;
}

@keyframes float {
  0% {
    opacity: 0;
    transform: translateY(100vh) scale(0);
  }

  10% {
    opacity: 0.6;
  }

  90% {
    opacity: 0.6;
  }

  100% {
    opacity: 0;
    transform: translateY(-10vh) scale(1);
  }
}

.landing-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.landing-card {
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  animation: fadeUp 600ms ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.logo-section {
  text-align: center;
  margin-bottom: 36px;
}

.logo-icon svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
}

.logo-text {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.accent {
  color: var(--accent-light);
}

.tagline {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 8px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-dim);
  font-size: 13px;
  margin: 4px 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.error-message {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--error);
  font-size: 13px;
  display: none;
  text-align: center;
}

.error-message.show {
  display: block;
  animation: shake 300ms ease;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-6px);
  }

  75% {
    transform: translateX(6px);
  }
}

.footer-note {
  margin-top: 24px;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════════════════
   Room Page
   ═══════════════════════════════════════════════════ */

.room-body {
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.room-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  height: 52px;
  flex-shrink: 0;
}

.header-logo {
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  margin-right: auto;
}

.header-room-info {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.room-badge {
  background: var(--accent-gradient);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
}

.copy-toast {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
  margin-top: 4px;
}

.copy-toast.show {
  opacity: 1;
}

.user-count {
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Layout ── */
.room-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 52px);
}

/* ── Video Area ── */
.video-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #000;
}

.video-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050510;
  overflow: hidden;
}

#yt-player-container,
#yt-player {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

#yt-player-container iframe {
  width: 100% !important;
  height: 100% !important;
}

#local-player {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-dim);
  font-size: 14px;
  animation: pulse 3s ease infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

/* Download Overlay */
.download-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.download-card {
  padding: 32px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: 300px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Video Source Bar ── */
.video-source-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.source-input-group {
  display: flex;
  flex: 1;
  gap: 8px;
}

.source-input-group input {
  flex: 1;
  padding: 8px 14px;
  font-size: 13px;
}

.source-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

.upload-label {
  cursor: pointer;
}

.upload-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

/* ── Sidebar ── */
.sidebar {
  width: 320px;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-bottom: 2px solid transparent;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.tab-panel.active {
  display: flex;
}

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

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  animation: fadeIn 200ms ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-msg-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-light);
}

.chat-msg-text {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.chat-msg-time {
  font-size: 10px;
  color: var(--text-dim);
  align-self: flex-end;
}

.chat-msg.system {
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid rgba(124, 58, 237, 0.15);
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 6px;
}

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

.chat-input-form input {
  flex: 1;
  padding: 10px 14px;
  font-size: 13px;
}

.send-btn {
  color: var(--accent-light);
}

.send-btn:hover {
  color: var(--accent);
}

/* Users */
.users-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  transition: background var(--transition);
}

.user-item:hover {
  background: var(--bg-card-hover);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
}

.user-host-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--warning);
  background: rgba(245, 158, 11, 0.12);
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Sidebar Toggle (mobile) ── */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-gradient);
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--accent-glow);
  z-index: 20;
  transition: transform var(--transition);
}

.sidebar-toggle:hover {
  transform: scale(1.05);
}

.sidebar-backdrop {
  display: none;
}

/* ── Notification Toast ── */
.notification {
  position: fixed;
  top: 64px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 100;
  animation: slideIn 300ms ease;
  box-shadow: var(--shadow);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.notification.info {
  background: rgba(124, 58, 237, 0.9);
  color: white;
}

.notification.success {
  background: rgba(16, 185, 129, 0.9);
  color: white;
}

.notification.error {
  background: rgba(239, 68, 68, 0.9);
  color: white;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 52px;
    right: -320px;
    bottom: 0;
    z-index: 31;
    transition: right 300ms ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open {
    right: 0;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 30;
  }

  .sidebar-backdrop.show {
    display: block;
  }

  .sidebar.open ~ #sidebar-toggle {
    display: none !important;
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 32;
  }

  .room-body.sidebar-open .video-area,
  .room-body.sidebar-open .video-wrapper,
  .room-body.sidebar-open #yt-player-container,
  .room-body.sidebar-open #local-player {
    touch-action: none;
  }

  .video-source-bar {
    flex-wrap: wrap;
  }

  .source-input-group {
    width: 100%;
  }

  .source-divider {
    display: none;
  }

  .header-actions .user-count {
    display: none;
  }

  .landing-card {
    padding: 32px 24px;
  }
}
