/* [FRONTEND-COPILOT] Main stylesheet following standard structure */
/* [FRONTEND-COPILOT] HP-FEA-002: Enhanced responsive design and accessibility */

/* CSS Reset & Base */
*,
*::before,
*::after {
	box-sizing: border-box;
}

:root {
	--primary-color: #2563eb;
	--primary-hover: #1d4ed8;
	--secondary-color: #64748b;
	--success-color: #059669;
	--error-color: #dc2626;
	--background-color: #f8fafc;
	--surface-color: #ffffff;
	--text-primary: #1e293b;
	--text-secondary: #64748b;
	--border-color: #e2e8f0;
	--shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
	--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
	--radius: 0.5rem;
	--font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

body {
	font-family: var(--font-family);
	background-color: var(--background-color);
	color: var(--text-primary);
	line-height: 1.6;
	margin: 0;
	padding: 0;
	min-height: 100vh;
}

/* Container */
.container {
	max-width: 600px;
	margin: 0 auto;
	padding: 2rem 1rem;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

/* Header */
.header {
	text-align: center;
	margin-bottom: 3rem;
}

.header__title {
	font-size: 3rem;
	font-weight: 800;
	margin: 0;
	background: linear-gradient(135deg, var(--primary-color), #7c3aed);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

.header__subtitle {
	font-size: 1.1rem;
	color: var(--text-secondary);
	margin: 0.5rem 0 0 0;
}

/* Main Content */
.main {
	flex: 1;
}

/* Form Section */
.form-section {
	background: var(--surface-color);
	border-radius: var(--radius);
	padding: 2rem;
	box-shadow: var(--shadow);
	margin-bottom: 2rem;
}

.form__group {
	margin-bottom: 1.5rem;
}

.form__group--checkbox {
	margin-bottom: 2rem;
}

.form__label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.5rem;
	color: var(--text-primary);
}

.form__optional {
	font-weight: 400;
	color: var(--text-secondary);
	font-size: 0.9rem;
}

.form__input {
	width: 100%;
	padding: 0.75rem 1rem;
	border: 2px solid var(--border-color);
	border-radius: var(--radius);
	font-size: 1rem;
	transition: border-color 0.15s ease;
	background: var(--surface-color);
}

.form__input:focus {
	outline: none;
	border-color: var(--primary-color);
	box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.form__input:invalid {
	border-color: var(--error-color);
}

.form__input--normalized {
	border-color: var(--success-color);
	background-color: #f0fdf4;
	transition: border-color 0.2s, background-color 0.2s;
}

.form__input--invalid {
	border-color: var(--error-color) !important;
	background-color: #fef2f2 !important;
	transition: border-color 0.2s, background-color 0.2s;
}

.form__help {
	display: block;
	margin-top: 0.25rem;
	font-size: 0.875rem;
	color: var(--text-secondary);
}

/* Enhanced visual feedback states */
.form__input--normalizing {
	border-left: 3px solid #f59e0b;
	background: linear-gradient(90deg, #fef3c7 0%, transparent 100%);
}

.form__input--valid {
	border-left: 3px solid #10b981;
	background: #f0fdf4;
}

.form__input--invalid {
	border-left: 3px solid #ef4444;
	background: #fef2f2;
}

/* Checkbox */
.form__checkbox {
	display: flex;
	align-items: center;
	cursor: pointer;
	font-weight: 500;
}

.form__checkbox input {
	position: absolute;
	opacity: 0;
	cursor: pointer;
}

.form__checkbox-mark {
	position: relative;
	display: inline-block;
	width: 1.25rem;
	height: 1.25rem;
	background: var(--surface-color);
	border: 2px solid var(--border-color);
	border-radius: 0.25rem;
	margin-right: 0.75rem;
	transition: all 0.15s ease;
}

.form__checkbox input:checked + .form__checkbox-mark {
	background: var(--primary-color);
	border-color: var(--primary-color);
}

.form__checkbox input:checked + .form__checkbox-mark::after {
	content: '✓';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	color: white;
	font-size: 0.875rem;
	font-weight: 600;
}

/* Buttons */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.75rem 1.5rem;
	border: none;
	border-radius: var(--radius);
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.15s ease;
	text-decoration: none;
	position: relative;
	min-height: 3rem;
}

.btn--primary {
	background: var(--primary-color);
	color: white;
}

.btn--primary:hover:not(:disabled) {
	background: var(--primary-hover);
	transform: translateY(-1px);
	box-shadow: var(--shadow-lg);
}

.btn--secondary {
	background: var(--secondary-color);
	color: white;
}

.btn--secondary:hover {
	background: #475569;
}

.btn--outline {
	background: transparent;
	color: var(--primary-color);
	border: 2px solid var(--primary-color);
}

.btn--outline:hover {
	background: var(--primary-color);
	color: white;
}

.btn--text {
	background: transparent;
	color: var(--text-secondary);
	padding: 0.5rem 1rem;
}

.btn--text:hover {
	color: var(--primary-color);
}

.btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none;
}

.btn__text {
	display: inline;
}

.btn__spinner {
	display: none;
	width: 1rem;
	height: 1rem;
	border: 2px solid transparent;
	border-top: 2px solid currentColor;
	border-radius: 50%;
	animation: spin 1s linear infinite;
}

.btn--loading {
	cursor: not-allowed;
	position: relative;
}

.btn--loading .btn__text {
	opacity: 0;
}

.btn--loading .btn__spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
}

.btn--loading .btn__text {
	display: none;
}

.btn--loading .btn__spinner {
	display: inline-block;
}

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

/* Results Section */
.results {
	background: var(--surface-color);
	border-radius: var(--radius);
	padding: 2rem;
	box-shadow: var(--shadow);
	margin-bottom: 2rem;
	border-left: 4px solid var(--success-color);
}

.results__title {
	margin: 0 0 1.5rem 0;
	color: var(--success-color);
	font-size: 1.25rem;
}

.results__url-container {
	display: flex;
	gap: 0.75rem;
	margin-bottom: 1.5rem;
}

.results__url {
	flex: 1;
	padding: 0.75rem 1rem;
	border: 2px solid var(--border-color);
	border-radius: var(--radius);
	background: #f1f5f9;
	font-family: 'Monaco', 'Menlo', monospace;
	font-size: 0.9rem;
}

.results__actions {
	display: flex;
	gap: 1rem;
	flex-wrap: wrap;
}

/* Stats Section */
.stats {
	background: var(--surface-color);
	border-radius: var(--radius);
	padding: 2rem;
	box-shadow: var(--shadow);
	margin-bottom: 2rem;
}

.stats__title {
	margin: 0 0 1.5rem 0;
	color: var(--text-primary);
	font-size: 1.25rem;
}

.stats__subtitle {
	margin: 2rem 0 1rem 0;
	color: var(--text-primary);
	font-size: 1.1rem;
}

.stats__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 1rem;
	margin-bottom: 2rem;
}

.stats__card {
	background: #f8fafc;
	padding: 1.5rem;
	border-radius: var(--radius);
	text-align: center;
	border: 1px solid var(--border-color);
}

.stats__number {
	font-size: 2rem;
	font-weight: 700;
	color: var(--primary-color);
	margin-bottom: 0.5rem;
}

.stats__label {
	color: var(--text-secondary);
	font-size: 0.875rem;
	font-weight: 500;
}

.stats__table-container {
	overflow-x: auto;
	border-radius: var(--radius);
	border: 1px solid var(--border-color);
}

.stats__table {
	width: 100%;
	border-collapse: collapse;
	background: var(--surface-color);
}

.stats__table th,
.stats__table td {
	padding: 0.75rem 1rem;
	text-align: left;
	border-bottom: 1px solid var(--border-color);
}

.stats__table th {
	background: #f8fafc;
	font-weight: 600;
	color: var(--text-primary);
}

.stats__table tr:last-child td {
	border-bottom: none;
}

/* Error Section */
.error {
	background: var(--surface-color);
	border-radius: var(--radius);
	padding: 2rem;
	box-shadow: var(--shadow);
	margin-bottom: 2rem;
	border-left: 4px solid var(--error-color);
}

.error__title {
	margin: 0 0 1rem 0;
	color: var(--error-color);
	font-size: 1.25rem;
}

.error__message {
	margin: 0 0 1.5rem 0;
	color: var(--text-secondary);
}

/* Footer */
.footer {
	text-align: center;
	padding: 2rem 0 1rem 0;
	color: var(--text-secondary);
	font-size: 0.875rem;
	border-top: 1px solid var(--border-color);
	margin-top: auto;
}

/* Accessibility: Screen reader only content */
.visually-hidden {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* Enhanced focus states for better accessibility */
.btn:focus-visible,
.form__input:focus-visible {
	outline: 3px solid var(--primary-color);
	outline-offset: 2px;
	box-shadow: 0 0 0 2px var(--surface-color), 0 0 0 5px var(--primary-color);
}

.form__checkbox input:focus-visible + .form__checkbox-mark {
	outline: 3px solid var(--primary-color);
	outline-offset: 2px;
	box-shadow: 0 0 0 2px var(--surface-color), 0 0 0 5px var(--primary-color);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
	:root {
		--border-color: #000000;
		--text-secondary: #000000;
		--shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
	}

	.btn--outline {
		border-width: 3px;
	}

	.form__input {
		border-width: 2px;
	}
}

/* Enhanced mobile responsiveness */
@media (max-width: 480px) {
	.container {
		padding: 0.75rem 0.5rem;
	}

	.header__title {
		font-size: 2rem;
	}

	.form-section,
	.results,
	.stats,
	.error {
		padding: 1rem;
		margin-bottom: 1rem;
	}

	.form__input,
	.btn {
		font-size: 16px; /* Prevent zoom on iOS */
	}

	.results__url-container {
		flex-direction: column;
		gap: 0.5rem;
	}

	.results__actions {
		flex-direction: column;
		align-items: stretch;
	}

	.btn {
		width: 100%;
		justify-content: center;
	}

	.stats__table-container {
		font-size: 0.875rem;
	}

	.stats__table th,
	.stats__table td {
		padding: 0.5rem 0.75rem;
	}
}

/* Tablet landscape adjustments */
@media (min-width: 481px) and (max-width: 768px) {
	.container {
		max-width: 90%;
		padding: 1.5rem 1rem;
	}

	.stats__grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 1.5rem;
	}
}

/* Large screen optimizations */
@media (min-width: 1024px) {
	.container {
		max-width: 700px;
	}

	.form-section,
	.results,
	.stats,
	.error {
		padding: 2.5rem;
	}

	.stats__grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 2rem;
	}
}

