/**
 * DJ Ymmude Player - Dark Theme
 * Humanizing the bridge through shared sound
 * Colors: #131313 bg, #d4d4d4 text, #2b5ab9 blue, #cf6679 red accent
 */

:root {
    --ymmude-bg: #131313;
    --ymmude-surface: #1e1e1e;
    --ymmude-surface-light: #2a2a2a;
    --ymmude-text: #d4d4d4;
    --ymmude-text-muted: #808080;
    --ymmude-blue: #2b5ab9;
    --ymmude-blue-glow: #3d6fd6;
    --ymmude-red: #cf6679;
    --ymmude-red-glow: #e07a8d;
    --ymmude-green: #4caf50;
    --ymmude-radius: 12px;
    --ymmude-transition: all 0.3s ease;
}

/* Main Container */
.dj-ymmude-player {
    position: relative;
    background: var(--ymmude-bg);
    border: 1px solid var(--ymmude-surface-light);
    border-radius: var(--ymmude-radius);
    padding: 20px;
    max-width: 400px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--ymmude-text);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.dj-ymmude-player::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ymmude-blue), var(--ymmude-red), var(--ymmude-blue));
    background-size: 200% 100%;
    animation: border-flow 4s linear infinite;
}

@keyframes border-flow {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* Header */
.ymmude-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ymmude-live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--ymmude-red);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
    box-shadow: 0 0 8px var(--ymmude-red-glow);
}

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

.live-text {
    color: var(--ymmude-red);
    font-weight: 600;
}

.ymmude-listeners {
    color: var(--ymmude-text-muted);
}

.listener-count {
    color: var(--ymmude-blue);
    font-weight: 600;
}

/* Visualizer */
.ymmude-visualizer {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 4px;
    height: 40px;
    margin-bottom: 16px;
}

.ymmude-visualizer .bar {
    width: 6px;
    background: linear-gradient(to top, var(--ymmude-blue), var(--ymmude-blue-glow));
    border-radius: 3px;
    animation: bounce 0.8s ease-in-out infinite;
    opacity: 0.6;
}

.ymmude-visualizer .bar:nth-child(1) { height: 20%; animation-delay: 0s; }
.ymmude-visualizer .bar:nth-child(2) { height: 60%; animation-delay: 0.1s; }
.ymmude-visualizer .bar:nth-child(3) { height: 80%; animation-delay: 0.2s; }
.ymmude-visualizer .bar:nth-child(4) { height: 50%; animation-delay: 0.3s; }
.ymmude-visualizer .bar:nth-child(5) { height: 30%; animation-delay: 0.4s; }

.dj-ymmude-player.playing .ymmude-visualizer .bar {
    opacity: 1;
    animation-duration: 0.4s;
}

.dj-ymmude-player:not(.playing) .ymmude-visualizer .bar {
    animation: none;
    height: 10%;
    opacity: 0.3;
}

@keyframes bounce {
    0%, 100% { transform: scaleY(0.5); }
    50% { transform: scaleY(1); }
}

/* Track Info */
.ymmude-track-info {
    text-align: center;
    margin-bottom: 16px;
}

.track-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--ymmude-text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-artist {
    font-size: 13px;
    color: var(--ymmude-text-muted);
}

/* Progress Bar */
.ymmude-progress-container {
    margin-bottom: 16px;
}

.ymmude-progress-bar {
    height: 4px;
    background: var(--ymmude-surface-light);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.ymmude-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--ymmude-blue), var(--ymmude-blue-glow));
    border-radius: 2px;
    transition: width 1s linear;
    box-shadow: 0 0 10px var(--ymmude-blue);
}

.ymmude-time {
    display: flex;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: var(--ymmude-text-muted);
    font-variant-numeric: tabular-nums;
}

.time-current {
    color: var(--ymmude-text);
}

/* Controls */
.ymmude-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.ymmude-btn {
    background: var(--ymmude-surface);
    border: 1px solid var(--ymmude-surface-light);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--ymmude-transition);
    color: var(--ymmude-text);
    font-size: 18px;
}

