/* 
   NeonBeat - Premium K-POP App Styles
   Theme: Dark, Neon, Glassmorphism
*/

:root {
    /* Colors */
    --bg-dark: #0f0f13;
    --bg-card: #1c1c24;
    --primary: #ff0055;
    /* Neon Pink */
    --secondary: #00f2ea;
    /* Neon Cyan */
    --accent: #7000ff;
    /* Neon Purple */
    --text-main: #ffffff;
    --text-muted: #a0a0b0;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #ff0055, #7000ff);
    --gradient-glass: linear-gradient(145deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);

    /* Spacing */
    --nav-height: 70px;
    /* Increase base header height calculation to include extra padding buffer */
    --header-height: calc(75px + env(safe-area-inset-top));

    /* Effects */
    --shadow-neon: 0 0 10px rgba(255, 0, 85, 0.4);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --glass-blur: blur(12px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100dvh;
    height: 100vh;
    /* Fallback for older browsers */
    height: 100dvh;
    /* Use dvh if available to account for dynamic address bar */
    touch-action: manipulation;
    /* Prevent double-tap zoom */
}

/* Modern Scrollbar (PC) - Enhanced */
*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

*::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
    transition: background-color 0.2s;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary);
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    background: radial-gradient(circle at top right, rgba(112, 0, 255, 0.15), transparent 40%),
        radial-gradient(circle at bottom left, rgba(255, 0, 85, 0.1), transparent 40%);
}

/* Typography */
h1,
h2,
h3 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* View Layout */
.content-area {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding-bottom: calc(var(--nav-height) + 20px + env(safe-area-inset-bottom));
    /* Removed padding-top so sticky header works correctly in flow */
    padding-top: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: scale(0.98);
}

.view.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
    z-index: 10;
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Force 15px extra padding on top of safe area */
    padding: calc(env(safe-area-inset-top) + 15px) 20px 0 20px;
    z-index: 100;
}

.controls-container {
    padding: 1rem 1rem 1rem 1rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    /* Push filters down further */
    margin-top: 15px;
}

.glass-header {
    background: rgba(15, 15, 19, 0.7);
    backdrop-filter: var(--glass-blur);
    border-bottom: var(--glass-border);
}

.app-header h1 {
    font-size: 1.5rem;
    letter-spacing: -0.5px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Navigation */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
}

.glass-nav {
    background: rgba(20, 20, 25, 0.8);
    backdrop-filter: var(--glass-blur);
    border-top: var(--glass-border);
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 60px;
}

.nav-item i {
    font-size: 1.4rem;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active i {
    transform: translateY(-3px);
    text-shadow: 0 0 10px rgba(255, 0, 85, 0.5);
}

/* Sort Controls */
.sort-controls {
    display: flex;
    gap: 10px;
    padding: 0 20px 10px 20px;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.sort-controls::-webkit-scrollbar {
    display: none;
}

.filter-group,
.sort-group {
    display: flex;
    gap: 0.5rem;
}

.btn-filter,
.btn-sort {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-weight: 500;
}

.btn-filter.active,
.btn-sort.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(255, 0, 85, 0.3);
}

/* Components: Artist List */
.artist-list {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 60vh;
}

.artist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: var(--gradient-glass);
    border: var(--glass-border);
    border-radius: 16px;
}

.artist-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.artist-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid transparent;
}

.artist-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.btn-follow {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-follow.following {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 0 10px rgba(255, 0, 85, 0.3);
}

/* Components: Timeline */
.timeline-container {
    padding: 20px 20px 20px 30px;
    position: relative;
}

.timeline-container::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 40px;
    bottom: 40px;
    width: 2px;
    background: linear-gradient(to bottom, var(--primary), var(--accordion-bg, #333));
    opacity: 0.3;
}

.timeline-date-group {
    margin-bottom: 25px;
    position: relative;
}

.timeline-date-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 10px;
    padding-left: 15px;
    position: relative;
}

.timeline-date-label::before {
    content: '';
    position: absolute;
    left: -14px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background: var(--bg-dark);
    border: 2px solid var(--secondary);
    border-radius: 50%;
    z-index: 2;
}

/* Explore Grid as List */
.grid-container {
    display: flex;
    flex-direction: column;
    padding: 0 20px 20px 20px;
    gap: 15px;
}

/* Release Card - List View Style */
.release-card {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    padding: 10px;
    min-height: 80px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    margin-left: 0;
    margin-bottom: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.release-card:active {
    transform: scale(0.98);
}

/* Target the Image Wrapper Div created in JS */
.release-card>div:first-child {
    width: 60px !important;
    height: 60px !important;
    flex-shrink: 0;
    margin-right: 15px;
    margin-bottom: 0 !important;
    position: relative;
}

.card-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    aspect-ratio: 1;
}

.card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 0;
    min-width: 0;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    color: var(--text-main);
}

.card-artist {
    font-size: 0.85rem;
    color: var(--primary);
}

.release-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 600;
    color: white;
}

