/* === VARIABILI E RESET === */
:root {
    --bg-color: #0a0a14;
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
    --neon-pink: #ff0076;
    --neon-purple: #590fb7;
    --neon-cyan: #00d9ff;
    --text-main: #ffffff;
    --text-sub: #9a9ab0;
}

* { box-sizing: border-box; }

body {
    background: var(--bg-color);
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(255, 0, 118, 0.18) 0%, transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(89, 15, 183, 0.18) 0%, transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(0, 217, 255, 0.05) 0%, transparent 60%);
    color: var(--text-main);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    min-height: 100vh;
    padding: 30px 20px;
    overflow-x: hidden;
}

/* === CANVAS PARTICELLE === */
#particles-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* === LOGO / HEADER === */
.logo-area {
    text-align: center;
    margin-bottom: 30px;
}
.logo-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 10px;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}
.logo-area h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(90deg, var(--neon-pink), var(--neon-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
}
.logo-area .subtitle {
    color: var(--text-sub);
    font-size: 0.9rem;
    margin-top: 4px;
    letter-spacing: 3px;
}

/* === PLAYER PRINCIPALE === */
.music-player {
    padding: 28px;
    border-radius: 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
    margin-bottom: 25px;
}

.player-top {
    display: flex;
    gap: 25px;
    align-items: center;
    flex-wrap: wrap;
}

/* === ALBUM ART / DISCO === */
.album-art {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7), inset 0 0 20px rgba(255, 255, 255, 0.03);
    border: 4px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.album-art.disc-mode {
    background: radial-gradient(circle at 35% 35%, #2d2d44, #16162a 65%, #0d0d1a 100%);
}

.album-art .disc-grooves {
    position: absolute;
    inset: 6%;
    border-radius: 50%;
    background: repeating-radial-gradient(
        circle at center,
        transparent 0px,
        transparent 3px,
        rgba(255, 255, 255, 0.04) 3px,
        rgba(255, 255, 255, 0.04) 4px
    );
    pointer-events: none;
}

.album-art .disc-label {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 38%;
    height: 38%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--neon-pink), var(--neon-purple));
    box-shadow: 0 0 25px rgba(255, 0, 118, 0.35);
    pointer-events: none;
}

.album-art .spindle-hole {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--bg-color);
    border: 2px solid rgba(255, 255, 255, 0.25);
    z-index: 6;
    pointer-events: none;
}

.album-art img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    z-index: 3;
    display: none;
}

.album-art.image-mode img {
    display: block;
}

.album-art.image-mode .disc-grooves,
.album-art.image-mode .disc-label {
    display: none;
}

@keyframes spin { 100% { transform: rotate(360deg); } }
.album-art.is-playing {
    animation: spin 8s linear infinite;
}

.album-art.is-playing.disc-mode .disc-label {
    animation: pulse-glow 2s ease-in-out infinite alternate;
}
@keyframes pulse-glow {
    0% { box-shadow: 0 0 15px rgba(255, 0, 118, 0.3); }
    100% { box-shadow: 0 0 35px rgba(255, 0, 118, 0.6), 0 0 60px rgba(89, 15, 183, 0.3); }
}

.player-info {
    flex: 1;
    min-width: 200px;
}
.player-info h2 {
    font-size: 1.6rem;
    margin: 0 0 12px 0;
    font-weight: 700;
}
.player-info .tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.tag {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(45deg, var(--neon-pink), var(--neon-purple));
    text-transform: uppercase;
}
.tag.lang {
    background: linear-gradient(45deg, var(--neon-cyan), #0077ff);
}

/* === PROGRESS BAR === */
.progress-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    margin: 20px 0 5px 0;
}
.progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--neon-pink), var(--neon-cyan));
    border-radius: 5px;
    pointer-events: none;
}
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    margin: 0;
    cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 10px var(--neon-pink);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
}
input[type="range"]:hover::-webkit-slider-thumb {
    opacity: 1; transform: scale(1.3);
}
input[type="range"]::-moz-range-thumb {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #fff;
    border: none;
    box-shadow: 0 0 10px var(--neon-pink);
    opacity: 0;
}
input[type="range"]:hover::-moz-range-thumb { opacity: 1; }

.time-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-sub);
}

/* === CONTROLLI === */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}
.control-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 44px;
    height: 44px;
    aspect-ratio: 1;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
    font-size: 1rem;
    padding: 0;
    flex-shrink: 0;
}
.control-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.08);
}
.control-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.control-btn.main {
    width: 64px;
    height: 64px;
    background: linear-gradient(45deg, var(--neon-pink), var(--neon-purple));
    border: none;
    box-shadow: 0 8px 20px rgba(255, 0, 118, 0.35);
}
.control-btn.main:hover {
    transform: scale(1.12);
    box-shadow: 0 12px 25px rgba(255, 0, 118, 0.55);
}
.control-btn.active {
    background: rgba(0, 217, 255, 0.25);
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: 0 0 12px rgba(0, 217, 255, 0.4);
}
.control-btn svg {
    width: 22px;
    height: 22px;
    display: block;
    flex-shrink: 0;
}
.control-btn.main svg {
    width: 28px;
    height: 28px;
}

