/**
 * MusicParty - Player Styles
 * Professional music player styling
 */

/* ============================================
   Player Bar
   ============================================ */
#player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--player-height);
    background:
        linear-gradient(90deg, rgba(15, 23, 42, 0.96), rgba(18, 18, 26, 0.92) 48%, rgba(24, 24, 36, 0.96)),
        rgba(18, 18, 26, 0.95);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-xl);
    z-index: var(--z-player);
}

#player-bar.player-autohide-enabled {
    transition: transform var(--transition-fast), opacity var(--transition-fast);
    will-change: transform;
}

#player-bar.player-autohide-hidden {
    transform: translateY(calc(var(--player-height) + 24px));
    opacity: 0;
    pointer-events: none;
}

/* Player Sections */
.player-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    width: 280px;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.player-cover {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
}

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

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

#player-title {
    font-size: 0.9375rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

#player-artist {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#player-genre {
    font-size: 0.6875rem;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Player Controls */
.player-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 600px;
    position: relative;
    z-index: 2;
}

.player-buttons {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
}

.player-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.125rem;
    transition: all var(--transition-fast);
}

.player-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.player-btn.active {
    color: var(--accent-primary);
}

#btn-play-pause {
    width: 44px;
    height: 44px;
    background: var(--accent-primary);
    color: white;
    font-size: 1.25rem;
}

#btn-play-pause:hover {
    background: #5558e8;
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

#btn-play-pause i {
    font-size: 1.25rem;
}

/* Progress Bar */
.player-progress-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    width: 100%;
}

.player-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 40px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.progress-wrapper {
    flex: 1;
    position: relative;
    height: 4px;
}

.progress-track {
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

#player-buffer {
    position: absolute;
    height: 100%;
    background: var(--border-light);
    border-radius: var(--radius-full);
    transition: width 0.1s linear;
}

#player-progress {
    position: absolute;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-full);
    transition: width 0.1s linear;
}

#progress-bar {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 100%;
    background: transparent;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

#progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.progress-wrapper:hover #progress-bar::-webkit-slider-thumb {
    opacity: 1;
}

#progress-bar::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-fast);
    border: none;
}

.progress-wrapper:hover #progress-bar::-moz-range-thumb {
    opacity: 1;
}

#progress-bar::-moz-range-track {
    background: transparent;
    border: none;
}

/* Volume Controls */
.player-volume {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    width: 220px;
    flex-shrink: 0;
    justify-content: flex-end;
    position: relative;
    z-index: 2;
}

#btn-volume,
#btn-volume-mute {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.125rem;
    transition: all var(--transition-fast);
}

#btn-volume:hover,
#btn-volume-mute:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.volume-control {
    position: relative;
    display: flex;
    align-items: center;
}

.volume-popover {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    width: 200px;
    padding: 12px;
    border-radius: 14px;
    background: rgba(18, 18, 26, 0.95);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

@supports not ((-webkit-backdrop-filter: blur(12px)) or (backdrop-filter: blur(12px))) {
    #player-bar,
    .volume-popover {
        background: rgba(18, 18, 26, 0.98);
    }
}

.volume-control.open .volume-popover {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.volume-popover-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    margin-bottom: 10px;
}

.volume-percent {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 44px;
    text-align: right;
}

#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: var(--radius-full);
    background: linear-gradient(to right, var(--accent-primary) 0%, var(--accent-primary) 70%, var(--bg-tertiary) 70%, var(--bg-tertiary) 100%);
    cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-primary);
    border: 2px solid rgba(18, 18, 26, 0.95);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

#volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-primary);
    border: 2px solid rgba(18, 18, 26, 0.95);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

#volume-slider::-moz-range-track {
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
}

.volume-slider-wrapper {
    width: 100px;
    position: relative;
    height: 4px;
}

.volume-track {
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 100%;
    background: transparent;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.volume-slider-wrapper:hover #volume-slider::-webkit-slider-thumb {
    opacity: 1;
}

.volume-fill {
    position: absolute;
    height: 100%;
    background: var(--accent-primary);
    border-radius: var(--radius-full);
}

