:root {
    --bg-color: #f0f0f0;
    --container-bg: #fff;
    --text-color: #000;
    --border-color: #000;
    --shadow-color: #888;
    --btn-bg: #eee;
    --hover-bg: #ddd;
    --bubble-color: #0044ff; /* Azul elétrico bem vivo */
    --neon-color: #00aaff; /* Neon Ciano/Azul */
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --container-bg: #2d2d2d;
    --text-color: #f0f0f0;
    --border-color: #f0f0f0;
    --shadow-color: #000;
    --btn-bg: #444;
    --hover-bg: #555;
    --bubble-color: #ff0000; /* Vermelho puro e vibrante */
    --neon-color: #ff0055; /* Neon Vermelho/Rosa */
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: "Courier New", Courier, monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    transition: background-color 0.3s, color 0.3s;
}

.theme-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--btn-bg);
    border: 2px solid var(--border-color);
    color: var(--text-color);
    padding: 10px;
    cursor: pointer;
    box-shadow: 4px 4px 0px var(--shadow-color);
    font-size: 1.2em;
    z-index: 1000;
}

.main-wrapper {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    justify-content: center;
    max-width: 900px;
    width: 90%;
    margin: 0 auto;
}

.player-container {
    flex: 1;
}

.player {
    background: var(--container-bg);
    padding: 20px;
    box-shadow: 10px 10px 0px var(--shadow-color);
    text-align: center;
}

.album-art img {
    width: 250px;
    height: 250px;
    border: 2px solid var(--border-color);
    object-fit: cover;
    background-color: #ddd;
}

.info h1 {
    font-size: 1.2em;
    margin: 15px 0 5px;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 10px 0; /* Zona de segurança maior ao redor dos botões */
    margin-bottom: 5px; /* Ajustado de 15px para compensar o padding e manter a proporção */
}

.control-btn {
    background: var(--btn-bg);
    border: 2px solid var(--border-color);
    color: var(--text-color);
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px 15px;
    box-shadow: 3px 3px 0px var(--shadow-color);
}

.control-btn:active {
    box-shadow: 0px 0px 0px;
    transform: translate(2px, 2px);
}

.playlist-container {
    flex: 1;
    background: var(--container-bg);
    padding: 20px;
    box-shadow: 10px 10px 0px var(--shadow-color);
    max-height: 450px;
    overflow-y: auto;
    /* Firefox scrollbar styles */
    scrollbar-width: thin;
    scrollbar-color: var(--btn-bg) var(--container-bg);
}

/* Custom scrollbar styles for Webkit (Chrome, Safari, Edge) */
.playlist-container::-webkit-scrollbar {
    width: 8px;
}

.playlist-container::-webkit-scrollbar-track {
    background: var(--container-bg);
}

.playlist-container::-webkit-scrollbar-thumb {
    background-color: var(--btn-bg);
    border: 2px solid var(--border-color);
}

.playlist-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--hover-bg);
}

.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.playlist-header h2 {
    font-size: 1.2em;
    margin: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.playlist-select-btn {
    background: var(--btn-bg);
    border: 2px solid var(--border-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9em;
    cursor: pointer;
    padding: 4px 10px;
    box-shadow: 3px 3px 0px var(--shadow-color);
    transition: background 0.2s, transform 0.1s;
}

.playlist-select-btn:active {
    box-shadow: 0px 0px 0px;
    transform: translate(2px, 2px);
}

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

.playlists-menu {
    background: var(--container-bg);
    border: 2px solid var(--border-color);
    margin-bottom: 15px;
    padding: 10px;
    box-shadow: 5px 5px 0px var(--shadow-color);
}

.playlists-menu.hidden {
    display: none;
}

#playlists-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.playlist-select-item {
    padding: 8px 10px;
    border-bottom: 1px dashed var(--border-color);
    cursor: pointer;
    font-size: 0.95em;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.playlist-select-item:last-child {
    border-bottom: none;
}

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

.playlist-select-item.active {
    background: var(--btn-bg);
    font-weight: bold;
    border-left: 4px solid var(--border-color);
}

#playlist-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.playlist-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    border-bottom: 1px dashed var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.playlist-info {
    display: flex;
    flex-direction: column;
}

.playlist-num {
    font-size: 0.85em;
    font-family: inherit; /* Inherits Courier New monospace style */
}

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

.playlist-item.active {
    background: var(--btn-bg);
    font-weight: bold;
    border-left: 4px solid var(--border-color);
}

.progress-container {
    width: 100%;
    margin-top: 5px; /* Ajustado de 15px para compensar o padding e manter a proporção */
    padding: 10px 0; /* Zona de segurança extra ao redor da barra de progresso */
}

/* Customização do Input Range (Barra de Reprodução) */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    --value: 0;
    background: linear-gradient(to right, 
        var(--text-color) calc(7px + (var(--value) / 100) * (100% - 14px)), 
        var(--btn-bg) calc(7px + (var(--value) / 100) * (100% - 14px))
    );
    border: 2px solid var(--border-color);
    box-sizing: border-box;
    cursor: pointer;
}

