/*
 * TagGenius AI - YouTube Title Generator
 * Frontend styles. Fully scoped under .tgai-ytt-wrapper — never touches
 * global selectors (body, button, input, h1-h3, etc.) so it cannot break
 * Astra, Elementor, Gutenberg, or other TagGenius AI tools on the page.
 *
 * Colors are defined as CSS custom properties scoped to the wrapper so
 * they automatically inherit Astra's active theme palette where available,
 * and fall back to the TagGenius AI blue/red brand combo otherwise.
 */

.tgai-ytt-wrapper {
	--tgai-primary: var(--ast-global-color-0, #1a56ff);
	--tgai-primary-dark: var(--ast-global-color-1, #123fc2);
	--tgai-accent: var(--ast-global-color-2, #ff2d55);
	--tgai-text: var(--ast-global-color-3, #1c1f2a);
	--tgai-text-muted: #6b7280;
	--tgai-bg: #ffffff;
	--tgai-surface: #f7f8fb;
	--tgai-border: #e5e7eb;
	--tgai-radius: 14px;
	--tgai-radius-sm: 10px;
	--tgai-shadow: 0 4px 24px rgba(20, 25, 45, 0.06);
	--tgai-font: var(--ast-body-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);

	all: initial;
	display: block;
	box-sizing: border-box;
	font-family: var(--tgai-font);
	color: var(--tgai-text);
	max-width: 720px;
	margin: 0 auto;
	width: 100%;
}

.tgai-ytt-wrapper *,
.tgai-ytt-wrapper *::before,
.tgai-ytt-wrapper *::after {
	box-sizing: border-box;
	font-family: inherit;
}

.tgai-ytt-wrapper .tgai-ytt-card {
	background: var(--tgai-bg);
	border: 1px solid var(--tgai-border);
	border-radius: var(--tgai-radius);
	box-shadow: var(--tgai-shadow);
	padding: 32px;
}

.tgai-ytt-wrapper .tgai-ytt-notice {
	background: #fff4f4;
	border: 1px solid #ffd4d4;
	color: #b42318;
	border-radius: var(--tgai-radius-sm);
	padding: 12px 16px;
	margin-bottom: 16px;
	font-size: 14px;
}

.tgai-ytt-wrapper .tgai-ytt-header {
	margin-bottom: 24px;
}

.tgai-ytt-wrapper .tgai-ytt-title {
	font-size: 26px;
	line-height: 1.25;
	font-weight: 700;
	margin: 0 0 8px;
	color: var(--tgai-text);
}

.tgai-ytt-wrapper .tgai-ytt-tagline {
	font-size: 15px;
	color: var(--tgai-text-muted);
	margin: 0;
}

.tgai-ytt-wrapper .tgai-ytt-form {
	display: block;
}

.tgai-ytt-wrapper .tgai-ytt-label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	color: var(--tgai-text);
	margin-bottom: 6px;
}

.tgai-ytt-wrapper .tgai-ytt-textarea {
	width: 100%;
	min-height: 88px;
	padding: 14px 16px;
	font-size: 15px;
	line-height: 1.5;
	color: var(--tgai-text);
	background: var(--tgai-surface);
	border: 1.5px solid var(--tgai-border);
	border-radius: var(--tgai-radius-sm);
	resize: vertical;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tgai-ytt-wrapper .tgai-ytt-textarea:focus {
	outline: none;
	border-color: var(--tgai-primary);
	box-shadow: 0 0 0 3px rgba(26, 86, 255, 0.15);
}

.tgai-ytt-wrapper .tgai-ytt-textarea.tgai-ytt-input-error {
	border-color: var(--tgai-accent);
}

.tgai-ytt-wrapper .tgai-ytt-field-error {
	color: var(--tgai-accent);
	font-size: 13px;
	margin: 6px 0 0;
	min-height: 0;
}

.tgai-ytt-wrapper .tgai-ytt-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
	margin-top: 18px;
}

.tgai-ytt-wrapper .tgai-ytt-field {
	display: flex;
	flex-direction: column;
}

.tgai-ytt-wrapper .tgai-ytt-select {
	width: 100%;
	padding: 12px 14px;
	font-size: 14px;
	color: var(--tgai-text);
	background: var(--tgai-surface);
	border: 1.5px solid var(--tgai-border);
	border-radius: var(--tgai-radius-sm);
	appearance: none;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' fill-rule='evenodd'/></svg>");
	background-repeat: no-repeat;
	background-position: right 14px center;
	padding-right: 34px;
	cursor: pointer;
}

.tgai-ytt-wrapper .tgai-ytt-select:focus {
	outline: none;
	border-color: var(--tgai-primary);
	box-shadow: 0 0 0 3px rgba(26, 86, 255, 0.15);
}

.tgai-ytt-wrapper .tgai-ytt-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	margin-top: 22px;
	padding: 14px 20px;
	font-size: 15px;
	font-weight: 600;
	border-radius: var(--tgai-radius-sm);
	border: none;
	cursor: pointer;
	transition: transform 0.1s ease, opacity 0.15s ease, background 0.15s ease;
	touch-action: manipulation;
}

.tgai-ytt-wrapper .tgai-ytt-btn:active {
	transform: scale(0.98);
}

.tgai-ytt-wrapper .tgai-ytt-btn:focus-visible {
	outline: 2px solid var(--tgai-primary);
	outline-offset: 2px;
}

.tgai-ytt-wrapper .tgai-ytt-btn-primary {
	background: linear-gradient(135deg, var(--tgai-primary), var(--tgai-primary-dark));
	color: #ffffff;
}

.tgai-ytt-wrapper .tgai-ytt-btn-primary:hover {
	opacity: 0.92;
}

.tgai-ytt-wrapper .tgai-ytt-btn-primary:disabled {
	opacity: 0.65;
	cursor: not-allowed;
	transform: none;
}

.tgai-ytt-wrapper .tgai-ytt-btn-secondary {
	background: var(--tgai-surface);
	color: var(--tgai-text);
	border: 1.5px solid var(--tgai-border);
	width: auto;
	margin-top: 0;
	padding: 10px 16px;
	font-size: 13px;
}

.tgai-ytt-wrapper .tgai-ytt-btn-secondary:hover {
	background: #eef0f4;
}

.tgai-ytt-wrapper .tgai-ytt-btn-outline {
	background: transparent;
	color: var(--tgai-primary);
	border: 1.5px solid var(--tgai-primary);
}

.tgai-ytt-wrapper .tgai-ytt-btn-outline:hover {
	background: rgba(26, 86, 255, 0.06);
}

.tgai-ytt-wrapper .tgai-ytt-spinner {
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #ffffff;
	border-radius: 50%;
	display: none;
	animation: tgai-ytt-spin 0.7s linear infinite;
}

.tgai-ytt-wrapper .tgai-ytt-btn-primary.tgai-ytt-loading-state .tgai-ytt-spinner {
	display: inline-block;
}

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

.tgai-ytt-wrapper .tgai-ytt-loading {
	margin: 18px 0 0;
	padding: 12px 16px;
	background: var(--tgai-surface);
	border-radius: var(--tgai-radius-sm);
	font-size: 14px;
	color: var(--tgai-text-muted);
	text-align: center;
}

.tgai-ytt-wrapper .tgai-ytt-error {
	margin: 18px 0 0;
	padding: 12px 16px;
	background: #fff4f4;
	border: 1px solid #ffd4d4;
	color: #b42318;
	border-radius: var(--tgai-radius-sm);
	font-size: 14px;
}

.tgai-ytt-wrapper .tgai-ytt-results {
	margin-top: 28px;
	padding-top: 24px;
	border-top: 1px solid var(--tgai-border);
}

.tgai-ytt-wrapper .tgai-ytt-results-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-wrap: wrap;
	margin-bottom: 16px;
}

.tgai-ytt-wrapper .tgai-ytt-results-header h3 {
	font-size: 18px;
	font-weight: 700;
	margin: 0;
	color: var(--tgai-text);
}

.tgai-ytt-wrapper .tgai-ytt-title-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.tgai-ytt-wrapper .tgai-ytt-title-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 16px;
	background: var(--tgai-surface);
	border: 1px solid var(--tgai-border);
	border-radius: var(--tgai-radius-sm);
}