/* Loading Indicator */
#player-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ============================================
   Mini Player
   ============================================ */
#mini-player {
    display: none;
    position: fixed;
    bottom: calc(var(--player-height) + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    align-items: center;
    padding: 0 var(--spacing-md);
    gap: var(--spacing-md);
    z-index: calc(var(--z-player) - 1);
    cursor: pointer;
}

.mini-cover {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}

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

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

.mini-title {
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-artist {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.mini-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.mini-controls button {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    color: var(--text-primary);
}

#mini-play-pause {
    width: 40px;
    height: 40px;
    background: var(--accent-primary);
    border-radius: 50%;
    font-size: 1rem;
}

/* ============================================
   Visualizer
   ============================================ */
.player-visualizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.36;
}

#visualizer-canvas {
    z-index: 0;
    mix-blend-mode: screen;
    filter: saturate(1.18);
}

#player-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        radial-gradient(circle at 18% 50%, rgba(34, 211, 238, 0.16), transparent 28%),
        radial-gradient(circle at 82% 46%, rgba(244, 63, 94, 0.12), transparent 30%),
        linear-gradient(180deg, rgba(2, 6, 23, 0.08), rgba(2, 6, 23, 0.54));
}

@supports not (mix-blend-mode: screen) {
    .player-visualizer {
        opacity: 0.28;
    }
}

/* ============================================
   Advanced Player Controls
   ============================================ */
.player-advanced-controls {
    display: flex;
    gap: 4px;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--border-color);
}

.player-advanced-controls .player-btn {
    width: 32px;
    height: 32px;
}

.player-advanced-controls .player-btn.active {
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

.sleep-timer-display {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: #ef4444;
    margin-left: 8px;
}

/* ============================================
   Equalizer Modal
   ============================================ */
.eq-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.eq-presets .btn {
    flex: 1;
    min-width: 60px;
    font-size: 0.8125rem;
}

.eq-bands {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.eq-band {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.eq-band label {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.eq-slider {
    -webkit-appearance: none;
    width: 40px;
    height: 100px;
    writing-mode: bt-lr;
    background: #020617;
    border-radius: var(--radius-full);
    outline: none;
}

.eq-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ef4444;
    cursor: pointer;
}

.eq-value {
    font-size: 0.625rem;
    color: var(--text-secondary);
    min-width: 20px;
    text-align: center;
}

/* ============================================
   Sleep Timer & Crossfade Options
   ============================================ */
#equalizerModal .modal-content {
    background: #111827;
    color: var(--text-primary);
    border-radius: 16px;
}

#equalizerModal .modal-header {
    border-bottom-color: #27272a;
}

#equalizerModal .modal-body {
    border-top: 1px solid #27272a;
}

#equalizerModal .eq-presets .btn {
    background: #020617;
    border-color: #27272a;
    color: #e5e7eb;
}

#equalizerModal .eq-presets .btn:hover {
    background: #111827;
    border-color: #4b5563;
}

#equalizerModal .btn-secondary {
    background: #7f1d1d;
    border-color: #b91c1c;
    color: #fee2e2;
}

#equalizerModal .btn-secondary:hover {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    border-color: #ef4444;
    color: #ffffff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

#sleepTimerModal .modal-content {
    background: #111827;
    color: var(--text-primary);
    border-radius: 16px;
}

#sleepTimerModal .modal-header {
    border-bottom-color: #27272a;
}

#sleepTimerModal .modal-body {
    border-top: 1px solid #27272a;
}

#crossfadeModal .modal-content {
    background: #111827;
    color: var(--text-primary);
    border-radius: 16px;
}

#crossfadeModal .modal-header {
    border-bottom-color: #27272a;
}

#crossfadeModal .modal-body {
    border-top: 1px solid #27272a;
}

.sleep-timer-modal-description {
    color: #fca5a5;
    font-weight: 500;
}

.crossfade-modal-description {
    color: #fca5a5;
    font-weight: 500;
}

.sleep-timer-options,
.crossfade-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.timer-option {
    padding: 12px;
    font-size: 0.875rem;
}

