/* ==========================================================================
   UCDREAMS TOOLS - TEXT TO NATURAL SPEECH (AI VOICE GENERATOR)
   Multi-Tier Neural Architecture (Kokoro-82M + VITS WASM + Device)
   100% Client-Side Neural Speech Studio with Tone Options & Offline Cache
   ========================================================================== */

.ucd-tts-wrapper {
	max-width: 980px;
	margin: 0 auto 60px;
	padding: 0 16px;
	font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Card Container */
.ucd-tts-card {
	background: var(--color-surface, #ffffff);
	border: 1px solid var(--color-border, #e2e8f0);
	border-radius: 20px;
	padding: 32px;
	box-shadow: 0 12px 36px rgba(0, 0, 0, 0.06);
	transition: all 0.3s ease;
	position: relative;
	overflow: hidden;
}

[data-theme="dark"] .ucd-tts-card,
body.dark-mode .ucd-tts-card {
	background: #111827;
	border-color: rgba(255, 255, 255, 0.1);
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

/* Privacy & Tech Pill Badge */
.ucd-tts-badge-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 20px;
}

.ucd-tts-pill-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 12px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	background: rgba(16, 185, 129, 0.1);
	color: #10b981;
	border: 1px solid rgba(16, 185, 129, 0.2);
}

.ucd-tts-storage-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 12px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	background: rgba(197, 69, 62, 0.08);
	color: #C5453E;
	border: 1px solid rgba(197, 69, 62, 0.2);
	cursor: pointer;
	transition: all 0.2s ease;
	text-decoration: none;
}

.ucd-tts-storage-pill:hover {
	background: rgba(197, 69, 62, 0.15);
	transform: translateY(-1px);
}

.ucd-tts-counter {
	font-size: 13px;
	color: #64748b;
	font-weight: 500;
}

/* Textarea Input */
.ucd-tts-textarea-wrap {
	position: relative;
	margin-bottom: 18px;
}

.ucd-tts-textarea {
	width: 100%;
	min-height: 150px;
	padding: 18px 20px;
	box-sizing: border-box;
	border-radius: 14px;
	border: 1.5px solid var(--color-border, #e2e8f0);
	background: var(--color-surface, #ffffff);
	color: var(--color-heading, #0f172a);
	font-size: 16px;
	line-height: 1.6;
	resize: vertical;
	outline: none;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
	font-family: inherit;
}

[data-theme="dark"] .ucd-tts-textarea,
body.dark-mode .ucd-tts-textarea {
	background: #1e293b;
	border-color: #334155;
	color: #f8fafc;
}

.ucd-tts-textarea:focus {
	border-color: #C5453E;
	box-shadow: 0 0 0 3px rgba(197, 69, 62, 0.15);
}

/* Quick Preset Chips */
.ucd-tts-presets {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	margin-bottom: 24px;
}

.ucd-tts-preset-label {
	font-size: 12px;
	font-weight: 600;
	color: #64748b;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.ucd-tts-chip {
	padding: 5px 12px;
	border-radius: 8px;
	background: rgba(0, 0, 0, 0.04);
	color: var(--color-heading, #0f172a);
	border: 1px solid var(--color-border, #e2e8f0);
	font-size: 12px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s ease;
}

[data-theme="dark"] .ucd-tts-chip,
body.dark-mode .ucd-tts-chip {
	background: #1e293b;
	border-color: #334155;
	color: #e2e8f0;
}

.ucd-tts-chip:hover {
	border-color: #C5453E;
	color: #C5453E;
	transform: translateY(-1px);
}

/* MODEL SELECTOR SECTION */
.ucd-tts-section-title {
	font-size: 13px;
	font-weight: 700;
	color: var(--color-heading, #0f172a);
	margin: 0 0 10px 0;
	text-transform: uppercase;
	letter-spacing: 0.6px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

[data-theme="dark"] .ucd-tts-section-title,
body.dark-mode .ucd-tts-section-title {
	color: #f1f5f9;
}

.ucd-tts-model-tiers {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 12px;
	margin-bottom: 20px;
}

.ucd-tts-tier-card {
	border: 2px solid var(--color-border, #e2e8f0);
	border-radius: 14px;
	padding: 14px 16px;
	cursor: pointer;
	background: var(--color-surface, #ffffff);
	transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
	position: relative;
	display: flex;
	flex-direction: column;
	text-align: left;
}

[data-theme="dark"] .ucd-tts-tier-card,
body.dark-mode .ucd-tts-tier-card {
	background: #1e293b;
	border-color: #334155;
}

.ucd-tts-tier-card:hover {
	border-color: #C5453E;
	transform: translateY(-2px);
}

.ucd-tts-tier-card.is-active {
	border-color: #C5453E;
	background: rgba(197, 69, 62, 0.04);
	box-shadow: 0 4px 16px rgba(197, 69, 62, 0.12);
}

[data-theme="dark"] .ucd-tts-tier-card.is-active,
body.dark-mode .ucd-tts-tier-card.is-active {
	background: rgba(197, 69, 62, 0.12);
	border-color: #C5453E;
}

.ucd-tts-tier-badge {
	display: inline-block;
	font-size: 10px;
	font-weight: 700;
	padding: 2px 7px;
	border-radius: 6px;
	margin-bottom: 6px;
	text-transform: uppercase;
	letter-spacing: 0.3px;
	align-self: flex-start;
}

.ucd-tts-tier-badge.badge-pro {
	background: linear-gradient(135deg, #10b981, #059669);
	color: #ffffff;
}

.ucd-tts-tier-badge.badge-fast {
	background: linear-gradient(135deg, #3b82f6, #2563eb);
	color: #ffffff;
}

.ucd-tts-tier-badge.badge-instant {
	background: linear-gradient(135deg, #8b5cf6, #7c3aed);
	color: #ffffff;
}

.ucd-tts-tier-name {
	font-size: 14px;
	font-weight: 700;
	color: var(--color-heading, #0f172a);
	margin-bottom: 4px;
}

[data-theme="dark"] .ucd-tts-tier-name,
body.dark-mode .ucd-tts-tier-name {
	color: #ffffff;
}

.ucd-tts-tier-desc {
	font-size: 11px;
	color: #64748b;
	line-height: 1.4;
	margin: 0;
	flex: 1;
}

/* Controls Grid */
.ucd-tts-controls-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 16px;
	margin-bottom: 20px;
	background: rgba(0, 0, 0, 0.02);
	padding: 20px;
	border-radius: 14px;
	border: 1px solid var(--color-border, #e2e8f0);
}

[data-theme="dark"] .ucd-tts-controls-grid,
body.dark-mode .ucd-tts-controls-grid {
	background: rgba(30, 41, 59, 0.5);
	border-color: rgba(255, 255, 255, 0.08);
}

.ucd-tts-control-item label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	color: var(--color-heading, #0f172a);
	margin-bottom: 8px;
}

[data-theme="dark"] .ucd-tts-control-item label,
body.dark-mode .ucd-tts-control-item label {
	color: #f1f5f9;
}

.ucd-tts-select {
	width: 100%;
	padding: 10px 14px;
	border-radius: 10px;
	border: 1px solid var(--color-border, #e2e8f0);
	background: var(--color-surface, #ffffff);
	color: var(--color-heading, #0f172a);
	font-size: 14px;
	font-weight: 500;
	outline: none;
	cursor: pointer;
	transition: border-color 0.2s ease;
	font-family: inherit;
}

[data-theme="dark"] .ucd-tts-select,
body.dark-mode .ucd-tts-select {
	background: #1e293b;
	border-color: #334155;
	color: #f8fafc;
}

.ucd-tts-select:focus {
	border-color: #C5453E;
}

/* TONE PRESET SELECTOR */
.ucd-tts-tone-row {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	margin-top: 6px;
}

.ucd-tts-tone-btn {
	padding: 6px 12px;
	border-radius: 8px;
	border: 1px solid var(--color-border, #e2e8f0);
	background: var(--color-surface, #ffffff);
	color: #64748b;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
}

[data-theme="dark"] .ucd-tts-tone-btn,
body.dark-mode .ucd-tts-tone-btn {
	background: #1e293b;
	border-color: #334155;
	color: #94a3b8;
}

.ucd-tts-tone-btn:hover {
	border-color: #C5453E;
	color: #C5453E;
}

.ucd-tts-tone-btn.is-active {
	background: #C5453E;
	color: #ffffff;
	border-color: #C5453E;
	box-shadow: 0 3px 10px rgba(197, 69, 62, 0.3);
}

.ucd-tts-slider-wrap {
	display: flex;
	align-items: center;
	gap: 12px;
}

.ucd-tts-slider {
	flex: 1;
	accent-color: #C5453E;
	cursor: pointer;
}

.ucd-tts-slider-val {
	font-size: 13px;
	font-weight: 700;
	color: #C5453E;
	min-width: 48px;
	text-align: right;
}

/* Action Buttons */
.ucd-tts-action-row {
	display: flex;
	align-items: center;
	gap: 14px;
	flex-wrap: wrap;
}

.ucd-tts-btn-generate {
	flex: 1;
	min-width: 220px;
	height: 50px;
	border-radius: 12px;
	background: linear-gradient(135deg, #C5453E 0%, #D74E46 100%);
	color: #ffffff;
	border: none;
	font-size: 15px;
	font-weight: 600;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	cursor: pointer;
	box-shadow: 0 8px 20px rgba(197, 69, 62, 0.3);
	transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
	outline: none;
}

.ucd-tts-btn-generate:hover:not(:disabled) {
	transform: translateY(-2px);
	box-shadow: 0 12px 24px rgba(197, 69, 62, 0.4);
}

.ucd-tts-btn-generate:disabled {
	opacity: 0.65;
	cursor: not-allowed;
	transform: none;
}

.ucd-tts-btn-clear {
	height: 50px;
	padding: 0 20px;
	border-radius: 12px;
	background: transparent;
	color: #64748b;
	border: 1px solid var(--color-border, #e2e8f0);
	font-size: 14px;
	font-weight: 500;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	cursor: pointer;
	transition: all 0.2s ease;
	outline: none;
}

[data-theme="dark"] .ucd-tts-btn-clear,
body.dark-mode .ucd-tts-btn-clear {
	border-color: #334155;
	color: #94a3b8;
}

.ucd-tts-btn-clear:hover {
	color: #C5453E;
	border-color: #C5453E;
}

/* Progress Container */
.ucd-tts-progress-box {
	margin-top: 24px;
	display: none;
	animation: ucdFadeIn 0.3s ease forwards;
}

.ucd-tts-progress-box.is-active {
	display: block;
}

.ucd-tts-progress-text {
	display: flex;
	justify-content: space-between;
	font-size: 13px;
	font-weight: 600;
	color: #C5453E;
	margin-bottom: 6px;
}

.ucd-tts-progress-bar {
	width: 100%;
	height: 8px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.08);
	overflow: hidden;
	position: relative;
}

[data-theme="dark"] .ucd-tts-progress-bar,
body.dark-mode .ucd-tts-progress-bar {
	background: rgba(255, 255, 255, 0.1);
}

.ucd-tts-progress-fill {
	height: 100%;
	width: 0%;
	background: linear-gradient(90deg, #C5453E, #f87171);
	border-radius: 999px;
	transition: width 0.25s ease;
}

/* Interactive Audio Player Result Box */
.ucd-tts-result-box {
	margin-top: 32px;
	padding: 24px;
	border-radius: 16px;
	background: #0f172a;
	color: #ffffff;
	border: 1px solid #1e293b;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
	display: none;
	animation: ucdFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ucd-tts-result-box.is-active {
	display: block;
}

@keyframes ucdFadeIn {
	from { opacity: 0; transform: translateY(10px); }
	to { opacity: 1; transform: translateY(0); }
}

.ucd-tts-player-row {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
}

.ucd-tts-play-btn {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: #C5453E;
	color: #ffffff;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 6px 18px rgba(197, 69, 62, 0.4);
	transition: transform 0.2s ease, background 0.2s ease;
	flex-shrink: 0;
	outline: none;
}

.ucd-tts-play-btn:hover {
	transform: scale(1.06);
	background: #D74E46;
}

.ucd-tts-timeline-wrap {
	flex: 1;
	min-width: 180px;
}

.ucd-tts-times {
	display: flex;
	justify-content: space-between;
	font-size: 11px;
	font-weight: 600;
	color: #94a3b8;
	margin-bottom: 6px;
}

.ucd-tts-scrubber {
	width: 100%;
	height: 6px;
	border-radius: 999px;
	background: #334155;
	position: relative;
	cursor: pointer;
	overflow: hidden;
}

.ucd-tts-scrubber-fill {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	width: 0%;
	background: #C5453E;
	border-radius: 999px;
	transition: width 0.1s linear;
}

/* Wave visualizer */
.ucd-tts-wave {
	display: flex;
	align-items: center;
	gap: 3px;
	height: 22px;
	padding: 0 8px;
}

.ucd-tts-wave span {
	width: 3px;
	height: 4px;
	background: #64748b;
	border-radius: 99px;
	transition: height 0.15s ease, background 0.15s ease;
}

.ucd-tts-wave.is-playing span {
	background: #C5453E;
	animation: ucdWaveDance 1s ease-in-out infinite alternate;
}

.ucd-tts-wave.is-playing span:nth-child(2) { animation-delay: 0.15s; }
.ucd-tts-wave.is-playing span:nth-child(3) { animation-delay: 0.3s; }
.ucd-tts-wave.is-playing span:nth-child(4) { animation-delay: 0.45s; }
.ucd-tts-wave.is-playing span:nth-child(5) { animation-delay: 0.6s; }

@keyframes ucdWaveDance {
	0% { height: 4px; }
	100% { height: 20px; }
}

/* Download Button */
.ucd-tts-download-btn {
	height: 44px;
	padding: 0 18px;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.08);
	color: #ffffff;
	border: 1px solid rgba(255, 255, 255, 0.15);
	font-size: 13px;
	font-weight: 600;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	transition: all 0.2s ease;
	text-decoration: none;
	flex-shrink: 0;
}

.ucd-tts-download-btn:hover {
	background: #10b981;
	border-color: #10b981;
	color: #ffffff;
	transform: translateY(-1px);
}

/* MODEL STORAGE MANAGER ACCORDION */
.ucd-tts-model-manager {
	margin-top: 32px;
	border-radius: 14px;
	border: 1px solid var(--color-border, #e2e8f0);
	background: rgba(0, 0, 0, 0.015);
	overflow: hidden;
}

[data-theme="dark"] .ucd-tts-model-manager,
body.dark-mode .ucd-tts-model-manager {
	border-color: rgba(255, 255, 255, 0.08);
	background: rgba(30, 41, 59, 0.3);
}

.ucd-tts-mm-header {
	padding: 16px 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	cursor: pointer;
	background: transparent;
	user-select: none;
}

.ucd-tts-mm-title {
	font-size: 13px;
	font-weight: 600;
	color: var(--color-heading, #0f172a);
	display: flex;
	align-items: center;
	gap: 8px;
}

[data-theme="dark"] .ucd-tts-mm-title,
body.dark-mode .ucd-tts-mm-title {
	color: #f1f5f9;
}

.ucd-tts-mm-content {
	padding: 0 20px 20px;
	display: none;
}

.ucd-tts-mm-content.is-open {
	display: block;
}

.ucd-tts-mm-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px;
	background: var(--color-surface, #ffffff);
	border: 1px solid var(--color-border, #e2e8f0);
	border-radius: 10px;
	margin-bottom: 10px;
	font-size: 13px;
}

[data-theme="dark"] .ucd-tts-mm-item,
body.dark-mode .ucd-tts-mm-item {
	background: #1e293b;
	border-color: #334155;
	color: #e2e8f0;
}

.ucd-tts-mm-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.ucd-tts-mm-btn {
	padding: 5px 12px;
	border-radius: 6px;
	font-size: 11px;
	font-weight: 600;
	cursor: pointer;
	border: 1px solid transparent;
	transition: all 0.2s ease;
}

.ucd-tts-mm-btn-dl {
	background: #C5453E;
	color: #ffffff;
}

.ucd-tts-mm-btn-dl:hover {
	background: #D74E46;
}

.ucd-tts-mm-btn-clear {
	background: rgba(239, 68, 68, 0.1);
	color: #ef4444;
	border-color: rgba(239, 68, 68, 0.2);
}

.ucd-tts-mm-btn-clear:hover {
	background: #ef4444;
	color: #ffffff;
}

.ucd-tts-mm-status-badge {
	font-size: 11px;
	font-weight: 600;
	color: #10b981;
	display: flex;
	align-items: center;
	gap: 4px;
}

/* Features Section */
.ucd-tts-features-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 20px;
	margin-top: 40px;
}

.ucd-tts-feat-card {
	padding: 24px;
	border-radius: 16px;
	background: var(--color-surface, #ffffff);
	border: 1px solid var(--color-border, #e2e8f0);
	transition: transform 0.2s ease;
}

[data-theme="dark"] .ucd-tts-feat-card,
body.dark-mode .ucd-tts-feat-card {
	background: #111827;
	border-color: rgba(255, 255, 255, 0.08);
}

.ucd-tts-feat-card:hover {
	transform: translateY(-2px);
}

.ucd-tts-feat-icon {
	width: 40px;
	height: 40px;
	border-radius: 10px;
	background: rgba(197, 69, 62, 0.1);
	color: #C5453E;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 14px;
}

.ucd-tts-feat-title {
	font-size: 15px;
	font-weight: 700;
	margin: 0 0 6px 0;
	color: var(--color-heading, #0f172a);
}

[data-theme="dark"] .ucd-tts-feat-title,
body.dark-mode .ucd-tts-feat-title {
	color: #f1f5f9;
}

.ucd-tts-feat-desc {
	font-size: 13px;
	line-height: 1.5;
	color: #64748b;
	margin: 0;
}

@media (max-width: 768px) {
	.ucd-tts-model-tiers {
		grid-template-columns: 1fr;
	}
	.ucd-tts-card {
		padding: 20px;
	}
	.ucd-tts-player-row {
		flex-direction: column;
		align-items: stretch;
	}
	.ucd-tts-play-btn {
		align-self: center;
	}
	.ucd-tts-download-btn {
		justify-content: center;
	}
}
