/* ==========================================================
   AIP YouTube Popup Player — Styles Frontend
   ========================================================== */

:root {
  --aip-accent: #e30613;
  --aip-width: 320px;
  --aip-radius: 12px;
  --aip-shadow: 0 8px 32px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.15);
  --aip-header-h: 52px;
  --aip-footer-h: 36px;
  --aip-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --aip-z: 999999;
}

/* ── Wrapper positionné ── */
.aip-yt-popup-wrapper {
  position: fixed;
  bottom: 24px;
  z-index: var(--aip-z);
  width: var(--aip-width);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  pointer-events: none;
  transition: transform var(--aip-transition), opacity var(--aip-transition);
}

.aip-pos-right { right: 24px; }
.aip-pos-left  { left: 24px;  }

/* Entrée animée */
.aip-yt-popup-wrapper.aip-hidden {
  transform: translateY(120%);
  opacity: 0;
}
.aip-yt-popup-wrapper.aip-visible {
  transform: translateY(0);
  opacity: 1;
}

/* Tous les enfants cliquables */
.aip-yt-popup-wrapper * { pointer-events: auto; }

/* ── Player complet ── */
.aip-popup-player {
  background: #1a1a1a;
  border-radius: var(--aip-radius);
  overflow: hidden;
  box-shadow: var(--aip-shadow);
  transition: all var(--aip-transition);
}

.aip-minimized .aip-popup-player {
  display: none;
}

/* ── Barre minimisée ── */
.aip-popup-minimized-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #1a1a1a;
  border-radius: var(--aip-radius);
  box-shadow: var(--aip-shadow);
  padding: 10px 12px;
  cursor: pointer;
  border-left: 3px solid var(--aip-accent);
  transition: background var(--aip-transition);
}

.aip-popup-minimized-bar:hover {
  background: #2a2a2a;
}

.aip-minimized .aip-popup-minimized-bar {
  display: flex;
}

.aip-mini-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  flex: 1;
}

.aip-mini-title {
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aip-mini-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Header ── */
.aip-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: var(--aip-header-h);
  background: linear-gradient(135deg, #111 0%, #1e1e1e 100%);
  border-bottom: 2px solid var(--aip-accent);
  gap: 8px;
}

.aip-header-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  flex: 1;
}

.aip-header-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.aip-popup-title {
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aip-popup-subtitle {
  color: rgba(255,255,255,0.55);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aip-header-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Indicateur live ── */
.aip-live-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--aip-accent);
  border-radius: 50%;
  flex-shrink: 0;
  animation: aip-pulse 1.8s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(227, 6, 19, 0.7);
}

@keyframes aip-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(227, 6, 19, 0.7); }
  70%  { box-shadow: 0 0 0 6px rgba(227, 6, 19, 0); }
  100% { box-shadow: 0 0 0 0 rgba(227, 6, 19, 0); }
}

/* ── Boutons ── */
.aip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  line-height: 1;
}

.aip-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.aip-btn-expand {
  color: rgba(255, 255, 255, 0.8);
}
.aip-btn-expand:hover { color: #fff; }

.aip-btn-close:hover {
  background: rgba(227, 6, 19, 0.3);
  border-color: rgba(227, 6, 19, 0.5);
  color: #ff4d4d;
}

/* ── Conteneur vidéo ── */
.aip-video-container {
  position: relative;
  width: 100%;
  /* ratio 16/9 */
  padding-bottom: 56.25%;
  background: #000;
  overflow: hidden;
}

.aip-video-container iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Overlay de chargement */
.aip-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 1;
  transition: opacity 0.5s;
}

.aip-loading-overlay.aip-loaded {
  opacity: 0;
  pointer-events: none;
}

.aip-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--aip-accent);
  border-radius: 50%;
  animation: aip-spin 0.8s linear infinite;
}

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

/* ── Footer ── */
.aip-popup-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: var(--aip-footer-h);
  padding: 0 12px;
  background: #111;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.aip-yt-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,0.5);
  font-size: 11px;
  text-decoration: none;
  transition: color 0.2s;
}

.aip-yt-link:hover {
  color: #fff;
  text-decoration: none;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .aip-yt-popup-wrapper {
    bottom: 0;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    --aip-width: 100%;
    border-radius: var(--aip-radius) var(--aip-radius) 0 0;
  }

  .aip-popup-player {
    border-radius: var(--aip-radius) var(--aip-radius) 0 0;
  }

  .aip-popup-minimized-bar {
    border-radius: var(--aip-radius) var(--aip-radius) 0 0;
  }
}

/* ── Accessibilité ── */
.aip-btn:focus-visible {
  outline: 2px solid var(--aip-accent);
  outline-offset: 2px;
}

/* Réduction de mouvement */
@media (prefers-reduced-motion: reduce) {
  .aip-live-indicator { animation: none; }
  .aip-yt-popup-wrapper { transition: none; }
}
