/* Music Review Platform - Dark Theme v2 */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #101018;
    --bg-card: #161620;
    --bg-elevated: #1c1c2a;
    --bg-hover: #222235;
    --bg-input: #12121c;
    --bg-glass: rgba(22, 22, 32, 0.75);

    --text-primary: #eaeaf2;
    --text-secondary: #9090a8;
    --text-muted: #5a5a70;
    --text-accent: #a78bfa;

    --accent: #7c3aed;
    --accent-light: #a78bfa;
    --accent-glow: rgba(124, 58, 237, 0.3);
    --accent-subtle: rgba(124, 58, 237, 0.08);

    --success: #34d399;
    --warning: #fbbf24;
    --error: #f87171;
    --favourite: #f59e0b;

    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --border-accent: rgba(124, 58, 237, 0.3);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);
    --shadow-up: 0 -4px 20px rgba(0, 0, 0, 0.5);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    --player-height: 80px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* WebGL Canvas */
#visualiser-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.35;
}

/* ─── Layout ─── */
.app-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: calc(var(--player-height) + 8px);
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: rgba(10, 10, 15, 0.88);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-logo {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.app-logo span { color: var(--accent-light); }

.app-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-xl);
    font-size: 0.82rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.user-badge .avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
    color: white;
}

.app-main {
    flex: 1;
    padding: 28px;
    padding-bottom: calc(var(--player-height) + 24px);
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-light);
    box-shadow: var(--shadow-glow);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

/* ─── Cards ─── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition-base), box-shadow var(--transition-base), transform var(--transition-base);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.card-body { padding: 20px; }

/* ─── Project Grid ─── */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.project-card {
    cursor: pointer;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.project-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-accent);
}

.project-card .project-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.project-card .project-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.track-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--accent-subtle);
    color: var(--accent-light);
    border-radius: var(--radius-xl);
    font-size: 0.72rem;
    font-weight: 500;
}

/* ─── Section / Breadcrumb ─── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.breadcrumb a:hover { color: var(--accent-light); }
.breadcrumb .separator { color: var(--text-muted); }

/* ─── Song Groups (collapsible) ─── */
.song-group {
    margin-bottom: 4px;
}

.song-group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.song-group-header:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.song-group-header.active {
    border-color: var(--border-accent);
    background: var(--accent-subtle);
}

.song-group-chevron {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.song-group-header.expanded .song-group-chevron {
    transform: rotate(90deg);
}

.song-group-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.95rem;
}

.song-group-badge {
    font-size: 0.72rem;
    color: var(--text-muted);
    padding: 2px 8px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
}

.song-group-versions {
    overflow: hidden;
    max-height: 0;
    transition: max-height var(--transition-base);
}

.song-group-versions.open {
    max-height: 600px;
}

/* ─── Track List ─── */
.track-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.track-item {
    display: grid;
    grid-template-columns: 44px 1fr auto auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 16px 10px 32px;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.track-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.track-item.playing {
    background: var(--accent-subtle);
    border-color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
}

.track-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.track-play-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.track-info .track-title {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 1px;
}

.track-info .track-style {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.track-duration {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    text-align: center;
    min-width: 50px;
}

.track-rating {
    display: flex;
    gap: 2px;
    justify-content: center;
}

.star {
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.star.filled { color: var(--favourite); }
.star:hover { color: var(--favourite); }

.track-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.fav-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    padding: 4px;
}

.fav-btn.active { color: var(--favourite); }
.fav-btn:hover { color: var(--favourite); transform: scale(1.15); }

.comment-count-badge {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 3px;
}

/* ─── Sticky Bottom Player ─── */
.bottom-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--player-height);
    background: rgba(12, 12, 20, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--border);
    z-index: 200;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-up);
    transform: translateY(100%);
    transition: transform var(--transition-slow);
    overflow: hidden;
}

.bottom-player.visible {
    transform: translateY(0);
}

.bottom-player-progress {
    height: 3px;
    background: var(--bg-hover);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.bottom-player-progress:hover {
    height: 5px;
}

.bottom-player-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    width: 0%;
    transition: width 200ms linear;
    border-radius: 0 2px 2px 0;
}

.bottom-player-inner {
    flex: 1;
    display: grid;
    grid-template-columns: 260px 1fr 220px;
    align-items: center;
    padding: 0 24px;
    gap: 20px;
}

.bottom-player-track-info {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.bottom-play-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-glow);
    flex-shrink: 0;
}

.bottom-play-btn:hover {
    background: var(--accent-light);
    transform: scale(1.06);
}

.bottom-track-meta {
    min-width: 0;
    overflow: hidden;
}

