/* ============================================================
   AudioPlayer — стили
   ============================================================ */

/* ── Нижняя фиксированная панель ────────────────────────────── */

.vk-player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #1a1d23;
    border-top: 1px solid #2e3240;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    font-family: 'Inter', Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    will-change: transform;
    -webkit-transform: translateY(100%);
    /* Safe-area padding for notched devices */
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.video-inside {
    width: 90%;
    margin: 0 auto;
}

.vk-player-bar--visible {
    transform: translateY(0);
    -webkit-transform: translateY(0);
}

/* Прогресс-бар (над телом панели) */
.vk-bar__progress-wrap {
    padding: 0;
    cursor: pointer;
}

.vk-bar__progress {
    position: relative;
    height: 3px;
    background: #2e3240;
    overflow: visible;
    transition: height .15s;
}

.vk-bar__progress:hover {
    height: 5px;
}

.vk-bar__fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0;
    background: linear-gradient(90deg, #4f8ef7, #7b6cf7);
    border-radius: 0 3px 3px 0;
    pointer-events: none;
    transition: width .1s linear;
}

.vk-bar__handle {
    position: absolute;
    top: 50%;
    left: 0;
    width: 12px;
    height: 12px;
    margin-top: -6px;
    margin-left: -6px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,.5);
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
}

.vk-bar__progress:hover .vk-bar__handle {
    opacity: 1;
}

/* ── Группа доп. кнопок (громкость / скорость / таймер / оглавление) ── */
/* На ПК: absolute поверх body справа — в одну строку с кнопками управления */
/* На мобиле: static, скрыт по умолчанию, при раскрытии — отдельная строка над body */
.vk-bar__extra-row {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    /* ПК: абсолютно справа, вертикально по центру body-строки */
    position: absolute;
    right: 16px;
    bottom: 0;
    top: 3px; /* смещение на высоту прогресс-бара (3px) */
    /* top+bottom=0+3px → занимает высоту от прогресса до низа бара */
    /* items центрированы через align-items: center */
}

/* Тело панели */
.vk-bar__body {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 190px 8px 16px; /* справа отступ под absolute extra-row: vol+speed+timer+chapters (без крестика) */
    min-height: 70px;
}

/* Обложка */
.vk-bar__cover {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 4px;
    background: #2e3240 center/cover no-repeat;
    flex-shrink: 0;
}

/* Информация о треке */
.vk-bar__info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.vk-bar__title {
    font-size: 14px;
    color: #8892a4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.vk-bar__subtitle {
    font-size: 13px;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    margin-top: 1px;
}

/* Кнопки управления */
.vk-bar__controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.vk-bar__btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8892a4;
    transition: color .15s;
    font-size: 14px;
    width: 28px;
    height: 28px;
}

.vk-bar__btn:hover {
    color: #e2e8f0;
}

.vk-btn-play {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: var(--accent) !important;
    color: #fff !important;
    font-size: 16px !important;
    transition: transform .15s, box-shadow .15s !important;
}

.vk-btn-play:hover {
    transform: scale(1.07);
    box-shadow: 0 4px 14px rgb(139 59 50) !important;
    color: #fff !important;
}

/* Время */
.vk-bar__time {
    font-size: 12px;
    color: #8892a4;
    flex-shrink: 0;
    min-width: 70px;
    text-align: center;
    line-height: 1;
}

.vk-bar__time-sep {
    margin: 0 2px;
    opacity: .5;
}

/* Кнопка закрыть */
.vk-bar__close {
    background: none;
    border: none;
    cursor: pointer;
    color: #4a5568;
    font-size: 14px;
    height:24px;
    width:24px;
    padding: 4px;
    line-height: 1;
    transition: color .15s;
    flex-shrink: 0;
}

.vk-bar__close:hover { color: #ffffff; }

/* ── Громкость ───────────────────────────────────────────────── */
.vk-bar__vol-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

/* Кнопка-иконка громкости */
.vk-bar__vol-btn {
    background: #2e3240;
    border: none;
    border-radius: 5px;
    color: #8892a4;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 7px;
    min-width: 36px;
    line-height: 1.6;
    transition: color .15s, background .15s;
}

.vk-bar__vol-btn:hover {
    color: #e2e8f0;
    background: #3a4055;
}

/* Вертикальный попап */
.vk-bar__vol-popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1d23;
    border: 1px solid #2e3240;
    border-radius: 10px;
    padding: 14px 0 10px;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 110px;
    z-index: 10001;
    box-shadow: 0 4px 16px rgba(0,0,0,.5);
}

.vk-bar__vol-popup--open {
    display: flex;
}

/* Вертикальный слайдер */
.vk-bar__vol-slider {
    -webkit-appearance: slider-vertical;
    appearance: slider-vertical;
    writing-mode: vertical-lr;
    direction: rtl;
    width: 4px;
    height: 80px;
    background: #2e3240;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    padding: 0;
}

