/* CSS Variables & Theme Definition */
:root {
    /* Colors - Dark Theme with Neon accents */
    --bg-dark: #0f111a;
    --bg-panel: rgba(20, 24, 36, 0.45);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.5);
    
    --glass-blur: blur(16px);
    --shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-glow: 0 0 20px var(--accent-glow);
    
    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Layout */
    --player-height: 90px;
    --sidebar-width: 320px;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow: hidden; /* Prevent body scrolling, handle in specific areas */
    -webkit-font-smoothing: antialiased;
}

/* Dynamic Background Effect */
.background-effect {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at 50% 50%, #161b22 0%, var(--bg-dark) 100%);
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s infinite ease-in-out alternate;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: var(--accent-purple);
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: var(--accent-blue);
    bottom: -200px;
    right: -100px;
    animation-delay: -5s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: #ec4899;
    top: 40%;
    left: 50%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

/* Glass Panel Utility */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-glass);
}

/* Main Layout Grid */
.app-container {
    display: flex;
    height: calc(100vh - var(--player-height));
    width: 100vw;
}

/* Header / Sidebar Area (Acts as sidebar on desktop) */
.header {
    width: var(--sidebar-width);
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 24px;
    border-right: 1px solid var(--border-glass);
    border-bottom: none;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-icon {
    color: var(--accent-blue);
    width: 32px;
    height: 32px;
}

h1 {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

h1 span {
    color: var(--accent-purple);
}

/* Search Bar */
.search-container {
    position: relative;
    margin-bottom: 32px;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    width: 18px;
    height: 18px;
}

#searchInput {
    width: 100%;
    padding: 14px 14px 14px 44px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    transition: all 0.3s ease;
    outline: none;
}

#searchInput:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
    background: rgba(0, 0, 0, 0.4);
}

/* Filters */
.filter-container h3 {
    font-family: var(--font-heading);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.chip.active {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-glow);
}

/* Main Content Area */
.content-area {
    flex: 1;
    padding: 32px 40px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.content-area::-webkit-scrollbar {
    width: 8px;
}

.content-area::-webkit-scrollbar-track {
    background: transparent;
}

.content-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.content-header {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 24px;
}

.content-header h2 {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 600;
}

.badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-blue);
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text-secondary);
}

.spin {
    animation: spin 1.5s linear infinite;
    mb-4;
    width: 32px;
    height: 32px;
    margin-bottom: 16px;
}

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

/* Stations Grid */
.stations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
    padding-bottom: 40px;
}

/* Station Card */
.station-card {
    background: rgba(20, 24, 36, 0.4);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.station-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.station-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-soft);
    background: rgba(30, 35, 50, 0.5);
    border-color: rgba(255, 255, 255, 0.15);
}

.station-card:hover::before {
    opacity: 1;
}

.station-card.playing {
    border-color: var(--accent-purple);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
}

.card-top {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 1;
}

.station-img-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border-glass);
}

.station-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.station-icon {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

.station-info {
    flex: 1;
    overflow: hidden;
}

.station-info h4 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.station-info p {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.tag {
    font-size: 11px;
    padding: 3px 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    color: var(--text-secondary);
}

.play-overlay {
    position: absolute;
    right: 20px;
    top: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2;
    box-shadow: var(--shadow-glow);
}

.station-card:hover .play-overlay {
    opacity: 1;
    transform: scale(1);
}

.station-card.playing .play-overlay {
    opacity: 1;
    transform: scale(1);
    background: var(--accent-blue);
}

.play-overlay svg {
    width: 16px;
    height: 16px;
    color: white;
    margin-left: 2px; /* optical alignment for play icon */
}
.station-card.playing .play-overlay svg {
    margin-left: 0;
}

/* Player Bar Bottom */
.player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: var(--player-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    border-top: 1px solid var(--border-glass);
    border-left: none;
    border-right: none;
    border-bottom: none;
    z-index: 100;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 300px;
}

.station-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.station-icon-wrapper img {
    width: 100%; height: 100%; object-fit: cover;
}

.station-details h4 {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.station-details p {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    transition: all 0.2s ease;
}

.control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.play-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

.play-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(139, 92, 246, 0.6);
}

.play-btn svg {
    width: 24px;
    height: 24px;
    margin-left: 2px; /* Optical alignment */
}

.play-btn.playing svg {
    margin-left: 0;
}

.player-volume {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 200px;
    justify-content: flex-end;
}

.player-volume svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

input[type=range] {
    -webkit-appearance: none;
    width: 100px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

/* Toast Notification (Optional for stream errors) */
.toast {
    position: fixed;
    bottom: calc(var(--player-height) + 20px);
    right: 40px;
    background: rgba(220, 38, 38, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }
    
    .header {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
        padding: 20px;
    }
    
    .logo {
        margin-bottom: 20px;
    }
    
    .search-container {
        margin-bottom: 20px;
    }
    
    .player-info {
        width: 150px;
    }
    
    .player-volume {
        display: none; /* Hide volume on smaller screens */
    }
    
    .content-area {
        padding: 20px;
    }
}
