/* SwagPlayer Unified - Beautiful Version Style */
:root {
    --ease: cubic-bezier(0.25, 1, 0.5, 1);
    --accent: #fa2d48;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: #000;
    color: #fff;
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

/* Scrollbar */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Auth Overlay */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* App Container */
.app-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding-top: var(--safe-top);
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    flex-shrink: 0;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-transform: lowercase;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
    overflow: hidden;
}
.icon-btn:hover { background: rgba(255,255,255,0.15); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn img { width: 100%; height: 100%; object-fit: cover; }

/* Search */
.search-bar {
    padding: 0 16px 12px;
}
.search-bar form {
    position: relative;
}
.search-bar input {
    width: 100%;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 100px;
    padding: 12px 16px 12px 44px;
    color: #fff;
    font-size: 16px;
    outline: none;
}
.search-bar input::placeholder { color: #666; }
.search-bar input:focus { background: rgba(255,255,255,0.15); }
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    width: 20px;
    height: 20px;
}

/* Tabs */
.tabs-container {
    display: flex;
    gap: 8px;
    padding: 0 16px 16px;
    overflow-x: auto;
    flex-shrink: 0;
}
.tabs-container::-webkit-scrollbar { display: none; }

.tab {
    padding: 8px 20px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255,255,255,0.1);
    color: #999;
}
.tab.active {
    background: #fff;
    color: #000;
}

/* Content */
.content-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 120px;
}
.content-scroll::-webkit-scrollbar { display: none; }

.section {
    padding: 0 16px 24px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #fff;
}
.section-title svg { color: #666; }

/* Tracks List */
.tracks-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.track-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}
.track-card:hover { background: rgba(255,255,255,0.05); }
.track-card:active { background: rgba(255,255,255,0.1); }

.track-card img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: #222;
    flex-shrink: 0;
}

