/**
 * Media Store — Offline Library + Download Manager (Phase 7).
 */

/* ── Manager panel (slide-out, mirrors the queue panel) ──────────────────── */
.mst-dl-panel {
	position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 100vw; z-index: 9600;
	display: flex; flex-direction: column;
	background: #16161c; color: #fff; border-left: 1px solid rgba(255,255,255,0.08);
	transform: translateX(100%); transition: transform 0.26s ease;
	box-shadow: -12px 0 40px rgba(0,0,0,0.45);
}
.mst-dl-panel.is-open { transform: translateX(0); }
.mst-dl-panel__head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 12px; }
.mst-dl-panel__title { margin: 0; font-size: 1.1rem; font-weight: 700; flex: 1; }
.mst-dl-panel__close { background: none; border: 0; color: rgba(255,255,255,0.6); cursor: pointer; padding: 6px; border-radius: 8px; }
.mst-dl-panel__close:hover { color: #fff; background: rgba(255,255,255,0.08); }

.mst-dl-panel__storage { padding: 0 18px 12px; }
.mst-dl-storage-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.12); overflow: hidden; }
.mst-dl-storage-bar span { display: block; height: 100%; background: var(--mst-accent,#5c6ef4); width: 0; transition: width 0.3s; }
.mst-dl-storage-text { margin: 8px 0 0; font-size: 0.72rem; color: rgba(255,255,255,0.55); }

.mst-dl-panel__controls { display: flex; align-items: center; gap: 12px; padding: 0 18px 12px; flex-wrap: wrap; }
.mst-dl-quality-wrap { display: inline-flex; align-items: center; gap: 8px; font-size: 0.8rem; color: rgba(255,255,255,0.7); }
.mst-dl-quality { padding: 6px 8px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: 8px; color: #fff; }
.mst-dl-panel__bulk { margin-left: auto; display: flex; gap: 6px; }

.mst-dl-panel__body { flex: 1; overflow-y: auto; padding: 6px 12px 18px; }
.mst-dl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mst-dl-empty { color: rgba(255,255,255,0.45); font-size: 0.85rem; text-align: center; padding: 24px 12px; }

.mst-dl-job { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: rgba(255,255,255,0.04); }
.mst-dl-job__cover { width: 40px; height: 40px; flex-shrink: 0; border-radius: 6px; object-fit: cover; background: rgba(255,255,255,0.08); }
.mst-dl-job__body { flex: 1; min-width: 0; }
.mst-dl-job__title { display: block; font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mst-dl-job__meta { display: block; font-size: 0.7rem; color: rgba(255,255,255,0.5); margin: 1px 0 5px; text-transform: capitalize; }
.mst-dl-job__bar { height: 3px; border-radius: 2px; background: rgba(255,255,255,0.12); overflow: hidden; }
.mst-dl-job__bar span { display: block; height: 100%; background: var(--mst-accent,#5c6ef4); width: 0; transition: width 0.2s; }
.mst-dl-job--done .mst-dl-job__bar span { background: #38c172; }
.mst-dl-job--error .mst-dl-job__bar span { background: #ff6b6b; }
.mst-dl-job__act { width: 30px; height: 30px; flex-shrink: 0; background: none; border: 0; border-radius: 50%; color: rgba(255,255,255,0.6); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.mst-dl-job__act:hover { color: #fff; background: rgba(255,255,255,0.12); }

@media (max-width: 768px) {
	.mst-dl-panel { width: 100vw; }
	@supports (padding: max(0px)) {
		.mst-dl-panel__head { padding-top: calc( 18px + env( safe-area-inset-top, 0px ) ); }
		.mst-dl-panel__body { padding-bottom: calc( 18px + env( safe-area-inset-bottom, 0px ) ); }
	}
}
@media (prefers-reduced-motion: reduce) { .mst-dl-panel { transition: none; } }

/* ── Library "Downloaded" tab ────────────────────────────────────────────── */
.mst-dl-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.mst-dl-filters { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.mst-dl-chip {
	padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 0.8rem;
	background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: rgba(255,255,255,0.75);
}
.mst-dl-chip:hover { color: #fff; }
.mst-dl-chip.is-active { background: var(--mst-accent,#5c6ef4); border-color: transparent; color: #fff; }

.mst-library-card--dl { position: relative; }
.mst-dl-play { position: absolute; right: 8px; bottom: 8px; }
.mst-dl-remove {
	margin-top: 6px; background: none; border: 0; color: #ff6b6b; cursor: pointer; font-size: 0.72rem; padding: 0;
}
.mst-dl-remove:hover { text-decoration: underline; }

/* ── Offline-cache buttons (cards / full player) ─────────────────────────── */
.mst-offline-btn.is-downloaded { color: #38c172; }
.mst-offline-btn.is-downloading { color: var(--mst-accent,#5c6ef4); animation: mst-dl-pulse 1s ease-in-out infinite; }
#mst-fp-download.is-active { border-color: #38c172; color: #fff; }
#mst-fp-download.is-active svg { color: #38c172; }
@keyframes mst-dl-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }
