/* =====================================================
   AdiMusic – Premium Dark Theme
   ===================================================== */

/* --- Design Tokens --- */
:root {
    --bg-primary: #09090b;
    --bg-secondary: #111114;
    --bg-card: rgba(255, 255, 255, 0.025);
    --bg-card-hover: rgba(255, 255, 255, 0.055);
    --border: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.14);
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;
    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --accent-glow: rgba(139, 92, 246, 0.18);
    --success: #22c55e;
    --success-glow: rgba(34, 197, 94, 0.18);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.18);
    --pink: #ec4899;
    --pink-glow: rgba(236, 72, 153, 0.12);
    --blue: #3b82f6;
    --blue-glow: rgba(59, 130, 246, 0.12);
    --radius: 14px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Ambient background glow */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 15% 45%, rgba(139, 92, 246, 0.07), transparent),
        radial-gradient(ellipse 50% 40% at 85% 15%, rgba(236, 72, 153, 0.05), transparent),
        radial-gradient(ellipse 50% 50% at 50% 90%, rgba(59, 130, 246, 0.05), transparent);
    pointer-events: none;
    z-index: 0;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* --- Font Awesome spin slow --- */
.fa-spin-slow {
    animation: fa-spin-slow 4s linear infinite;
}

@keyframes fa-spin-slow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =====================================================
   Header
   ===================================================== */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 2rem;
    background: rgba(9, 9, 11, 0.82);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-left h1 {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--accent-light), var(--pink));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-left h1 i {
    -webkit-text-fill-color: var(--accent);
    margin-right: 0.35rem;
    font-size: 1.25rem;
}

.header-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    padding-left: 1rem;
    border-left: 1px solid var(--border);
}

.header-right {
    display: flex;
    align-items: center;
}

.user-selector {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 0.4rem 0.5rem 0.4rem 1rem;
}

.user-selector > i {
    color: var(--accent);
    font-size: 1.15rem;
}

.user-selector label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

#component-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.45rem 0.85rem;
    border-radius: 50px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    transition: all var(--transition);
    min-width: 180px;
}

#component-select:hover { border-color: var(--border-hover); }

#component-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#component-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* =====================================================
   Main Content
   ===================================================== */
main {
    position: relative;
    z-index: 1;
    max-width: 1500px;
    margin: 0 auto;
    padding: 1.5rem 2rem 4rem;
}

/* =====================================================
   Player Zone
   ===================================================== */
.player-zone {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem 1.5rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(12px);
    transition: all var(--transition-slow);
}

.player-zone.active {
    border-color: rgba(139, 92, 246, 0.35);
    box-shadow: 0 0 40px var(--accent-glow), inset 0 0 40px rgba(139, 92, 246, 0.03);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-bottom: 0.6rem;
}

.player-info i {
    color: var(--accent);
    font-size: 1.1rem;
}

.player-info span {
    font-weight: 600;
    color: var(--text-primary);
}

.player-zone:not(.active) .player-info span {
    color: var(--text-secondary);
    font-weight: 400;
}

#audio-player {
    display: none;
    width: 100%;
    height: 42px;
    border-radius: var(--radius-sm);
    outline: none;
    filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9);
}

#video-player {
    display: none;
    width: 100%;
    max-height: 420px;
    border-radius: var(--radius-sm);
    outline: none;
    background: #000;
    margin-top: 0.5rem;
}

/* =====================================================
   Tabs
   ===================================================== */
.tabs {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.tab {
    flex: 1;
    padding: 0.85rem 1.5rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    user-select: none;
}

.tab i { font-size: 1rem; }

.tab:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    color: var(--text-secondary);
}

.tab.active {
    color: var(--text-primary);
}

.tab.active[data-category="female"] {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.13), rgba(236, 72, 153, 0.04));
    border-color: rgba(236, 72, 153, 0.5);
    color: var(--pink);
    box-shadow: 0 0 25px var(--pink-glow);
}

.tab.active[data-category="male"] {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.13), rgba(59, 130, 246, 0.04));
    border-color: rgba(59, 130, 246, 0.5);
    color: var(--blue);
    box-shadow: 0 0 25px var(--blue-glow);
}

/* =====================================================
   Table
   ===================================================== */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    backdrop-filter: blur(12px);
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

/* Table Head */
thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(9, 9, 11, 0.96);
    backdrop-filter: blur(10px);
    padding: 0.8rem 0.9rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

thead th.col-component {
    text-align: center;
    min-width: 75px;
}

thead th.col-vote { text-align: center; }
thead th.col-play { text-align: center; width: 52px; }

/* Table Body */
tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.025);
    transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover {
    background: var(--bg-card-hover);
}

tbody td {
    padding: 0.65rem 0.9rem;
    font-size: 0.85rem;
    vertical-align: middle;
    white-space: nowrap;
}

