/* styles.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --bg-dark: #121212;
    --card-dark: #1e1e1e;
    --text-dark: #e9ecef;
    --border-dark: #343a40;
    --success: #4cc9f0;
    --shadow-dark: rgba(0, 0, 0, 0.3);
}

h2 {
    font-size: 1.5rem;
    text-align: center;
    margin: 0 0 10px 0;
    padding-top: 25px;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-dark);
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-dark);
    flex-shrink: 0;
    z-index: 100;
    background-color: var(--bg-dark);
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 0 auto;
}

.logo i {
    font-size: 2rem;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    color: var(--text-dark);
    transition: transform 0.3s;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.home-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-dark);
    transition: transform 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.home-btn:hover {
    transform: scale(1.1);
    background-color: rgba(67, 97, 238, 0.1);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.player-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    flex: 1;
    min-height: 0;
}

.player-controls-container {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    width: 100%;
    max-width: 400px;
    transition: top 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.player-controls-container.controls-top {
    top: 20px;
    transform: translate(-50%, 0);
}

.player-bg {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    background-size: cover;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.bg-blur {
    position: absolute;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background-size: cover;
    background-position: center;
    filter: blur(3px) brightness(0.7);
    z-index: 1;
    pointer-events: none;
}

.book-cover-large {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-height: 200px;
}

.cover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.4) 50%, rgba(0,0,0,0.7) 100%);
}

.cover-content {
    position: relative;
    z-index: 3;
    text-align: center;
    padding: 20px;
    color: white;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

.cover-content h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.audio-player {
    flex: 2;
    background-color: rgba(30, 30, 30, 0.3);
    border-radius: 15px;
    /* padding: 20px; */
    box-shadow: 0 10px 30px var(--shadow-dark);
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
}

.audio-player.centered {
    position: static; /* Меняем с absolute на static */
    left: auto;
    top: auto;
    transform: none;
    max-width: 400px;
    width: 100%;
    padding: 24px;
    border-radius: 16px;
    background: transparent;
    box-shadow: none;
    z-index: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.player-title {
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 15px;
    background: transparent;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.speed-control label {
    font-size: 0.9rem;
    opacity: 0.8;
}

.speed-input {
    width: 70px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-dark);
    background-color: var(--shadow-dark);
    color: var(--text-dark);
    text-align: center;
    font-size: 0.9rem;
}

.speed-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    background: transparent;
}

.progress-container {
    margin-bottom: 20px;
    position: relative;
    width: 90%;
}

.progress-bar {
    height: 6px;
    width: 100%;
    background-color: var(--border-dark);
    border-radius: 3px;
    cursor: pointer;
    margin-bottom: 10px;
    position: relative;
}

.progress {
    height: 100%;
    width: 0%;
    background-color: var(--primary);
    border-radius: 3px;
    transition: width 0.1s linear;
    position: relative;
}

.progress-handle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translate(50%, -50%);
    width: 24px;
    height: 24px;
    background-color: var(--primary);
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    z-index: 10;
    transition: transform 0.2s, background-color 0.2s;
    border: 2px solid white;
}

.progress-handle:hover {
    transform: translate(50%, -50%) scale(1.1);
    background-color: var(--primary-dark);
}

.progress-handle:active {
    cursor: grabbing;
    transform: translate(50%, -50%) scale(1.2);
}

.progress-handle-drag-area {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translate(50%, -50%);
    width: 40px;
    height: 40px;
    cursor: grab;
    z-index: 11;
    background: transparent;
}

.progress-handle-drag-area:active {
    cursor: grabbing;
}

.time-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    opacity: 0.8;
}

.remaining-time-container {
    text-align: center;
    margin-bottom: 10px;
    background: transparent;
    padding: 12px;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    margin: 0 auto;
    color: var(--text-dark);
    font-size: 1.2rem;
}

.remaining-label {
    margin-bottom: 5px;
    padding-right: 5px;
}

.remaining-value {
    font-weight: bold;
    margin-bottom: 5px;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    background: transparent;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.control-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-dark);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.control-btn:hover {
    background-color: rgba(67, 97, 238, 0.1);
    color: var(--primary);
}

.play-btn {
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
    background-color: var(--primary);
    color: white;
}

.play-btn:hover {
    background-color: var(--primary-dark);
    transform: scale(1.05);
}

.rewind-text {
    font-size: 1rem;
    display: block;
    padding: 0 8px 0 8px;
}