.badge-new {
    background: var(--primary);
    box-shadow: var(--shadow-neon);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    justify-content: center;
    align-items: flex-end;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active .modal-backdrop {
    opacity: 1;
}

/* Modal Content State Handling */
/* Modal Content State Handling - active and loading */
.modal.loading .modal-content,
.modal.active.loading .modal-content {
    opacity: 0 !important;
    transform: translateY(100%) !important;
    pointer-events: none;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    background: #1e1e24;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1001;
    position: relative;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.modal.active .modal-content {
    transform: translateY(0);
}

@media (min-width: 600px) {
    .modal {
        align-items: center;
    }

    .modal-content {
        border-radius: 20px;
        width: 90%;
    }
}

.modal-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-cover {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 12px;
    object-fit: cover;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-title {
    font-size: 1.8rem;
    margin-bottom: 5px;
    line-height: 1.2;
}

.modal-artist {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.modal-meta {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
}

.modal-meta span {
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 12px;
    border-radius: 20px;
}

/* Album Actions (Streaming Links) - Unified Horizontal Row */
.album-actions {
    display: flex;
    flex-direction: row;
    gap: 15px;
    justify-content: center;
    flex-direction: row;
    /* Horizontal row everywhere */
    gap: 15px;
    justify-content: center;
    /* Center horizontally */
    flex-wrap: wrap;
    /* Allow wrapping */
    margin-bottom: 20px;
}

/* UNIFIED LAYOUT: SINGLE COLUMN VERTICAL (MOBILE-FIRST) */
.album-detail-view {
    display: flex;
    flex-direction: column;
    /* Stack globally */
    gap: 20px;
    align-items: center;
    /* Center content */
    padding-top: 60px;
    /* Added spacing for header */
}

.album-info-side {
    width: 100%;
    text-align: center;
}

.album-tracks-side {
    width: 100%;
    max-width: 600px;
    /* Limit width on PC */
}

.btn-streaming {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    /* Fixed size circle */
    height: 48px;
    border-radius: 50%;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.1s;
    font-size: 1.2rem;
    padding: 0;
}

.btn-streaming:active {
    transform: scale(0.9);
}

.btn-streaming span {
    display: none;
    /* Hide Text Globally */
}

/* Album Cover Default */
.album-cover-large {
    width: 100%;
    height: auto;
    max-width: 200px;
    /* Reasonable size for all devices */
    margin: 0 auto 15px auto;
    display: block;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
    border-radius: 8px;
}

.album-title-large {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 5px;
}

/* REMOVED: DESKTOP SPLIT VIEW OVERRIDE */
/* Only keep minor aesthetic adjustments for larger screens if needed */
@media (min-width: 768px) {
    .album-cover-large {
        max-width: 250px;
        /* Slightly larger on PC */
    }

    .album-title-large {
        font-size: 1.8rem;
    }
}

.btn-streaming.youtube {
    background: #212121;
    color: white;
}

.btn-streaming.youtube i {
    color: #ff0000;
}

.btn-streaming.apple {
    background: #fa243c;
    color: white;
}

/* --- Track List Styling --- */
.tracklist {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.track-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    /* Optional: subtle border or background */
    /* border-bottom: 1px solid rgba(255, 255, 255, 0.05); */
}

.track-item:hover {
    background: rgba(255, 255, 255, 0.08);
    /* Hover effect */
}

.track-num {
    width: 30px;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
    margin-right: 15px;
    font-weight: 500;
}

.track-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    /* Text overflow */
}

.track-title {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

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

.track-duration {
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    margin-left: 15px;
    min-width: 40px;
    text-align: right;
}

/* --- Mobile Specific Tweaks for Tracks --- */
@media (max-width: 767px) {
    .track-item {
        padding: 10px 12px;
        /* Slightly tighter on mobile */
    }

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

.btn-streaming.spotify {
    background: #1db954;
    color: black;
}

.btn-streaming.amazon {
    background: #232f3e;
    color: white;
}

/* Make album cover smaller on mobile to save space */
.album-cover-large {
    width: 120px;
    /* Smaller */
    height: 120px;
    margin: 0 auto 15px auto;
    /* Center */
    display: block;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
    border-radius: 8px;
}

.album-title-large {
    font-size: 1.3rem;
    text-align: center;
    margin-bottom: 5px;
}

.album-artist-large {
    text-align: center;
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 10px;
}

.album-meta-large {
    justify-content: center;
    margin-bottom: 15px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state.hidden {
    display: none;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 24px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.5);
}

/* Artist Detail View Styles */
#view-artist-detail {
    z-index: 200 !important;
    /* Above bottom nav */
    background: var(--bg-dark);
}

#view-artist-detail header {
    justify-content: flex-start;
    gap: 15px;
}

#view-artist-detail h1 {
    font-size: 1.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-back {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.2rem;
    padding: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Neon Loader Overlay */
.loader-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 19, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: inherit;
}

/* Ensure containers can handle absolute overlay */
.timeline-container,
.grid-container,
.artist-list,
.modal-body {
    position: relative;
    min-height: 200px;
}

.loader-ring-wrapper {
    position: relative;
    width: 60px;
    height: 60px;
    margin-bottom: 20px;
}

/* Outer Ring */
.neon-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
    /* Base transparent */
    border-top-color: var(--primary);
    /* Pink */
    border-right-color: rgba(255, 0, 85, 0.3);
    /* Faint pink */
    box-shadow: 0 0 15px var(--primary), inset 0 0 8px var(--primary);
    animation: spin 1.5s linear infinite;
}

/* Inner Ring */
.neon-ring::before {
    content: '';
    position: absolute;
    inset: 10px;
    /* Smaller */
    border-radius: 50%;
    border: 3px solid transparent;
    border-bottom-color: var(--secondary);
    /* Cyan */
    border-left-color: rgba(0, 242, 234, 0.3);
    /* Faint cyan */
    box-shadow: 0 0 10px var(--secondary), inset 0 0 5px var(--secondary);
    animation: spin-reverse 2s linear infinite;
}

.loader-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: lowercase;
    /* Gradient Text */
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 1.1rem;
    animation: pulse 1.5s ease-in-out infinite alternate;
    text-shadow: 0 0 10px rgba(112, 0, 255, 0.5);
    /* glow behind */
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

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

    100% {
        transform: rotate(0deg);
    }
}

@keyframes pulse {
    0% {
        opacity: 0.6;
        filter: blur(0.5px);
    }

    100% {
        opacity: 1;
        filter: blur(0px);
    }
}