/*!
 * AI Meta Title & Description Generator - Frontend Styles
 * Modern, minimal, professional, fully responsive, accessible.
 */

.amg-wrapper {
	--amg-primary: #4f46e5;
	--amg-primary-hover: #4338ca;
	--amg-primary-light: #eef2ff;
	--amg-success: #16a34a;
	--amg-warning: #d97706;
	--amg-danger: #dc2626;
	--amg-bg: #ffffff;
	--amg-surface: #f9fafb;
	--amg-border: #e5e7eb;
	--amg-text: #111827;
	--amg-text-muted: #6b7280;
	--amg-radius-lg: 16px;
	--amg-radius-md: 10px;
	--amg-radius-sm: 6px;
	--amg-shadow: 0 4px 24px rgba(17, 24, 39, 0.08);
	--amg-shadow-sm: 0 1px 3px rgba(17, 24, 39, 0.08);

	max-width: 640px;
	margin: 2rem auto;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
	.amg-wrapper {
		--amg-primary: #818cf8;
		--amg-primary-hover: #a5b4fc;
		--amg-primary-light: #1e1b4b;
		--amg-success: #4ade80;
		--amg-warning: #fbbf24;
		--amg-danger: #f87171;
		--amg-bg: #18181b;
		--amg-surface: #1f1f23;
		--amg-border: #33333a;
		--amg-text: #f4f4f5;
		--amg-text-muted: #a1a1aa;
		--amg-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
		--amg-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
	}
}

.amg-wrapper *,
.amg-wrapper *::before,
.amg-wrapper *::after {
	box-sizing: border-box;
}

.amg-card {
	background: var(--amg-bg);
	border: 1px solid var(--amg-border);
	border-radius: var(--amg-radius-lg);
	box-shadow: var(--amg-shadow);
	padding: 2rem;
	transition: box-shadow 0.2s ease;
}

@media (max-width: 480px) {
	.amg-card {
		padding: 1.25rem;
		border-radius: var(--amg-radius-md);
	}
}

.amg-header {
	margin-bottom: 1.5rem;
	text-align: center;
}

.amg-title {
	margin: 0 0 0.5rem;
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--amg-text);
	line-height: 1.3;
}

.amg-subtitle {
	margin: 0;
	font-size: 0.9375rem;
	color: var(--amg-text-muted);
	line-height: 1.5;
}

.amg-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.amg-form {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.amg-field {
	display: flex;
	flex-direction: column;
	gap: 0.375rem;
}

.amg-input {
	width: 100%;
	padding: 0.875rem 1rem;
	font-size: 1rem;
	color: var(--amg-text);
	background: var(--amg-surface);
	border: 1.5px solid var(--amg-border);
	border-radius: var(--amg-radius-md);
	outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.amg-input::placeholder {
	color: var(--amg-text-muted);
}

.amg-input:focus,
.amg-input:focus-visible {
	border-color: var(--amg-primary);
	box-shadow: 0 0 0 3px var(--amg-primary-light);
}

.amg-input.amg-input-invalid {
	border-color: var(--amg-danger);
}

.amg-error {
	min-height: 1.125rem;
	font-size: 0.8125rem;
	color: var(--amg-danger);
	font-weight: 500;
}

.amg-actions {
	display: flex;
}

.amg-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.875rem 1.5rem;
	font-size: 0.9375rem;
	font-weight: 600;
	border-radius: var(--amg-radius-md);
	border: 1.5px solid transparent;
	cursor: pointer;
	transition: transform 0.1s ease, background-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
	font-family: inherit;
	line-height: 1.2;
}

.amg-btn:active:not(:disabled) {
	transform: scale(0.98);
}

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

.amg-btn:disabled {
	opacity: 0.65;
	cursor: not-allowed;
}

.amg-btn-primary {
	background: var(--amg-primary);
	color: #ffffff;
	width: 100%;
}

.amg-btn-primary:hover:not(:disabled) {
	background: var(--amg-primary-hover);
	box-shadow: var(--amg-shadow-sm);
}

.amg-btn-secondary {
	background: var(--amg-surface);
	color: var(--amg-text);
	border-color: var(--amg-border);
}

.amg-btn-secondary:hover:not(:disabled) {
	background: var(--amg-primary-light);
	border-color: var(--amg-primary);
}

.amg-btn-ghost {
	background: transparent;
	color: var(--amg-text-muted);
}

.amg-btn-ghost:hover:not(:disabled) {
	color: var(--amg-danger);
}

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

.amg-btn-loading .amg-spinner {
	display: inline-block;
}

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

/* Loading skeleton */
.amg-skeleton {
	margin-top: 1.5rem;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.amg-skeleton-line {
	border-radius: var(--amg-radius-sm);
	background: linear-gradient(90deg, var(--amg-surface) 25%, var(--amg-border) 50%, var(--amg-surface) 75%);
	background-size: 200% 100%;
	animation: amg-shimmer 1.4s ease-in-out infinite;
}

.amg-skeleton-line-label {
	width: 30%;
	height: 12px;
	margin-top: 0.75rem;
}

.amg-skeleton-line-box {
	width: 100%;
	height: 40px;
}

.amg-skeleton-line-tall {
	height: 72px;
}

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

/* Retry box */
.amg-retry-box {
	margin-top: 1.5rem;
	padding: 1rem;
	text-align: center;
	background: var(--amg-surface);
	border: 1px dashed var(--amg-danger);
	border-radius: var(--amg-radius-md);
}

.amg-retry-message {
	margin: 0 0 0.75rem;
	color: var(--amg-danger);
	font-size: 0.875rem;
	font-weight: 500;
}

/* Results */
.amg-results {
	margin-top: 1.5rem;
	animation: amg-fade-in 0.4s ease both;
}

@keyframes amg-fade-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.amg-score-row {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	margin-bottom: 1.5rem;
	position: relative;
}

.amg-seo-score {
	position: relative;
	width: 80px;
	height: 80px;
}

.amg-score-ring {
	width: 80px;
	height: 80px;
	transform: rotate(-90deg);
}

.amg-score-ring-bg {
	fill: none;
	stroke: var(--amg-border);
	stroke-width: 6;
}

.amg-score-ring-fill {
	fill: none;
	stroke: var(--amg-success);
	stroke-width: 6;
	stroke-linecap: round;
	stroke-dasharray: 213.6;
	stroke-dashoffset: 213.6;
	transition: stroke-dashoffset 0.8s ease, stroke 0.3s ease;
}

.amg-score-value {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	text-align: center;
	line-height: 1.1;
}

.amg-score-value span {
	display: block;
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--amg-text);
}

.amg-score-value small {
	font-size: 0.625rem;
	color: var(--amg-text-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.amg-success-check {
	width: 32px;
	height: 32px;
	opacity: 0;
	transform: scale(0.6);
}

.amg-success-check.amg-show-check {
	animation: amg-check-pop 0.5s ease forwards;
}

@keyframes amg-check-pop {
	to {
		opacity: 1;
		transform: scale(1);
	}
}

.amg-check-circle {
	stroke: var(--amg-success);
	stroke-width: 3;
	stroke-dasharray: 151;
	stroke-dashoffset: 151;
	animation: amg-circle-draw 0.5s ease forwards;
}

.amg-check-mark {
	stroke: var(--amg-success);
	stroke-width: 4;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-dasharray: 36;
	stroke-dashoffset: 36;
	animation: amg-mark-draw 0.3s 0.4s ease forwards;
}

@keyframes amg-circle-draw {
	to {
		stroke-dashoffset: 0;
	}
}

@keyframes amg-mark-draw {
	to {
		stroke-dashoffset: 0;
	}
}

.amg-result-block {
	margin-bottom: 1.25rem;
}

.amg-result-label-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 0.375rem;
}

.amg-result-label {
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--amg-text);
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.amg-copy-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	padding: 0.3rem 0.7rem;
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--amg-primary);
	background: var(--amg-primary-light);
	border: none;
	border-radius: 999px;
	cursor: pointer;
	transition: background-color 0.15s ease, transform 0.1s ease;
	font-family: inherit;
}

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

