/* ════════════════════════════════════════════════════════
   CallElayne — Cinema Room  🎬
   Premium watch-together experience with ambient lighting
   ════════════════════════════════════════════════════════ */

/* ── Cinema Mode Layout Transition ──────────────────── */

/* When cinema mode is active, reorganize the video container */
.video-container.cinema-mode {
  display: grid !important;
  grid-template-columns: 1fr 260px;
  grid-template-rows: 1fr;
  gap: 0;
  background: linear-gradient(145deg, #08091a 0%, #0d0f24 40%, #111333 100%) !important;
  transition: all 0.7s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Override parent black backgrounds */
.call-screen:has(.cinema-mode) {
  background: linear-gradient(145deg, #08091a 0%, #0d0f24 40%, #111333 100%) !important;
}

/* ── Right Sidebar: Both cameras stacked identically ── */
.video-container.cinema-mode .video-remote,
.video-container.cinema-mode .video-local {
  position: relative !important;
  inset: auto !important;
  top: auto !important;
  left: auto !important;
  width: calc(100% - 24px) !important;
  height: calc(50% - 18px) !important;
  aspect-ratio: auto !important;
  border-radius: 14px !important;
  border: 1px solid rgba(108, 99, 255, 0.18) !important;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset !important;
  grid-column: 2;
  grid-row: 1;
  margin: 0 12px;
  z-index: 2 !important;
  pointer-events: auto !important;
  overflow: hidden !important;
  transition: all 0.7s cubic-bezier(0.25, 1, 0.5, 1);
}

.video-container.cinema-mode .video-remote {
  align-self: start;
  margin-top: 12px;
}

.video-container.cinema-mode .video-local {
  align-self: end;
  margin-bottom: 12px;
}

/* Ensure videos fill their frames consistently */
.video-container.cinema-mode .video-remote video,
.video-container.cinema-mode .video-local video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

/* Subtle labels inside cinema sidebar cameras */
.video-container.cinema-mode .video-label {
  bottom: 8px !important;
  left: 8px !important;
  font-size: 0.65rem !important;
  padding: 3px 8px !important;
  border-radius: 6px !important;
  background: rgba(0, 0, 0, 0.55) !important;
  backdrop-filter: blur(8px) !important;
}

/* Hide resize handle in cinema mode */
.video-container.cinema-mode .resize-handle {
  display: none !important;
}

/* ── Cinema Overlay (Main Area) ─────────────────────── */
.cinema-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #08091a 0%, #0d0f24 40%, #111333 100%);
  overflow: hidden;
  border-right: 1px solid rgba(108, 99, 255, 0.08);
}

.cinema-overlay.active {
  display: flex;
}

.video-container.cinema-mode .cinema-overlay {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  inset: auto;
  width: 100%;
  height: 100%;
}

/* ── Ambient Canvas (Background Glow) ───────────────── */
.cinema-ambient-canvas {
  position: absolute;
  inset: -80px;
  width: calc(100% + 160px);
  height: calc(100% + 160px);
  z-index: 0;
  opacity: 0;
  filter: blur(80px) saturate(1.8) brightness(0.6);
  transition: opacity 1.2s ease;
  pointer-events: none;
}

.cinema-ambient-canvas.active {
  opacity: 1;
}

/* ── Movie Player Container ─────────────────────── */
.cinema-player-wrap {
  position: relative;
  z-index: 1;
  width: 96%;
  max-width: 1400px;
  aspect-ratio: 16/9;
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(108, 99, 255, 0.12);
  background: #050510;
  transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1),
              box-shadow 0.5s ease;
}

.cinema-player-wrap:hover {
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.8),
    0 0 60px rgba(108, 99, 255, 0.08),
    0 0 0 1px rgba(108, 99, 255, 0.18);
}

/* The actual video element */
.cinema-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
  cursor: pointer;
}

/* ── Custom Controls Bar ────────────────────────────── */
.cinema-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.92) 0%,
    rgba(0, 0, 0, 0.6) 60%,
    transparent 100%
  );
  z-index: 3;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cinema-player-wrap:hover .cinema-controls,
.cinema-controls.force-visible {
  opacity: 1;
}

