/* ===== YouTube In-Page Floating Miniplayer ===== */

@keyframes ytFadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes ytPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes ytSpin {
  to { transform: rotate(360deg); }
}
@keyframes ytMiniIn {
  from { opacity: 0; transform: translateY(40px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.videos-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}
.videos-section-header .section-label,
.videos-section-header .preview-section-title {
  margin-bottom: 0;
}
.section-count {
  font-size: 11px;
  color: var(--text-muted, #6b6b7b);
  background: var(--surface-2, #1c1c26);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  white-space: nowrap;
}

.videos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.video-item {
  position: relative;
  background: var(--surface, #14141c);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: var(--radius-sm, 14px);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(.2,.8,.2,1);
  animation: ytFadeUp 0.5s ease both;
  padding: 0;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
}
.video-item:nth-child(1) { animation-delay: 0.05s; }
.video-item:nth-child(2) { animation-delay: 0.1s; }
.video-item:nth-child(3) { animation-delay: 0.15s; }
.video-item:nth-child(4) { animation-delay: 0.2s; }

.video-item:hover {
  transform: translateY(-3px);
  border-color: var(--border-2, rgba(255,255,255,0.14));
  box-shadow: 0 12px 32px -8px rgba(0,0,0,0.5);
}

.video-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--surface-2, #1c1c26);
}
.video-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
  display: block;
}
.video-item:hover .video-thumb img { transform: scale(1.08); }
.video-thumb-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
}
.video-item .video-play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(233,30,140,0.95);
  display: grid; place-items: center;
  color: #fff; font-size: 15px;
  box-shadow: 0 8px 24px rgba(233,30,140,0.5);
  transition: all 0.25s;
  z-index: 1;
}
.video-item:hover .video-play {
  transform: translate(-50%, -50%) scale(1.15);
  box-shadow: 0 12px 32px rgba(233,30,140,0.7);
}
.video-duration {
  position: absolute;
  bottom: 8px; right: 8px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.85);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  z-index: 1;
}
.video-delete {
  position: absolute;
  top: 8px; right: 8px;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  display: grid; place-items: center;
  font-size: 10px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s;
  z-index: 2;
  padding: 0;
  font-family: inherit;
}
.video-item:hover .video-delete { opacity: 1; }
.video-delete:hover {
  background: rgba(239,68,68,0.9);
  border-color: transparent;
}
.video-badge-live {
  position: absolute;
  top: 8px; left: 8px;
  padding: 2px 6px;
  background: rgba(239,68,68,0.9);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 3px;
  z-index: 1;
}
.video-badge-live::before {
  content: '';
  width: 4px; height: 4px;
  background: #fff;
  border-radius: 50%;
  animation: ytPulse 1.5s infinite;
}

.video-item .video-info { padding: 10px 12px; }
.video-item .video-title {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
  color: var(--text, #fff);
  position: static;
  background: none;
}
.video-meta {
  font-size: 10.5px;
  color: var(--text-muted, #6b6b7b);
  display: flex; align-items: center; gap: 6px;
}
.video-meta i { font-size: 9px; }

/* Floating miniplayer */
.yt-miniplayer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 320px;
  max-width: calc(100vw - 40px);
  background: var(--surface, #14141c);
  border: 1px solid var(--border-2, rgba(255,255,255,0.14));
  border-radius: var(--radius-sm, 14px);
  overflow: hidden;
  box-shadow:
    0 30px 80px -20px rgba(0,0,0,0.8),
    0 0 0 1px rgba(255,255,255,0.05);
  z-index: 9999;
  animation: ytMiniIn 0.4s cubic-bezier(.2,.8,.2,1);
  transition: width 0.3s cubic-bezier(.2,.8,.2,1);
  user-select: none;
}
.yt-miniplayer.hidden { display: none; }
.yt-miniplayer.dragging {
  transition: none;
  cursor: grabbing;
}
.yt-miniplayer.maximized {
  width: calc(100vw - 40px);
  max-width: 500px;
}
.yt-miniplayer.minimized { width: 220px; }
.yt-miniplayer.snapping {
  transition: left 0.3s cubic-bezier(.2,.8,.2,1), top 0.3s cubic-bezier(.2,.8,.2,1);
}

.yt-miniplayer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-2, #1c1c26);
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
  cursor: grab;
}
.yt-miniplayer-header:active { cursor: grabbing; }
.yt-miniplayer-grip {
  width: 12px;
  height: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--text-muted, #6b6b7b);
  flex-shrink: 0;
}
.yt-miniplayer-grip::before,
.yt-miniplayer-grip::after {
  content: '';
  width: 12px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
  box-shadow: 0 3px 0 currentColor, 0 6px 0 currentColor;
}
.yt-miniplayer-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #fff);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.yt-miniplayer-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.yt-miniplayer-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-secondary, #a0a0b0);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 11px;
  transition: all 0.15s;
  font-family: inherit;
  padding: 0;
}
.yt-miniplayer-btn:hover {
  background: var(--surface-3, #252532);
  color: var(--text, #fff);
}
.yt-miniplayer-btn.close:hover {
  background: rgba(239,68,68,0.2);
  color: var(--danger, #ef4444);
}

.yt-miniplayer-video {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
}
.yt-miniplayer-video > div:not(.yt-miniplayer-loading) {
  position: absolute;
  inset: 0;
}
.yt-miniplayer-video iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.yt-miniplayer-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--surface-2, #1c1c26);
  border-top: 1px solid var(--border, rgba(255,255,255,0.08));
}
.yt-control-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-secondary, #a0a0b0);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 12px;
  transition: all 0.15s;
  font-family: inherit;
  padding: 0;
}
.yt-control-btn:hover {
  background: var(--surface-3, #252532);
  color: var(--text, #fff);
}
.yt-control-btn.active { color: var(--brand, #e91e8c); }
.yt-control-spacer { flex: 1; }
.yt-progress-bar {
  height: 3px;
  background: var(--surface-3, #252532);
  position: relative;
  cursor: pointer;
  overflow: hidden;
}
.yt-progress-fill {
  height: 100%;
  background: var(--brand-grad, linear-gradient(135deg, #e91e8c, #8b5cf6));
  width: 0%;
  transition: width 0.2s linear;
  border-radius: 0 2px 2px 0;
}
.yt-time-display {
  font-size: 10.5px;
  color: var(--text-muted, #6b6b7b);
  font-weight: 600;
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.yt-miniplayer-loading {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary, #a0a0b0);
  font-size: 12px;
  gap: 8px;
  z-index: 2;
}
.yt-miniplayer-loading .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--surface-3, #252532);
  border-top-color: var(--brand, #e91e8c);
  border-radius: 50%;
  animation: ytSpin 0.8s linear infinite;
}

.yt-miniplayer.minimized .yt-miniplayer-video,
.yt-miniplayer.minimized .yt-miniplayer-controls,
.yt-miniplayer.minimized .yt-progress-bar {
  display: none;
}

@media (max-width: 480px) {
  .yt-miniplayer {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 16px;
  }
  .yt-miniplayer.maximized {
    width: calc(100vw - 32px);
    max-width: none;
  }
  .yt-miniplayer.minimized { width: 180px; }
}
