/* Story Page Player Styles */
.story-player-wrapper {
    overflow-x: hidden;
    max-width: 100%;
    position: relative;
}

.story-player {
    background: white;
    border-radius: 20px;
    padding: 30px;
    color: #2c3e50;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    position: relative;
}

.player-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
}

.album-artwork {
    width: 120px;
    height: 120px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    position: relative;
    background: #f8f9fa;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.album-artwork img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.album-artwork.playing img {
    transform: scale(1.05);
}

.story-info {
    flex: 1;
}

.story-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 8px 0;
    line-height: 1.2;
    color: #2c3e50;
}

.story-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    color: #7f8c8d;
    font-size: 14px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.meta-link {
    color: #7f8c8d;
    text-decoration: none;
    transition: all 0.3s ease;
    padding: 4px 8px;
    border-radius: 6px;
}

.meta-link:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    text-decoration: none;
    transform: translateY(-1px);
}

.episode-selector {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.episode-selector h5 {
    margin: 0 0 15px 0;
    font-weight: 600;
    color: #2c3e50;
}

.episode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.episode-item {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 12px 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #2c3e50;
}

.episode-item:hover {
    background: #f8f9fa;
    border-color: #667eea;
    transform: translateY(-2px);
}

.episode-item.active {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.episode-item.playing {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.episode-title {
    font-weight: 500;
    font-size: 14px;
}

.episode-number {
    background: #e9ecef;
    color: #6c757d;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}

.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

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

.control-btn {
    width: 50px;
    height: 50px;
    border: 2px solid #e9ecef;
    border-radius: 50%;
    background: white;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.control-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.control-btn.primary {
    width: 70px;
    height: 70px;
    background: #667eea;
    color: white;
    font-size: 24px;
    border-color: #667eea;
}

.control-btn.primary:hover {
    background: #5a67d8;
    border-color: #5a67d8;
}



.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.progress-section {
    margin-bottom: 20px;
}

.time-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    color: #6c757d;
    font-weight: 500;
}

.progress-container {
    position: relative;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    position: relative;
    transition: width 0.1s ease;
}

.progress-handle {
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: #667eea;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.progress-container:hover .progress-handle {
    opacity: 1;
}

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

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

.volume-slider {
    width: 80px;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.player-options {
    display: flex;
    gap: 15px;
}

.option-btn {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    padding: 8px 16px;
    color: #6c757d;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-btn:hover, .option-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

/* Sleep Timer Dropdown */
.sleep-timer-dropdown {
    position: relative;
    display: inline-block;
}

.sleep-timer-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 10px 0;
    min-width: 150px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.sleep-timer-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.sleep-timer-option {
    display: block;
    width: 100%;
    padding: 10px 20px;
    border: none;
    background: none;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    text-align: left;
}

.sleep-timer-option:hover {
    background: #f5f5f5;
}

.sleep-timer-option.danger {
    color: #e53e3e;
}

/* History Panel Overlay */
.history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.history-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* History Panel */
.history-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 400px;
    max-width: 90vw; /* Prevent panel from being wider than viewport */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    transform: translateX(100%); /* Use transform instead of right */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1051;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    overflow-x: hidden; /* Prevent horizontal overflow */
}

.history-panel.open {
    transform: translateX(0); /* Slide in */
}

/* Prevent body scroll when panel is open */
body.history-panel-open {
    overflow-x: hidden;
    position: relative;
}

.history-header {
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.close-history {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.close-history:hover {
    background: rgba(255, 255, 255, 0.2);
}

.history-list {
    height: calc(100vh - 80px);
    overflow-y: auto;
    padding: 20px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.history-story-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    min-width: 0;
}

.history-story-info img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.history-details {
    flex: 1;
    min-width: 0;
}

.history-story-title {
    font-weight: 600;
    font-size: 14px;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}

.history-episode {
    font-size: 13px;
    color: #666;
    margin: 0 0 6px 0;
    font-weight: 500;
}

.history-date {
    font-size: 12px;
    color: #999;
    flex-shrink: 0;
    margin-left: 10px;
}

.no-history {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

.history-item:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.history-album-art {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.history-album-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-story-title {
    font-weight: 600;
    font-size: 14px;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-episode-title {
    font-size: 13px;
    color: #666;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-progress {
    font-size: 12px;
    color: #888;
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-bar-small {
    width: 60px;
    height: 3px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 11px;
    color: #666;
    white-space: nowrap;
}
    overflow: hidden;
}

.history-progress-fill {
    height: 100%;
    background: #667eea;
    border-radius: 2px;
}

.history-time {
    font-size: 11px;
    color: #aaa;
    text-align: right;
}

.empty-history {
    text-align: center;
    padding: 40px 20px;
    color: #888;
}

.empty-history i {
    font-size: 48px;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* Mini Player */
.mini-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding: 15px 20px;
    z-index: 1050;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
}

.mini-player.show {
    transform: translateY(0);
}

.mini-player-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 20px;
}

.mini-album-art {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.mini-album-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mini-track-info {
    flex: 1;
    min-width: 0;
}

.mini-track-title {
    font-weight: 600;
    font-size: 14px;
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-track-subtitle {
    font-size: 12px;
    color: #666;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mini-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #667eea;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-btn:hover {
    background: #5a67d8;
    transform: scale(1.05);
}

.mini-btn.secondary {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.mini-btn.secondary:hover {
    background: rgba(102, 126, 234, 0.2);
}

#miniSleepTimerBtn {
    position: relative;
}

#miniSleepTimerBtn.active {
    background: #f56565;
    color: white;
}

#miniSleepTimerBtn.active:hover {
    background: #e53e3e;
}

.mini-sleep-timer-menu {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 10px 0;
    min-width: 150px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    animation: fadeInUp 0.2s ease;
}

.mini-sleep-timer-menu .sleep-timer-option {
    display: block;
    width: 100%;
    padding: 10px 20px;
    border: none;
    background: none;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    text-align: left;
}

.mini-sleep-timer-menu .sleep-timer-option:hover {
    background: #f5f5f5;
}

.mini-sleep-timer-menu .sleep-timer-option.danger {
    color: #e53e3e;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mini-progress {
    width: 150px;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.mini-progress-bar {
    height: 100%;
    background: #667eea;
    border-radius: 2px;
    transition: width 0.1s ease;
}

.mini-close {
    background: rgba(0, 0, 0, 0.1);
    color: #666;
}

.mini-close:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Wave Animation */
.wave-indicator {
    display: flex;
    gap: 2px;
    align-items: center;
    height: 16px;
}

.wave-bar {
    width: 3px;
    height: 100%;
    background: currentColor;
    border-radius: 2px;
    animation: wave 1.2s infinite ease-in-out;
}

.wave-bar:nth-child(1) { animation-delay: 0s; }
.wave-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; }

@keyframes wave {
    0%, 40%, 100% { transform: scaleY(0.4); }
    20% { transform: scaleY(1); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .story-player {
        padding: 20px;
        border-radius: 15px;
    }
    
    .player-header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .album-artwork {
        width: 100px;
        height: 100px;
    }
    
    .story-title {
        font-size: 20px;
    }
    
    .episode-grid {
        grid-template-columns: 1fr;
        max-height: 150px;
    }
    
    .player-controls {
        justify-content: center;
        gap: 15px;
    }
    
    .control-btn {
        width: 45px;
        height: 45px;
    }
    
    .control-btn.primary {
        width: 60px;
        height: 60px;
    }
    
    .player-extras {
        flex-direction: column;
        gap: 10px;
    }
    
    .mini-player-content {
        gap: 15px;
    }
    
    .mini-controls {
        gap: 10px;
    }
    
    .mini-progress {
        width: 100px;
    }
}

@media (max-width: 480px) {
    .story-meta {
        flex-direction: column;
        gap: 8px;
    }
    
    .player-options {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .mini-track-info {
        display: none;
    }
}

/* Custom Scrollbar */
.episode-grid::-webkit-scrollbar {
    width: 6px;
}

.episode-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.episode-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.episode-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}