.vk-bar__vol-slider::-webkit-slider-runnable-track {
    width: 4px;
    background: linear-gradient(to top, #4f8ef7 var(--vol, 100%), #2e3240 var(--vol, 100%));
    border-radius: 3px;
}

.vk-bar__vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,.5);
    margin-left: -5px;
}

.vk-bar__vol-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 4px rgba(0,0,0,.5);
}

.vk-bar__vol-slider::-moz-range-track {
    width: 4px;
    background: #2e3240;
    border-radius: 3px;
}

/* ── Скорость ───────────────────────────────────────────────── */
.vk-bar__speed-wrap {
    position: relative;
}

.vk-bar__speed-btn {
    background: #2e3240;
    border: none;
    border-radius: 5px;
    color: #8892a4;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 7px;
    min-width: 36px;
    transition: color .15s, background .15s;
    line-height: 1.4;
}

.vk-bar__speed-btn:hover {
    color: #e2e8f0;
    background: #3a4055;
}

.vk-bar__speed-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1d23;
    border: 1px solid #2e3240;
    border-radius: 8px;
    overflow: hidden;
    min-width: 80px;
    z-index: 10001;
    box-shadow: 0 4px 16px rgba(0,0,0,.5);
}

.vk-bar__speed-menu--open { display: block; }

.vk-speed__item {
    padding: 8px 14px;
    font-size: 13px;
    color: #8892a4;
    cursor: pointer;
    text-align: center;
    transition: background .12s, color .12s;
}

.vk-speed__item:hover { background: #232736; color: #e2e8f0; }

.vk-speed__item--active {
    color: #4f8ef7;
    font-weight: 600;
}

/* ── Таймер сна ──────────────────────────────────────────────── */
.vk-bar__timer-wrap {
    position: relative;
}

.vk-bar__timer-btn {
    background: #2e3240;
    border: none;
    border-radius: 5px;
    color: #8892a4;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 7px;
    min-width: 36px;
    line-height: 1.4;
    transition: color .15s, background .15s;
}

.vk-bar__timer-btn:hover {
    color: #e2e8f0;
    background: #3a4055;
}

.vk-bar__timer-btn--active {
    color: #f7a74f !important;
    background: #2e2a1a !important;
}

.vk-bar__timer-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #1a1d23;
    border: 1px solid #2e3240;
    border-radius: 8px;
    overflow: hidden;
    min-width: 110px;
    z-index: 10001;
    box-shadow: 0 4px 16px rgba(0,0,0,.5);
}

.vk-bar__timer-menu--open { display: block; }

