/* ==========================================================================
   AM Text to Speech Reader - Frontend Styles
   ========================================================================== */

:root {
	--am-tts-accent: #6366f1;
	--am-tts-accent-hover: #4f46e5;
	--am-tts-highlight-bg: #fef08a;
	--am-tts-radius: 50px;
	--am-tts-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	--am-tts-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* Container Positioning & Layout */
.am-tts-player-container {
	font-family: var(--am-tts-font);
	box-sizing: border-box;
	z-index: 999990;
	transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.am-tts-player-container *,
.am-tts-player-container *::before,
.am-tts-player-container *::after {
	box-sizing: border-box;
}

/* Inline Content Insertion */
.am-tts-player-container.content-inline,
.am-tts-player-container.shortcode-inline {
	margin: 1.5rem 0;
	width: 100%;
	max-width: 100%;
}

/* Floating Fixed Positions */
.am-tts-player-container.floating {
	position: fixed;
	margin: 0;
}

.am-tts-player-container.floating_bottom_right {
	bottom: 24px;
	right: 24px;
}

.am-tts-player-container.floating_bottom_left {
	bottom: 24px;
	left: 24px;
}

.am-tts-player-container.floating_top_right {
	top: 24px;
	right: 24px;
}

.am-tts-player-container.floating_top_left {
	top: 24px;
	left: 24px;
}

/* Player Shell Inner */
.am-tts-player-inner {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	padding: 8px 12px 8px 8px;
	border-radius: var(--am-tts-radius);
	box-shadow: var(--am-tts-shadow);
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
	transition: all 0.3s ease;
}

/* Themes */
.am-tts-player-container.theme-glass .am-tts-player-inner {
	background: rgba(255, 255, 255, 0.85);
	border: 1px solid rgba(255, 255, 255, 0.4);
	color: #1e293b;
}

.am-tts-player-container.theme-dark .am-tts-player-inner {
	background: rgba(15, 23, 42, 0.92);
	border: 1px solid rgba(255, 255, 255, 0.1);
	color: #f8fafc;
}

.am-tts-player-container.theme-light .am-tts-player-inner {
	background: #ffffff;
	border: 1px solid #e2e8f0;
	color: #0f172a;
}

/* Main Play / Pause Trigger Button */
.am-tts-btn-main {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	background-color: var(--am-tts-accent);
	color: #ffffff !important;
	border: none;
	padding: 10px 18px;
	border-radius: var(--am-tts-radius);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	line-height: 1;
	transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
	outline: none;
	box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.am-tts-btn-main:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
	opacity: 0.95;
}

.am-tts-btn-main:active {
	transform: translateY(0);
}

.am-tts-player-container.style-compact .am-tts-btn-main {
	padding: 10px;
	border-radius: 50%;
	width: 42px;
	height: 42px;
}

.am-tts-player-container.style-compact .am-tts-btn-text {
	display: none;
}

/* Expanded Controls */
.am-tts-expanded-controls {
	display: flex;
	align-items: center;
	gap: 10px;
	animation: amTtsFadeIn 0.25s ease-out forwards;
}

@keyframes amTtsFadeIn {
	from { opacity: 0; transform: translateX(-8px); }
	to { opacity: 1; transform: translateX(0); }
}

/* Stop Button */
.am-tts-btn-stop {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: rgba(239, 68, 68, 0.12);
	color: #ef4444 !important;
	border: 1px solid rgba(239, 68, 68, 0.2);
	border-radius: 50%;
	width: 32px;
	height: 32px;
	cursor: pointer;
	transition: all 0.2s ease;
	padding: 0;
}

.am-tts-btn-stop:hover {
	background: #ef4444;
	color: #ffffff !important;
}

/* Reading Animated Waveform */
.am-tts-reading-wave {
	display: flex;
	align-items: flex-end;
	gap: 3px;
	height: 16px;
	padding: 0 4px;
}

.am-tts-reading-wave span {
	display: block;
	width: 3px;
	background-color: var(--am-tts-accent);
	border-radius: 2px;
	animation: amTtsWave 1s ease-in-out infinite alternate;
}

.am-tts-reading-wave span:nth-child(1) { height: 6px; animation-delay: 0.1s; }
.am-tts-reading-wave span:nth-child(2) { height: 14px; animation-delay: 0.3s; }
.am-tts-reading-wave span:nth-child(3) { height: 10px; animation-delay: 0.2s; }
.am-tts-reading-wave span:nth-child(4) { height: 16px; animation-delay: 0.4s; }

.am-tts-player-container:not(.is-playing):not(.is-generating) .am-tts-reading-wave span {
	animation: none;
	height: 4px;
}

/* Generating State for Waveform */
.am-tts-player-container.is-generating .am-tts-reading-wave span {
	background-color: #f59e0b;
	animation: amTtsPulseWave 0.6s ease-in-out infinite alternate;
}

@keyframes amTtsWave {
	0% { height: 4px; }
	100% { height: 16px; }
}

@keyframes amTtsPulseWave {
	0% { height: 3px; opacity: 0.4; }
	100% { height: 14px; opacity: 1; }
}

/* Progress Indicator */
.am-tts-progress-wrap {
	display: flex;
	align-items: center;
	gap: 8px;
}

.am-tts-progress-bar {
	width: 90px;
	height: 8px;
	background: rgba(148, 163, 184, 0.25);
	border-radius: 4px;
	overflow: hidden;
	position: relative;
}

.am-tts-progress-fill {
	height: 100%;
	background-color: var(--am-tts-accent);
	transition: width 0.2s ease-out;
}

/* Shimmer Progress Loading Bar during Generation */
.am-tts-player-container.is-generating .am-tts-progress-fill {
	background: linear-gradient(90deg, #f59e0b 0%, #3b82f6 50%, #f59e0b 100%);
	background-size: 200% 100%;
	animation: amTtsShimmer 1.5s infinite linear;
}

@keyframes amTtsShimmer {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

.am-tts-progress-text {
	font-size: 11px;
	font-weight: 600;
	opacity: 0.85;
	min-width: 32px;
}

/* Select Control Dropdowns */
.am-tts-control-item select {
	background: rgba(148, 163, 184, 0.15);
	color: inherit;
	border: 1px solid rgba(148, 163, 184, 0.25);
	border-radius: 12px;
	font-size: 11px;
	font-weight: 500;
	padding: 4px 8px;
	cursor: pointer;
	outline: none;
	font-family: inherit;
}

.am-tts-voice-control select {
	max-width: 110px;
	text-overflow: ellipsis;
}

/* Text Highlighting Style */
mark.am-tts-highlighted {
	background-color: var(--am-tts-highlight-bg);
	color: #000000;
	border-radius: 3px;
	padding: 2px 4px;
	box-shadow: 0 0 8px var(--am-tts-highlight-bg);
	transition: background-color 0.2s ease;
}

/* Responsive adjustments */
@media (max-width: 640px) {
	.am-tts-player-container.floating {
		left: 16px !important;
		right: 16px !important;
		bottom: 16px !important;
		top: auto !important;
	}

	.am-tts-player-inner {
		width: 100%;
		justify-content: space-between;
	}

	.am-tts-voice-control {
		display: none;
	}

	.am-tts-progress-bar {
		width: 55px;
	}
}