/* Form validation states */
.form__input:invalid:not(:focus) {
	border-color: var(--error-color);
	background-color: #fef2f2;
}

.form__input:valid:not(:placeholder-shown) {
	border-color: var(--success-color);
	background-color: #f0fdf4;
}

.form__input[aria-invalid='true'] {
	border-color: var(--error-color);
	background-color: #fef2f2;
}

.form__input[aria-invalid='false']:not(:placeholder-shown) {
	border-color: var(--success-color);
	background-color: #f0fdf4;
}

/* Copy button feedback animation */
@keyframes copy-success {
	0% {
		transform: scale(1);
	}
	50% {
		transform: scale(1.05);
	}
	100% {
		transform: scale(1);
	}
}

.btn--copied {
	animation: copy-success 0.3s ease;
	background-color: var(--success-color) !important;
}

/* Error section enhanced styling */
.error[role='alert'] {
	animation: slideIn 0.3s ease;
}

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

/* Results section animation */
.results[aria-live='polite'] {
	animation: fadeInUp 0.4s ease;
}

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

/* Print styles */
@media print {
	.btn,
	.form__checkbox,
	.form__input,
	.error,
	.footer {
		display: none !important;
	}

	.results__url {
		border: 1px solid #000;
		background: white;
		font-size: 14px;
	}

	.container {
		max-width: 100%;
		padding: 0;
	}

	.stats__table {
		border: 1px solid #000;
	}

	.stats__table th,
	.stats__table td {
		border: 1px solid #000;
	}
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}

	.btn__spinner {
		animation: none;
		border: 2px solid currentColor;
		border-top: 2px solid transparent;
	}
}

