/* ============================================
   Design System - CSS Custom Properties
   ============================================ */
:root {
    /* Colors */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(20, 20, 30, 0.8);
    --bg-card-hover: rgba(30, 30, 45, 0.9);

    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --accent-glow: rgba(99, 102, 241, 0.4);

    --error: #ef4444;
    --success: #22c55e;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px var(--accent-glow);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

/* ============================================
   Base Styles
   ============================================ */
*,
*::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: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ============================================
   Container & Layout
   ============================================ */
.container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    position: relative;
}

/* ============================================
   Background Decoration
   ============================================ */
.background-decoration {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

.circle-1 {
    width: 600px;
    height: 600px;
    background: var(--accent-primary);
    top: -200px;
    right: -200px;
    animation-delay: 0s;
}

.circle-2 {
    width: 400px;
    height: 400px;
    background: var(--accent-secondary);
    bottom: -100px;
    left: -100px;
    animation-delay: -5s;
}

.circle-3 {
    width: 300px;
    height: 300px;
    background: #a855f7;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -30px) scale(1.05);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.95);
    }
}

/* ============================================
   Login Card
   ============================================ */
.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-lg);
}

.logo {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.logo-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-xs);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================
   Form Elements
   ============================================ */
.input-group {
    position: relative;
    margin-bottom: var(--space-lg);
}

.input-group input {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition-normal);
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.input-glow {
    position: absolute;
    inset: -2px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    opacity: 0;
    z-index: -1;
    transition: var(--transition-normal);
    filter: blur(8px);
}

.input-group input:focus~.input-glow {
    opacity: 0.5;
}

/* ============================================
   Buttons
   ============================================ */
.btn-primary {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-primary .arrow-icon {
    width: 20px;
    height: 20px;
    transition: var(--transition-normal);
}

.btn-primary:hover:not(:disabled) .arrow-icon {
    transform: translateX(4px);
}

.btn-primary.loading span {
    opacity: 0;
}

.btn-primary.loading::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid transparent;
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Error Message
   ============================================ */
.error-message {
    margin-top: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 0.875rem;
    text-align: center;
    opacity: 0;
    transform: translateY(-10px);
    transition: var(--transition-normal);
}

.error-message.show {
    opacity: 1;
    transform: translateY(0);
}

.error-message:empty {
    display: none;
}

/* ============================================
   Player Page Styles
   ============================================ */
.player-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    width: 100%;
    max-width: 500px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-lg);
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
}

.player-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn-logout {
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-normal);
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ============================================
   Time Picker Section
   ============================================ */
.time-section {
    margin-bottom: var(--space-xl);
}

.time-section label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: var(--space-sm);
}

.time-input {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition-normal);
}

.time-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

/* Fix for datetime-local input styling */
.time-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* Side-by-side date and time inputs */
.time-inputs {
    display: flex;
    gap: var(--space-sm);
}

.time-inputs .time-input {
    flex: 1;
}

/* ============================================
   Play Controls
   ============================================ */
.play-section {
    text-align: center;
}

.btn-play {
    width: 100%;
    padding: var(--space-lg);
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    transition: var(--transition-normal);
}

.btn-play:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-play:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-play svg {
    width: 28px;
    height: 28px;
}

.btn-stop {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.btn-scheduled {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* ============================================
   Now Playing Info
   ============================================ */
.now-playing {
    margin-top: var(--space-xl);
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    display: none;
}

.now-playing.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.now-playing-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.now-playing-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: blink 1s ease-in-out infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.now-playing-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--success);
}

.now-playing-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.now-playing-time {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Progress Bar */
.progress-container {
    margin-top: var(--space-md);
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width 0.5s linear;
}

/* ============================================
   Audio Files List
   ============================================ */
.audio-list {
    margin-top: var(--space-xl);
}

.audio-list-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.audio-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
    transition: var(--transition-normal);
}

.audio-item:hover {
    background: var(--bg-card-hover);
}

.audio-item.current {
    border: 1px solid var(--accent-primary);
}

.audio-item-number {
    width: 28px;
    height: 28px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.audio-item-name {
    flex: 1;
    font-size: 0.875rem;
}

.audio-item-duration {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 480px) {

    .login-card,
    .player-card {
        padding: var(--space-xl);
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .btn-play {
        font-size: 1rem;
        padding: var(--space-md);
    }
}

/* ============================================
   Two Column Layout (Player Page)
   ============================================ */
.container.two-column {
    display: flex;
    gap: var(--space-xl);
    align-items: flex-start;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-xl);
}

.container.two-column .player-card {
    flex: 0 0 500px;
}

/* ============================================
   Song List Card
   ============================================ */
.song-list-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    flex: 1;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-lg);
}

.song-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.song-list-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.song-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
}

.song-list-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.btn-goto-current {
    padding: var(--space-xs) var(--space-sm);
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-normal);
    opacity: 0.7;
}

.btn-goto-current:hover {
    opacity: 1;
    transform: translateY(-1px);
}

/* ============================================
   Song Items
   ============================================ */
.song-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
    transition: var(--transition-normal);
}

.song-item:hover {
    background: var(--bg-card-hover);
}

.song-item.hour-2 {
    border-left: 3px solid var(--accent-secondary);
}

.song-item.now-playing {
    background: rgba(99, 102, 241, 0.2);
    border: 2px solid var(--accent-primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
    animation: nowPlayingPulse 2s ease-in-out infinite;
}

@keyframes nowPlayingPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
    }

    50% {
        box-shadow: 0 0 30px rgba(99, 102, 241, 0.5);
    }
}

.song-rank {
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    flex-shrink: 0;
}

.song-rank.top-3 {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.song-info {
    flex: 1;
    min-width: 0;
}

.song-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-artist {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.song-meta {
    display: flex;
    gap: var(--space-md);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.song-meta span {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* Hour divider */
.hour-divider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin: var(--space-lg) 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.hour-divider::before,
.hour-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

/* Responsive: Stack on smaller screens */
@media (max-width: 1024px) {
    .container.two-column {
        flex-direction: column;
        align-items: stretch;
    }

    .container.two-column .player-card {
        flex: none;
        max-width: 100%;
    }

    .song-list-card {
        max-height: 50vh;
    }
}

/* ============================================
   Header Actions
   ============================================ */
.header-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.btn-power-mode {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-power-mode:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.btn-power-mode.low-power-active {
    background: rgba(34, 197, 94, 0.2);
    border-color: var(--success);
    color: var(--success);
}

/* ============================================
   Low-Power Mode
   Disables GPU-intensive effects for mobile/battery saving
   ============================================ */
body.low-power .background-decoration {
    display: none;
}

body.low-power .login-card,
body.low-power .player-card,
body.low-power .song-list-card {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg-secondary);
}

body.low-power .now-playing-dot {
    animation: none;
}

body.low-power .song-item.now-playing {
    animation: none;
    box-shadow: none;
    border-color: var(--accent-primary);
}

body.low-power .btn-play,
body.low-power .btn-login {
    box-shadow: none;
}

body.low-power .btn-play:hover,
body.low-power .btn-login:hover {
    box-shadow: none;
    transform: none;
}

body.low-power * {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
}

/* ============================================
   Audio Visualizer
   ============================================ */
.visualizer-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.visualizer-canvas.active {
    opacity: 1;
}

.btn-visualizer {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-visualizer:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.btn-visualizer.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Hide visualizer in low-power mode */
body.low-power .visualizer-canvas {
    display: none;
}

body.low-power .btn-visualizer {
    opacity: 0.5;
    pointer-events: none;
}