/* ═══════════════════════════════════════════════════════════════════════
   Pattupetti PWA Styles
   Dark theme, mobile-first music player.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --surface-light: #1f3050;
    --primary: #6c5ce7;
    --primary-glow: rgba(108, 92, 231, 0.4);
    --accent: #a29bfe;
    --text: #e8e8f0;
    --text-muted: #8892a4;
    --danger: #e74c3c;
    --success: #2ecc71;
    --radius: 12px;
    --radius-sm: 8px;
    --safe-bottom: env(safe-area-inset-bottom, 16px);
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
}

/* ── Screen Container ────────────────────────────────────────────────────── */

.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    padding: 24px 20px;
    overflow-y: auto;
}

.screen.active {
    display: flex;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.app-header {
    text-align: center;
    padding: 16px 0 32px;
}

.app-header h1 {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-header .subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card h2 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ── Select & Input ──────────────────────────────────────────────────────── */

.select-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

select {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892a4' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ── Checkbox List ───────────────────────────────────────────────────────── */

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 280px;
    overflow-y: auto;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.checkbox-item:hover {
    background: rgba(108, 92, 231, 0.1);
}

.checkbox-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-item .video-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    background: rgba(255,255,255,0.05);
    padding: 3px 8px;
    border-radius: 10px;
}

/* ── Mode Toggle ─────────────────────────────────────────────────────────── */

.mode-toggle {
    display: flex;
    background: var(--surface-light);
    border-radius: var(--radius-sm);
    padding: 4px;
    gap: 4px;
}

.mode-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px var(--primary-glow);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-small {
    width: auto;
    padding: 10px 18px;
    font-size: 14px;
}

/* ── Now Playing ─────────────────────────────────────────────────────────── */

#player-screen {
    padding: 16px;
    justify-content: space-between;
}

.now-playing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.now-playing-header .back-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
}

.now-playing-header .playlist-label {
    font-size: 13px;
    color: var(--text-muted);
}

.now-playing-header .connection-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 10px;
}

.now-playing-header .connection-status.online {
    color: var(--success);
    background: rgba(46, 204, 113, 0.1);
}

.now-playing-header .connection-status.offline {
    color: var(--danger);
    background: rgba(231, 76, 60, 0.1);
}

/* Album Art Placeholder */
.album-art {
    width: 100%;
    max-width: 300px;
    aspect-ratio: 1;
    margin: 16px auto;
    background: linear-gradient(135deg, var(--primary), #2d3436);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px var(--primary-glow);
}

.album-art .art-icon {
    font-size: 80px;
    opacity: 0.7;
}

/* Song Info */
.song-info {
    text-align: center;
    margin: 16px 0;
}

.song-info .song-title {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.song-info .song-playlist {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Progress */
.progress-container {
    margin: 8px 0 16px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--surface-light);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s linear;
    width: 0%;
}

.progress-time {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Controls */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 8px 0 16px;
}

.ctrl-btn {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.15s;
}

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

.ctrl-btn.play-btn {
    width: 72px;
    height: 72px;
    background: var(--primary);
    font-size: 32px;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.ctrl-btn.play-btn:active {
    box-shadow: 0 2px 8px var(--primary-glow);
}

.ctrl-btn.small {
    width: 44px;
    height: 44px;
    font-size: 18px;
    color: var(--text-muted);
}

/* Queue & Info Bar */
.player-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: var(--safe-bottom);
}

.queue-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    text-align: center;
}

.queue-list {
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface);
    border-radius: var(--radius-sm);
    display: none;
}

.queue-list.open {
    display: block;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 14px;
}

.queue-item.current {
    background: rgba(108, 92, 231, 0.15);
    font-weight: 600;
}

.queue-item .queue-index {
    color: var(--text-muted);
    font-size: 12px;
    width: 24px;
}

.queue-item .queue-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item .queue-cached {
    font-size: 10px;
    color: var(--success);
}

/* Cache info */
.cache-info {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    padding: 4px;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */

.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    color: var(--text);
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

/* ── Empty State ─────────────────────────────────────────────────────────── */

.empty-message {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.5;
}

.empty-message .emoji {
    font-size: 40px;
    display: block;
    margin-bottom: 12px;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (min-width: 480px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #app {
        height: 90vh;
        max-height: 850px;
        border-radius: 20px;
        overflow: hidden;
        box-shadow: 0 0 60px rgba(108, 92, 231, 0.15);
    }
}
