/**
 * MMP Advanced Video Ads - Styling
 * 
 * Seamless integration with watch-player.js
 * Features:
 * - Responsive design (mobile-first)
 * - Smooth animations
 * - No layout shift (CLS optimized)
 * - Accessible UI
 * - Dark theme compatible
 * 
 * @package theme-movie-manager
 * @since 1.0.0
 */

/* ============================================================================
   🎬 PRE-ROLL AD CONTAINER
   ============================================================================ */

.mmp-preroll-ad-wrapper {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto 2rem;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 50;
  
  /* Prevent CLS */
  contain: layout style paint;
  will-change: contents;
  min-height: 504px; /* 16:9 @ 900px */
  
  animation: mmpPrerollFadeIn 0.4s ease-out;
}

.mmp-preroll-ad-wrapper.mmp-preroll-active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mmp-preroll-ad-wrapper.mmp-preroll-completed {
  animation: mmpPrerollFadeOut 0.3s ease-out forwards;
}

.mmp-preroll-ad-wrapper.mmp-preroll-skipped {
  animation: mmpPrerollSlideUp 0.3s ease-out forwards;
}

/* Inner container */
.mmp-preroll-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 504px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ad player area */
.mmp-preroll-player {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  border-radius: 12px;
  overflow: hidden;
  background: #1a1a1a;
}

.mmp-preroll-player iframe {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  border-radius: 12px !important;
}

/* ============================================================================
   ⏭️  SKIP BUTTON
   ============================================================================ */

.mmp-skip-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 20;
  
  background: rgba(255, 255, 255, 0.95);
  color: #1a1a1a;
  border: none;
  border-radius: 24px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  
  display: flex;
  align-items: center;
  gap: 8px;
  
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.mmp-skip-btn:hover:not(.mmp-skip-btn--hidden) {
  background: #fff;
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.mmp-skip-btn:active:not(.mmp-skip-btn--hidden) {
  transform: scale(0.98);
}

.mmp-skip-btn--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

/* Countdown display */
.mmp-skip-countdown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #ff4444;
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.mmp-skip-text {
  display: inline;
}

/* ============================================================================
   📌 AD BADGE
   ============================================================================ */

.mmp-ad-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 15;
  
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  
  display: flex;
  align-items: center;
  gap: 8px;
  
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  
  animation: mmpBadgeFadeIn 0.5s ease-out 0.2s backwards;
}

.mmp-ad-label {
  font-weight: 700;
}

.mmp-ad-timestamp {
  font-family: 'Courier New', monospace;
  font-size: 10px;
  opacity: 0.8;
}

/* ============================================================================
   ℹ️  AD INFO
   ============================================================================ */

.mmp-preroll-info {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 15;
  
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  font-weight: 500;
  
  animation: mmpInfoFadeIn 0.5s ease-out 0.3s backwards;
}

.mmp-preroll-info p {
  margin: 0;
  padding: 0;
  line-height: 1.4;
}

/* ============================================================================
   🎬 MID-ROLL AD CONTAINER
   ============================================================================ */

.mmp-midroll-ad-wrapper {
  position: fixed;
  inset: 0;
  z-index: 9999;
  
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(4px);
  
  display: flex;
  align-items: center;
  justify-content: center;
  
  animation: mmpMidrollFadeIn 0.3s ease-out;
}

.mmp-midroll-inner {
  position: relative;
  width: 90%;
  max-width: 800px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8);
}

.mmp-midroll-player {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
}

.mmp-midroll-player iframe {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  border-radius: 12px !important;
}

.mmp-midroll-ad-wrapper .mmp-ad-badge {
  top: 12px;
  left: 12px;
}

/* ============================================================================
   ✨ ANIMATIONS
   ============================================================================ */

@keyframes mmpPrerollFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes mmpPrerollFadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

