@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
    /* DEFAULT DARK (ID: 1) */
    --bg: #121212; --surface: #1e1e1e; --border: #000000; --text-main: #e0e0e0; --text-muted: #888888;
    --primary: #ff758f; --accent: #6b8e85; --accent2: #d4a373; 
    --brutal-shadow: 4px 4px 0px #000000; --brutal-shadow-hover: 6px 6px 0px #000000;
    --brutal-border: 3px solid #000000; --spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* CUSTOMIZABLE */
    --radius: 0px;
    --primary-grad: var(--primary);
    --accent2-grad: var(--accent2);
}

[data-theme="banana"] {
    --bg: #fef2a4; --surface: #fff; --text-main: #000; --text-muted: #555;
    --primary: #f1c40f; --accent: #000; --accent2: #f1c40f;
}
[data-theme="blood"] {
    --bg: #1a0000; --surface: #2d0000; --text-main: #ff4d4d; --text-muted: #800000;
    --primary: #ff0000; --accent: #000; --accent2: #ff4d4d;
}
[data-theme="ocean"] {
    --bg: #e0f2f1; --surface: #ffffff; --text-main: #006064; --text-muted: #0097a7;
    --primary: #00bcd4; --accent: #006064; --accent2: #b2ebf2;
}
[data-theme="orange"] {
    --bg: #fff3e0; --surface: #ffffff; --text-main: #e65100; --text-muted: #ef6c00;
    --primary: #ff9800; --accent: #e65100; --accent2: #ffe0b2;
}