input[type="range"]:focus {
    outline: none;
}

/* Trilho - Webkit (Chrome, Safari, Edge) */
input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: transparent;
    border: none;
    box-sizing: border-box;
}

/* Marcador (Thumb) - Webkit */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 18px;
    background: var(--text-color);
    border: 2px solid var(--border-color);
    box-sizing: border-box;
    margin-top: -6px; /* Centraliza verticalmente em relação ao trilho */
    transition: background-color 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--bubble-color);
}

/* Trilho - Firefox */
input[type="range"]::-moz-range-track {
    width: 100%;
    height: 6px;
    background: transparent;
    border: none;
    box-sizing: border-box;
}

/* Marcador (Thumb) - Firefox */
input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 18px;
    background: var(--text-color);
    border: 2px solid var(--border-color);
    border-radius: 0;
    box-sizing: border-box;
    transition: background-color 0.2s;
}

input[type="range"]::-moz-range-thumb:hover {
    background: var(--bubble-color);
}

/* Informações de tempo da música */
.time-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    margin-top: 6px;
    font-family: inherit;
    color: var(--text-color);
}

/* Responsividade simples */
/* Responsividade simples e otimização para celular */
@media (max-width: 700px) {
    body {
        padding: 30px 0;
        align-items: flex-start; /* Melhora a rolagem vertical de múltiplos blocos */
    }

    .main-wrapper {
        flex-direction: column;
        align-items: center;
        gap: 30px;
        width: 90%;
        max-width: 360px; /* Mantém os dois blocos com exatamente a mesma largura */
    }

    .player-container, 
    .playlist-container {
        width: 100%;
        box-sizing: border-box;
    }

    .player {
        width: 100%;
        box-sizing: border-box;
    }

    .album-art img {
        max-width: 100%; /* Evita quebra de layout em telas muito estreitas */
    }

    .theme-btn {
        top: 10px;
        right: 10px;
        padding: 8px 12px;
        font-size: 1em;
    }

    /* Otimização de performance: substitui o filtro gooey pesado por um blur simples */
    /* Isso economiza bateria e evita travamentos em GPUs de smartphones */
    .lava-lamp {
        filter: blur(40px);
        opacity: 0.45;
    }
}

/* Estilos para botão shuffle - Ícone customizado lofi */
.shuffle-btn {
    position: relative;
    font-size: 0 !important;
    min-width: 45px;
    min-height: 45px;
    padding: 5px 12px !important;
}

.shuffle-btn::before {
    content: '⇄';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: Arial, "Segoe UI Symbol", "Segoe UI", sans-serif;
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    color: var(--text-color);
}

.shuffle-btn.active {
    background: var(--hover-bg);
}

.shuffle-btn.inactive::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom right, transparent calc(50% - 1.5px), var(--text-color) calc(50% - 1.5px), var(--text-color) calc(50% + 1.5px), transparent calc(50% + 1.5px));
    pointer-events: none;
}

/* Estilos para botão loop - dois estados */
.loop-btn {
    position: relative;
    font-size: 0 !important;
    min-width: 45px;
    min-height: 45px;
    padding: 5px 12px !important;
}

/* Estado desligado: seta para a direita */
.loop-btn::before {
    content: '>';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: Arial, "Segoe UI Symbol", "Segoe UI", sans-serif;
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
    color: var(--text-color);
    transform: translateY(-1px);
}

.loop-btn.active {
    background: var(--hover-bg);
}

/* Estado ligado: seta circular */
.loop-btn.active::before {
    content: '↻';
    font-size: 26px;
    transform: translateY(0);
}
/* Removidos estilos desnecessários do shuffle-btn */

/* Lava Lamp Background - Fluid Liquid style */
.lava-lamp {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    filter: url('#goo') drop-shadow(0 0 15px var(--neon-color)) drop-shadow(0 0 35px var(--neon-color));
    opacity: 0.55; /* Cores bem mais vivas e presentes */
    pointer-events: none;
    mix-blend-mode: multiply; /* Mesclagem perfeita no tema claro */
}

[data-theme="dark"] .lava-lamp {
    mix-blend-mode: screen; /* Brilho líquido suave no tema escuro */
}

.bubble {
    position: absolute;
    background-color: var(--bubble-color);
    border-radius: 50%;
    transition: background-color 0.5s;
    pointer-events: none;
    will-change: transform, border-radius;
}

