:root {
    --bg-primary: #f0f4f8;
    --bg-secondary: rgba(255, 255, 255, 0.75);
    --text-primary: #1a202c;
    --text-secondary: #718096;
    --text-accent: #38b2ac;
    --accent-color: #38b2ac;
    --accent-gradient: linear-gradient(135deg, #38b2ac 0%, #2c7a7b 100%);
    --accent-hover: #319795;
    --success-color: #48bb78;
    --success-gradient: linear-gradient(135deg, #48bb78 0%, #2f855a 100%);
    --shadow-soft: 0 10px 30px -10px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 15px 35px -5px rgba(0, 0, 0, 0.12);
    --shadow-strong: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --border-radius: 24px;
    --border-radius-small: 16px;
    --glass-border: 1px solid rgba(255, 255, 255, 0.8);
}

* {
    margin: 0;
    box-sizing: border-box;
}

body {
    overflow-x: hidden;
    width: 100%;
    min-height: 100vh;
}

.container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Ensure children are centered even if flex fails or for fallback */
.main-grid,
.next-song-bar {
    margin-left: auto;
    margin-right: auto;
}

/* Dynamic Background */
#dynamic-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-primary);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(40px);
    transform: scale(1.2);
    z-index: -1;
    transition: background-image 1.5s ease-in-out;
    opacity: 0.6;
}

#dynamic-bg::after {
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: relative;
    z-index: 10;
    align-items: center;
}

/* Animations */
@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse-soft {
    0% {
        box-shadow: 0 0 0 0 rgba(56, 178, 172, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(56, 178, 172, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(56, 178, 172, 0);
    }
}

/* Alerts */
.alerts-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 3000;
    max-width: 340px;
}

.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-medium);
    border-left: 4px solid var(--accent-color);
    animation: slideInRight 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.alert.alert-success {
    border-left-color: var(--success-color);
}

.alert.alert-error {
    border-left-color: #e53e3e;
}

.alert-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #cbd5e0;
    margin-left: auto;
    transition: color 0.2s;
}

.alert-close:hover {
    color: var(--text-primary);
}

/* Next Song Bar */
.next-song-bar {
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-small);
    padding: 16px 24px;
    box-shadow: var(--shadow-soft);
    border: var(--glass-border);
    width: 100%;
    max-width: 900px;
    cursor: pointer;
    animation: fadeIn 1s ease-out;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.next-song-bar:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.next-song-content {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
}

.next-label {
    color: var(--text-accent);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.next-song-text {
    color: var(--text-primary);
    font-weight: 500;
}

.next-song-queue {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s;
    opacity: 0;
}

.next-song-queue[data-open="1"] {
    opacity: 1;
}

#nextSongQueueList {
    padding: 15px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* Main Player */
.main-grid {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 900px;
}

.main-player {
    background: var(--bg-secondary);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: var(--border-radius);
    padding: 50px;
    box-shadow: var(--shadow-strong);
    border: var(--glass-border);
    text-align: center;
    width: 100%;
    animation: slideUpFade 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.album-art-container {
    position: relative;
    width: 320px;
    height: 320px;
    margin: 0 auto 40px;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.album-art-container:hover {
    transform: scale(1.02) translateY(-5px);
}

.album-art {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.album-art-container:hover .play-overlay {
    opacity: 1;
}

.play-overlay i {
    font-size: 64px;
    color: white;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.song-info {
    margin-bottom: 35px;
}

.song-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.song-artist {
    font-size: 18px;
    color: var(--text-accent);
    font-weight: 600;
    margin-bottom: 6px;
}

.song-album {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.song-requester {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.5);
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
}

/* Progress Bar */
.progress-container {
    margin-bottom: 40px;
}

.progress-bar {
    height: 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    margin-bottom: 10px;
    overflow: hidden;
    cursor: pointer;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    transition: width 0.1s linear;
    width: 0%;
    box-shadow: 0 0 10px rgba(56, 178, 172, 0.5);
}

.time-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Controls */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.control-btn {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: white;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
    color: var(--accent-color);
}

.control-btn:active {
    transform: translateY(-1px);
}

#playPauseBtn {
    width: 80px;
    height: 80px;
    background: var(--accent-gradient);
    color: white;
    font-size: 28px;
    box-shadow: 0 10px 25px rgba(56, 178, 172, 0.4);
}

#playPauseBtn:hover {
    transform: scale(1.05) translateY(-4px);
    box-shadow: 0 15px 35px rgba(56, 178, 172, 0.5);
}

#playPauseBtn.playing {
    animation: pulse-soft 2s infinite;
}

.program-btn {
    width: auto;
    height: 50px;
    padding: 0 24px;
    border-radius: 25px;
    font-size: 14px;
    gap: 10px;
    font-weight: 600;
    background: white;
    color: var(--text-primary);
}

.program-btn i {
    font-size: 16px;
    color: var(--accent-color);
}

.program-btn:hover {
    background: white;
    color: var(--accent-color);
}

/* Volume */
.volume-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
}

.volume-slider {
    width: 100px;
    height: 4px;
    border-radius: 2px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    transition: transform 0.2s;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Listeners */
.listeners-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    background: rgba(255, 255, 255, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
}

.listeners-info i {
    color: var(--accent-color);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: white;
    border-radius: 24px;
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: var(--shadow-strong);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid #edf2f7;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f7fafc;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    max-height: calc(85vh - 80px);
}

/* Request Form */
.request-form-active {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.request-form-active input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    transition: border-color 0.2s;
    outline: none;
}

.request-form-active input:focus {
    border-color: var(--accent-color);
}

.request-form-active button {
    padding: 0 24px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.request-form-active button:hover {
    background: var(--accent-hover);
}

.request-result-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 12px;
    margin-bottom: 8px;
    transition: transform 0.2s;
}

.request-result-item:hover {
    transform: translateX(4px);
    background: #f1f5f9;
}

.request-result-action {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.request-result-action:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.request-result-action:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
}

/* Responsive */
@media (max-width: 768px) {
    .main-player {
        padding: 30px 20px;
    }

    .album-art-container {
        width: 260px;
        height: 260px;
        margin-bottom: 30px;
    }

    .song-title {
        font-size: 24px;
    }

    .controls {
        gap: 16px;
    }

    .control-btn {
        width: 56px;
        height: 56px;
        font-size: 20px;
    }

    #playPauseBtn {
        width: 72px;
        height: 72px;
        font-size: 24px;
    }

    .program-btn span {
        display: none;
    }

    .program-btn {
        padding: 0;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        justify-content: center;
    }

    .program-btn i {
        font-size: 20px;
        margin: 0;
    }
}