/* Add these styles for alias preview */
.alias-preview {
	margin-top: 0.25rem;
	font-size: 0.95em;
	color: var(--text-secondary);
}
.alias-preview--normalized .alias-preview__value {
	background: #f0fdf4;
	color: var(--primary-color);
	padding: 0.1em 0.4em;
	border-radius: 0.25em;
	font-family: monospace;
}
.alias-preview--warning {
	color: var(--error-color);
}

/* Enhanced URL preview styles */
.url-preview {
	font-size: 0.875rem;
	margin-top: 0.5rem;
	padding: 0.75rem;
	border-radius: 0.375rem;
	border: 1px solid;
	transition: all 0.2s ease;
	animation: fadeIn 0.3s ease;
}

.url-preview--normalized {
	background: #f0fdf4;
	color: #166534;
	border-color: #bbf7d0;
}

.url-preview--error {
	background: #fef2f2;
	color: #dc2626;
	border-color: #fecaca;
}

.url-preview--validating {
	background: #f1f5f9;
	color: #475569;
	border-color: #cbd5e1;
}

.url-preview--success {
	background: #f0fdf4;
	color: #166534;
	border-color: #bbf7d0;
}

.url-preview--warning {
	background: #fffbeb;
	color: #d97706;
	border-color: #fed7aa;
}

