/**
 * TorrentPier Video Player Styles
 * Базовые стили для видеоплеера
 */

/* Основной контейнер */
.tp-player-container {
  position: relative;
  width: 100%;
  max-width: 560px; /* Фиксированная ширина по умолчанию */
  margin: 1em 0; /* Отступы сверху/снизу, без центрирования */
  background: #000;
  overflow: hidden;
}

/* Placeholder (превью перед загрузкой) */
.tp-player-placeholder {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  background-color: #000;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.3s ease, transform 0.2s ease;
  user-select: none;
}

.tp-player-placeholder:hover {
  opacity: 0.9;
}

.tp-player-placeholder:active {
  transform: scale(0.98);
}

.tp-player-placeholder:focus {
  outline: 3px solid #4CAF50;
  outline-offset: 2px;
}

.tp-player-placeholder > span {
  position: relative;
  z-index: 2;
  padding: 15px 25px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: background 0.3s ease;
}

.tp-player-placeholder:hover > span {
  background: rgba(0, 0, 0, 0.85);
}

/* Затемнение для placeholder с фоновым изображением */
.tp-player-placeholder::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1;
  transition: background 0.3s ease;
}

.tp-player-placeholder:hover::before {
  background: rgba(0, 0, 0, 0.2);
}

/* Индикатор загрузки */
.tp-player-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  background: #000;
  color: #fff;
  padding: 20px;
}

.tp-player-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: tp-spinner-rotate 1s linear infinite;
}

@keyframes tp-spinner-rotate {
  to { transform: rotate(360deg); }
}

.tp-player-loading-text {
  margin-top: 15px;
  font-size: 16px;
  font-weight: 400;
  opacity: 0.9;
}

/* Сообщение об ошибке */
.tp-player-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  background: #000;
  color: #ff6b6b;
  padding: 20px;
  text-align: center;
}

.tp-player-error-icon {
  font-size: 48px;
  margin-bottom: 15px;
  opacity: 0.9;
}

.tp-player-error-text {
  font-size: 16px;
  font-weight: 400;
  max-width: 400px;
  line-height: 1.5;
}

/* Кнопка Picture-in-Picture */
.tp-player-pip-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 100;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: background 0.2s ease, transform 0.1s ease;
  user-select: none;
}

.tp-player-pip-button:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: translateY(-1px);
}

.tp-player-pip-button:active {
  transform: translateY(0);
}

.tp-player-pip-button:focus {
  outline: 2px solid #4CAF50;
  outline-offset: 2px;
}

/* Responsive wrapper для iframe и video */
.tp-player-responsive-wrapper {
  position: relative;
  width: 100%;
  height: 0;
  overflow: hidden;
  background: #000;
}

.tp-player-responsive-wrapper > iframe,
.tp-player-responsive-wrapper > video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Адаптивность */
@media (max-width: 768px) {
  .tp-player-placeholder {
    min-height: 200px;
  }
  
  .tp-player-placeholder > span {
    font-size: 13px;
    padding: 12px 20px;
  }
  
  .tp-player-loading,
  .tp-player-error {
    min-height: 200px;
  }
  
  .tp-player-spinner {
    width: 40px;
    height: 40px;
    border-width: 4px;
  }
  
  .tp-player-loading-text,
  .tp-player-error-text {
    font-size: 14px;
  }
  
  .tp-player-error-icon {
    font-size: 36px;
  }
  
  .tp-player-pip-button {
    top: 5px;
    right: 5px;
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* Темная тема (опционально) */
.tp-player-container.dark-theme .tp-player-placeholder > span {
  background: rgba(0, 0, 0, 0.9);
}

/* Светлая тема (опционально) */
.tp-player-container.light-theme .tp-player-placeholder {
  background-color: #f5f5f5;
  color: #333;
}

.tp-player-container.light-theme .tp-player-loading {
  background: #f5f5f5;
  color: #333;
}

.tp-player-container.light-theme .tp-player-spinner {
  border-color: rgba(0, 0, 0, 0.2);
  border-top-color: #333;
}

.tp-player-container.light-theme .tp-player-error {
  background: #f5f5f5;
}

/* Кастомные размеры 
 * По умолчанию: 560px (стандартный размер для встроенного видео)
 * Используйте классы для изменения размера:
 * .small - компактный (320px, используется в чате)
 * .medium - средний (720px, HD)
 * .large - большой (1080px, Full HD)
 * .fullwidth - на всю ширину родителя
 */
.tp-player-container.small {
  max-width: 320px;
  margin: 0.5em 0; /* Меньшие отступы для компактного варианта */
}

/* Специальные настройки для small размера */
.tp-player-container.small .tp-player-placeholder {
  min-height: 180px; /* 320px * 9/16 = 180px для соотношения 16:9 */
  background-size: contain; /* Показываем весь постер без обрезки */
}

.tp-player-container.small .tp-player-placeholder > span {
  font-size: 12px;
  padding: 10px 15px;
}

.tp-player-container.small .tp-player-loading,
.tp-player-container.small .tp-player-error {
  min-height: 180px;
}

.tp-player-container.small .tp-player-spinner {
  width: 35px;
  height: 35px;
  border-width: 3px;
}

.tp-player-container.small .tp-player-loading-text,
.tp-player-container.small .tp-player-error-text {
  font-size: 12px;
}

.tp-player-container.small .tp-player-error-icon {
  font-size: 30px;
}

.tp-player-container.medium {
  max-width: 720px;
}

.tp-player-container.large {
  max-width: 1080px;
}

.tp-player-container.fullwidth {
  width: 100%;
  max-width: none;
}

/* Анимация появления */
@keyframes tp-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tp-player-container.animate-in {
  animation: tp-fade-in 0.3s ease-out;
}

/* Печать */
@media print {
  .tp-player-container {
    display: none;
  }
}

/* Accessibility: высокий контраст */
@media (prefers-contrast: high) {
  .tp-player-placeholder:focus {
    outline-width: 4px;
  }
  
  .tp-player-pip-button:focus {
    outline-width: 3px;
  }
}

/* Accessibility: уменьшенная анимация */
@media (prefers-reduced-motion: reduce) {
  .tp-player-placeholder,
  .tp-player-placeholder > span,
  .tp-player-pip-button,
  .tp-video-player.animate-in {
    transition: none;
    animation: none;
  }
  
  .tp-player-spinner {
    animation: none;
    border-top-color: transparent;
  }
}

