/* Persistent Audio Player Styles */

:root {
    --pap-bg: #282828;
    --pap-text: #ffffff;
    --pap-hover: rgba(255, 255, 255, 0.1);
    --pap-border: rgba(255, 255, 255, 0.1);
}

/* Player Container */
#pap-player-container {
    position: fixed;
    left: 0;
    right: 0;
    background: var(--pap-bg);
    color: var(--pap-text);
    z-index: 99999;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

/* Playbar at top of drawer (default) */
#pap-player-container.pap-layout-playbar-top {
    flex-direction: column;
}

/* Playbar at bottom of drawer */
#pap-player-container.pap-layout-playbar-bottom {
    flex-direction: column-reverse;
}

#pap-player-container.pap-position-bottom {
    bottom: 0;
}

#pap-player-container.pap-position-top {
    top: 0;
}

/* Main Player */
.pap-player {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    gap: 15px;
    position: relative;
    z-index: 2;
    background: var(--pap-bg);
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

/* Buttons */
.pap-btn {
    background: none;
    border: none;
    color: var(--pap-text);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pap-btn:hover {
    background: var(--pap-hover);
    color: var(--pap-color);
}

.pap-btn-play {
    width: 40px;
    height: 40px;
}

/* Controls */
.pap-player-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Artwork */
.pap-artwork-container {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#pap-artwork {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pap-artwork-placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* Track Info */
.pap-track-info {
    flex: 0 0 200px;
    min-width: 0;
}

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

.pap-track-artist {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Progress Bar */
.pap-progress-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pap-time {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    min-width: 40px;
}

.pap-progress-bar {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.pap-progress-fill {
    height: 100%;
    background: var(--pap-color);
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
}

.pap-progress-bar:hover .pap-progress-fill {
    background: var(--pap-color);
    opacity: 0.8;
}

/* Volume */
.pap-volume-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pap-volume-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    outline: none;
}

.pap-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--pap-color);
    cursor: pointer;
}

.pap-volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--pap-color);
    cursor: pointer;
    border: none;
}

/* Playlist Drawer */
.pap-playlist-drawer {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--pap-bg);
    max-height: 400px;
    overflow-y: auto;
    border-top: 1px solid var(--pap-border);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.pap-playlist-drawer.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

.pap-position-top .pap-playlist-drawer {
    bottom: auto;
    top: 100%;
    transform: translateY(-100%);
}

.pap-position-top .pap-playlist-drawer.active {
    transform: translateY(0);
}

.pap-playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--pap-border);
}

.pap-playlist-header h3 {
    margin: 0;
    font-size: 16px;
}

.pap-playlist-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

/* Playlist Items */
.pap-playlist-items {
    padding: 0;
}

.pap-playlist-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--pap-border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pap-admin-track-count,
.pap-visitor-track-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
}

.pap-playlist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1px 20px;
    border-bottom: 1px solid var(--pap-border);
    cursor: pointer;
    transition: background 0.2s;
}

.pap-playlist-item:hover {
    background: var(--pap-hover);
}

.pap-playlist-item.active {
    background: rgba(29, 185, 84, 0.1);
}

.pap-playlist-item.active .pap-playlist-title {
    color: var(--pap-color);
}

