:root {
  --bg-color: #0f172a;
  --bg-secondary: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --accent-color: #6366f1;
  --accent-hover: #4f46e5;
  --success-color: #10b981;
  --error-color: #ef4444;
  --border-color: rgba(255, 255, 255, 0.1);
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --radius-lg: 16px;
  --radius-md: 8px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

/* Glassmorphism Utilities */
.glass-header {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Header */
.logo-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.accent-icon {
  color: var(--accent-color);
  fill: rgba(99, 102, 241, 0.2);
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

/* Status Badge */
.status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

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

.dot.disconnected {
  background-color: var(--error-color);
}

/* Main Content Layout */
.main-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  width: 100%;
}

.control-panel {
  width: 100%;
  max-width: 480px;
}

.video-section {
  width: 100%;
  max-width: 1000px;
}

/* Control Panel */
.control-panel h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.control-panel h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
  margin-top: 1.5rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

input[type="url"],
input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

button {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-primary {
  background-color: var(--accent-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}

.divider span {
  padding: 0 10px;
}

.status-message {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  background: rgba(0, 0, 0, 0.2);
  border-left: 3px solid var(--accent-color);
}

.status-message.hidden {
  display: none;
}

/* Video Player */
.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

video {
  width: 100%;
  height: 100%;
  outline: none;
}

.overlay-message {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  z-index: 10;
  transition: opacity 0.3s ease;
}

.overlay-message p {
  color: var(--text-secondary);
  font-weight: 500;
}

.overlay-message.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Custom Fullscreen Wrapper Rules */
.video-container:fullscreen {
  width: 100vw;
  height: 100vh;
  padding: 0;
  margin: 0;
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-container:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  padding: 0;
  margin: 0;
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================
   Custom Video Controls 
   ========================================== */
.custom-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 0 1rem 0.5rem 1rem;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 25;
  transition: opacity 0.3s ease;
}

/* Hide native controls fullscreen button in webkit browsers as fallback */
video::-webkit-media-controls-fullscreen-button {
  display: none;
}
/* Hide all native controls just in case */
video::-webkit-media-controls {
  display: none !important;
}

/* Progress Bar */
.progress-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: height 0.2s ease;
}

.progress-container:hover {
  height: 8px;
}

.progress-bar {
  height: 100%;
  background: var(--accent-color);
  border-radius: 3px;
  width: 0%;
  position: relative;
  pointer-events: none;
}

.progress-bar::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.progress-container:hover .progress-bar::after {
  transform: translateY(-50%) scale(1);
}

/* Controls Layout */
.controls-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 40px;
}

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

.control-btn {
  background: none;
  border: none;
  color: white;
  opacity: 0.8;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.control-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

.time-display {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

.volume-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
  cursor: pointer;
}

/* Emoji Reaction Bar (Default Windowed State) */
.reaction-bar {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0.5rem 1.5rem;
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  width: max-content;
  margin: 1.5rem auto 0;
  transition: opacity 0.3s ease, bottom 0.3s ease;
}

/* Float over video when teleported via JS into the fullscreen container */
.video-container:fullscreen .reaction-bar {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  margin: 0;
}
.video-container:-webkit-full-screen .reaction-bar {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  margin: 0;
}

/* Fade out UI when idle (managed by JS class) */
.video-container.idle .reaction-bar,
.video-container.idle .custom-controls {
  opacity: 0;
  pointer-events: none;
}

/* ==========================================
   Theater Mode OVERRIDES
   ========================================== */
body.theater-mode .app-container {
  max-width: 100%;
  padding-left: 0;
  padding-right: 0;
}

body.theater-mode .glass-header {
  margin-left: 2rem;
  margin-right: 2rem;
}

body.theater-mode .video-section {
  max-width: 100%;
}

body.theater-mode .video-container {
  aspect-ratio: auto;
  height: 75vh;
  border-radius: 0;
  border-left: none;
  border-right: none;
}

.reaction-btn {
  background: transparent;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
}

.reaction-btn:hover {
  transform: scale(1.3) translateY(-5px);
  background: rgba(255, 255, 255, 0.1);
}

.reaction-btn:active {
  transform: scale(0.9);
}

/* Floating Emoji Animations */
#reaction-container {
  position: absolute;
  bottom: 10px;
  right: 20px;
  width: 100px;
  height: 80%; /* Don't want them floating all the way to the very absolute top edge */
  pointer-events: none;
  z-index: 20; /* Above the video overlay */
  overflow: visible;
}

.floating-emoji {
  position: absolute;
  bottom: 0;
  font-size: 2.5rem;
  animation: floatUp 2.5s ease-out forwards;
  opacity: 1;
  filter: drop-shadow(0px 4px 6px rgba(0,0,0,0.5));
}

@keyframes floatUp {
  0% {
    transform: translateY(0) scale(0.5) rotate(0deg);
    opacity: 0;
  }
  15% {
    transform: translateY(-20px) scale(1.2) rotate(-10deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-250px) scale(1) rotate(20deg);
    opacity: 0;
  }
}

/* Smooth Fade In Util */
.animate-fade-in {
  animation: fadeIn 0.5s ease-in-out;
}

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