.tgai-ytt-wrapper .tgai-ytt-title-content {
	flex: 1;
	min-width: 0;
}

.tgai-ytt-wrapper .tgai-ytt-title-text {
	font-size: 15px;
	font-weight: 500;
	color: var(--tgai-text);
	line-height: 1.4;
	word-break: break-word;
}

.tgai-ytt-wrapper .tgai-ytt-title-meta {
	font-size: 12px;
	color: var(--tgai-text-muted);
	margin-top: 4px;
}

.tgai-ytt-wrapper .tgai-ytt-copy-btn {
	flex-shrink: 0;
	padding: 8px 14px;
	font-size: 13px;
	font-weight: 600;
	color: var(--tgai-primary);
	background: #ffffff;
	border: 1.5px solid var(--tgai-primary);
	border-radius: 8px;
	cursor: pointer;
	min-width: 68px;
	min-height: 38px;
	touch-action: manipulation;
	transition: background 0.15s ease, color 0.15s ease;
}

.tgai-ytt-wrapper .tgai-ytt-copy-btn:hover {
	background: var(--tgai-primary);
	color: #ffffff;
}

.tgai-ytt-wrapper .tgai-ytt-copy-btn.tgai-ytt-copied {
	background: #12b76a;
	border-color: #12b76a;
	color: #ffffff;
}

.tgai-ytt-wrapper [hidden] {
	display: none !important;
}

.tgai-ytt-wrapper .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

/* Responsive breakpoints */
@media (max-width: 480px) {
	.tgai-ytt-wrapper .tgai-ytt-card {
		padding: 20px;
		border-radius: 12px;
	}

	.tgai-ytt-wrapper .tgai-ytt-title {
		font-size: 21px;
	}

	.tgai-ytt-wrapper .tgai-ytt-row {
		grid-template-columns: 1fr;
		gap: 12px;
	}

	.tgai-ytt-wrapper .tgai-ytt-results-header {
		flex-direction: column;
		align-items: flex-start;
	}

	.tgai-ytt-wrapper .tgai-ytt-results-header .tgai-ytt-btn-secondary {
		width: 100%;
	}

	.tgai-ytt-wrapper .tgai-ytt-title-item {
		flex-direction: column;
		align-items: stretch;
	}

	.tgai-ytt-wrapper .tgai-ytt-copy-btn {
		width: 100%;
	}
}

@media (min-width: 481px) and (max-width: 767px) {
	.tgai-ytt-wrapper .tgai-ytt-card {
		padding: 24px;
	}
}