.playlist {
    display: block;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 470px;
    bottom: 0;
    max-width: 700px;
    width: 100%;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    z-index: 1;
    background: transparent;
    border-radius: 0 0 16px 16px;
    box-shadow: none;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-20px);
    transition: opacity 0.3s ease-in-out, 
                visibility 0.3s ease-in-out, 
                transform 0.3s ease-in-out;
}

.playlist.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.playlist-header {
    text-align: center;
    margin-bottom: 8px;
    background: transparent;
}

.playlist-title {
    font-weight: bold;
}

.playlist-items {
    background: transparent;
    padding: 0;
}

.playlist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    border-radius: 0;
    margin-bottom: 0;
    cursor: pointer;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.25s ease-out, 
                transform 0.25s ease-out,
                background-color 0.2s ease-in-out;
}

.playlist.show .playlist-item {
    opacity: 1;
    transform: translateY(0);
}

/* .playlist.show .playlist-item:nth-child(1) { transition-delay: 0.05s; }
.playlist.show .playlist-item:nth-child(2) { transition-delay: 0.1s; }
.playlist.show .playlist-item:nth-child(3) { transition-delay: 0.15s; }
.playlist.show .playlist-item:nth-child(4) { transition-delay: 0.2s; }
.playlist.show .playlist-item:nth-child(5) { transition-delay: 0.25s; }
.playlist.show .playlist-item:nth-child(6) { transition-delay: 0.3s; }
.playlist.show .playlist-item:nth-child(7) { transition-delay: 0.35s; }
.playlist.show .playlist-item:nth-child(8) { transition-delay: 0.4s; }
.playlist.show .playlist-item:nth-child(9) { transition-delay: 0.45s; }
.playlist.show .playlist-item:nth-child(10) { transition-delay: 0.5s; } */

.playlist-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.playlist-item-number {
    min-width: 24px;
    text-align: left;
    opacity: 0.7;
}

.playlist-item-title {
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-item-time {
    min-width: 50px;
    text-align: right;
    opacity: 0.7;
    font-variant-numeric: tabular-nums;
}

.playlist-item.active {
    background-color: rgba(67, 97, 238, 0.9);
    border-radius: 8px;
}

.playlist-toggle-btn-blur {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(30,30,30,0.25);
    border: none;
    border-radius: 12px;
    padding: 12px 18px;
    cursor: pointer;
    color: var(--text-dark);
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: background 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.playlist-toggle-btn-blur i {
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    align-items: center;
}

.playlist-toggle-btn-blur:hover {
    background: rgba(67, 97, 238, 0.18);
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.playlist-toggle-btn-blur.active {
    background: rgba(67, 97, 238, 0.25);
    box-shadow: 0 6px 16px rgba(67, 97, 238, 0.15);
}

.playlist-toggle-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-dark);
    line-height: 1;
    margin: 0;
}

.playlist-toggle-row {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.books-list-container {
    padding: 20px;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    padding: 10px;
}

.book-card {
    background-color: var(--card-dark);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    height: 300px;
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px var(--shadow-dark);
}

.book-cover {
    flex: 1;
    background-size: cover;
    background-position: center;
    min-height: 180px;
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-title {
    padding: 15px 12px;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    background-color: var(--card-dark);
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px;
    color: var(--text-dark);
}

.loading i {
    font-size: 3rem;
    margin-bottom: 20px;
    color: var(--primary);
}

.error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px;
    color: var(--text-dark);
    text-align: center;
}

.error-message i {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #dc3545;
}

.main-content {
    min-height: 100dvh;
    box-sizing: border-box;
    padding-bottom: env(safe-area-inset-bottom, 16px);
}

#playerBlock {
    transition: margin-top 0.3s, align-items 0.3s;
}

#playlistPanel {
    transition: max-height 0.3s;
}

.audio-player,
.playlist,
.player-title,
.controls,
.remaining-time-container,
.playlist-header {
    background: transparent !important;
    box-shadow: none !important;
}

/* Медиазапросы */
@media (min-width: 1200px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 25px;
    }
    
    .book-card {
        height: 320px;
    }
    
    .progress-handle-drag-area {
        width: 44px;
        height: 44px;
    }
}

@media (min-width: 768px) {
    .player-container {
        flex-direction: row;
    }
    
    header {
        padding: 20px;
    }
    
    .logo h1 {
        font-size: 2rem;
    }
    
    .logo i {
        font-size: 2.5rem;
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 20px;
    }
    
    .book-card {
        height: 280px;
    }
    
    .progress-handle-drag-area {
        width: 42px;
        height: 42px;
    }
}