@keyframes mmpPrerollSlideUp {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

@keyframes mmpBadgeFadeIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes mmpInfoFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes mmpMidrollFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============================================================================
   📱 RESPONSIVE DESIGN
   ============================================================================ */

/* Tablet */
@media (max-width: 768px) {
  .mmp-preroll-ad-wrapper {
    margin: 0 12px 1.5rem;
    border-radius: 8px;
    min-height: 420px;
  }

  .mmp-preroll-inner {
    min-height: 420px;
  }

  .mmp-skip-btn {
    bottom: 12px;
    right: 12px;
    padding: 8px 14px;
    font-size: 12px;
  }

  .mmp-skip-countdown {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }

  .mmp-ad-badge {
    top: 8px;
    left: 8px;
    padding: 4px 8px;
    font-size: 10px;
  }

  .mmp-preroll-info {
    bottom: 12px;
    left: 12px;
    font-size: 11px;
  }

  .mmp-midroll-inner {
    width: 95%;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .mmp-preroll-ad-wrapper {
    margin: 0 8px 1rem;
    border-radius: 6px;
    min-height: 360px;
  }

  .mmp-preroll-inner {
    min-height: 360px;
  }

  .mmp-skip-btn {
    bottom: 8px;
    right: 8px;
    padding: 6px 12px;
    font-size: 11px;
    border-radius: 20px;
  }

  .mmp-skip-countdown {
    width: 18px;
    height: 18px;
    font-size: 9px;
  }

  .mmp-skip-text {
    display: none;
  }

  .mmp-ad-badge {
    top: 6px;
    left: 6px;
    padding: 3px 6px;
    font-size: 9px;
  }

  .mmp-preroll-info {
    bottom: 8px;
    left: 8px;
    font-size: 10px;
  }

  .mmp-ad-label {
    display: none;
  }

  .mmp-midroll-inner {
    width: 98%;
    aspect-ratio: 16 / 9;
  }
}

/* ============================================================================
   ♿ ACCESSIBILITY
   ============================================================================ */

.mmp-skip-btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.mmp-preroll-ad-wrapper:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.3);
}

/* High contrast mode */
@media (prefers-contrast: more) {
  .mmp-ad-badge {
    background: #000;
    border: 2px solid #fff;
  }

  .mmp-skip-btn {
    border: 2px solid #1a1a1a;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .mmp-preroll-ad-wrapper,
  .mmp-skip-btn,
  .mmp-ad-badge,
  .mmp-preroll-info,
  .mmp-midroll-ad-wrapper {
    animation: none;
    transition: none;
  }
}

/* Dark mode preference */
@media (prefers-color-scheme: dark) {
  .mmp-skip-btn {
    background: rgba(30, 30, 30, 0.95);
    color: #fff;
  }

  .mmp-skip-btn:hover:not(.mmp-skip-btn--hidden) {
    background: rgba(50, 50, 50, 0.95);
  }
}

/* ============================================================================
   🔧 UTILITY CLASSES
   ============================================================================ */

.mmp-ad-loading {
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.mmp-ad-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: mmpSpinnerRotate 1s linear infinite;
}

@keyframes mmpSpinnerRotate {
  to {
    transform: rotate(360deg);
  }
}

.mmp-ad-error {
  color: #ffcccc;
  text-align: center;
  padding: 24px;
  font-size: 14px;
}

/* ============================================================================
   🎨 THEME COLOR INTEGRATION
   ============================================================================ */

.mmp-preroll-ad-wrapper {
  background: var(--color-bg-dark, #000);
  color: var(--color-text-light, #fff);
}

.mmp-skip-btn {
  background: var(--color-primary, rgba(255, 255, 255, 0.95));
  color: var(--color-bg-dark, #1a1a1a);
}

.mmp-ad-badge {
  background: var(--color-overlay-dark, rgba(0, 0, 0, 0.8));
  border-color: var(--color-border-light, rgba(255, 255, 255, 0.15));
}