/* === VOLUME === */
.volume-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    padding: 0 10px;
}
.vol-icon {
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s, opacity 0.2s;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-main);
}
.vol-icon:hover {
    transform: scale(1.2);
}
.vol-icon.muted {
    opacity: 0.4;
}
.vol-icon svg {
    width: 22px;
    height: 22px;
    display: block;
}
.volume-slider {
    position: relative !important;
    height: 5px !important;
    background: rgba(255, 255, 255, 0.12) !important;
    border-radius: 5px;
    flex: 1;
}
.volume-slider.ios-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
.vol-percent {
    font-size: 0.8rem;
    color: var(--text-sub);
    min-width: 38px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* === TOAST iOS === */
.ios-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.85rem;
    z-index: 1000;
    pointer-events: none;
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s;
    text-align: center;
    max-width: 90%;
}
.ios-toast.show {
    opacity: 1;
}

/* === VISUALIZZATORE === */
.visualizer-container {
    width: 100%;
    height: 60px;
    margin-top: 20px;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
}
#visualizer {
    width: 100%;
    height: 100%;
    display: block;
}

/* === FILTRI === */
.filters-section {
    padding: 20px 25px;
    border-radius: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    margin-bottom: 25px;
}
.filter-group { margin-bottom: 15px; }
.filter-group:last-child { margin-bottom: 0; }
.filter-label {
    font-size: 0.75rem;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
    display: block;
}
.filter-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.filter-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-sub);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 1px;
    transition: all 0.25s;
}
.filter-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.filter-btn.active {
    background: linear-gradient(45deg, var(--neon-pink), var(--neon-purple));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(255, 0, 118, 0.3);
}
.filter-btn.active.lang {
    background: linear-gradient(45deg, var(--neon-cyan), #0077ff);
    box-shadow: 0 4px 12px rgba(0, 217, 255, 0.3);
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
}
.search-input:focus {
    border-color: var(--neon-pink);
    box-shadow: 0 0 0 3px rgba(255, 0, 118, 0.15);
}
.search-input::placeholder { color: #555570; }

/* === PLAYLIST === */
.playlist-section {
    padding: 20px 25px;
    border-radius: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
}
.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}
.playlist-title {
    font-size: 0.85rem;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 2px;
}
.playlist-count {
    font-size: 0.8rem;
    color: var(--text-sub);
}
.playlist-list {
    max-height: 400px;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0;
}
.playlist-list::-webkit-scrollbar { width: 6px; }
.playlist-list::-webkit-scrollbar-track { background: transparent; }
.playlist-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 3px;
}

.playlist-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    gap: 12px;
    margin-bottom: 4px;
}
.playlist-item:hover {
    background: rgba(255, 255, 255, 0.06);
}
.playlist-item.active {
    background: linear-gradient(90deg, rgba(255, 0, 118, 0.15), rgba(89, 15, 183, 0.1));
    border-left: 3px solid var(--neon-pink);
    padding-left: 11px;
}
.playlist-item.active .track-title { color: var(--neon-pink); }
.playlist-item .track-number {
    font-size: 0.85rem;
    color: var(--text-sub);
    min-width: 24px;
    text-align: center;
}
.playlist-item .track-details { flex: 1; min-width: 0; }
.playlist-item .track-title {
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.playlist-item .track-meta {
    font-size: 0.75rem;
    color: var(--text-sub);
    display: flex;
    gap: 8px;
    margin-top: 2px;
}
.playlist-empty {
    text-align: center;
    color: var(--text-sub);
    padding: 40px 20px;
    font-style: italic;
}

/* === DEBUG BANNER === */
.debug-banner {
    max-width: 900px;
    margin: 0 auto 15px auto;
    padding: 10px 15px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.85rem;
    transition: opacity 0.6s ease, transform 0.6s ease;
    position: relative;
    z-index: 2;
}
.debug-banner.success {
    background: rgba(0, 200, 100, 0.15);
    border: 1px solid rgba(0, 200, 100, 0.4);
    color: #00c864;
}
.debug-banner.warning {
    background: rgba(255, 200, 0, 0.15);
    border: 1px solid rgba(255, 200, 0, 0.4);
    color: #ffc800;
}
.debug-banner.fade-out {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

@media (max-width: 600px) {
    .player-top { justify-content: center; text-align: center; }
    .album-art { width: 150px; height: 150px; }
    .player-info { text-align: center; }
    .tags { justify-content: center; }
    .volume-container { flex-wrap: wrap; justify-content: center; }
}