/* Progress bar */
.cinema-progress-container {
  width: 100%;
  padding: 0 16px;
  cursor: pointer;
  position: relative;
}

.cinema-progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  transition: height 0.15s ease;
}

.cinema-progress-container:hover .cinema-progress-track {
  height: 7px;
}

.cinema-progress-buffered {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.cinema-progress-filled {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #6c63ff, #00d4aa);
  border-radius: 4px;
  transition: width 0.1s linear;
}

.cinema-progress-thumb {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.cinema-progress-container:hover .cinema-progress-thumb {
  opacity: 1;
}

/* Controls buttons row */
.cinema-controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 14px;
}

.cinema-ctrl-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  flex-shrink: 0;
  padding: 0;
}

.cinema-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

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

.cinema-ctrl-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cinema-play-btn svg {
  width: 26px;
  height: 26px;
}

.cinema-time-display {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  user-select: none;
}

.cinema-controls-spacer {
  flex: 1;
}

/* Volume control */
.cinema-volume-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.cinema-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.cinema-volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* Movie title in controls */
.cinema-now-playing {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

/* ── Movie Selector Panel ───────────────────────────── */
.cinema-selector {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 20, 0.92);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.cinema-selector.active {
  opacity: 1;
  pointer-events: auto;
}

.cinema-selector-header {
  text-align: center;
  margin-bottom: 32px;
}

.cinema-selector-title {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, #6c63ff, #00d4aa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.cinema-selector-subtitle {
  font-size: 0.82rem;
  color: rgba(139, 146, 197, 0.7);
  font-weight: 500;
}

.cinema-movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  max-width: 700px;
  width: 90%;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px;
}

/* Movie Card */
.cinema-movie-card {
  background: rgba(17, 22, 56, 0.7);
  border: 1px solid rgba(108, 99, 255, 0.12);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1),
              border-color 0.3s ease,
              box-shadow 0.3s ease;
  position: relative;
}

.cinema-movie-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: rgba(108, 99, 255, 0.35);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(108, 99, 255, 0.1);
}

.cinema-movie-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #1a1e3a 0%, #0d1025 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.cinema-movie-thumb-icon {
  font-size: 2.5rem;
  opacity: 0.4;
  transition: opacity 0.3s, transform 0.3s;
}

.cinema-movie-card:hover .cinema-movie-thumb-icon {
  opacity: 0.7;
  transform: scale(1.1);
}

/* Play overlay on hover */
.cinema-movie-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(108, 99, 255, 0.15);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cinema-movie-card:hover .cinema-movie-play-overlay {
  opacity: 1;
}

.cinema-movie-play-btn {
  width: 50px;
  height: 50px;
  background: rgba(108, 99, 255, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(108, 99, 255, 0.4);
  transition: transform 0.2s;
}

.cinema-movie-card:hover .cinema-movie-play-btn {
  transform: scale(1.05);
}

.cinema-movie-play-btn svg {
  width: 22px;
  height: 22px;
  fill: #fff;
  stroke: none;
  margin-left: 3px;
}

.cinema-movie-info {
  padding: 14px 16px;
}

.cinema-movie-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f0f2ff;
  margin-bottom: 4px;
}

.cinema-movie-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: rgba(139, 146, 197, 0.6);
}

.cinema-movie-duration {
  padding: 2px 8px;
  background: rgba(108, 99, 255, 0.15);
  border-radius: 999px;
  font-weight: 600;
}

.cinema-movie-desc {
  font-size: 0.75rem;
  color: rgba(139, 146, 197, 0.5);
  margin-top: 6px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Close / Back Buttons ───────────────────────────── */
.cinema-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s, color 0.2s;
  z-index: 20;
}

.cinema-close-btn:hover {
  background: rgba(255, 71, 87, 0.2);
  color: #ff4757;
  border-color: rgba(255, 71, 87, 0.3);
}

.cinema-browse-btn {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.2s, color 0.2s;
  z-index: 20;
}

.cinema-browse-btn:hover {
  background: rgba(108, 99, 255, 0.15);
  color: #fff;
  border-color: rgba(108, 99, 255, 0.3);
}

