/* ============================================
   AV1Kino Video Player — полупрозрачные кнопки
   ============================================ */

/* === Сброс === */
.av1-player *, .av1-player *::before, .av1-player *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* === Контейнер плеера === */
.av1-player {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
    line-height: 1.4;
    aspect-ratio: 16 / 9;
    padding-bottom: 56.25%;
    height: 0;
}

@supports (aspect-ratio: 16 / 9) {
    .av1-player { padding-bottom: 0; height: auto; }
}

/* 🆕 Скрываем нативные контролы браузера через CSS (двойная защита) */
.av1-player video::-webkit-media-controls {
    display: none !important;
    -webkit-appearance: none !important;
}
.av1-player video::-webkit-media-controls-enclosure {
    display: none !important;
}
.av1-player video::-webkit-media-controls-panel {
    display: none !important;
}
.av1-player video::-webkit-media-controls-play-button {
    display: none !important;
}
.av1-player video::-webkit-media-controls-start-playback-button {
    display: none !important;
}

.av1-player video {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: block;
    background: #000;
    cursor: pointer;
    object-fit: contain;
}

/* === Полноэкранный режим === */
.av1-player.is-fullscreen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; max-width: none; height: 100%;
    border-radius: 0;
    z-index: 99999;
    aspect-ratio: unset;
    padding-bottom: 0;
}
.av1-player.is-fullscreen video { object-fit: contain; }

/* === Стартовый экран === */
.av1-start-screen {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: opacity 0.3s;
    z-index: 5;
}
.av1-start-screen.hidden { opacity: 0; pointer-events: none; }
.av1-start-btn {
    width: 88px; height: 88px;
    border-radius: 50%;
    background: #6366f1;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5);
}
.av1-start-btn:hover {
    transform: scale(1.1);
    background: #4f46e5;
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.7);
}
.av1-start-btn svg { width: 36px; height: 36px; fill: #fff; margin-left: 4px; }

/* === Индикатор загрузки === */
.av1-loader {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 50px; height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: av1-spin 0.8s linear infinite;
    opacity: 0; pointer-events: none; z-index: 4;
    transition: opacity 0.2s;
}
.av1-player.is-loading .av1-loader { opacity: 1; }
@keyframes av1-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* === Индикатор действий === */
.av1-action-indicator {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    width: 80px; height: 80px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.9);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; z-index: 6;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}
.av1-action-indicator.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.av1-action-indicator svg { width: 36px; height: 36px; fill: #fff; }

/* === Контролбар === */
.av1-controls {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    padding: 40px 12px 10px;
    opacity: 0; transition: opacity 0.3s; z-index: 10;
}
.av1-player:hover .av1-controls,
.av1-player.controls-visible .av1-controls,
.av1-player.is-paused .av1-controls { opacity: 1; }
.av1-player.hide-cursor { cursor: none; }
.av1-player.hide-cursor .av1-controls { opacity: 0; }

/* === Прогресс-бар === */
.av1-progress {
    position: relative; width: 100%; height: 4px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px; cursor: pointer; margin-bottom: 10px;
    transition: height 0.15s;
}
.av1-progress:hover { height: 6px; }
.av1-progress-buffered {
    position: absolute; top: 0; left: 0; height: 100%;
    background: rgba(255, 255, 255, 0.4); border-radius: 2px; pointer-events: none;
}
.av1-progress-played {
    position: absolute; top: 0; left: 0; height: 100%;
    background: #6366f1;
    border-radius: 2px; pointer-events: none;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}
.av1-progress-thumb {
    position: absolute; top: 50%;
    width: 14px; height: 14px;
    background: #fff;
    border: 3px solid #6366f1;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.15s; pointer-events: none;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.6);
}
.av1-progress:hover .av1-progress-thumb { transform: translate(-50%, -50%) scale(1); }
.av1-progress-tooltip {
    position: absolute; bottom: 100%; transform: translateX(-50%);
    background: #6366f1;
    color: #fff;
    padding: 4px 10px; border-radius: 6px; font-size: 12px;
    white-space: nowrap; pointer-events: none;
    opacity: 0; transition: opacity 0.15s; margin-bottom: 10px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}
.av1-progress-tooltip::after {
    content: '';
    position: absolute;
    top: 100%; left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #6366f1;
}
.av1-progress:hover .av1-progress-tooltip { opacity: 1; }

/* === Кнопки управления === */
.av1-controls-row { display: flex; align-items: center; gap: 6px; }

/* Базовая кнопка — ПОЛУПРОЗРАЧНЫЙ ИНДИГО ФОН + ЦВЕТНАЯ ИКОНКА */
.av1-btn {
    background: rgba(99, 102, 241, 0.2);
    border: none;
    color: #a5b4fc;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 36px; height: 36px;
    position: relative;
}
.av1-btn svg {
    width: 20px; height: 20px;
    fill: currentColor;
}
.av1-btn:hover {
    background: rgba(99, 102, 241, 0.4);
    color: #fff;
    transform: translateY(-1px);
}
.av1-btn:active {
    transform: translateY(0);
    background: rgba(99, 102, 241, 0.5);
}
.av1-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Play/Pause — чуть более выразительная */
.av1-play {
    background: rgba(99, 102, 241, 0.35);
    color: #fff;
}
.av1-play:hover {
    background: rgba(99, 102, 241, 0.55);
}

/* Rate — специальный стиль для текста */
.av1-rate-btn {
    font-weight: 700;
    font-size: 13px;
    padding: 6px 12px;
    min-width: auto;
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.2);
}
.av1-rate-btn:hover {
    background: rgba(99, 102, 241, 0.4);
    color: #fff;
}