.bottom-track-title {
    font-weight: 500;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bottom-track-version {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bottom-player-waveform {
    height: 48px;
    max-height: 48px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    pointer-events: none;
}

.bottom-player-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: flex-end;
}

.bottom-time {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.bottom-volume {
    display: flex;
    align-items: center;
    gap: 6px;
}

.volume-icon {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.volume-slider {
    -webkit-appearance: none;
    width: 80px;
    height: 4px;
    border-radius: 2px;
    background: var(--bg-hover);
    outline: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-light);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

/* ─── Main Content Area (track detail) ─── */
.track-detail-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    margin-top: 20px;
}

.track-detail-main {
    min-width: 0;
}

/* Inline waveform (in track detail area, above comments) */
.detail-waveform-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.detail-waveform-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.detail-track-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.detail-track-style {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.detail-waveform {
    position: relative;
    margin: 12px 0 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

/* Comment markers on waveform */
.comment-marker {
    position: absolute;
    bottom: 0;
    width: 2px;
    height: 100%;
    background: var(--accent-light);
    opacity: 0.5;
    pointer-events: auto;
    cursor: pointer;
    z-index: 10;
    transition: opacity var(--transition-fast);
}

.comment-marker:hover { opacity: 1; }

.comment-marker::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    width: 10px;
    height: 10px;
    background: var(--accent-light);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--accent-glow);
}

/* ─── Comments Side Panel ─── */
.comments-sidebar {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    max-height: calc(100vh - 200px);
}

.comments-sidebar-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.comment-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comment-item {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: border-color var(--transition-fast);
}

.comment-item:hover {
    border-color: var(--border-hover);
}

.comment-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-subtle), var(--accent-glow));
    color: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 600;
    flex-shrink: 0;
}

.comment-content { flex: 1; min-width: 0; }

.comment-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
    flex-wrap: wrap;
}

.comment-author {
    font-weight: 500;
    font-size: 0.8rem;
}

.comment-timestamp {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent-light);
    background: var(--accent-subtle);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.comment-timestamp:hover {
    background: var(--accent-glow);
}

.comment-time-ago {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.comment-body {
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.comment-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 4px;
    line-height: 1;
    opacity: 0;
    transition: all var(--transition-fast);
    margin-left: auto;
}

.comment-item:hover .comment-delete-btn { opacity: 1; }
.comment-delete-btn:hover { color: var(--error); }

/* Comment input */
.comment-input-area {
    padding: 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.comment-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.timestamp-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--accent-subtle);
    color: var(--accent-light);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    white-space: nowrap;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.timestamp-badge:hover {
    border-color: var(--accent);
}

.timestamp-badge.captured {
    background: var(--accent);
    color: white;
}

.comment-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.84rem;
    resize: none;
    outline: none;
    transition: border-color var(--transition-fast);
    min-height: 38px;
    max-height: 100px;
}

.comment-input:focus { border-color: var(--accent); }
.comment-input::placeholder { color: var(--text-muted); }

/* ─── Forms (login/invite) ─── */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    position: relative;
    z-index: 1;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
}

.auth-card h1 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 4px;
    text-align: center;
}

.auth-card .subtitle {
    font-size: 0.88rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 32px;
}

.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 11px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.92rem;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }

.form-error {
    font-size: 0.78rem;
    color: var(--error);
    margin-top: 8px;
    display: none;
}

.form-error.visible { display: block; }

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p { font-size: 0.92rem; margin-bottom: 20px; }

/* ─── Toast ─── */
.toast {
    position: fixed;
    bottom: calc(var(--player-height) + 16px);
    right: 24px;
    padding: 12px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.88rem;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-base);
}

.toast.visible { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }

/* ─── Spinner ─── */
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .track-detail-layout {
        grid-template-columns: 1fr;
    }

    .comments-sidebar {
        max-height: 400px;
    }

    .bottom-player-inner {
        grid-template-columns: 1fr auto;
    }

    .bottom-player-waveform {
        display: none;
    }
}

@media (max-width: 768px) {
    .app-main { padding: 16px; }

    .track-item {
        grid-template-columns: 36px 1fr auto;
        gap: 8px;
        padding: 10px 12px 10px 20px;
    }

    .track-rating { display: none; }
    .track-actions { display: none; }

    .project-grid { grid-template-columns: 1fr; }

    .bottom-player-inner {
        grid-template-columns: 1fr auto;
        padding: 0 16px;
        gap: 12px;
    }

    /* Show time on mobile but hide volume */
    .bottom-player-controls {
        display: flex;
        gap: 8px;
    }

    .volume-slider { display: none; }
    .volume-icon { display: none; }

    .bottom-player-track-info {
        justify-content: flex-start;
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .app-header { padding: 12px 16px; }
    .auth-card { padding: 28px 20px; }
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
