/* Audio Player Styles */
.audio-player {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 1.5rem;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    margin: 1rem 0;
}

.audio-player-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.audio-book-cover {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.audio-book-info h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.audio-book-info p {
    margin: 0;
    opacity: 0.8;
    font-size: 0.9rem;
}

.audio-progress {
    margin-bottom: 1.5rem;
}

.audio-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    margin: 0.5rem 0;
}

.audio-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffd700, #ffed4e);
    border-radius: 3px;
    transition: width 0.1s ease;
}

.audio-time-display {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    opacity: 0.8;
}

.audio-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.audio-control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
    position: relative;
}

.audio-control-btn .skip-label {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: rgba(255, 215, 0, 0.9);
    color: #333;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 6px;
    line-height: 1;
    min-width: 16px;
    text-align: center;
}

.audio-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.audio-control-btn.play-pause {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
}

.audio-control-btn.play-pause:hover {
    background: white;
    transform: scale(1.1);
}

.audio-secondary-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
}

.audio-speed-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.audio-speed-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.audio-speed-btn:hover,
.audio-speed-btn.active {
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
}

.audio-action-btns {
    display: flex;
    gap: 0.5rem;
}

.audio-action-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background 0.2s ease;
    opacity: 0.8;
}

.audio-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

/* Chapter List */
.audio-chapter-list {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

/* Chapter List Items as Buttons */
.audio-chapter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-bottom: 0.5rem;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    width: 100%;
    text-align: left;
}

.audio-chapter-item:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.audio-chapter-item.active {
    background: rgba(255, 255, 255, 0.2);
}

.audio-chapter-item.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.audio-chapter-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Bookmark Items as Buttons */
.audio-bookmark-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    cursor: pointer;
    flex: 1;
    background: transparent;
    border: none;
    color: inherit;
    font: inherit;
    text-align: left;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.audio-bookmark-info:hover {
    background: rgba(255, 255, 255, 0.1);
}

.audio-bookmark-info:focus,
.audio-bookmark-info:focus-visible {
    outline: 2px solid #ffeb3b;
    outline-offset: 1px;
    background: rgba(255, 235, 59, 0.1);
}