/* Кнопка Chromecast в том же стиле */
.av1-cast-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.2);
    border-radius: 6px;
    min-width: 36px;
    height: 36px;
    padding: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}
.av1-cast-wrap:hover {
    background: rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

/* Стилизация самого google-cast-launcher */
google-cast-launcher {
    width: 22px !important;
    height: 22px !important;
    cursor: pointer;
    display: block;
}

/* Когда Chromecast активен */
google-cast-launcher[active] {
    filter: brightness(1.3);
}

/* === Время === */
.av1-time {
    font-size: 13px;
    color: #a5b4fc;
    padding: 0 8px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-weight: 600;
}
.av1-time .av1-duration {
    color: rgba(255, 255, 255, 0.5);
}
.av1-spacer { flex: 1; }

/* === Громкость === */
.av1-volume-wrap { display: flex; align-items: center; position: relative; }
.av1-volume-slider {
    width: 0; overflow: hidden; transition: width 0.2s, margin 0.2s;
    display: flex; align-items: center;
}
.av1-volume-wrap:hover .av1-volume-slider,
.av1-volume-wrap.active .av1-volume-slider { width: 80px; margin-left: 6px; }
.av1-volume-range {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px; outline: none; cursor: pointer;
}
.av1-volume-range::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 14px; height: 14px;
    background: #6366f1;
    border: 2px solid #fff;
    border-radius: 50%; cursor: pointer;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.5);
}
.av1-volume-range::-moz-range-thumb {
    width: 14px; height: 14px;
    background: #6366f1;
    border: 2px solid #fff;
    border-radius: 50%; cursor: pointer;
}

/* === Меню выбора качества/скорости === */
.av1-menu {
    position: absolute; bottom: 100%; right: 0;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    padding: 6px 0; min-width: 150px; margin-bottom: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    display: none;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.av1-menu.open { display: block; animation: menuFadeIn 0.2s ease; }
@keyframes menuFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.av1-menu-item {
    padding: 10px 16px; cursor: pointer; font-size: 13px; color: #fff;
    display: flex; align-items: center; justify-content: space-between;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.av1-menu-item:hover {
    background: rgba(99, 102, 241, 0.15);
    border-left-color: #6366f1;
}
.av1-menu-item.active {
    color: #a5b4fc;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.1);
    border-left-color: #6366f1;
}
.av1-menu-item.active::after { content: '✓'; margin-left: 8px; color: #6366f1; }
.av1-menu-title {
    padding: 8px 16px; font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
    margin-bottom: 4px;
    font-weight: 600;
}

/* === Ошибки === */
.av1-error {
    position: absolute; inset: 0; display: none;
    align-items: center; justify-content: center; flex-direction: column;
    background: rgba(127, 29, 29, 0.95);
    color: #fff; text-align: center;
    padding: 20px; z-index: 20;
}
.av1-error.show { display: flex; }
.av1-error-icon { font-size: 48px; margin-bottom: 16px; }
.av1-error-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.av1-error-message { font-size: 14px; color: rgba(255, 255, 255, 0.9); max-width: 400px; }

/* ============================================
   Индикатор подготовки Chromecast HLS
   ============================================ */
.av1-cast-preparing {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    color: #fff;
    animation: av1-cast-fadein 0.3s ease;
}

@keyframes av1-cast-fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}

.av1-cast-preparing-content {
    text-align: center;
    max-width: 400px;
    padding: 2rem;
}

.av1-cast-preparing-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 1.5rem;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: av1-spin 0.8s linear infinite;
}

.av1-cast-preparing-text {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    color: #e5e7eb;
}

.av1-cast-preparing-progress {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.av1-cast-preparing-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.av1-cast-preparing-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: av1-shimmer 2s infinite;
}

@keyframes av1-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.av1-cast-preparing-percent {
    font-size: 0.875rem;
    font-weight: 700;
    color: #a5b4fc;
    font-variant-numeric: tabular-nums;
}

/* ============================================
   Плейлист серий внутри плеера
   ============================================ */
.av1-playlist-panel {
    position: absolute; top: 0; right: 0; bottom: 0;
    width: 340px; max-width: 85%;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-left: 1px solid rgba(99, 102, 241, 0.3);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50; display: flex; flex-direction: column; color: #fff;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.5);
}
.av1-playlist-panel.open { transform: translateX(0); }
.av1-playlist-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(99, 102, 241, 0.3);
    font-weight: 600; font-size: 0.95rem;
    background: rgba(99, 102, 241, 0.15);
}
.av1-close-playlist {
    background: rgba(99, 102, 241, 0.2);
    border: none;
    color: #a5b4fc; cursor: pointer;
    width: 32px; height: 32px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.av1-close-playlist:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}