/* Song title */
.song-title {
    font-weight: 500;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

.song-title .song-artist {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.8rem;
}

/* No-media placeholder */
.no-media {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* =====================================================
   Play Buttons
   ===================================================== */
.btn-play {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    transition: all var(--transition);
}

.btn-play:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent-light);
    transform: scale(1.12);
}

.btn-play.btn-mp4:hover {
    background: var(--pink-glow);
    border-color: var(--pink);
    color: var(--pink);
}

.btn-play.playing {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 16px var(--accent-glow);
    animation: pulse-play 2s ease-in-out infinite;
}

.btn-play.playing.btn-mp4 {
    background: var(--pink);
    border-color: var(--pink);
    box-shadow: 0 0 16px var(--pink-glow);
}

@keyframes pulse-play {
    0%, 100% { box-shadow: 0 0 8px var(--accent-glow); }
    50% { box-shadow: 0 0 20px var(--accent-glow); }
}

/* =====================================================
   Vote Buttons
   ===================================================== */
.vote-cell {
    display: flex;
    gap: 0.3rem;
    align-items: center;
    justify-content: center;
}

.btn-vote {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    transition: all var(--transition);
    position: relative;
}

.btn-vote:hover {
    transform: scale(1.15);
}

.btn-vote.btn-up:hover,
.btn-vote.btn-up.active {
    background: var(--success-glow);
    border-color: var(--success);
    color: var(--success);
}

.btn-vote.btn-up.active {
    box-shadow: 0 0 10px var(--success-glow);
}

.btn-vote.btn-down:hover,
.btn-vote.btn-down.active {
    background: var(--danger-glow);
    border-color: var(--danger);
    color: var(--danger);
}

.btn-vote.btn-down.active {
    box-shadow: 0 0 10px var(--danger-glow);
}

.btn-vote.btn-blank:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-hover);
    color: var(--text-secondary);
}

/* Component vote display in columns */
.component-vote {
    text-align: center;
    font-size: 0.85rem;
}

.component-vote .vote-icon-up {
    color: var(--success);
}

.component-vote .vote-icon-down {
    color: var(--danger);
}

/* No user selected prompt */
.no-user {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
    white-space: nowrap;
}

/* =====================================================
   Empty State
   ===================================================== */
.empty-state {
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
}

.empty-state p {
    font-size: 0.95rem;
}

/* =====================================================
   Animations
   ===================================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.player-zone { animation: fadeInUp 0.45s ease-out both; }
.tabs { animation: fadeInUp 0.45s ease-out 0.08s both; }
.table-container { animation: fadeInUp 0.45s ease-out 0.16s both; }

/* Row animation */
tbody tr {
    animation: fadeInUp 0.3s ease-out both;
}

/* Stagger first 20 rows */
tbody tr:nth-child(1) { animation-delay: 0.02s; }
tbody tr:nth-child(2) { animation-delay: 0.04s; }
tbody tr:nth-child(3) { animation-delay: 0.06s; }
tbody tr:nth-child(4) { animation-delay: 0.08s; }
tbody tr:nth-child(5) { animation-delay: 0.10s; }
tbody tr:nth-child(6) { animation-delay: 0.12s; }
tbody tr:nth-child(7) { animation-delay: 0.14s; }
tbody tr:nth-child(8) { animation-delay: 0.16s; }
tbody tr:nth-child(9) { animation-delay: 0.18s; }
tbody tr:nth-child(10) { animation-delay: 0.20s; }
tbody tr:nth-child(11) { animation-delay: 0.22s; }
tbody tr:nth-child(12) { animation-delay: 0.24s; }
tbody tr:nth-child(13) { animation-delay: 0.26s; }
tbody tr:nth-child(14) { animation-delay: 0.28s; }
tbody tr:nth-child(15) { animation-delay: 0.30s; }

/* Vote button click feedback */
.btn-vote:active,
.btn-play:active {
    transform: scale(0.9);
}

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 900px) {
    header {
        flex-direction: column;
        gap: 0.8rem;
        padding: 0.8rem 1rem;
    }

    .header-subtitle { display: none; }

    .user-selector {
        width: 100%;
        justify-content: center;
    }

    #component-select { flex: 1; min-width: 0; }

    main { padding: 1rem; }

    .tabs { flex-direction: column; gap: 0.4rem; }

    .song-title { max-width: 170px; }

    .table-container { overflow-x: auto; }
}

@media (max-width: 600px) {
    .user-selector label { display: none; }
    .song-title { max-width: 120px; font-size: 0.8rem; }
    thead th { font-size: 0.6rem; padding: 0.6rem 0.5rem; }
    tbody td { padding: 0.5rem 0.5rem; font-size: 0.78rem; }
    .btn-play { width: 30px; height: 30px; font-size: 0.65rem; }
    .btn-vote { width: 26px; height: 26px; font-size: 0.65rem; }
}