.audio-chapter-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.audio-chapter-number {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.audio-chapter-title {
    font-size: 0.9rem;
    font-weight: 500;
}

.audio-chapter-duration {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Mini Player */
.mini-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    color: white;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.mini-player.visible {
    transform: translateY(0);
}

.mini-player-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mini-player-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.mini-player-cover {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
}

.mini-player-details h4 {
    margin: 0 0 0.25rem 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.mini-player-details p {
    margin: 0;
    font-size: 0.8rem;
    opacity: 0.8;
}

.mini-player-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mini-player-progress {
    flex: 2;
    margin: 0 1rem;
}

.mini-player-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.mini-player-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffd700, #ffed4e);
    border-radius: 2px;
    transition: width 0.1s ease;
}

.mini-player-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.mini-player-close:hover {
    opacity: 1;
}

/* Bookmarks */
.audio-bookmarks,
.audio-settings {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.audio-setting-group {
    margin-bottom: 1rem;
}

.skip-settings {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.skip-setting {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.skip-setting label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.skip-setting select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.skip-setting select option {
    background: #333;
    color: white;
}

.keyboard-shortcuts {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.25rem 0;
}

.shortcut-item kbd {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    min-width: 2rem;
    text-align: center;
}

.shortcut-item span {
    font-size: 0.85rem;
    opacity: 0.9;
}

.audio-bookmark-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
}

.audio-bookmark-title {
    font-size: 0.9rem;
    font-weight: 500;
}

.audio-bookmark-time {
    font-size: 0.8rem;
    opacity: 0.7;
}

.audio-bookmark-notes {
    font-size: 0.8rem;
    font-style: italic;
    opacity: 0.8;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border-left: 2px solid rgba(255, 255, 255, 0.2);
    margin-top: 0.25rem;
    max-width: 200px;
    word-wrap: break-word;
}

.audio-bookmark-actions {
    display: flex;
    gap: 0.5rem;
}

/* Loading states */
.audio-loading {
    text-align: center;
    padding: 2rem;
    opacity: 0.7;
}

.audio-error {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 8px;
    padding: 1rem;
    color: #dc3545;
    text-align: center;
    margin: 1rem 0;
}

/* Responsive design */
@media (max-width: 768px) {
    .audio-player {
        padding: 1rem;
        margin: 0.5rem;
    }
    
    .audio-player-header {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .audio-controls {
        gap: 0.75rem;
    }
    
    .audio-control-btn {
        width: 45px;
        height: 45px;
    }
    
    .audio-control-btn.play-pause {
        width: 55px;
        height: 55px;
    }
    
    .audio-secondary-controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .mini-player-content {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .mini-player-info {
        justify-content: center;
    }
    
    .mini-player-progress {
        order: -1;
        margin: 0;
    }
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Accessibility and Focus States */
.audio-control-btn:focus,
.audio-action-btn:focus,
.audio-speed-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* Enhanced focus states for better visibility */
.audio-control-btn:focus-visible,
.audio-action-btn:focus-visible,
.audio-speed-btn:focus-visible {
    outline: 3px solid #ffeb3b;
    outline-offset: 3px;
    box-shadow: 0 0 0 5px rgba(255, 235, 59, 0.3);
}

.audio-progress-bar:focus-visible,
.mini-player-progress-bar:focus-visible {
    outline: 2px solid #ffeb3b;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(255, 235, 59, 0.3);
}

/* Chapter and bookmark item focus */
.audio-chapter-item:focus,
.audio-bookmark-item:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.audio-chapter-item:focus-visible,
.audio-bookmark-item:focus-visible {
    outline: 2px solid #ffeb3b;
    background: rgba(255, 235, 59, 0.1);
}

/* Skip setting controls focus */
.skip-setting select:focus,
.skip-setting select:focus-visible {
    outline: 2px solid #ffeb3b;
    outline-offset: 1px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .audio-player {
        background: #000000;
        border: 2px solid #ffffff;
    }
    
    .audio-control-btn,
    .audio-action-btn,
    .audio-speed-btn {
        background: #000000;
        border: 2px solid #ffffff;
        color: #ffffff;
    }
    
    .audio-control-btn.play-pause {
        background: #ffffff;
        color: #000000;
        border: 2px solid #000000;
    }
    
    .audio-control-btn:hover,
    .audio-action-btn:hover,
    .audio-speed-btn:hover {
        background: #ffffff;
        color: #000000;
    }
    
    .audio-control-btn.play-pause:hover {
        background: #000000;
        color: #ffffff;
        border: 2px solid #ffffff;
    }
    
    .audio-progress-bar {
        background: #333333;
        border: 1px solid #ffffff;
    }
    
    .audio-progress-fill {
        background: #ffffff;
    }
    
    .audio-chapter-list,
    .audio-bookmarks,
    .audio-settings {
        background: #000000;
        border: 1px solid #ffffff;
    }
    
    .audio-chapter-item:hover,
    .audio-bookmark-item:hover {
        background: #ffffff;
        color: #000000;
    }
    
    .audio-speed-btn.active {
        background: #ffffff;
        color: #000000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .audio-player {
        animation: none;
    }
    
    .audio-control-btn,
    .audio-action-btn,
    .audio-speed-btn,
    .post-container,
    .mini-player {
        transition: none;
    }
    
    .audio-progress-fill,
    .mini-player-progress-fill {
        transition: none;
    }
}

/* Animation for player visibility */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.audio-player {
    animation: slideInUp 0.3s ease-out;
}

/* Chapter preview badge */
.audio-chapter-preview-badge {
    background: #28a745;
    color: white;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
}

.audio-chapter-locked-badge {
    background: #6c757d;
    color: white;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
}

/* Listen tab integration styles */
.book-reader-listen {
    padding: 1rem 0;
    min-height: 400px;
}

.book-reader-listen .audio-player {
    margin: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.2);
}

@media (max-width: 768px) {
    .book-reader-listen {
        padding: 0.5rem 0;
        min-height: 350px;
    }
    
    .book-reader-listen .audio-player {
        border-radius: 12px;
        padding: 1rem;
    }
}