.av1-close-playlist svg { width: 18px; height: 18px; fill: currentColor; }
.av1-playlist-content { flex: 1; overflow-y: auto; padding: 0.75rem; }
.av1-playlist-content::-webkit-scrollbar { width: 6px; }
.av1-playlist-content::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.4);
    border-radius: 3px;
}
.av1-season-group {
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px; margin-bottom: 0.5rem; overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
}
.av1-season-group[open] {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}
.av1-season-group summary {
    padding: 0.875rem 1rem; cursor: pointer; font-weight: 600;
    list-style: none; display: flex; justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.2s; font-size: 0.9rem;
}
.av1-season-group summary::-webkit-details-marker { display: none; }
.av1-season-group summary:hover {
    background: rgba(99, 102, 241, 0.1);
}
.av1-season-group[open] summary {
    background: rgba(99, 102, 241, 0.2);
    color: #c7d2fe;
    border-bottom: 1px solid rgba(99, 102, 241, 0.3);
}
.av1-ep-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    background: rgba(99, 102, 241, 0.4);
    padding: 2px 8px;
    border-radius: 10px;
}
.av1-episodes-list { display: flex; flex-direction: column; }
.av1-episode-item {
    display: flex; align-items: center; padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.15s; gap: 0.75rem;
}
.av1-episode-item:last-child { border-bottom: none; }
.av1-episode-item:hover {
    background: rgba(99, 102, 241, 0.1);
    padding-left: 1.25rem;
}
.av1-episode-item.active {
    background: rgba(99, 102, 241, 0.15);
    border-left: 3px solid #6366f1;
    padding-left: calc(1rem - 3px);
}
.av1-ep-number {
    font-weight: 700;
    color: #fff;
    min-width: 28px;
    font-size: 0.95rem;
    background: rgba(99, 102, 241, 0.6);
    width: 28px; height: 28px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
}
.av1-episode-item.active .av1-ep-number {
    background: #6366f1;
}
.av1-ep-info { flex: 1; min-width: 0; }
.av1-ep-title {
    font-weight: 500; font-size: 0.85rem; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 2px;
}
.av1-episode-item.active .av1-ep-title {
    color: #c7d2fe;
    font-weight: 600;
}
.av1-ep-meta {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    display: flex; align-items: center; gap: 6px;
}
.av1-playing-indicator {
    color: #6366f1;
    font-size: 1rem;
    animation: pulse 1.5s infinite;
    background: rgba(99, 102, 241, 0.2);
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.95); }
}

/* === Адаптивность === */
@media (max-width: 640px) {
    .av1-start-btn { width: 72px; height: 72px; }
    .av1-start-btn svg { width: 28px; height: 28px; }
    .av1-btn svg { width: 18px; height: 18px; }
    .av1-time { font-size: 12px; padding: 0 4px; }
    .av1-controls { padding: 30px 8px 8px; }
    .av1-controls-row { gap: 4px; }
    .av1-volume-wrap:hover .av1-volume-slider,
    .av1-volume-wrap.active .av1-volume-slider { width: 60px; }
    .av1-player { border-radius: 8px; }
    .av1-playlist-panel { width: 100%; max-width: 100%; border-left: none; }
    .av1-btn {
        min-width: 32px; height: 32px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .av1-player * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}