.ymmude-btn:hover {
    background: var(--ymmude-surface-light);
    border-color: var(--ymmude-blue);
    transform: scale(1.05);
}

.ymmude-btn:active {
    transform: scale(0.95);
}

.ymmude-play .icon-pause {
    display: none;
}

.dj-ymmude-player.playing .ymmude-play .ymmude-icon-play {
    display: none;
}

.dj-ymmude-player.playing .ymmude-play .icon-pause {
    display: inline;
}

.ymmude-skip {
    width: 40px;
    height: 40px;
    font-size: 14px;
}

.ymmude-volume {
    display: flex;
    align-items: center;
    gap: 8px;
}

.volume-icon {
    font-size: 14px;
    opacity: 0.7;
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    background: var(--ymmude-surface-light);
    border-radius: 2px;
    outline: none;
}

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

.volume-slider::-webkit-slider-thumb:hover {
    background: var(--ymmude-blue-glow);
    transform: scale(1.2);
}

/* Next Track */
.ymmude-next-track {
    background: var(--ymmude-surface);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    font-size: 12px;
}

.next-label {
    display: block;
    color: var(--ymmude-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    font-size: 10px;
}

.next-info {
    color: var(--ymmude-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Connection Status */
.ymmude-connection {
    text-align: center;
    margin-top: 12px;
    font-size: 11px;
}

.conn-status {
    color: var(--ymmude-green);
}

.conn-status.disconnected {
    color: var(--ymmude-red);
}

.conn-status.connecting {
    color: var(--ymmude-blue);
}

/* Hidden Audio Element */
.ymmude-audio {
    display: none;
}

/* Light Theme Override */
.dj-ymmude-theme-light {
    --ymmude-bg: #f5f5f5;
    --ymmude-surface: #ffffff;
    --ymmude-surface-light: #e0e0e0;
    --ymmude-text: #212121;
    --ymmude-text-muted: #666666;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .dj-ymmude-player {
    position: relative;
        max-width: 100%;
        padding: 16px;
    }
    
    .track-title {
        font-size: 16px;
    }
}

/* Single Toggle Button - Play/Stop */
.ymmude-toggle .ymmude-icon-stop { display: none; }
.ymmude-toggle .ymmude-icon-play { display: inline; }
.dj-ymmude-player.playing .ymmude-toggle .ymmude-icon-stop { display: inline; }
.dj-ymmude-player.playing .ymmude-toggle .ymmude-icon-play { display: none; }

/* Hide old separate buttons if any */
.ymmude-play, .ymmude-stop, .ymmude-skip { display: none !important; }
.ymmude-toggle { display: inline-flex !important; }

/* FIX: Ensure single button icon display */
.ymmude-toggle { position: relative; overflow: hidden; }
.ymmude-toggle .ymmude-icon-play, .ymmude-toggle .ymmude-icon-stop { display: none; line-height: 1; }
.ymmude-toggle .ymmude-icon-play { display: inline-block; }
.dj-ymmude-player.playing .ymmude-toggle .ymmude-icon-play { display: none !important; }
.dj-ymmude-player.playing .ymmude-toggle .ymmude-icon-stop { display: inline-block !important; }

/* Popup overlay - shown when popup player is active */
.ymmude-popup-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(19, 19, 19, 0.95);
    z-index: 100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: var(--ymmude-radius, 12px);
}
.ymmude-popup-overlay-content {
    padding: 20px;
}
.popup-overlay-icon {
    font-size: 48px;
    margin-bottom: 10px;
}
.popup-overlay-text {
    color: #d4d4d4;
    margin-bottom: 15px;
    font-size: 16px;
}
.ymmude-popup-focus-btn {
    background: var(--ymmude-blue, #2b5ab9);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.ymmude-popup-focus-btn:hover {
    background: var(--ymmude-blue-glow, #3d6fd6);
}