/* Animações de deformação de bordas e movimento líquido orgânico */
@keyframes liquid-1 {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        border-radius: 42% 58% 70% 30% / 45% 45% 55% 55%;
    }
    33% {
        transform: translate(12vw, 12vh) scale(1.1) rotate(120deg);
        border-radius: 70% 30% 52% 48% / 60% 40% 60% 40%;
    }
    66% {
        transform: translate(-8vw, 20vh) scale(0.9) rotate(240deg);
        border-radius: 30% 70% 40% 60% / 50% 60% 40% 50%;
    }
    100% {
        transform: translate(0, 0) scale(1) rotate(360deg);
        border-radius: 42% 58% 70% 30% / 45% 45% 55% 55%;
    }
}

@keyframes liquid-2 {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        border-radius: 50% 50% 30% 70% / 50% 60% 40% 50%;
    }
    50% {
        transform: translate(-12vw, 15vh) scale(1.15) rotate(-180deg);
        border-radius: 30% 70% 70% 30% / 50% 30% 70% 50%;
    }
    100% {
        transform: translate(0, 0) scale(1) rotate(-360deg);
        border-radius: 50% 50% 30% 70% / 50% 60% 40% 50%;
    }
}

@keyframes liquid-3 {
    0% {
        transform: translate(0, 0) scale(1.05) rotate(0deg);
        border-radius: 60% 40% 60% 40% / 40% 60% 40% 60%;
    }
    40% {
        transform: translate(8vw, -8vh) scale(0.95) rotate(90deg);
        border-radius: 40% 60% 30% 70% / 60% 40% 60% 40%;
    }
    80% {
        transform: translate(-5vw, 12vh) scale(1.05) rotate(270deg);
        border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%;
    }
    100% {
        transform: translate(0, 0) scale(1.05) rotate(360deg);
        border-radius: 60% 40% 60% 40% / 40% 60% 40% 60%;
    }
}

@keyframes liquid-4 {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        border-radius: 40% 60% 50% 50% / 50% 40% 60% 50%;
    }
    35% {
        transform: translate(-8vw, -12vh) scale(0.9) rotate(-120deg);
        border-radius: 60% 40% 70% 30% / 30% 60% 40% 70%;
    }
    70% {
        transform: translate(12vw, 8vh) scale(1.1) rotate(120deg);
        border-radius: 50% 50% 30% 70% / 60% 50% 50% 40%;
    }
    100% {
        transform: translate(0, 0) scale(1) rotate(360deg);
        border-radius: 40% 60% 50% 50% / 50% 40% 60% 50%;
    }
}

@keyframes liquid-5 {
    0% {
        transform: translate(0, 0) scale(1.1) rotate(0deg);
        border-radius: 50% 50% 60% 40% / 40% 50% 50% 60%;
    }
    50% {
        transform: translate(8vw, 15vh) scale(0.95) rotate(180deg);
        border-radius: 70% 30% 40% 60% / 60% 40% 60% 40%;
    }
    100% {
        transform: translate(0, 0) scale(1.1) rotate(360deg);
        border-radius: 50% 50% 60% 40% / 40% 50% 50% 60%;
    }
}

/* Tamanhos menores e maior quantidade de bolhas */
.bubble:nth-child(1) {
    width: 220px;
    height: 220px;
    left: 10%;
    top: 10%;
    animation: liquid-1 25s infinite ease-in-out;
}

.bubble:nth-child(2) {
    width: 260px;
    height: 260px;
    right: 10%;
    bottom: 10%;
    animation: liquid-2 30s infinite ease-in-out;
}

.bubble:nth-child(3) {
    width: 180px;
    height: 180px;
    left: 45%;
    top: 35%;
    animation: liquid-3 22s infinite ease-in-out;
}

.bubble:nth-child(4) {
    width: 240px;
    height: 240px;
    right: 35%;
    top: 15%;
    animation: liquid-4 28s infinite ease-in-out;
}

.bubble:nth-child(5) {
    width: 200px;
    height: 200px;
    left: 20%;
    bottom: 20%;
    animation: liquid-5 24s infinite ease-in-out;
}

.bubble:nth-child(6) {
    width: 250px;
    height: 250px;
    left: 60%;
    bottom: 15%;
    animation: liquid-1 32s infinite ease-in-out alternate;
}

.bubble:nth-child(7) {
    width: 190px;
    height: 190px;
    right: 15%;
    top: 40%;
    animation: liquid-2 27s infinite ease-in-out alternate;
}

.bubble:nth-child(8) {
    width: 230px;
    height: 230px;
    left: 40%;
    bottom: 40%;
    animation: liquid-4 35s infinite ease-in-out alternate;
}

/* Cursor e Z-Index ao arrastar containers */
.player.dragging,
.playlist-container.dragging {
    z-index: 100 !important;
}

/* Impedir seleção de texto indesejada e comportamentos de arraste do navegador */
.player,
.playlist-container {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Impedir scrollbar geral na página em telas maiores, pois o player é um elemento fixo/single-page */
@media (min-width: 701px) {
    html, body {
        overflow: hidden;
    }
}