@media (max-width: 767px) {
    .container {
        height: 100vh;
        max-width: none;
        border-radius: 0;
    }
    
    header {
        padding: 12px 15px;
    }
    
    .logo h1 {
        font-size: 1.3rem;
    }
    
    .logo i {
        font-size: 1.8rem;
    }
    
    .theme-toggle {
        font-size: 1.2rem;
    }
    
    .home-btn {
        font-size: 1.3rem;
        width: 35px;
        height: 35px;
    }
    
    .player-container {
        flex-direction: column;
        margin: 0;
        border-radius: 0;
        gap: 15px;
        padding: 15px;
    }

    .player-controls-container.controls-top {
        top: 10px;
    }

    
    .book-cover-large {
        min-height: 150px;
    }
    
    .cover-content h2 {
        font-size: 1.2rem;
    }
    
    .audio-player {
        padding: 15px;
        border-radius: 12px;
        overflow-y: auto;
    }
    
    .audio-player.centered.playerBlock--topmost {
        top: 10px;
    }
    
    .player-header {
        flex-direction: column;
        align-items: center;
        margin-bottom: 15px;
        gap: 10px;
    }
    
    .player-title {
        font-size: 1.1rem;
        text-align: center;
    }
    
    .speed-control {
        width: 100%;
        justify-content: center;
    }
    
    .speed-input {
        width: 60px;
        padding: 5px 8px;
        font-size: 0.8rem;
    }
    
    .controls {
        gap: 12px;
        margin-bottom: 5px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .play-btn {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .progress-container {
        margin-bottom: 15px;
    }
    
    .progress-handle-drag-area {
        width: 46px;
        height: 46px;
    }
    
    .remaining-time-container {
        padding: 10px;
    }
    
    .playlist {
        top: 365px;
        transform: translateX(-50%) translateY(-15px);
    }
    
    .playlist.show {
        transform: translateX(-50%) translateY(0);
    }
    
    .playlist-header {
        margin-bottom: 8px;
        padding-bottom: 6px;
    }
    
    .playlist-title {
        font-size: 1rem;
    }
    
    .playlist-item {
        padding: 8px 10px;
        margin-bottom: 5px;
    }
    
    .playlist-item-number {
        width: 22px;
        font-size: 0.7rem;
    }
    
    .playlist-item-title {
        font-size: 0.85rem;
        padding: 0 10px;
    }
    
    .playlist-item-time {
        font-size: 0.7rem;
    }
    
    .books-list-container {
        padding: 15px;
    }
    
    .books-list-container h2 {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }
    
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 15px;
        padding: 5px;
    }
    
    .book-card {
        height: 250px;
    }
    
    .book-cover {
        min-height: 160px;
    }
    
    .book-title {
        padding: 12px 8px;
        font-size: 0.8rem;
    }
    
    .playlist-toggle-btn-blur {
        padding: 10px 16px;
    }
    
    .playlist-toggle-text {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .audio-player {
        padding: 12px;
        overflow-y: auto;
    }
    
    .player-title {
        font-size: 1rem;
    }
    
    .controls {
        gap: 10px;
    }
    
    .control-btn {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
    
    .play-btn {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
    
    .progress-handle-drag-area {
        width: 50px;
        height: 50px;
    }
    
    .remaining-value {
        font-size: 1.1rem;
    }
    
    .remaining-label {
        font-size: 1.1rem;
    }
    
    .playlist-item-number {
        width: 20px;
        font-size: 0.65rem;
    }
    
    .playlist-item-title {
        font-size: 0.8rem;
    }
    
    .playlist-item-time {
        font-size: 0.65rem;
    }
    
    .home-btn {
        font-size: 1.2rem;
        width: 30px;
        height: 30px;
    }
    
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }
    
    .book-card {
        height: 220px;
    }
    
    .book-cover {
        min-height: 140px;
    }
    
    .book-title {
        padding: 10px 6px;
        font-size: 0.75rem;
    }

    h2 {
        padding-top: 15px;
        font-size: 1.2rem;
    }
    
    .progress-container {
        margin-bottom: 2px;
    }
    
    .remaining-time-container {
        margin-bottom: 1px;
        padding: 5px;
        font-weight: bold;
    }
    
    .playlist-item-title {
        font-size: 15px;
    }
    
    .playlist-item-time {
        
    }
    
    .playlist-toggle-btn-blur {
        padding: 8px 14px;
    }
    
    .playlist-toggle-btn-blur i {
        font-size: 1rem;
    }
    
    .playlist-toggle-text {
        font-size: 0.85rem;
    }
}

@media (min-width: 481px) and (max-width: 767px) {
    .playlist {
        top: 470px;
    }
}

@media (min-width: 320px) and (max-width: 480px) {
     .playlist {
        top: 405px;
    }
}