.url-preview--info {
	background: #eff6ff;
	color: #1d4ed8;
	border-color: #bfdbfe;
}

.url-preview__label {
	font-weight: 500;
	margin-right: 0.5rem;
}

.url-preview__url {
	background: rgba(0, 0, 0, 0.1);
	padding: 0.125rem 0.375rem;
	border-radius: 0.25rem;
	font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
	font-size: 0.8rem;
}

.url-preview__errors {
	color: inherit;
	font-style: italic;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(-5px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

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

.url-preview--validating .url-preview__label::after {
	content: '...';
	animation: pulse 1.5s ease-in-out infinite;
}

/* Enhanced input states */
.form__input--url-valid {
	border-left: 4px solid var(--success-color);
	background: linear-gradient(90deg, #f0fdf4 0%, transparent 100%);
}

.form__input--url-invalid {
	border-left: 4px solid var(--error-color);
	background: linear-gradient(90deg, #fef2f2 0%, transparent 100%);
}

/* Enhanced alias preview styles */
.alias-preview {
	font-size: 0.875rem;
	margin-top: 0.5rem;
	padding: 0.75rem;
	border-radius: 0.375rem;
	border: 1px solid;
	transition: all 0.2s ease;
	animation: slideIn 0.3s ease;
}

.alias-preview--normalized {
	background: #f0fdf4;
	color: #166534;
	border-color: #bbf7d0;
}

.alias-preview--error {
	background: #fef2f2;
	color: #dc2626;
	border-color: #fecaca;
}

.alias-preview--warning {
	background: #fffbeb;
	color: #92400e;
	border-color: #fde68a;
}

.alias-preview__label {
	font-weight: 500;
	margin-right: 0.5rem;
}

.alias-preview__value {
	background: rgba(0, 0, 0, 0.1);
	padding: 0.125rem 0.375rem;
	border-radius: 0.25rem;
	font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
	font-size: 0.8rem;
}

.alias-preview__hint {
	font-size: 0.75rem;
	opacity: 0.8;
	margin-left: 0.5rem;
}

.alias-preview__errors {
	color: inherit;
	font-style: italic;
}

.alias-preview__suggestion {
	display: block;
	margin-top: 0.25rem;
	font-style: italic;
	opacity: 0.8;
}

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