/* Базовые переменные и сброс */
:root {
    --bg-color: #f4f6f8;
    --text-color: #2c3e50;
    --card-bg: white;
    --primary-color: #e74c3c;
}

body.dark-theme {
    --bg-color: #0f2027;
    --text-color: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.1);
}

body {
    font-family: 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;

    /* Добавлено для блокировки внешнего скролла */
    height: 100vh;
    /* Запасной вариант для старых браузеров */
    height: 100dvh;
    /* Динамическая высота для телефонов */
    overflow: hidden;
}

.split-layout {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    max-height: calc(100vh - 80px) !important;
    /* Добавлено для ограничения высоты */
    flex: 1; /* Автоматически заполняет всю пустоту до низа экрана */
    min-height: 0; /* Не дает блоку вывалиться за пределы монитора */
    overflow: hidden;
}

.panel {
    flex: 1;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    min-width: 0;

    /* Добавлено для внутреннего растягивания */
    display: flex;
    flex-direction: column;
    min-height: 0;
}



/* Мобильные вкладки по умолчанию скрыты */
.tabs-container {
    display: none;
    width: 100%;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-color);
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Компактный дизайн для локальной библиотеки */
/* Разрешаем карточке переносить элементы на новую строку */
.lib-card {
    display: flex;
    flex-wrap: wrap;
    /* Ключевое: позволяет плееру уйти вниз */
    align-items: center;
    gap: 10px;
    padding: 10px;
}

/* Плеер занимает всю ширину под контентом */
#localPlayer {
    width: 100%;
    margin-top: 10px;
}

.lib-thumb {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.lib-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.lib-title {
    font-weight: bold;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lib-author {
    font-size: 12px;
    color: #7f8c8d;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-color);
    padding: 5px;
}

.icon-btn.play {
    color: #27ae60;
}



.back-btn {
    margin-bottom: 20px;
    display: block;
    text-decoration: none;
    color: var(--text-color);
    font-weight: bold;
    align-self: flex-start;
}

/* Десктопная строка поиска */
.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

.search-input {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #ccc;
    font-size: 16px;
    box-sizing: border-box;
}

.search-btn {
    padding: 12px 20px;
    border-radius: 10px;
    border: none;
    background: var(--primary-color);
    color: white;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    text-align: left;
    margin-top: 20px;

    /* Добавлено для внутреннего скролла */
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

.video-card {
    display: flex;
    flex-direction: row;
    gap: 15px;
    background: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 12px;
    align-items: center;
}

.video-thumb-container {
    position: relative;
    width: 160px;
    /* Фиксированная ширина для ПК */
    aspect-ratio: 16 / 9;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

.video-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.2s;
}

.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    opacity: 1;
}

.video-thumb-container:hover .video-thumb {
    opacity: 0.7;
}

.video-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.video-title {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-author {
    font-size: 14px;
    color: #7f8c8d;
    margin-bottom: 8px;
}

.add-btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    background: #27ae60;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    align-self: flex-start;
    /* Кнопка не растягивается на ПК */
}

.mic-btn {
    padding: 0 15px;
    border-radius: 10px;
    border: 1px solid #ccc;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mic-btn.recording {
    background: #e74c3c;
    border-color: #e74c3c;
    color: white;
    animation: pulse 1.5s infinite;
}

/* Контейнер для кнопки и меню */
.menu-container {
    position: relative;
    display: inline-block;
}

/* Само выпадающее меню */
.menu-popup {
    display: none;
    /* Скрыто по умолчанию */
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--card-bg);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    min-width: 150px;
    overflow: hidden;
}

/* Элементы внутри меню */
.menu-option {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    color: var(--text-color);
}

.menu-option:hover {
    background: rgba(0, 0, 0, 0.05);
}

.menu-option.delete {
    color: #e74c3c;
    /* Красный цвет для удаления */
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* МОБИЛЬНАЯ ВЕРСИЯ (экраны до 768px) */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }

    .split-layout {
        flex-direction: column;
    }

    .tabs-container {
        display: flex;
    }

    /* Скрываем неактивную панель на телефоне */
    .panel {
        display: none;
    }

    .panel.active-panel {
        display: flex;
    }

    .search-box {
        gap: 8px;
    }

    .search-input {
        min-width: 0;
        /* Не дает полю ввода выталкивать кнопку */
    }

    /* Карточка становится вертикальной */
    .video-card {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
    }

    /* Плеер на всю ширину */
    .video-thumb-container {
        width: 100%;
    }

    .play-overlay {
        font-size: 40px;
    }

    .video-info {
        width: 100%;
    }

    /* Текст переносится */
    .video-title {
        white-space: normal;
        line-height: 1.3;
    }

    /* Кнопка на всю ширину */
    .add-btn {
        width: 100%;
        text-align: center;
        padding: 12px;
        border-radius: 8px;
    }

    .mic-btn {
        padding: 0 12px;
        font-size: 18px;
    }
}

/* --- СТИЛИ ДЛЯ ПЛЕЙЛИСТОВ --- */
.playlist-header {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.playlist-header-info h3 {
    margin: 0 0 5px 0;
}

.playlist-header-info label {
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}

.playlist-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 16px;
    font-weight: bold;
    color: var(--text-color);
}

.track-checkbox {
    transform: scale(1.3);
    cursor: pointer;
}

/* Адаптация под Fold и смартфоны (интеграция с твоими 768px) */
@media (max-width: 768px) {
    .playlist-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .playlist-header button {
        width: 100%;
    }

    /* Выстраиваем номер и чекбокс красивой полоской над обложкой */
    .playlist-meta {
        width: 100%;
        justify-content: space-between;
        padding-bottom: 10px;
        margin-bottom: 5px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }

    body.dark-theme .playlist-meta {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
}

/* Состояние активной кнопки (играет) */
.play-btn.active {
    background-color: #27ae60 !important;
    /* Зеленый при проигрывании */
    color: white;
}