/**
 * Hason TTS WP Styles
 *
 * @package Hason_TTS_WP
 */

/* CSS Variables */
:root {
	--hsv-tts-color: #0073aa;
	--hsv-tts-custom-size: 14px;
}

/* Player Container */
.hsv-tts-player {
	display: flex;
	align-items: center;
	margin: 10px 0;
	width: 100%;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Button Base */
.hsv-tts-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	transition: all 0.2s ease;
	background-color: var(--hsv-tts-color);
	color: #fff;
}

.hsv-tts-btn:hover {
	opacity: 0.9;
	transform: translateY(-1px);
}

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

.hsv-tts-btn:focus {
	outline: 2px solid var(--hsv-tts-color);
	outline-offset: 2px;
}

/* Size Variations */
.hsv-tts-size-small .hsv-tts-btn {
	padding: 6px 12px;
	font-size: 12px;
}

.hsv-tts-size-medium .hsv-tts-btn {
	padding: 8px 16px;
	font-size: 14px;
}

.hsv-tts-size-large .hsv-tts-btn {
	padding: 12px 24px;
	font-size: 16px;
}

.hsv-tts-size-custom .hsv-tts-btn {
	padding: 8px 16px;
	font-size: var(--hsv-tts-custom-size);
}

/* Icon Only Style */
.hsv-tts-style-icon_only .hsv-tts-btn {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	padding: 0;
}

.hsv-tts-size-small.hsv-tts-style-icon_only .hsv-tts-btn {
	width: 32px;
	height: 32px;
}

.hsv-tts-size-large.hsv-tts-style-icon_only .hsv-tts-btn {
	width: 48px;
	height: 48px;
}

/* Icons */
.hsv-tts-icon {
	display: inline-block;
	width: 16px;
	height: 16px;
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
}

.hsv-tts-icon-play {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
}

.hsv-tts-icon-pause {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'/%3E%3C/svg%3E");
}

.hsv-tts-icon-stop {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M6 6h12v12H6z'/%3E%3C/svg%3E");
}

/* Loading Spinner */
.hsv-tts-loading {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-top-color: #fff;
	border-radius: 50%;
	animation: hsv-spin 0.8s linear infinite;
}

@keyframes hsv-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Full Player Base Style */
.hsv-tts-full-player {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 10px;
	padding: 10px 14px;
	border-radius: 12px;
	width: 100%;
	position: relative;
	box-sizing: border-box;
	flex-wrap: wrap;
	overflow: visible;
}