.cinema-browse-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Sync Status Badge ──────────────────────────────── */
.cinema-sync-badge {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 14px;
  background: rgba(0, 212, 170, 0.12);
  border: 1px solid rgba(0, 212, 170, 0.25);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #00d4aa;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.cinema-sync-badge.visible {
  opacity: 1;
}

/* ── Loading State ──────────────────────────────────── */
.cinema-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.7);
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.cinema-loading.active {
  opacity: 1;
  pointer-events: auto;
}

.cinema-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(108, 99, 255, 0.2);
  border-top-color: #6c63ff;
  border-radius: 50%;
  animation: cinemaSpinner 0.8s linear infinite;
}

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

.cinema-loading-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
}

/* ── Cinema Button Style (control bar) ──────────────── */
#btn-cinema .control-icon {
  stroke: currentColor;
}

#btn-cinema.active {
  background: linear-gradient(180deg, rgba(108, 99, 255, 0.92), rgba(79, 70, 229, 0.92));
}

/* ── Entrance / Exit Animations ─────────────────────── */
@keyframes cinemaSlideIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes cinemaSlideOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

.cinema-overlay.entering {
  animation: cinemaSlideIn 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.cinema-overlay.exiting {
  animation: cinemaSlideOut 0.4s ease-in forwards;
}

/* ── Mobile Responsive ──────────────────────────────── */
@media (max-width: 768px) {
  .video-container.cinema-mode {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr 140px;
  }

  .video-container.cinema-mode .cinema-overlay {
    grid-row: 1;
  }

  .video-container.cinema-mode .video-remote,
  .video-container.cinema-mode .video-local {
    grid-column: 1;
    grid-row: 2;
    width: calc(50% - 8px) !important;
    height: calc(100% - 8px) !important;
    margin: 4px !important;
    align-self: center !important;
  }

  .video-container.cinema-mode .video-remote {
    justify-self: start;
  }

  .video-container.cinema-mode .video-local {
    justify-self: end;
  }

  .cinema-player-wrap {
    width: 96%;
    border-radius: 12px;
  }

  .cinema-movie-grid {
    grid-template-columns: 1fr;
    max-width: 320px;
  }

  .cinema-volume-slider {
    width: 50px;
  }
}

/* ── Cinema Mode: Auto-hide Control Bar ─────────────── */
.video-container.cinema-mode ~ .control-bar {
  opacity: 0 !important;
  transform: translateX(-50%) translateY(30px) !important;
  pointer-events: none !important;
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.25, 1, 0.5, 1) !important;
}

.video-container.cinema-mode ~ .control-bar:hover {
  opacity: 1 !important;
  transform: translateX(-50%) translateY(0) !important;
  pointer-events: auto !important;
}

/* Also show control bar when mouse is near the bottom */
.call-screen:has(.cinema-mode)::after {
  content: '';
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  z-index: 39;
}

.call-screen:has(.cinema-mode):hover .control-bar {
  opacity: 1 !important;
  transform: translateX(-50%) translateY(0) !important;
  pointer-events: auto !important;
}

/* Re-hide when idle even in cinema */
body.is-idle .call-screen:has(.cinema-mode) .control-bar:not(:hover) {
  opacity: 0 !important;
  transform: translateX(-50%) translateY(30px) !important;
  pointer-events: none !important;
}

/* ── Cinema Subtitles (Dual Language) ───────────────── */
.cinema-subtitles {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 800px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.cinema-subtitle-line {
  padding: 6px 18px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
  max-width: 100%;
  word-wrap: break-word;
  animation: subtitleFadeIn 0.3s ease;
}

.cinema-subtitle-line.sub-primary {
  color: #ffffff;
  font-size: 1.05rem;
}

.cinema-subtitle-line.sub-secondary {
  color: #FFD700;
  font-size: 0.88rem;
  font-style: italic;
  opacity: 0.9;
}

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

/* Subtitle toggle button */
.cinema-subtitle-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  padding: 0;
  position: relative;
}

.cinema-subtitle-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.cinema-subtitle-btn.active {
  color: #FFD700;
}

.cinema-subtitle-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Subtitle indicator dot */
.cinema-subtitle-btn.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: #FFD700;
  border-radius: 50%;
}