.timer-option.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.sleep-timer-options .timer-option,
.crossfade-options .timer-option {
    background: #7f1d1d;      /* vermelho escuro */
    border-color: #b91c1c;    /* borda vermelha */
    color: #fee2e2;           /* texto vermelho bem claro */
}

.sleep-timer-options .timer-option.active,
.crossfade-options .timer-option.active {
    background: linear-gradient(135deg, #ef4444, #b91c1c); /* vermelho em degradê */
    border-color: #ef4444;
    color: #ffffff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}

/* ============================================
   Smart Playlists Panel
   ============================================ */
.smart-playlists-panel {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: 360px;
    height: calc(100vh - var(--header-height) - var(--player-height));
    height: calc(100dvh - var(--header-height) - var(--player-height));
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    z-index: calc(var(--z-player) - 1);
    overflow-y: auto;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.panel-header h5 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-content {
    padding: var(--spacing-md);
}

.playlist-category {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    margin-bottom: 8px;
}

.playlist-category:hover {
    background: var(--bg-hover);
}

.category-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.category-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.playlist-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.playlist-actions .player-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
}

.category-icon.warmup {
    background: linear-gradient(135deg, #f97316, #eab308);
}

.category-icon.cardio {
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
}

.category-icon.motivation {
    background: linear-gradient(135deg, #eab308, #22c55e);
}

.category-icon.favorites {
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
}

.category-info h6 {
    margin: 0 0 4px 0;
    font-size: 0.9375rem;
}

.category-info p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.category-access-count {
    font-weight: 600;
    color: var(--text-secondary) !important;
}

/* Voice Control Active State */
.player-btn.listening {
    color: #ef4444;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* ============================================
   Player Expand Animation
   ============================================ */
@media (min-width: 1024px) {
    #player-bar.expanded {
        height: 300px;
        flex-wrap: wrap;
        padding: var(--spacing-xl);
    }
    
    #player-bar.expanded .player-info {
        width: 100%;
        justify-content: center;
        margin-bottom: var(--spacing-lg);
    }
    
    #player-bar.expanded .player-cover {
        width: 120px;
        height: 120px;
    }
    
    #player-bar.expanded .player-details {
        text-align: center;
    }
    
    #player-bar.expanded #player-title {
        font-size: 1.5rem;
    }
    
    #player-bar.expanded #player-artist {
        font-size: 1rem;
    }
}

/* ============================================
   Queue Page Styles
   ============================================ */
.queue-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.queue-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.queue-item:hover {
    background: var(--bg-hover);
}

.queue-item.current {
    background: rgba(99, 102, 241, 0.1);
}

.queue-item.current .queue-title {
    color: var(--accent-primary);
}

.queue-index {
    width: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.queue-index i {
    color: var(--accent-primary);
    animation: soundwave 1s ease-in-out infinite;
}

@keyframes soundwave {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.queue-cover {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}

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

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

.queue-title {
    font-size: 0.9375rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-artist {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.queue-duration {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-right: var(--spacing-md);
}

.btn-remove-queue {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    opacity: 0;
    transition: all var(--transition-fast);
}

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

.btn-remove-queue:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* ============================================
   Genre Page Styles
   ============================================ */
.genre-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
}

.genre-item {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.genre-item-bg {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.genre-item-content {
    padding: var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.genre-item-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.genre-icon-large {
    font-size: 2.5rem;
    color: white;
}

.genre-item-name {
    font-size: 1.5rem;
    color: white;
    margin-bottom: 2px;
}

.genre-item-count {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
}

.genre-item-access {
    margin: 2px 0 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.82);
}

.genre-item-actions {
    display: flex;
    gap: var(--spacing-md);
}

.genre-item-actions .btn {
    white-space: nowrap;
}

.genre-songs {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
}

.genre-song-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.genre-song-item:hover {
    background: var(--bg-hover);
}

.genre-song-cover {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}

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

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

.genre-song-title {
    font-size: 0.9375rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.genre-song-artist {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    display: block;
}

.genre-song-duration {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.btn-view-all {
    width: 100%;
    padding: var(--spacing-md);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-top: var(--spacing-sm);
    transition: all var(--transition-fast);
}

.btn-view-all:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
