/* =========================================
   GLOBAL CORE & CANVAS
   ========================================= */
* {
	user-select: none;
}

/* Enable selection in text-entry fields */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="search"],
textarea {
	user-select: text;
}

body,
html {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

canvas {
	display: block;
	width: 100vw;
	height: 100vh;
}

/* =========================================
   CANVAS OVERLAYS
   ========================================= */

/* =========================================
   LAYOUT: TOP ACTION BAR
   ========================================= */
.top-actions {
	position: absolute;
	top: 20px;
	left: 20px;
	right: 20px;
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	transition: transform var(--transition-normal), opacity var(--transition-normal), visibility var(--transition-normal);
	transform: translateY(0);
	opacity: 1;
	visibility: visible;
}

.top-actions.is-inactive {
	transform: translateY(-100px);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

/* =========================================
   SIDEBAR: PLAYLIST STYLES
   ========================================= */

.playlist-float {
	position: absolute;
	top: 80px;
	left: 20px;
	width: 320px;
	max-height: calc(100vh - 250px);
	overflow: hidden; /* Contain the scrollable body */
	z-index: 10;
	border-radius: var(--radius-lg);
	display: flex;
	flex-direction: column;
	transition: transform var(--transition-normal), opacity var(--transition-normal), visibility var(--transition-normal);
	transform: translateX(0);
	opacity: 1;
	visibility: visible;
}

@media (max-width: 768px) {
	.playlist-float { width: calc(100% - 40px); max-height: 50vh; }
	.playlist-float.is-hidden,
	.playlist-float.is-inactive { transform: translateX(-110%); }
}

.playlist-float.is-hidden,
.playlist-float.is-inactive {
	transform: translateX(-360px); /* Moves it off-screen to the left (Width 320 + Left 20 + Buffer) */
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.playlist-header {
	padding: 16px;
	border-bottom: 1px solid var(--glass-border);
	font-weight: bold;
	font-size: 14px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: rgba(255, 255, 255, 0.05);
	flex-shrink: 0; /* Don't allow header to shrink */
}

.playlist-header-title {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	flex: 1;
	margin-right: 12px;
	min-width: 0; /* Essential for ellipsis in flexbox */
}

.playlist-content {
	display: flex;
	flex-direction: column;
}

.playlist-body {
	flex: 1;
	overflow-y: auto;
	padding-bottom: 8px; /* Extra space at the bottom */
}
.playlist-body.disabled {
	overflow-y: hidden;
	opacity: 0.4;
	pointer-events: none;
	filter: grayscale(0.5);
}

/* Playlist Loading Overlay */
.playlist-loader {
	position: absolute;
	top: 0; /* Positioned within .playlist-content */
	left: 0;
	width: 100%;
	height: 100%;
	display: none; /* Hidden by default */
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.1); /* Light darkening only for the list area */
	z-index: 20;
	pointer-events: none;
	color: var(--accent-primary);
	font-size: 32px;
}

.playlist-body.disabled + .playlist-loader {
	display: flex;
}

.playlist-item {
	display: flex;
	align-items: center;
	padding: 12px 16px;
	gap: 12px;
	cursor: pointer;
	transition: all var(--transition-fast);
	border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.playlist-item:hover {
	background: rgba(255, 255, 255, 0.08);
}

.playlist-item.active {
	background: rgba(255, 255, 255, 0.12);
	/*border-left: 3px solid var(--accent-primary);*/
}

.playlist-thumb {
	width: 80px;
	height: 45px;
	background: var(--bg-surface-elevated);
	border-radius: 4px;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	position: relative;
}

.playlist-thumb i {
	color: var(--text-muted);
	font-size: 16px;
}

.playlist-info {
	flex-grow: 1;
	min-width: 0;
}

.playlist-title {
	font-size: 12px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	display: block;
	margin-bottom: 2px;
}

.playlist-meta {
	font-size: 10px;
	color: var(--text-secondary);
	display: flex;
	justify-content: space-between;
}

@keyframes spin {
	from { transform: rotate(0deg); }
	to { transform: rotate(360deg); }
}
.rotate {
	animation: spin 1s linear infinite;
}

/* Custom Scrollbar for Playlist */
.playlist-body::-webkit-scrollbar {
	width: 4px;
}

.playlist-body::-webkit-scrollbar-track {
	background: transparent;
}

.playlist-body::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.2);
	border-radius: 10px;
}

.playlist-body::-webkit-scrollbar-thumb:hover {
	background: rgba(255, 255, 255, 0.4);
}

/* =========================================
   PLAYER: BOTTOM CONTROLS
   ========================================= */

.player-controls-wrapper {
	position: absolute;
	bottom: 20px;
	left: 20px;
	right: 20px;
	transition: transform var(--transition-normal), opacity var(--transition-normal), visibility var(--transition-normal);
	transform: translateY(0);
	opacity: 1;
	visibility: visible;
}

.player-controls-wrapper.is-inactive {
	transform: translateY(150px);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.player-controls-bar {
	padding: 10px 20px;
	border-radius: var(--radius-md);
}

.btn-control-primary,
.btn-control-secondary {
	backdrop-filter: none;
	box-shadow: none;
}

/* Media Control Specific States */
.btn-control-primary.active,
.btn-control-secondary.active {
	background: rgba(255, 255, 255, 0.12) !important;
	color: var(--accent-primary) !important;
	opacity: 1 !important;
}

.btn-control-primary.active:hover,
.btn-control-secondary.active:hover {
	background: rgba(255, 255, 255, 0.2) !important;
}

.btn-control-primary:disabled,
.btn-control-secondary:disabled,
.btn-control-primary.disabled,
.btn-control-secondary.disabled {
	opacity: 0.4 !important;
	background: rgba(255, 255, 255, 0.05) !important;
	border: 1px solid rgba(255, 255, 255, 0.1) !important;
	cursor: not-allowed !important;
	transform: none !important;
	box-shadow: none !important;
}
.btn-control-secondary {
	width: 32px !important;
	height: 32px !important;
}
.btn-control-secondary i {
	font-size: 16px;
}

.btn-control-primary {
	width: 48px !important;
	height: 48px !important;
}

.btn-control-primary i {
	font-size: 24px;
}

/* =========================================
   MEDIA COMPONENTS: SEEKBAR & INFO
   ========================================= */

.progress-container {
	-webkit-appearance: none;
	appearance: none;
	flex-grow: 1;
	height: 4px;
	background: linear-gradient(to right, var(--accent-primary) 0%, var(--accent-primary) var(--progress-percent, 0%), rgba(255, 255, 255, 0.2) var(--progress-percent, 0%), rgba(255, 255, 255, 0.2) 100%);
	border-radius: var(--radius-pill);
	position: relative;
	outline: none;
	cursor: pointer;
	transition: height var(--transition-fast);
}

.progress-container:hover {
	height: 8px;
}

/* Progress Disabled State */
.progress-container.disabled {
	opacity: 0.3;
	pointer-events: none;
	cursor: not-allowed;
}

.progress-container.disabled:hover {
	height: 4px; /* Prevent expansion */
}

/* Native Slider Thumb Styling (The white circle on hover) */
.progress-container::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 0;
	height: 0;
	background: #fff;
	border-radius: 50%;
	box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
	transition: width var(--transition-fast), height var(--transition-fast);
	visibility: hidden;
}

.progress-container:hover::-webkit-slider-thumb {
	width: 12px;
	height: 12px;
}

.progress-container::-moz-range-thumb {
	width: 0;
	height: 0;
	background: #fff;
	border: none;
	border-radius: 50%;
	box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
	transition: width var(--transition-fast), height var(--transition-fast);
	visibility: hidden;
}

.progress-container:hover::-moz-range-thumb {
	width: 12px;
	height: 12px;
}

/* Skip Markers */
.progress-container::before,
.progress-container::after {
	content: "";
	position: absolute;
	top: 0;
	height: 100%;
	background: rgba(0, 0, 0, 0.15);
	pointer-events: none;
	z-index: 1;
	display: none; /* Hidden by default, shown when video loads */
}

.progress-container::before { left: 0; width: var(--intro-percent, 0%); display: block; border-radius: 4px 0 0 4px; }
.progress-container::after { right: 0; width: var(--outro-percent, 0%); display: block; border-radius: 0 4px 4px 0; }

.seekbar-tooltip {
	position: absolute;
	bottom: 20px;
	left: 0;
	padding: var(--space-xs) var(--space-sm);
	background: var(--glass-bg);
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
	border: 1px solid var(--glass-border);
	color: var(--text-primary);
	border-radius: var(--radius-sm);
	font-size: var(--font-size-xs);
	font-weight: 600;
	pointer-events: none;
	z-index: var(--z-tooltip);
	
	/* Animation settings */
	opacity: 0;
	visibility: hidden;
	transform: translateX(-50%) translateY(5px);
	transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
}

.seekbar-tooltip.is-active {
	opacity: 1;
	visibility: visible;
	transform: translateX(-50%) translateY(0);
}

/* Track Info Styling */
.track-status {
	font-size: 10px;
	text-transform: uppercase;
	font-style: italic;
	color: var(--text-secondary);
	display: inline-block;
}

.preload-status {
	font-size: 10px; /* Adjusted to better match track-status */
	color: var(--text-muted); /* Color same as track-status */
	display: inline-block; /* Side by side */
	font-weight: 700;
	margin-left: 8px; /* Gap to track-status */
	margin-top: 0; /* No more vertical margins */
	margin-bottom: 0; /* No more vertical margins */
	opacity: 0.8;
}

.track-name {
	font-size: 12px;
	font-weight: bold;
	display: block;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* =========================================
   UI COMPONENTS: INPUT CLEAR BUTTON
   ========================================= */
.input-wrapper {
	position: relative;
	display: flex;
	align-items: center;
}

.input-wrapper .form-control {
	padding-right: 36px; /* Reserve space for the X button */
}

.input-clear-btn {
	position: absolute;
	right: 8px;
	background: transparent;
	border: none;
	color: var(--text-muted);
	cursor: pointer;
	padding: 4px;
	display: flex;
	align-items: center;
	z-index: 5;
}

.input-clear-btn:hover {
	color: var(--text-primary);
}

/* =========================================
   RESPONSIVE OVERRIDES
   ========================================= */
@media (max-width: 767px) {
	.top-actions { left: 10px; right: 10px; top: 10px; }

	.player-controls-wrapper { left: 10px; right: 10px; bottom: 10px; }

	.player-controls-bar { padding: 12px 15px; }

	.player-row {
		flex-direction: column !important;
		gap: 15px;
	}

	/* Reorder elements for mobile: 1. Controls, 2. Info */
	.player-row .col-controls { order: 1; }
	.player-row .col-info { order: 2; text-align: center; }
	.player-row .col-info .flex-col { align-items: center; }
	.player-row .col-utils { order: 3; justify-content: center !important; }
	.player-row .col-info .flex { justify-content: center; } /* Zentriert die Statuszeile auf Mobilgeräten */
	.track-name { font-size: 11px; white-space: normal; line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; }
	
	.btn-control-primary { width: 42px !important; height: 42px !important; }
	.btn-control-secondary { width: 36px !important; height: 36px !important; }
}
