/* ==========================================================================
   06_MUSIC.CSS — PREMIUM EDITION
   Squares + Lyrics + Player. Базовая структура сохранена 1:1.
   ========================================================================== */

/* --- ОСНОВНОЙ КОНТЕЙНЕР --- */
#music-view {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    gap: 1rem;
    overflow: hidden;
    background-color: var(--bg-panel);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1rem;
}

/* --- ТАБЫ --- */
.music-tabs {
    flex-shrink: 0;
    display: flex;
    gap: 1.5rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
}
.music-tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.25rem 0;
    cursor: pointer;
    position: relative;
    transition: color 0.3s;
}
.music-tab-btn:hover { color: var(--text-main); }
.music-tab-btn.active { color: var(--primary); }
.music-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -14px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--primary-2));
    border-radius: 2px;
    box-shadow: 0 0 10px var(--primary-glow);
    animation: tab-underline 0.3s var(--ease);
}
@keyframes tab-underline {
    from { transform: scaleX(0); opacity: 0; }
    to   { transform: scaleX(1); opacity: 1; }
}

/* ==========================================================================
   СЕТКА ТРЕКОВ (MUSIC GRID)
   ========================================================================== */
.music-track-list {
    flex-grow: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    grid-auto-rows: max-content;
    gap: 16px;
    padding: 12px 8px 40px 4px;
}

.music-card-simple {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: transform 0.35s var(--ease),
                box-shadow 0.35s var(--ease),
                border-color 0.35s var(--ease);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    
    /* === ФИКСЫ ТОРЧАЩИХ УГЛОВ === */
    isolation: isolate;
    transform: translateZ(0);                                  /* GPU слой */
    -webkit-mask-image: -webkit-radial-gradient(white, black); /* фикс WebKit */
    background-color: transparent;                             /* убираем тёмный квадрат */
}

.music-card-simple:hover {
    transform: translateY(-4px) translateZ(0);  /* ОБЯЗАТЕЛЬНО translateZ(0) тоже здесь */
    box-shadow:
        0 14px 35px rgba(0, 0, 0, 0.6),
        0 0 22px var(--primary-glow);
    border-color: var(--primary);
    z-index: 3;
}

.music-card-simple:active {
    transform: translateY(-2px) translateZ(0);
    transition-duration: 0.1s;
}

/* Убираем ::before полностью, рамку делаем через тень внутрь */
.music-card-simple::before {
    content: none;  /* отключаем псевдоэлемент */
}

/* Обложка */
.simple-card-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s var(--ease), filter 0.4s ease;
    z-index: 0;
    background-color: #222;
}
.music-card-simple:hover .simple-card-cover {
    transform: scale(1.1);
    filter: saturate(1.15) brightness(1.05);
}

/* Градиент для текста */
.music-card-simple::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom,
                transparent 35%,
                rgba(0, 0, 0, 0.55) 75%,
                rgba(0, 0, 0, 0.95) 100%);
    z-index: 1;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Инфо на карточке */
.simple-card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 14px;
    z-index: 2;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform 0.35s var(--ease);
}
.music-card-simple:hover .simple-card-info {
    transform: translateY(-4px);
}

.simple-card-title {
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}

.simple-card-status {
    font-size: 0.75rem;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 5px;
}
/* БОНУС: маленькая золотая точка-индикатор перед статусом */
.simple-card-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 6px var(--primary);
    flex-shrink: 0;
}

/* Иконка Play при наведении */
.simple-play-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.music-card-simple:hover .simple-play-overlay { opacity: 1; }

.simple-play-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transform: scale(0.8) translateY(10px);
    transition: transform 0.35s var(--ease), background 0.3s ease;
}
.music-card-simple:hover .simple-play-icon {
    transform: scale(1) translateY(0);
}
/* БОНУС: при наведении прямо на иконку — золотая подсветка + пульс */
.simple-play-overlay:hover .simple-play-icon {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
    box-shadow: 0 0 25px var(--primary-glow);
    animation: play-pulse 1.5s infinite;
}
@keyframes play-pulse {
    0%, 100% { box-shadow: 0 0 20px var(--primary-glow); }
    50%      { box-shadow: 0 0 35px var(--primary-glow); }
}

/* ==========================================================================
   ЗАГЛУШКА (LOADING PLACEHOLDER)
   ========================================================================== */
.music-track-card.is-loading {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 15px;
    gap: 15px;
    overflow: hidden;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
/* БОНУС: бегущий блик (shimmer) по заглушке */
.music-track-card.is-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg,
                transparent 30%,
                rgba(255, 255, 255, 0.06) 50%,
                transparent 70%);
    transform: translateX(-100%);
    animation: shimmer 1.8s infinite;
}
@keyframes shimmer {
    100% { transform: translateX(100%); }
}

.loading-visualizer {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 40px;
    position: relative;
    z-index: 1;
}
.visualizer-bar {
    width: 6px;
    background: linear-gradient(to top, var(--primary-2), var(--primary));
    border-radius: 3px;
    animation: sound-wave 1s infinite ease-in-out;
}
/* БОНУС: добавил 5 полосок вместо 3 для более живого эквалайзера */
.visualizer-bar:nth-child(1) { height: 40%; animation-delay: 0s;    }
.visualizer-bar:nth-child(2) { height: 70%; animation-delay: 0.2s;  }
.visualizer-bar:nth-child(3) { height: 50%; animation-delay: 0.4s;  }
.visualizer-bar:nth-child(4) { height: 80%; animation-delay: 0.15s; }
.visualizer-bar:nth-child(5) { height: 55%; animation-delay: 0.35s; }

@keyframes sound-wave {
    0%, 100% { height: 20%; opacity: 0.5; }
    50%      { height: 100%; opacity: 1; box-shadow: 0 0 10px var(--primary); }
}

.is-loading .track-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    z-index: 1;
}
.is-loading .track-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   МОДАЛЬНОЕ ОКНО ПЛЕЕРА (PLAYER)
   ========================================================================== */
#musicPlayerModal { z-index: 1055 !important; }

.music-player-content {
    background-color: var(--modal-bg, var(--bg-card));
    color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    position: relative;
}
/* БОНУС: тонкое золотое свечение сверху модалки */
.music-player-content::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    opacity: 0.6;
}

.modal-header { border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.modal-header .btn-close { filter: invert(1); opacity: 0.7; transition: 0.2s; }
.modal-header .btn-close:hover { opacity: 1; transform: rotate(90deg); }

.player-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    padding: 10px 0;
}
.player-cover-column { width: 280px; flex-shrink: 0; }
.player-cover-large {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.4s var(--ease);
}
/* БОНУС: лёгкий 3D-наклон обложки при наведении */
.player-cover-large:hover {
    transform: perspective(800px) rotateY(-6deg) rotateX(3deg) scale(1.02);
}

.player-controls-column {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 280px;
}

.player-track-info-header h3 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    background: linear-gradient(90deg, #fff, #ddd);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Слайдер */
.player-progress-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 1.5rem 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: monospace;
}
.styled-slider {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    position: relative;
    transition: height 0.2s ease;
}
.styled-slider:hover { height: 7px; }
.styled-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 0 12px var(--primary-glow);
    border: 2px solid #fff;
}
.styled-slider::-webkit-slider-thumb:hover { transform: scale(1.3); }
.styled-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    cursor: pointer;
}

/* Кнопки плеера */
.player-main-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}
.player-play-btn-large {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--primary), var(--primary-2));
    color: #000;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s var(--ease), box-shadow 0.3s ease;
    box-shadow: 0 8px 25px var(--primary-glow);
}
.player-play-btn-large:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 40px var(--primary-glow);
}
.player-play-btn-large:active { transform: scale(0.96); }

.player-actions-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
}
.player-action-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}
.player-action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.2);
}
.player-action-btn.danger:hover {
    color: #ff4d4d;
    background: rgba(255, 77, 77, 0.12);
    border-color: rgba(255, 77, 77, 0.4);
}

/* Кнопка избранного */
#player-fav-btn .star-outline { display: block !important; }
#player-fav-btn .star-filled  { display: none !important; }
#player-fav-btn.active .star-outline { display: none !important; }
#player-fav-btn.active .star-filled  {
    display: block !important;
    filter: drop-shadow(0 0 6px var(--primary));
}
#player-fav-btn.active {
    color: var(--primary) !important;
    border-color: var(--primary) !important;
    background-color: rgba(250, 191, 60, 0.15) !important;
    animation: fav-pop 0.4s var(--ease);
}
@keyframes fav-pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* Доп. детали */
.player-divider {
    border-color: rgba(255, 255, 255, 0.1);
    margin: 1.5rem 0;
}
.player-detail-box {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: border-color 0.3s ease;
}
.player-detail-box:hover { border-color: rgba(255, 255, 255, 0.12); }
.detail-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}
.copy-btn-sm {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
}
.copy-btn-sm:hover {
    color: #000;
    background: var(--primary);
    border-color: var(--primary);
}
.detail-content {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #eee;
    white-space: pre-wrap;
    margin: 0;
}

/* Ремикс модалка (выше плеера) */
#musicReplaceModal { z-index: 1060 !important; }
.modal-backdrop + .modal-backdrop { z-index: 1058 !important; }

/* ==========================================================================
   ПЕРЕКЛЮЧАТЕЛЬ (CUSTOM SWITCH)
   ========================================================================== */
.custom-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 5px 0;
}
.custom-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    margin-bottom: 0;
}
.custom-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    transition: 0.4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: 0.4s var(--ease);
    border-radius: 50%;
}
.custom-switch input:checked + .slider {
    background-color: rgba(250, 191, 60, 0.2);
    border-color: var(--primary);
}
.custom-switch input:checked + .slider:before {
    transform: translateX(22px);
    background-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}
.switch-label-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: 0.3s;
}
.custom-switch input:checked ~ .switch-label-text {
    color: var(--text-main);
}

/* ==========================================================================
   АДАПТИВ ДЛЯ МОБИЛЬНЫХ
   ========================================================================== */
@media (max-width: 768px) {
    /* Плеер */
    .music-track-list { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .player-layout {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
        text-align: center;
    }
    .player-cover-column { width: 100%; max-width: 280px; }
    .player-cover-large:hover { transform: none; } /* убираем 3D на тач-устройствах */
    .player-controls-column { height: auto; width: 100%; }
    .player-track-info-header h3 { font-size: 1.2rem; }
    .player-actions-row { gap: 0.5rem; }

    /* На мобильных play-иконку показываем сразу (нет hover) */
    .simple-play-overlay { opacity: 0; }
    .music-card-simple:active .simple-play-overlay { opacity: 1; }

    /* Lyrics экран */
    #lyrics-edit-screen { padding: 0; gap: 1rem; }
    #generated-lyrics-input { font-size: 0.9rem; padding: 12px; }
    .lyrics-actions { grid-template-columns: 1fr 1.5fr; gap: 10px; }
    .lyrics-actions-row {
        flex-direction: column-reverse; /* Кнопка "Назад" уходит вниз */
        gap: 10px;
    }
    #back-to-idea-btn {
        width: 100%;
        height: 48px;
    }
    #send-to-suno-btn {
        width: 100%;
        height: 56px;
    }
}