.track-card .info {
    flex: 1;
    min-width: 0;
}
.track-card .title {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.track-card .artist {
    font-size: 13px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.track-card .stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #555;
}
.track-card .stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Albums Grid */
.albums-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
@media (min-width: 640px) { .albums-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .albums-grid { grid-template-columns: repeat(4, 1fr); } }

.album-card {
    background: #181818;
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.album-card:hover { background: #252525; transform: translateY(-2px); }

.album-card .cover {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: #222;
    margin-bottom: 12px;
}
.album-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.album-card .cover .placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #444;
}

.album-card .title {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.album-card .subtitle {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #555;
}
.empty-state svg { margin: 0 auto 16px; color: #444; }
.empty-state p { margin-bottom: 16px; }

/* Buttons */
.btn-primary {
    background: #fff;
    color: #000;
    padding: 12px 24px;
    border-radius: 100px;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-primary:hover { transform: scale(1.02); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: #fff;
    padding: 10px 20px;
    border-radius: 100px;
    font-weight: 500;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}
.btn-secondary:hover { background: rgba(255,255,255,0.15); }

/* ============ MINI PLAYER ============ */
.mini-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(20,20,20,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 10px 16px;
    padding-bottom: calc(10px + var(--safe-bottom));
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.4s var(--ease);
}
.mini-player.visible { transform: translateY(0); }

.mini-cover {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
    background: #222;
    flex-shrink: 0;
}

.mini-info {
    flex: 1;
    min-width: 0;
}
.mini-title {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mini-artist {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}
.mini-controls button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
}
.mini-controls button:hover { background: rgba(255,255,255,0.1); }

/* Mini Volume */
.volume-btn-mini {
    position: relative;
}
.volume-popup {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30,30,30,0.95);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    padding: 16px 10px;
    margin-bottom: 8px;
    display: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.volume-popup.visible { display: block; }
.volume-popup input {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 6px;
    height: 100px;
    -webkit-appearance: none;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}
.volume-popup input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
}

/* ============ FULL PLAYER ============ */
.full-player {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s var(--ease);
}
.full-player.visible {
    opacity: 1;
    pointer-events: auto;
}

.player-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 24px;
    padding-top: calc(24px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
    transition: all 1s var(--ease);
    position: relative;
}

.close-btn {
    position: absolute;
    top: calc(16px + var(--safe-top));
    left: 16px;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 8px;
    z-index: 10;
}
.close-btn:hover { color: #fff; }

/* Art Card - Beautiful Version Style */
.art-container {
    margin-bottom: 32px;
}

.art-card {
    width: 80vw;
    height: 80vw;
    max-width: 360px;
    max-height: 360px;
    border-radius: 20px;
    background-size: cover;
    background-position: center;
    background-color: #222;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    transition: all 0.8s var(--ease);
    transform: scale(0.9);
}
.art-card.playing { transform: scale(1); }

/* Info & Controls */
.info-controls {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.track-info {
    text-align: center;
}
.full-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.full-artist {
    font-size: 16px;
    color: #888;
    margin: 0;
}

/* Progress */
.progress-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-range {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    cursor: pointer;
}
.progress-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
.progress-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    border: none;
}

.time-display {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Main Controls */
.main-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.ctrl-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
}
.ctrl-btn:hover { color: #fff; }
.ctrl-btn:active { transform: scale(0.9); }
.ctrl-btn.active { color: #fff; background: rgba(255,255,255,0.1); }

.play-btn {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 20px rgba(255,255,255,0.2);
}
.play-btn:hover { transform: scale(1.05); }
.play-btn:active { transform: scale(0.95); }
.play-btn svg { color: #000; margin-left: 2px; }

/* Secondary Controls */
.secondary-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
}

.like-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 100px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.like-btn:hover { background: rgba(255,255,255,0.15); }
.like-btn.liked { color: var(--accent); }
.like-btn.liked svg { fill: var(--accent); }

.volume-control {
    display: none;
    align-items: center;
    gap: 8px;
    color: #666;
}
@media (min-width: 640px) { .volume-control { display: flex; } }

.volume-slider {
    width: 100px;
    height: 4px;
    -webkit-appearance: none;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
}

.share-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    border-radius: 50%;
}
.share-btn:hover { color: #fff; }

/* ============ LYRICS SECTION ============ */
.lyrics-section {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 210;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.8s var(--ease), transform 0.8s var(--ease), visibility 0s 0.8s;
    transform: translateY(100%);
}
.lyrics-section.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition: opacity 0.8s var(--ease), transform 0.8s var(--ease), visibility 0s 0s;
}

@media (min-width: 1024px) {
    .lyrics-section {
        position: absolute;
        left: auto;
        right: 0;
        width: 50%;
        background: transparent;
        transform: translateX(100%);
    }
    .lyrics-section.visible { 
        transform: translateX(0); 
    }
    
    /* Layout split - плеер сдвигается влево когда текст открыт */
    .full-player.lyrics-open .player-section { 
        transform: translateX(-20vw); 
    }
    .full-player.lyrics-open .lyrics-section { 
        opacity: 1; 
        visibility: visible;
        pointer-events: auto; 
        transform: translateX(0); 
    }
}

.close-lyrics-btn {
    position: absolute;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    z-index: 10;
}
@media (min-width: 1024px) { .close-lyrics-btn { display: none; } }

.lyrics-scroll {
    height: 100%;
    overflow-y: auto;
    padding: 45vh 32px;
}
.lyrics-scroll::-webkit-scrollbar { display: none; }

/* Lyric Line - Beautiful Blur Effect */
.lyric-line {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin-bottom: 32px;
    cursor: pointer;
    transition: opacity 0.8s var(--ease), transform 0.8s var(--ease), filter 1s;
    opacity: 0.15;
    transform: scale(0.95) translateX(-10px);
    filter: blur(4px);
}
@media (min-width: 768px) { .lyric-line { font-size: 48px; } }

.lyric-line.active {
    opacity: 1;
    transform: scale(1.05) translateX(0);
    filter: blur(0);
}
.lyric-line:hover:not(.active) {
    opacity: 0.4;
    filter: blur(2px);
}

/* ============ MODAL ============ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(20px);
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    flex-shrink: 0;
}
.modal-header button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
}
.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* ============ MOBILE LANDSCAPE ============ */
@media (orientation: landscape) and (max-height: 500px) {
    .player-section {
        flex-direction: row;
        padding: 12px 24px;
        padding-left: calc(24px + var(--safe-top));
        padding-right: calc(24px + var(--safe-top));
        gap: 20px;
        justify-content: center;
        align-items: center;
    }
    
    .art-container {
        width: auto;
        max-width: 35%;
        margin: 0;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .art-card {
        width: auto;
        height: calc(100vh - 48px);
        max-height: calc(100vh - 48px);
        aspect-ratio: 1;
        max-width: 100%;
    }
    
    .info-controls {
        flex: 1;
        gap: 12px;
        justify-content: center;
        max-width: 400px;
    }
    
    .track-info { margin-bottom: 0; }
    .full-title { font-size: 18px; margin-bottom: 2px; }
    .full-artist { font-size: 13px; }
    
    .progress-container { gap: 4px; }
    .time-display { font-size: 10px; }
    
    .main-controls { gap: 12px; }
    .ctrl-btn { width: 40px; height: 40px; }
    .ctrl-btn svg { width: 20px; height: 20px; }
    .play-btn { width: 52px; height: 52px; }
    .play-btn svg { width: 24px; height: 24px; }
    
    .secondary-controls { padding: 0; margin-top: 8px; }
    .like-btn { padding: 6px 12px; font-size: 12px; }
    .volume-control { display: none !important; }
    .share-btn { width: 36px; height: 36px; }
    
    .lyrics-section { display: none !important; }
    #lyrics-btn { display: none !important; }
    
    .close-btn { 
        top: 8px; 
        left: 8px;
        padding: 4px;
    }
    .close-btn svg { width: 24px; height: 24px; }
}

/* Extra small landscape (very short screens) */
@media (orientation: landscape) and (max-height: 380px) {
    .player-section {
        padding: 8px 16px;
        gap: 16px;
    }
    
    .art-card {
        height: calc(100vh - 32px);
        max-height: calc(100vh - 32px);
    }
    
    .info-controls { gap: 8px; }
    .full-title { font-size: 16px; }
    .full-artist { font-size: 12px; }
    
    .main-controls { gap: 8px; }
    .play-btn { width: 44px; height: 44px; }
    
    .secondary-controls { display: none; }
}

/* ============ ALBUM VIEW ============ */
.album-view {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 50;
    overflow-y: auto;
    padding-bottom: 120px;
}

.album-header {
    position: sticky;
    top: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(20px);
    padding: 16px;
    z-index: 10;
}

.back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    color: #fff;
    text-decoration: none;
}
.back-link:hover { background: rgba(255,255,255,0.15); }

.album-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px 32px;
    text-align: center;
}

@media (min-width: 640px) {
    .album-hero {
        flex-direction: row;
        text-align: left;
        gap: 32px;
        padding: 32px;
    }
}

.album-cover-large {
    width: 200px;
    height: 200px;
    border-radius: 16px;
    overflow: hidden;
    background: #222;
    flex-shrink: 0;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    margin-bottom: 24px;
}
@media (min-width: 640px) {
    .album-cover-large {
        width: 240px;
        height: 240px;
        margin-bottom: 0;
    }
}

.album-cover-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.album-cover-large .placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #444;
}

.album-info-large h1 {
    font-size: 28px;
    font-weight: 800;
    margin: 0 0 8px;
}
@media (min-width: 640px) {
    .album-info-large h1 { font-size: 36px; }
}

.album-desc {
    color: #888;
    margin: 0 0 12px;
}

.album-meta {
    display: flex;
    gap: 16px;
    justify-content: center;
    color: #666;
    font-size: 14px;
    margin-bottom: 20px;
}
@media (min-width: 640px) {
    .album-meta { justify-content: flex-start; }
}

.play-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.album-tracks-list {
    padding: 0 16px;
}

.album-tracks-list .track-card {
    display: flex;
    align-items: center;
    gap: 12px;
}

.track-num {
    width: 24px;
    text-align: center;
    color: #666;
    font-size: 14px;
    flex-shrink: 0;
}

.track-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    background: #222;
    flex-shrink: 0;
}

/* ============ SHARED MODE ============ */
body.shared-mode .app-container { display: none; }
body.shared-mode .mini-player { display: none; }
body.shared-mode .full-player { opacity: 1; pointer-events: auto; }

/* Album mode - hide main app */
body.album-mode .app-container { display: none; }