.pap-playlist-track-info {
    display: flex;
    gap: 15px;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.pap-playlist-number {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    min-width: 25px;
}

.pap-playlist-artwork {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pap-playlist-artwork img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pap-playlist-artwork-placeholder {
    color: rgba(255, 255, 255, 0.3);
}

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

.pap-playlist-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pap-playlist-artist {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Playlist Actions */
.pap-playlist-actions {
    display: flex;
    gap: 8px;
}

.pap-playlist-item {
    position: relative;
}

.pap-btn-add-to-cart {
    color: var(--pap-color);
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}

.pap-playlist-item:hover .pap-btn-add-to-cart {
    opacity: 1;
}

.pap-btn-add-to-cart:hover {
    background: var(--pap-hover);
}

.pap-btn-add-to-cart.loading svg {
    animation: spin 1s linear infinite;
}

.pap-btn-add-to-cart.success {
    color: #4caf50;
}

.pap-btn-go-to-release {
    color: var(--pap-color);
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}

.pap-playlist-item:hover .pap-btn-go-to-release {
    opacity: 1;
}

.pap-btn-go-to-release:hover {
    background: var(--pap-hover);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.pap-btn-remove {
    color: rgba(255, 255, 255, 0.5);
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}

.pap-playlist-item:hover .pap-btn-remove {
    opacity: 1;
}

.pap-btn-remove:hover {
    color: #f44336;
}

/* ── WordPress Playlist Integration ── */
.pap-wp-playlist-button-container {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.pap-btn-add-all-tracks {
    width: 100%;
    background: var(--pap-color);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: opacity 0.2s;
}

.pap-btn-add-all-tracks:hover {
    opacity: 0.9;
}

.wp-playlist .wp-playlist-item {
    position: relative;
}

.pap-btn-add-single-track {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--pap-color);
    color: #fff;
    border: none;
    padding: 2px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10;
    line-height: 1.2;
}

.wp-playlist .wp-playlist-item:hover .pap-btn-add-single-track {
    opacity: 1;
}

.pap-btn-add-single-track:hover {
    transform: translateY(-50%) scale(1.1);
}

/* Tighten the gap between the "Add All" button and the track list */
.wp-playlist .pap-wp-playlist-button-container + .wp-playlist-tracks {
    margin-top: -5px;
}

/* ── Notifications ── */
.pap-notification {
    position: fixed;
    bottom: 100px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 4px;
    color: #fff;
    background-color: var(--pap-color);
    z-index: 100001;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.pap-notification-error {
    background-color: #f44336;
}

/* Responsive Design */
@media (max-width: 768px) {
    .pap-player {
        flex-wrap: wrap;
        padding: 10px;
        gap: 10px;
    }
    
    .pap-track-info {
        flex: 0 0 150px;
    }
    
    .pap-volume-container {
        display: none;
    }
    
    .pap-progress-container {
        order: 10;
        width: 100%;
    }
}

/* Scrollbar Styling */
.pap-playlist-drawer::-webkit-scrollbar {
    width: 8px;
}

.pap-playlist-drawer::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.pap-playlist-drawer::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.pap-playlist-drawer::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ── Variation Selector Modal ── */
.pap-variation-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.pap-variation-content {
    background: var(--pap-bg);
    border-radius: 10px;
    padding: 24px;
    max-width: 520px;
    width: 92%;
    max-height: 88vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.pap-variation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--pap-border);
}

.pap-variation-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--pap-text);
}

.pap-variation-close {
    background: none;
    border: none;
    color: var(--pap-text);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pap-variation-close:hover {
    background: var(--pap-hover);
}

.pap-variation-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 4px;
}

.pap-variation-option {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 14px;
    padding: 12px;
    border: 2px solid var(--pap-border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, opacity 0.15s;
    align-items: center;
    outline: none;
}

.pap-variation-option:hover:not(.is-disabled) {
    border-color: var(--pap-color);
    background: var(--pap-hover);
}

.pap-variation-option:focus-visible {
    box-shadow: 0 0 0 2px var(--pap-color);
}

.pap-variation-option.selected {
    border-color: var(--pap-color);
    background: rgba(255, 255, 255, 0.04);
}

.pap-variation-option.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(0, 0, 0, 0.15);
}

.pap-variation-thumb {
    width: 64px;
    height: 64px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pap-variation-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pap-variation-thumb-placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.pap-variation-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.pap-variation-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--pap-text);
}

.pap-variation-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pap-variation-pricerow {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
}

.pap-variation-price {
    font-size: 14px;
    color: var(--pap-color);
    font-weight: 700;
}

.pap-variation-stock {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.pap-stock-low {
    background: rgba(255, 152, 0, 0.18);
    color: #ffb74d;
}

.pap-stock-out {
    background: rgba(244, 67, 54, 0.18);
    color: #ef9a9a;
}

/* Quantity stepper */
.pap-variation-quantity {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-top: 1px solid var(--pap-border);
    border-bottom: 1px solid var(--pap-border);
}

.pap-qty-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--pap-text);
}

.pap-qty-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--pap-border);
    border-radius: 6px;
    overflow: hidden;
}

.pap-qty-stepper button {
    background: transparent;
    border: none;
    color: var(--pap-text);
    width: 32px;
    height: 32px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.pap-qty-stepper button:hover {
    background: var(--pap-hover);
}

.pap-qty-input {
    width: 48px;
    height: 32px;
    background: transparent;
    border: none;
    border-left: 1px solid var(--pap-border);
    border-right: 1px solid var(--pap-border);
    color: var(--pap-text);
    font-size: 14px;
    text-align: center;
    -moz-appearance: textfield;
}

.pap-qty-input::-webkit-outer-spin-button,
.pap-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pap-variation-footer {
    display: flex;
    gap: 12px;
}

.pap-variation-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s, background 0.15s;
}

.pap-variation-btn-primary {
    background: var(--pap-color);
    color: #fff;
}

.pap-variation-btn-primary:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}

.pap-variation-btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.pap-variation-btn-primary.loading {
    opacity: 0.7;
    cursor: progress;
}

.pap-variation-btn-secondary {
    background: transparent;
    color: var(--pap-text);
    border: 1px solid var(--pap-border);
}

.pap-variation-btn-secondary:hover {
    background: var(--pap-hover);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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