.vk-timer__label {
    padding: 8px 14px 4px;
    font-size: 11px;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.vk-timer__item {
    padding: 7px 14px;
    font-size: 13px;
    color: #8892a4;
    cursor: pointer;
    transition: background .12s, color .12s;
}

.vk-timer__item:hover { background: #232736; color: #e2e8f0; }

.vk-timer__item--cancel {
    color: #e74c3c;
    border-top: 1px solid #2e3240;
    margin-top: 2px;
}

.vk-timer__item--cancel:hover { background: #2a1a1a; color: #ff6b6b; }

/* ── Инлайн-блок на странице ─────────────────────────────────── */

.vk-inline-player {
    background: #1b1d23;
    border: 1px solid #2e3240;
    border-radius: 10px;
    overflow: hidden;
    font-family: 'Inter', Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    margin: 16px 0;
}

.vk-inline__top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
}

/* Кнопка play в инлайн */
.vk-inline__play {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s, box-shadow .15s;
    flex-shrink: 0;
}

.vk-inline__play:hover {
    transform: scale(1.07);
    box-shadow: 0 4px 16px rgb(139 59 50);
    background: #8b3b32;
}

/* Мета (название трека + время) */
.vk-inline__meta {
    flex: 1;
    min-width: 0;
}

.vk-inline__track {
    font-size: 13px;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.vk-inline__time {
    font-size: 12px;
    color: #8892a4;
    margin-top: 2px;
    line-height: 1;
}

/* Кнопка списка */
.vk-inline__list-toggle {
    background: none;
    border: 1px solid #2e3240;
    border-radius: 6px;
    color: #8892a4;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 10px;
    transition: color .15s, border-color .15s;
    flex-shrink: 0;
}

/* Список треков */
.vk-inline__list {
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease;
    border-top: 0 solid #2e3240;
}

.vk-inline__list--open {
    max-height: 400px;
    overflow-y: auto;
    border-top-width: 1px;
}

/* Скроллбар */
.vk-inline__list::-webkit-scrollbar {
    width: 4px;
}
.vk-inline__list::-webkit-scrollbar-track {
    background: #1a1d23;
}
.vk-inline__list::-webkit-scrollbar-thumb {
    background: #2e3240;
    border-radius: 2px;
}

/* Элемент списка */
.vk-inline__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    border-bottom: 1px solid #232736;
    transition: background .12s;
}

.vk-inline__item:last-child {
    border-bottom: none;
}

.vk-inline__item:hover {
    background: #232736;
}

.vk-inline__item--active {
    background: #1c2540;
}

.vk-inline__item--active .vk-inline__item-num {
    color: #4f8ef7;
}

.vk-inline__item--active .vk-inline__item-title {
    color: #fff;
}

.vk-inline__item-num {
    font-size: 12px;
    color: #4a5568;
    min-width: 22px;
    font-variant-numeric: tabular-nums;
}

.vk-inline__item-title {
    flex: 1;
    font-size: 13px;
    color: #c5cdd8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.vk-inline__item-dur {
    font-size: 12px;
    color: #4a5568;
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Кнопка оглавления в баре — стиль как у vol/speed/timer ──── */
.vk-bar__chapters-btn {
    background: #2e3240;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    padding: 4px 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8892a4;
    transition: color .15s, background .15s;
    font-size: 14px;
    min-width: 36px;
    height: 40px;
    line-height: 1.6;
    flex-shrink: 0;
}
.vk-bar__chapters-btn:hover {
    color: #e2e8f0;
    background: #3a4055;
}

/* ── Кнопка стрелки (только мобиль) ────────────────────────────── */
.vk-bar__collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: none; /* показываем только на мобиле */
    align-items: center;
    justify-content: center;
    color: #8892a4;
    transition: color .15s;
    font-size: 13px;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}
.vk-bar__collapse-btn:hover {
    color: #e2e8f0;
}

/* ── Fullscreen overlay с главами ───────────────────────────────── */
/* Находится в <body>, не внутри бара — поэтому z-index работает корректно */
.vk-bar__chapters-menu {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    /* bottom выставляется JS или через CSS; по умолчанию оставляем место под бар */
    bottom: 0;
    top: 0;
    background: #1b1d23;
    z-index: 10000;
    flex-direction: column;
    overflow: hidden;
}
.vk-bar__chapters-menu--open {
    display: flex;
}

/* Шапка overlay */
.vk-bar__ch-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 10px;
    border-bottom: 1px solid #2e3240;
    flex-shrink: 0;
}
.vk-bar__ch-header-title {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
}
.vk-bar__ch-header-book {
    font-size: 12px;
    color: #8892a4;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}
.vk-bar__ch-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #8892a4;
    font-size: 18px;
    width:28px;
    height:28px;
    padding: 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color .15s;
}
.vk-bar__ch-close:hover {
    color: #e2e8f0;
}

/* Список */
.vk-bar__ch-list {
    overflow-y: auto;
    flex: 1;
    padding: 4px 0 8px;
}
.vk-bar__ch-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    color: #8892a4;
    border-bottom: 1px solid #1e2230;
    transition: background .12s, color .12s;
}
.vk-bar__ch-item:last-child {
    border-bottom: none;
}
.vk-bar__ch-item:hover {
    background: #1e2740;
    color: #e2e8f0;
}
.vk-bar__ch-item--active {
    color: #ffffff;
    background: #1a2240;
}
.vk-bar__ch-num {
    font-size: 12px;
    color: #4a5568;
    min-width: 24px;
    flex-shrink: 0;
}
.vk-bar__ch-title {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.vk-bar__ch-dur {
    font-size: 12px;
    color: #ffffff;
    flex-shrink: 0;
    min-width: 38px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Адаптив ─────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .vk-bar__title {
        display: none;
    }
    .vk-bar__body {
        padding: 7px 10px;
        gap: 8px;
    }
    .vk-bar__cover {
        width: 34px;
        height: 34px;
        min-width: 34px;
    }
    .vk-bar__time {
        min-width: 60px;
        font-size: 11px;
    }
}

/* На узких экранах (≤430px) скрываем постер — освобождаем место */
@media (max-width: 430px) {
    .vk-bar__cover {
        display: none;
    }
}

/* ── Мобиль (≤600px): extra-row скрыт; при раскрытии — строка выше основной ── */
@media (max-width: 600px) {
    /* Показываем кнопку стрелки */
    .vk-bar__collapse-btn {
        display: flex;
    }

    /* На мобиле снимаем absolute, скрываем блок */
    .vk-bar__extra-row {
        position: static;
        display: none;
    }

    /* body — без правого отступа под absolute (его нет на мобиле) */
    .vk-bar__body {
        padding-right: 10px;
    }

    /* Когда раскрыто — extra-row появляется как отдельная строка между прогрессом и body */
    .vk-player-bar--expanded .vk-bar__extra-row {
        display: flex;
        justify-content: center;
        gap: 8px;
        padding: 6px 16px;
        border-bottom: 1px solid #2e3240;
    }

    /* Крестик всегда виден в body-строке рядом со стрелкой */
    .vk-bar__close {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Overlay занимает весь экран */
    .vk-bar__chapters-menu {
        bottom: 0;
    }

    .vk-bar__ch-header {
        padding: 12px 16px 8px;
    }
    .vk-bar__ch-item {
        padding: 11px 16px;
    }
}
