@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-color: #0f172a;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --surface: #1e293b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    /* App-like feel */
}

.app-container {
    display: flex;
    height: 100vh;
    padding: 20px;
    gap: 20px;
}

/* Sections */
.player-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
    /* Fix flex overflow */
}

.explorer-section {
    flex: 0 0 350px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.explorer-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}

.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* Player Card */
.player-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.player-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.track-info {
    text-align: center;
    z-index: 1;
}

.track-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.track-folder {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-family: monospace;
}

audio {
    width: 100%;
    margin-top: 10px;
    border-radius: 8px;
}

/* Metadata Panel */
.metadata-panel {
    flex: 1;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
    overflow-y: auto;
}

.meta-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.meta-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Inputs */
input[type="text"],
textarea {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 16px;
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.4);
}

button.primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

button.primary:hover {
    background: var(--accent-hover);
}

/* Rating Stars */
.rating-stars {
    display: flex;
    gap: 8px;
    font-size: 1.5rem;
    cursor: pointer;
    flex-direction: row-reverse;
    /* Right to left */
    justify-content: flex-end;
    /* Keep them aligned left visually */
}

/* 
   Since we reversed the row, the "right" stars are actually earlier siblings in DOM if we reorder HTML?
   Wait, if we do row-reverse:
   [5] [4] [3] [2] [1]  <-- Visual
   [1] [2] [3] [4] [5]  <-- DOM
   Hovering [4] selects [4] and all subsequent siblings ([5] in DOM, which is left in Visual).
   This works perfectly for "fill right to left" if we want 5 on right?
   User said: "leftmost star is 1 star, stars should fill up to the right"
   Standard LTR flex: [1] [2] [3] [4] [5]
   Hover [3] -> 1, 2, 3 should fill.
   Legacy CSS trick: `row-reverse` makes DOM [5][4][3][2][1] appear as 1 2 3 4 5 ? No.
   
   Let's stick to standard flex-direction: row. 
   [1] [2] [3] [4] [5]
   Hover [3] -> We want [1], [2], [3] to be active.
   CSS General Sibling (`~`) selects siblings AFTER.
   So if we hover [3], we can target [4] and [5]... to be UNFILLED?
   Strategy:
   1. Set all stars to "Filled" color by default on parent hover.
   2. Set stars AFTER the hovered one to "Empty" color.
*/

.rating-stars {
    display: flex;
    gap: 8px;
    font-size: 1.5rem;
    cursor: pointer;
    /* Resetting previous flex-direction attempt */
    flex-direction: row;
}

/* visual trick: when hovering container, treat all as filled? No, easier logic: */
.rating-stars:hover .star {
    color: #fbbf24;
    /* Fill all */
}

.rating-stars .star:hover~.star {
    color: var(--text-secondary);
    /* Unfill subsequent */
}

.star {
    color: var(--text-secondary);
    transition: color 0.1s;
}

.star.active {
    color: #fbbf24;
}

/* File Tree Items */
.tree-item {
    margin-bottom: 2px;
}

.tree-label {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    transition: all 0.15s;
    font-size: 0.9rem;
}

.tree-label:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.tree-label.active {
    background: rgba(139, 92, 246, 0.2);
    color: var(--accent);
    font-weight: 500;
}

.tree-children {
    margin-left: 20px;
    border-left: 1px solid var(--glass-border);
    display: none;
}

.tree-children.open {
    display: block;
}

/* Comments */
.comments-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 12px;
    font-size: 0.9rem;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.comment-author {
    font-weight: 600;
    color: var(--accent);
}

/* Suggestions */
.suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.chip {
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    color: var(--text-primary);
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chip:hover {
    border-color: var(--glass-border);
    background: rgba(255, 255, 255, 0.15);
}

.vote-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
}

.vote-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.7rem;
    cursor: pointer;
    line-height: 1;
    padding: 2px;
}

.vote-btn:hover {
    color: var(--accent);
}

.score-display {
    font-weight: 600;
    font-size: 0.8rem;
    margin-left: auto;
    padding-left: 8px;
    color: var(--text-secondary);
}

/* Best Name Banner */
.best-name-banner {
    color: var(--accent);
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: -10px;
    margin-bottom: 20px;
}

/* Header with Top Rated */
.explorer-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-rated-toggle {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.top-rated-toggle.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Inputs */
.input-group {
    display: flex;
    gap: 10px;
}

.author-input {
    width: 30%;
    min-width: 100px;
}

/* Shuffle Button */
.shuffle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    margin-left: 10px;
}

.shuffle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--accent);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    .app-container {
        flex-direction: column;
        height: auto;
        padding: 10px;
        overflow-y: visible;
        /* Let body handle scrolling */
    }

    .player-section {
        flex: none;
        width: 100%;
        order: 1;
    }

    .player-card {
        padding: 20px;
    }

    .metadata-panel {
        max-height: 400px;
    }

    .explorer-section {
        flex: none;
        width: 100%;
        height: 500px;
        /* Give it enough space */
        max-height: 60vh;
        order: 2;
    }

    .track-title {
        font-size: 1.5rem;
    }
}