.amg-copy-btn:active {
	transform: scale(0.95);
}

.amg-copy-btn:focus-visible {
	outline: 2px solid var(--amg-primary);
	outline-offset: 2px;
}

.amg-copy-btn.amg-copied {
	background: var(--amg-success);
	color: #ffffff;
}

.amg-output {
	width: 100%;
	resize: none;
	padding: 0.75rem 1rem;
	font-size: 0.9375rem;
	font-family: inherit;
	color: var(--amg-text);
	background: var(--amg-surface);
	border: 1.5px solid var(--amg-border);
	border-radius: var(--amg-radius-md);
	line-height: 1.5;
}

.amg-output:focus {
	outline: 2px solid var(--amg-primary);
	outline-offset: 1px;
}

.amg-counter-row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-top: 0.375rem;
}

.amg-progress-bar {
	flex: 1;
	height: 5px;
	border-radius: 999px;
	background: var(--amg-border);
	overflow: hidden;
}

.amg-progress-fill {
	height: 100%;
	width: 0%;
	background: var(--amg-success);
	border-radius: 999px;
	transition: width 0.4s ease, background-color 0.3s ease;
}

.amg-char-counter {
	flex-shrink: 0;
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--amg-success);
	white-space: nowrap;
}

.amg-char-counter.amg-counter-warning {
	color: var(--amg-warning);
}

.amg-char-counter.amg-counter-danger {
	color: var(--amg-danger);
}

.amg-progress-fill.amg-counter-warning {
	background: var(--amg-warning);
}

.amg-progress-fill.amg-counter-danger {
	background: var(--amg-danger);
}

.amg-result-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.625rem;
	margin-top: 1.5rem;
}

.amg-result-actions .amg-btn {
	flex: 1 1 auto;
	width: auto;
	white-space: nowrap;
}

.amg-result-actions .amg-btn-primary {
	flex-basis: 100%;
}

@media (min-width: 480px) {
	.amg-result-actions .amg-btn-primary {
		flex-basis: auto;
	}
}

/* Toast notifications */
.amg-toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%) translateY(20px);
	background: var(--amg-text);
	color: var(--amg-bg);
	padding: 0.75rem 1.25rem;
	border-radius: var(--amg-radius-md);
	font-size: 0.875rem;
	font-weight: 500;
	box-shadow: var(--amg-shadow);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s ease, transform 0.25s ease;
	z-index: 9999;
	max-width: 90vw;
	text-align: center;
}

.amg-toast.amg-toast-visible {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

.amg-toast.amg-toast-error {
	background: var(--amg-danger);
	color: #ffffff;
}

.amg-toast.amg-toast-success {
	background: var(--amg-success);
	color: #ffffff;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
	.amg-wrapper *,
	.amg-wrapper *::before,
	.amg-wrapper *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
}