[data-gradients="true"] {
    --primary-grad: linear-gradient(135deg, var(--primary), #ff4d4d);
    --accent2-grad: linear-gradient(135deg, var(--accent2), var(--primary));
}

* { box-sizing: border-box; margin: 0; padding: 0; border-radius: var(--radius) !important; max-width: 100vw; }

html, body { overflow-x: hidden; }
html { font-size: 90%; }

body {
    font-family: 'Space Grotesk', sans-serif; 
    background-color: var(--bg); 
    background-image: var(--wallpaper, none);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh; padding-bottom: 140px;
    transition: background-color 0.5s ease, color 0.5s ease, border-radius 0.3s ease;
    width: 100%;
}

[data-gradients="true"] body {
    background: linear-gradient(-45deg, var(--bg), var(--surface), var(--primary), var(--accent));
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    background-attachment: fixed;
}

[data-gradients="true"] body[style*="--wallpaper: url"] {
    background: var(--bg);
    background-image: var(--wallpaper);
    background-size: cover;
    animation: none;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

a { color: inherit; text-decoration: none; transition: 0.2s var(--spring); }

/* LAYOUT */
.content { max-width: 1250px; margin: 2rem auto; padding: 0 2rem; animation: fadeIn 0.5s var(--spring); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

/* NAVBAR */
.navbar {
    user-select: none; background: var(--accent); border-bottom: var(--brutal-border);
    height: 65px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 2rem; position: sticky; top: 0; z-index: 1000;
}
.logo { font-weight: 900; font-size: 1.4rem; color: #fff !important; text-shadow: 2px 2px 0 #000; text-transform: uppercase; }
.navbar-nav { display: flex; gap: 1.2rem; margin-left: 1.5rem; }
.navbar-nav a { font-weight: 800; color: #fff; text-shadow: 1px 1px 0 #000; text-transform: uppercase; font-size: 0.9rem; }
.search-bar { background: #fff; border: var(--brutal-border); height: 38px; padding: 0 1rem; display: flex; align-items: center; flex: 0 1 350px; box-shadow: 2px 2px 0 #000; }
.search-bar input { background: transparent; border: none; outline: none; width: 100%; font-family: 'Space Grotesk'; font-weight: 700; color: #000; }

/* BUTTONS */
.brutal-btn, .square-btn, .player-btn, .theme-toggle {
    background: var(--accent2-grad); border: var(--brutal-border); box-shadow: var(--brutal-shadow);
    color: #000; font-weight: 800; text-transform: uppercase; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; transition: all 0.2s var(--spring);
}
.brutal-btn:hover, .square-btn:hover, .player-btn:hover { transform: translate(-2px, -2px); box-shadow: var(--brutal-shadow-hover); background: var(--primary-grad); color: #fff; }
.square-btn, .player-btn { width: 40px; height: 40px; padding: 0; flex-shrink: 0; }
.brutal-btn { padding: 0.5rem 1.2rem; }

/* Active states for player buttons */
.player-btn.active {
    background: var(--primary-grad) !important;
    color: #fff !important;
    box-shadow: 1px 1px 0 #000 !important;
    transform: translate(2px, 2px) !important;
}
#master-like-btn.active {
    background: var(--primary-grad) !important;
    color: #fff !important;
}

/* PLAYER */
.player {
    user-select: none; position: fixed; bottom: 0; left: 0; right: 0;
    height: 100px; background: var(--accent2-grad); border-top: var(--brutal-border);
    display: flex; align-items: center; padding: 0 2rem; z-index: 1001;
    box-shadow: 0 -4px 0 #000; color: #000;
}
.player-track-info { display: flex; align-items: center; gap: 1rem; width: 300px; flex-shrink: 0; cursor: pointer; }
.player-track-cover { width: 60px; height: 60px; border: var(--brutal-border); background: #000; overflow: hidden; flex-shrink: 0; box-shadow: 2px 2px 0 #000; }
.player-track-cover img { width: 100%; height: 100%; object-fit: cover; }
.player-track-details { display: flex; flex-direction: column; overflow: hidden; white-space: nowrap; flex: 1; min-width: 0; }
.player-track-title { font-weight: 900; font-size: 0.95rem; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; }
.player-track-artist { font-size: 0.75rem; font-weight: 700; color: rgba(0,0,0,0.6); overflow: hidden; text-overflow: ellipsis; }

#master-like-btn { 
    width: 40px !important; height: 40px !important; 
    margin-left: 0.2rem; flex-shrink: 0; 
}

.player-center { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; justify-content: center; padding: 0 1rem; }
.player-controls { display: flex; align-items: center; gap: 1.2rem; }
.player-btn-large { width: 54px !important; height: 50px !important; background: var(--primary-grad) !important; color: #fff !important; }
.player-progress-container { width: 100%; display: flex; align-items: center; gap: 0.8rem; font-family: 'JetBrains Mono'; font-weight: 800; font-size: 0.8rem; }
.progress-bar { flex: 1; height: 12px; background: #fff; border: var(--brutal-border); box-shadow: 2px 2px 0 #000; position: relative; cursor: pointer; }
.progress-filled { height: 100%; background: var(--primary-grad); border-right: 2px solid #000; position: absolute; left: 0; top: 0; }

.player-right { display: flex; align-items: center; gap: 1rem; width: 300px; flex-shrink: 0; justify-content: flex-end; }
.volume-container { display: flex; align-items: center; gap: 0.6rem; }
.volume-bar { width: 90px; height: 12px; background: #fff; border: 2px solid #000; box-shadow: 2px 2px 0 #000; cursor: pointer; position: relative; }
.volume-filled { height: 100%; background: var(--accent); border-right: 2px solid #000; position: absolute; top: 0; left: 0; }
#volume-icon-btn { width: 38px !important; height: 38px !important; box-shadow: 2px 2px 0 #000 !important; }

/* SETTINGS MODAL */
.settings-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8); z-index: 2000;
    display: none; align-items: center; justify-content: center;
}
.settings-content {
    background: var(--surface); border: var(--brutal-border); box-shadow: 10px 10px 0 #000;
    padding: 2rem; width: 100%; max-width: 500px;
}
.theme-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-top: 1.5rem;
}
.theme-option {
    padding: 1rem; border: var(--brutal-border); cursor: pointer; font-weight: 900;
    text-transform: uppercase; text-align: center; transition: 0.1s;
}
.theme-option:hover { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 #000; }
.theme-option.active { background: var(--primary-grad); color: #fff; box-shadow: 2px 2px 0 #000; }

.settings-group { margin-top: 2rem; border-top: 3px solid #000; padding-top: 1.5rem; }
.settings-label { font-weight: 900; text-transform: uppercase; display: block; margin-bottom: 1rem; font-size: 0.9rem; }

/* PROFILE HERO */
.profile-hero { border: var(--brutal-border); box-shadow: var(--brutal-shadow); background: var(--surface); margin-bottom: 3rem; overflow: hidden; display: flex; flex-direction: column; }
.profile-banner-img { width: 100%; height: 240px; object-fit: cover; border-bottom: var(--brutal-border); }
.profile-hero-content { display: flex; gap: 2rem; padding: 0 2.5rem 2rem 2.5rem; margin-top: -80px; align-items: flex-end; }
.profile-avatar { width: 180px; height: 180px; border: var(--brutal-border); box-shadow: 6px 6px 0 #000; background: #fff; overflow: hidden; flex-shrink: 0; position: relative; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-details { flex: 1; padding-bottom: 5px; }
.profile-name { font-size: 3.5rem; font-weight: 900; color: #fff; text-shadow: 2px 2px 0 var(--primary), 4px 4px 0 #000; text-transform: uppercase; line-height: 1; margin-bottom: 1rem; }
.profile-stats { display: inline-flex; gap: 1.5rem; background: #fff; color: #000; border: 3px solid #000; padding: 0.6rem 1.2rem; font-family: 'JetBrains Mono'; font-weight: 800; box-shadow: 3px 3px 0 #000; }

/* TABS */
.tabs { display: flex; gap: 1.5rem; border-bottom: 4px solid #000; margin-bottom: 2.5rem; }
.tab-link { padding: 0.8rem 1.8rem; font-weight: 900; cursor: pointer; color: var(--text-main); text-transform: uppercase; font-size: 1.1rem; transition: 0.2s var(--spring); }
.tab-link.active { background: #fff; color: #000; border: 4px solid #000; border-bottom: none; margin-bottom: -4px; transform: translateY(-4px); }

/* TRACKS & GRID */
.track-list { display: flex; flex-direction: column; gap: 1.5rem; }
.track-item { background: var(--surface); border: var(--brutal-border); box-shadow: var(--brutal-shadow); padding: 1rem; display: flex; gap: 1.5rem; transition: 0.3s var(--spring); }
.track-item:hover { transform: translate(-3px, -3px); box-shadow: var(--brutal-shadow-hover); }
.track-cover { width: 140px; height: 140px; border: var(--brutal-border); position: relative; overflow: hidden; flex-shrink: 0; }
.track-cover img { width: 100%; height: 100%; object-fit: cover; }
.track-info { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
.track-title { font-size: 1.6rem; font-weight: 900; text-transform: uppercase; color: var(--text-main); }
.track-artist { font-size: 1rem; color: var(--primary); font-weight: 800; }

.track-waveform-placeholder { height: 40px; background: rgba(128,128,128,0.1); border: 2px solid #000; position: relative; cursor: pointer; margin: 0.5rem 0; }
.placeholder-progress { position: absolute; left: 0; top: 0; height: 100%; background: var(--primary); opacity: 0.4; width: 0; }

/* SIDEBAR DISCOVERY */
.discovery-grid { display: grid; grid-template-columns: 260px 1fr 260px; gap: 2.5rem; align-items: start; }

/* IMAGES GLOBAL */
img { display: block; max-width: 100%; }

/* CUSTOM DIALOG MODALS */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85); z-index: 4000;
    display: none; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-dialog {
    background: var(--surface); border: 4px solid #000;
    box-shadow: 12px 12px 0 #000; width: 100%; max-width: 450px;
    padding: 2.5rem; animation: modalIn 0.3s var(--spring) forwards;
}
@keyframes modalIn {
    from { transform: scale(0.8) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}
.modal-title { font-weight: 900; font-size: 1.5rem; text-transform: uppercase; margin-bottom: 1.5rem; line-height: 1; }
.modal-body { font-weight: 700; margin-bottom: 2rem; color: var(--text-main); font-size: 1.1rem; }
.modal-input { 
    width: 100%; padding: 1rem; border: 3px solid #000; background: #fff; 
    font-family: 'JetBrains Mono'; font-weight: 800; margin-bottom: 2rem; outline: none;
}
.modal-footer { display: flex; gap: 1.5rem; justify-content: flex-end; }

/* TOAST NOTIFICATIONS */
.toast-container {
    position: fixed; top: 80px; right: 2rem; z-index: 3000;
    display: flex; flex-direction: column; gap: 1rem; pointer-events: none;
}
.toast {
    pointer-events: auto; background: var(--surface); border: var(--brutal-border);
    box-shadow: 6px 6px 0 #000; padding: 1rem 1.5rem; min-width: 250px;
    font-weight: 900; text-transform: uppercase; display: flex; align-items: center; gap: 1rem;
    animation: toastIn 0.4s var(--spring) forwards;
}
@keyframes toastIn {
    from { transform: translateX(120%); }
    to { transform: translateX(0); }
}
.toast.out { animation: toastOut 0.4s var(--spring) forwards; }
@keyframes toastOut {
    to { transform: translateX(120%); opacity: 0; }
}
.toast-success { border-color: var(--accent); }
.toast-error { border-color: var(--primary); }

/* BRUTAL MODAL (DIALOG) */
dialog.brutal-modal {
    background: var(--surface);
    border: 4px solid #000;
    box-shadow: 15px 15px 0 #000;
    padding: 2.5rem;
    max-width: 500px;
    width: 95%;
    color: var(--text-main);
    outline: none;
    z-index: 5000;
    
    /* Centering logic */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

dialog.brutal-modal::backdrop {
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(5px);
}

/* BRUTAL FORM */
.brutal-form .form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.brutal-form label {
    font-weight: 900;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.brutal-form input[type="text"],
.brutal-form input[type="email"],
.brutal-form input[type="password"],
.brutal-form textarea,
.brutal-form select {
    width: 100%;
    padding: 0.8rem 1rem;
    background: #fff;
    border: 3px solid #000;
    box-shadow: 4px 4px 0 #000;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    outline: none;
    color: #000;
}

.brutal-form input:focus,
.brutal-form textarea:focus {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--primary);
}

.brutal-form input[type="file"] {
    background: var(--surface);
    border: 3px dashed #000;
    padding: 1rem;
    cursor: pointer;
}

/* MINI PROFILE HOVER CARD */
.mini-profile-card {
    position: absolute;
    width: 280px;
    background: var(--surface);
    border: 4px solid #000;
    box-shadow: 10px 10px 0 #000;
    z-index: 10000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: brutalPop 0.2s var(--spring);
}

.mini-profile-banner {
    height: 80px;
    background: var(--primary);
    background-size: cover;
    background-position: center;
    border-bottom: 4px solid #000;
}

.mini-profile-content {
    padding: 1rem;
    padding-top: 0;
    margin-top: -30px;
}

.mini-profile-avatar {
    width: 60px;
    height: 60px;
    border: 3px solid #000;
    background: #fff;
    margin-bottom: 0.5rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 4px 4px 0 #000;
}

.mini-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mini-profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 1rem;
    text-align: center;
    font-family: 'JetBrains Mono';
}

.mini-stat-val { font-weight: 900; font-size: 0.9rem; }
.mini-stat-label { font-size: 0.6rem; opacity: 0.6; font-weight: 800; text-transform: uppercase; }

@keyframes brutalPop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); border-left: 2px solid #000; }
::-webkit-scrollbar-thumb { background: var(--accent); border: 2px solid #000; }

/* MOBILE BOTTOM NAV */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: #000;
    border-top: 3px solid var(--primary);
    z-index: 1002;
    padding: 0 1rem;
    align-items: center;
    justify-content: space-around;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    color: #fff;
    font-weight: 800;
    font-size: 0.65rem;
    text-transform: uppercase;
    transition: 0.2s;
}

.mobile-nav-item i { width: 20px; height: 20px; }
.mobile-nav-item:active { transform: scale(0.9); opacity: 0.7; }

.mobile-only { display: none; }

/* RESPONSIVE DESIGN */
@media (max-width: 1024px) {
    .discovery-grid { grid-template-columns: 1fr; }
    .pinned-sidebar { display: none; }
    .player-track-info { width: 200px; }
    .player-right { width: 200px; }
}

@media (max-width: 768px) {
    .mobile-only { display: flex !important; }
    html { font-size: 85%; }
    .navbar { padding: 0 1rem; height: 60px; }
    .logo-text { display: none; }
    .navbar-nav { display: none; }
    .top-profile-name { display: none; }
    .top-profile-btn { padding: 0 !important; width: 40px; height: 40px; justify-content: center; }
    .navbar-right .brutal-btn:not(.top-profile-btn) { display: none; }
    .search-bar { display: none; }
    
    .mobile-nav { display: flex; }
    
    /* Player on mobile */
    .player { 
        bottom: 70px; /* Above mobile nav */
        height: 80px; 
        padding: 0 1rem;
        background: var(--bg);
        border-top: 3px solid #000;
        box-shadow: none;
    }
    
    .player-track-info { width: 60px; } /* Only cover on small screens */
    .player-track-details { display: none; }
    .player-center { padding: 0; }
    .player-controls { gap: 0.8rem; }
    .player-btn { width: 34px; height: 34px; }
    .player-btn i { width: 14px; height: 14px; }
    .player-btn-large { width: 44px !important; height: 44px !important; }
    .player-btn-large i { width: 20px; height: 20px; }
    .player-progress-container { position: absolute; top: -6px; left: 0; right: 0; padding: 0; }
    .player-progress-container span { display: none; } /* Hide times on mini player */
    .progress-bar { border: none; height: 6px; box-shadow: none; }
    
    .player-right { display: none; }
    
    body { padding-bottom: 160px; }
    .content { padding: 0 1rem; margin: 1rem auto; }
    
    .profile-hero-content { flex-direction: column; align-items: center; text-align: center; margin-top: -60px; padding: 0 1.5rem 1.5rem; }
    .profile-avatar { width: 120px; height: 120px; }
    .profile-info { display: flex; flex-direction: column; align-items: center; width: 100%; min-width: 0; }
    .profile-info > div:first-child { justify-content: center; flex-wrap: wrap; width: 100%; min-width: 0; }
    .profile-name, .profile-username { width: 100%; font-size: 2rem !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; max-width: 100%; display: block; }
    .profile-stats { gap: 1rem; font-size: 0.7rem; justify-content: center; flex-wrap: wrap; width: 100%; margin-top: 1rem; }
    .profile-actions { justify-content: center; width: 100%; }
    .profile-actions > div { align-items: center !important; }
    
    .track-item { flex-direction: column; gap: 1rem; }
    .track-cover { width: 100%; height: auto; aspect-ratio: 1; }
    .track-title { font-size: 1.2rem; }
    
    .featured-track-card { flex-direction: column !important; padding: 1rem !important; gap: 1rem !important; box-shadow: 6px 6px 0 #000 !important; border-width: 3px !important; }
    .featured-track-card .track-cover { width: 100% !important; height: auto !important; aspect-ratio: 1; }
    .featured-track-card a { font-size: 1.8rem !important; text-align: center; }
    .featured-track-card > div:last-child { align-items: center; text-align: center; }
    .featured-track-card > div:last-child > div:nth-child(2) { justify-content: center; width: 100%; }
    .featured-track-card > div:last-child > div:last-child { justify-content: center; width: 100%; }

    #queue-panel { width: 100%; right: 0; bottom: 150px; border-right: none; border-left: none; }

    /* FULL MOBILE TAB/PAGE FIXES */
    .track-hero { flex-direction: column-reverse; padding: 1.5rem !important; gap: 1.5rem !important; min-height: auto !important; }
    .track-hero-left { gap: 1rem; }
    .track-hero-cover { margin-left: 0 !important; width: 100% !important; max-width: 300px; align-self: center; height: auto !important; aspect-ratio: 1; }
    .track-hero-title-box { align-items: center; text-align: center; }
    .track-hero-title-box .title { font-size: 2.2rem !important; }
    .track-hero-title-box > div { justify-content: center; }
    .track-actions { flex-wrap: wrap; justify-content: center; gap: 1rem !important; padding: 1rem !important; }
    .track-actions .brutal-btn { flex: 1; font-size: 0.9rem !important; padding: 0.6rem !important; min-width: 100px; justify-content: center; }
    .two-col-layout { flex-direction: column; gap: 1.5rem !important; margin-top: 1rem !important; }
    .comment-item { flex-direction: column; gap: 1rem !important; padding: 1rem !important; }
    .comment-avatar { width: 48px !important; height: 48px !important; }
    .comment-time { margin-left: 0 !important; display: block; margin-top: 0.5rem; }
    
    .tabs { flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; border-bottom: none; }
    .tab-link { flex: 1; text-align: center; padding: 0.6rem; font-size: 0.9rem; min-width: 30%; border: 4px solid transparent; border-bottom: 4px solid #000; }
    .tab-link.active { border: 4px solid #000; transform: none; margin-bottom: 0; }
    
    .studio-track-list > .brutal-card { flex-direction: column; align-items: flex-start !important; gap: 1rem !important; }
    .studio-track-list > .brutal-card > div:last-child { margin-left: 0 !important; width: 100%; justify-content: space-between; }
    
    .responsive-grid { grid-template-columns: 1fr !important; }
    .responsive-flex { flex-direction: column !important; }
}

/* MOBILE SEARCH OVERLAY STYLES */
#mobile-search-overlay .brutal-card {
    margin: 2rem auto;
    max-width: 500px;
    box-shadow: 10px 10px 0 #000;
}
#mobile-search-overlay .brutal-form input {
    font-size: 1.2rem;
    padding: 1rem;
}