/* Dark Theme (default) */
.hsv-tts-bg-dark .hsv-tts-full-player {
	background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Light Theme */
.hsv-tts-bg-light .hsv-tts-full-player {
	background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* Play Button - Clean Circle Design */
.hsv-tts-full-player .hsv-tts-play {
	flex-shrink: 0;
	width: 36px;
	height: 36px;
	min-width: 36px;
	min-height: 36px;
	border-radius: 50%;
	padding: 0;
	background: var(--hsv-tts-color);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	transition: all 0.2s ease;
	position: relative;
	border: none;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	vertical-align: middle;
}

.hsv-tts-full-player .hsv-tts-play:hover {
	transform: scale(1.08);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.hsv-tts-full-player .hsv-tts-play:active {
	transform: scale(0.95);
}

.hsv-tts-full-player .hsv-tts-play .hsv-tts-icon {
	width: 14px;
	height: 14px;
}

/* Audio Wave Animation */
.hsv-tts-wave {
	display: flex;
	align-items: center;
	gap: 3px;
	height: 16px;
	padding: 0 6px;
}

.hsv-tts-wave-bar {
	width: 3px;
	height: 6px;
	background: var(--hsv-tts-color);
	border-radius: 2px;
	opacity: 0.4;
	transition: all 0.2s ease;
}

.hsv-tts-player.is-playing .hsv-tts-wave-bar {
	animation: hsv-wave 0.5s ease-in-out infinite;
	opacity: 1;
}

.hsv-tts-wave-bar:nth-child(1) { animation-delay: 0s; }
.hsv-tts-wave-bar:nth-child(2) { animation-delay: 0.1s; }
.hsv-tts-wave-bar:nth-child(3) { animation-delay: 0.2s; }
.hsv-tts-wave-bar:nth-child(4) { animation-delay: 0.1s; }
.hsv-tts-wave-bar:nth-child(5) { animation-delay: 0s; }

@keyframes hsv-wave {
	0%, 100% { height: 6px; opacity: 0.6; }
	50% { height: 14px; opacity: 1; }
}

/* Progress Bar */
.hsv-tts-progress {
	flex: 1;
	height: 4px;
	border-radius: 100px;
	cursor: pointer;
	position: relative;
	overflow: visible;
	min-width: 80px;
}

.hsv-tts-bg-dark .hsv-tts-progress { background: rgba(255, 255, 255, 0.15); }
.hsv-tts-bg-light .hsv-tts-progress { background: #e5e7eb; }

.hsv-tts-progress-bar {
	height: 100%;
	background: var(--hsv-tts-color);
	width: 0;
	transition: width 0.1s linear;
	border-radius: inherit;
	position: relative;
}

/* Progress handle */
.hsv-tts-progress-bar::after {
	content: '';
	position: absolute;
	right: -4px;
	top: 50%;
	transform: translateY(-50%) scale(0);
	width: 10px;
	height: 10px;
	background: #fff;
	border: 2px solid var(--hsv-tts-color);
	border-radius: 50%;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
	transition: transform 0.2s ease;
}

.hsv-tts-player:hover .hsv-tts-progress-bar::after,
.hsv-tts-player.is-playing .hsv-tts-progress-bar::after {
	transform: translateY(-50%) scale(1);
}

/* Time Display */
.hsv-tts-time {
	flex-shrink: 0;
	font-size: 11px;
	font-weight: 500;
	min-width: 32px;
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.hsv-tts-bg-dark .hsv-tts-time { color: rgba(255, 255, 255, 0.7); }
.hsv-tts-bg-light .hsv-tts-time { color: #6b7280; }

/* Speed Control */
.hsv-tts-speed-control {
	position: relative;
	flex-shrink: 0;
}

.hsv-tts-speed-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 3px;
	min-width: 36px;
	height: 24px;
	padding: 0 8px;
	border-radius: 100px;
	cursor: pointer;
	transition: all 0.2s ease;
	vertical-align: middle;
}

.hsv-tts-bg-dark .hsv-tts-speed-btn {
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.15);
}
.hsv-tts-bg-dark .hsv-tts-speed-btn:hover {
	background: rgba(255, 255, 255, 0.15);
}

.hsv-tts-bg-light .hsv-tts-speed-btn {
	background: #f3f4f6;
	border: 1px solid #e5e7eb;
}
.hsv-tts-bg-light .hsv-tts-speed-btn:hover {
	background: #e5e7eb;
}

.hsv-tts-speed-value {
	font-size: 10px;
	font-weight: 600;
}

.hsv-tts-bg-dark .hsv-tts-speed-value { color: rgba(255, 255, 255, 0.9); }
.hsv-tts-bg-light .hsv-tts-speed-value { color: #374151; }

.hsv-tts-speed-menu {
	position: absolute;
	bottom: calc(100% + 6px);
	right: 0;
	background: rgba(255, 255, 255, 0.98);
	backdrop-filter: blur(20px);
	-webkit-backdrop-filter: blur(20px);
	border-radius: 10px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.04);
	border: 1px solid rgba(0, 0, 0, 0.06);
	padding: 4px;
	display: none;
	z-index: 100;
	min-width: 60px;
}

.hsv-tts-speed-control.is-open .hsv-tts-speed-menu {
	display: block;
	animation: hsv-fade-in 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes hsv-fade-in {
	from { opacity: 0; transform: translateY(6px) scale(0.96); }
	to { opacity: 1; transform: translateY(0) scale(1); }
}

.hsv-tts-speed-menu button {
	display: block;
	width: 100%;
	padding: 6px 10px;
	border: none;
	background: transparent;
	border-radius: 6px;
	cursor: pointer;
	font-size: 11px;
	font-weight: 500;
	color: #374151;
	text-align: center;
	transition: all 0.15s ease;
}

.hsv-tts-speed-menu button:hover {
	background: #f3f4f6;
}

.hsv-tts-speed-menu button.active {
	background: linear-gradient(135deg, var(--hsv-tts-color), color-mix(in srgb, var(--hsv-tts-color) 80%, #8b5cf6));
	color: #fff;
	box-shadow: 0 1px 4px color-mix(in srgb, var(--hsv-tts-color) 25%, transparent);
}

/* Voice Control */
.hsv-tts-voice-control {
	position: relative;
	flex-shrink: 0;
}

.hsv-tts-voice-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	height: 24px;
	padding: 0 10px;
	border-radius: 100px;
	cursor: pointer;
	transition: all 0.2s ease;
	vertical-align: middle;
}

.hsv-tts-bg-dark .hsv-tts-voice-btn {
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.15);
}
.hsv-tts-bg-dark .hsv-tts-voice-btn:hover {
	background: rgba(255, 255, 255, 0.15);
}

.hsv-tts-bg-light .hsv-tts-voice-btn {
	background: #f3f4f6;
	border: 1px solid #e5e7eb;
}
.hsv-tts-bg-light .hsv-tts-voice-btn:hover {
	background: #e5e7eb;
}

.hsv-tts-voice-icon {
	font-size: 11px;
	line-height: 1;
}

.hsv-tts-bg-dark .hsv-tts-voice-icon { filter: grayscale(1) brightness(2); }

.hsv-tts-voice-label {
	font-size: 10px;
	font-weight: 500;
}

.hsv-tts-bg-dark .hsv-tts-voice-label { color: rgba(255, 255, 255, 0.6); }
.hsv-tts-bg-light .hsv-tts-voice-label { color: #6b7280; }

.hsv-tts-voice-name {
	font-size: 10px;
	font-weight: 600;
	color: var(--hsv-tts-color);
	max-width: 80px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hsv-tts-voice-menu {
	position: absolute;
	bottom: calc(100% + 6px);
	right: 0;
	background: rgba(255, 255, 255, 0.98);
	backdrop-filter: blur(20px);
	-webkit-backdrop-filter: blur(20px);
	border-radius: 10px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.04);
	border: 1px solid rgba(0, 0, 0, 0.06);
	padding: 4px;
	display: none;
	z-index: 100;
	min-width: 120px;
	max-height: 180px;
	overflow-y: auto;
}

.hsv-tts-voice-control.is-open .hsv-tts-voice-menu {
	display: block;
	animation: hsv-fade-in 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.hsv-tts-voice-menu button {
	display: block;
	width: 100%;
	padding: 6px 10px;
	border: none;
	background: transparent;
	border-radius: 6px;
	cursor: pointer;
	font-size: 11px;
	font-weight: 500;
	color: #374151;
	text-align: left;
	white-space: nowrap;
	transition: all 0.15s ease;
}

.hsv-tts-voice-menu button:hover {
	background: #f3f4f6;
}

.hsv-tts-voice-menu button.active {
	background: linear-gradient(135deg, var(--hsv-tts-color), color-mix(in srgb, var(--hsv-tts-color) 80%, #8b5cf6));
	color: #fff;
	box-shadow: 0 1px 4px color-mix(in srgb, var(--hsv-tts-color) 25%, transparent);
}

/* Compact Player Layout (for button_text and icon_only styles) */
.hsv-tts-compact-player {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

/* Status Display */
.hsv-tts-status {
	font-size: 10px;
	color: #6b7280;
	margin-left: 3px;
	font-weight: 500;
}

.hsv-tts-player.is-loading .hsv-tts-status {
	color: var(--hsv-tts-color);
	font-weight: 600;
	animation: hsv-pulse 1.5s ease-in-out infinite;
}

@keyframes hsv-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.5; }
}

/* Audio Element (hidden) */
.hsv-tts-audio {
	display: none;
}

/* State Classes */
.hsv-tts-player.is-loading .hsv-tts-icon {
	display: none;
}

.hsv-tts-player.is-loading .hsv-tts-loading {
	display: inline-block !important;
}

.hsv-tts-player.is-playing .hsv-tts-icon-play {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'/%3E%3C/svg%3E");
}

.hsv-tts-player.is-error .hsv-tts-btn {
	background-color: #dc3545;
}

/* Admin Preview Container */
.hsv-tts-preview-container {
	background: #f0f0f1;
	padding: 30px;
	border: 1px solid #ccd0d4;
	border-radius: 4px;
	margin-top: 10px;
}

/* Color Picker Fix */
.wp-picker-container {
	display: inline-block;
}

/* Responsive - Tablet */
@media (max-width: 768px) {
	.hsv-tts-player {
		display: flex;
		width: 100%;
		max-width: 100%;
	}

	.hsv-tts-full-player {
		min-width: auto;
		width: 100%;
		padding: 10px 12px;
		gap: 8px;
		border-radius: 10px;
		flex-wrap: wrap;
	}

	.hsv-tts-full-player .hsv-tts-play {
		width: 30px;
		height: 30px;
	}

	.hsv-tts-compact-player {
		width: 100%;
		gap: 6px;
	}

	.hsv-tts-wave {
		display: none;
	}

	/* Voice control on tablet */
	.hsv-tts-voice-btn {
		padding: 0 8px;
		height: 24px;
	}

	.hsv-tts-voice-label {
		display: none;
	}

	.hsv-tts-voice-name {
		font-size: 10px;
		max-width: 60px;
	}

	/* Speed control */
	.hsv-tts-speed-btn {
		min-width: 34px;
		height: 24px;
	}

	.hsv-tts-status {
		font-size: 10px;
	}
}

/* Responsive - Mobile (compact 70% height) */
@media (max-width: 480px) {
	.hsv-tts-player {
		margin: 6px 0;
	}

	/* Full player mobile - single row compact */
	.hsv-tts-full-player {
		padding: 8px 10px;
		gap: 6px;
		border-radius: 8px;
		flex-wrap: nowrap;
	}

	.hsv-tts-full-player .hsv-tts-play {
		width: 28px;
		height: 28px;
	}

	.hsv-tts-full-player .hsv-tts-play .hsv-tts-icon {
		width: 12px;
		height: 12px;
	}

	.hsv-tts-progress {
		flex: 1;
		min-width: 50px;
		height: 3px;
	}

	.hsv-tts-progress-bar::after {
		width: 8px;
		height: 8px;
		right: -4px;
	}

	.hsv-tts-time {
		font-size: 10px;
		min-width: 28px;
	}

	/* Speed & Voice inline with player */
	.hsv-tts-full-player .hsv-tts-speed-control,
	.hsv-tts-full-player .hsv-tts-voice-control {
		order: unset;
		flex: 0;
	}

	.hsv-tts-full-player .hsv-tts-status {
		order: unset;
		margin-left: 0;
		font-size: 9px;
	}

	/* Remove line break */
	.hsv-tts-full-player::after {
		display: none;
	}

	/* Wave hidden on mobile */
	.hsv-tts-wave {
		display: none;
	}

	/* Compact player mobile */
	.hsv-tts-compact-player {
		flex-wrap: nowrap;
		gap: 6px;
	}

	.hsv-tts-compact-player .hsv-tts-btn,
	.hsv-tts-compact-player .hsv-tts-status,
	.hsv-tts-compact-player .hsv-tts-speed-control,
	.hsv-tts-compact-player .hsv-tts-voice-control {
		order: unset;
	}

	/* Remove line break */
	.hsv-tts-compact-player::after {
		display: none;
	}

	.hsv-tts-text-btn {
		flex: 0;
		min-width: auto;
	}

	/* Button sizes */
	.hsv-tts-size-small .hsv-tts-btn {
		padding: 6px 12px;
		font-size: 12px;
	}

	.hsv-tts-size-small .hsv-tts-btn {
		padding: 4px 8px;
		font-size: 10px;
	}

	.hsv-tts-size-medium .hsv-tts-btn {
		padding: 5px 10px;
		font-size: 11px;
	}

	.hsv-tts-size-large .hsv-tts-btn {
		padding: 6px 12px;
		font-size: 12px;
	}

	.hsv-tts-icon {
		width: 10px;
		height: 10px;
	}

	.hsv-tts-label {
		font-size: 10px;
	}

	/* Voice control mobile - compact inline */
	.hsv-tts-voice-btn {
		width: auto;
		padding: 0 6px;
		height: 24px;
		gap: 3px;
	}

	.hsv-tts-voice-icon {
		font-size: 10px;
	}

	.hsv-tts-voice-label {
		display: none;
	}

	.hsv-tts-voice-name {
		font-size: 9px;
		max-width: 50px;
	}

	.hsv-tts-voice-menu {
		right: 0;
		left: auto;
		min-width: 100px;
		width: auto;
	}

	.hsv-tts-voice-menu button {
		padding: 6px 10px;
		font-size: 11px;
	}

	/* Speed control mobile - compact inline */
	.hsv-tts-speed-btn {
		width: auto;
		min-width: 32px;
		height: 24px;
		padding: 0 6px;
	}

	.hsv-tts-speed-value {
		font-size: 9px;
	}

	.hsv-tts-speed-menu {
		min-width: 50px;
		width: auto;
		right: 0;
		left: auto;
	}

	.hsv-tts-speed-menu button {
		padding: 6px 10px;
		font-size: 11px;
	}

	.hsv-tts-status {
		font-size: 9px;
		margin-left: 2px;
	}
}

/* Responsive - Small Mobile */
@media (max-width: 360px) {
	.hsv-tts-btn {
		gap: 6px;
	}

	.hsv-tts-full-player {
		padding: 12px;
		gap: 8px;
	}

	.hsv-tts-full-player .hsv-tts-play {
		width: 38px;
		height: 38px;
	}

	.hsv-tts-progress {
		min-width: 60px;
	}

	.hsv-tts-time {
		font-size: 11px;
		min-width: 32px;
	}

	.hsv-tts-compact-player {
		gap: 6px;
	}

	/* Speed + Voice buttons - side by side, full width row */
	.hsv-tts-speed-control,
	.hsv-tts-voice-control {
		flex: 1;
	}

	.hsv-tts-voice-btn,
	.hsv-tts-speed-btn {
		width: 100%;
		height: 34px;
		justify-content: center;
	}

	.hsv-tts-voice-name {
		max-width: 60px;
	}

	.hsv-tts-status {
		order: 3;
		width: auto;
		margin: 0 0 0 4px;
	}
}
