/*
 * Instagram Bio Generator CSS
 * Premium, fully-responsive styling with Instagram branding details,
 * fluid typography, touch-friendly targets, and container query support.
 */

:root {
	--ibg-gradient: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
	--ibg-gradient-hover: linear-gradient(45deg, #e08423 0%, #d6582c 25%, #cc1733 50%, #bc1356 75%, #ac0878 100%);
	--ibg-primary: #0095f6;
	--ibg-primary-hover: #1877f2;
	--ibg-text: #262626;
	--ibg-text-muted: #737373;
	--ibg-border: #dbdbdb;
	--ibg-border-subtle: #efefef;
	--ibg-bg-input: #fafafa;
	--ibg-radius-lg: 16px;
	--ibg-radius-md: 10px;
	--ibg-radius-sm: 8px;
}

/* Base Container */
#ibg-generator-app {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--ibg-text);
	background-color: #ffffff;
	border-radius: var(--ibg-radius-lg);
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
	max-width: 850px;
	width: 100%;
	margin: 1.5rem auto;
	padding: 1.75rem;
	box-sizing: border-box;
	border: 1px solid rgba(0, 0, 0, 0.06);
	/* Container Query Context */
	container-type: inline-size;
	container-name: ibg-container;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

/* Fluid Resizing Across Breakpoints */
@media (max-width: 768px) {
	#ibg-generator-app {
		margin: 0.75rem auto;
		padding: 1.25rem;
		border-radius: var(--ibg-radius-md);
		box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
	}
}

@media (max-width: 480px) {
	#ibg-generator-app {
		margin: 0.35rem auto;
		padding: 1rem 0.85rem;
		border-radius: var(--ibg-radius-sm);
	}
}

/* Ensure box-sizing applies to all plugin elements */
#ibg-generator-app *,
#ibg-generator-app *::before,
#ibg-generator-app *::after {
	box-sizing: border-box;
}

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

.ibg-title {
	font-size: clamp(1.4rem, 4vw, 2.25rem);
	font-weight: 800;
	line-height: 1.2;
	margin: 0 0 0.5rem 0;
	background: var(--ibg-gradient);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	display: inline-block;
}

.ibg-subtitle {
	color: var(--ibg-text-muted);
	font-size: clamp(0.875rem, 2.5vw, 1.05rem);
	line-height: 1.45;
	margin: 0;
	padding: 0 0.5rem;
}

.ibg-intro {
	color: #000000;
	font-size: clamp(0.925rem, 2.2vw, 1.025rem);
	line-height: 1.55;
	margin: 0 auto;
	max-width: 680px;
	padding: 0 0.5rem;
}

.ibg-highlights-wrap {
	margin-top: 0.85rem;
	display: flex;
	justify-content: center;
}

.ibg-highlights {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 0.25rem;
	min-height: 38px;
	padding: 6px 18px;
	max-width: 100%;
	font-size: 13px;
	font-weight: 600;
	color: #262626;
	background: #ffffff;
	border-radius: 999px;
	border: 1px solid rgba(225, 48, 108, 0.35);
	box-shadow: 0 2px 8px rgba(225, 48, 108, 0.08);
	box-sizing: border-box;
}

.ibg-highlight-item {
	letter-spacing: 0.01em;
}

.ibg-highlight-dot {
	color: #dc2743;
	background: var(--ibg-gradient);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	font-weight: 900;
	font-size: 14px;
	line-height: 1;
	display: inline-block;
	vertical-align: middle;
	margin: 0 4px;
}

/* Form Structure */
.ibg-form {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

.ibg-section {
	border-style: solid;
	border-width: 0 0 2px 0;
	border-image: var(--ibg-gradient) 1;
	padding-bottom: 1.75rem;
	margin-bottom: 0.25rem;
}

.ibg-section:last-of-type {
	border-width: 0;
	padding-bottom: 0;
	margin-bottom: 0;
}

.ibg-section-title {
	font-size: clamp(0.95rem, 2.5vw, 1.05rem);
	font-weight: 700;
	line-height: 1.3;
	margin: 0 0 1rem 0;
	color: var(--ibg-text);
	display: flex;
	align-items: center;
	gap: 0.4rem;
}

.ibg-section-desc {
	font-size: 0.85rem;
	color: var(--ibg-text-muted);
	margin: -0.5rem 0 0.85rem 0;
	line-height: 1.4;
}

/* Form Grid */
.ibg-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1.25rem;
}

.ibg-field {
	display: flex;
	flex-direction: column;
	gap: 0.45rem;
	min-width: 0;
}

.ibg-field-full {
	grid-column: span 2;
}

/* Form Elements */
.ibg-field label {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--ibg-text);
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 0.35rem;
}

/* Inputs & Selects - 16px min font size on mobile to prevent iOS Safari auto-zoom */
.ibg-field input[type="text"],
.ibg-field input[type="number"],
.ibg-field select {
	font-family: inherit;
	font-size: 16px; /* Strictly 16px prevents iOS Safari auto-zoom */
	min-height: 48px;
	padding: 0.75rem 1rem;
	border: 1px solid var(--ibg-border);
	border-radius: var(--ibg-radius-sm);
	background-color: var(--ibg-bg-input);
	color: var(--ibg-text);
	outline: none;
	transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
	width: 100%;
	line-height: 1.3;
	-webkit-tap-highlight-color: transparent;
}

/* Custom dropdown chevron for selects across all mobile and desktop OS */
.ibg-field select {
	padding-right: 2.5rem;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.85rem center;
	background-size: 14px;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	cursor: pointer;
}

.ibg-field input::placeholder {
	color: #b0b0b0;
}

/* Focus States */
.ibg-field input:focus,
.ibg-field select:focus {
	border-color: #cc2366;
	background-color: #ffffff;
	box-shadow: 0 0 0 3px rgba(204, 35, 102, 0.15);
}

/* Primary Button (Generate) */
.ibg-btn-generate {
	background: var(--ibg-gradient);
	color: #ffffff;
	border: none;
	border-radius: var(--ibg-radius-md);
	padding: 0.85rem 1.5rem;
	min-height: 52px;
	font-size: clamp(1rem, 2.5vw, 1.08rem);
	font-weight: 700;
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
	width: 100%;
	margin-top: 0.75rem;
	box-shadow: 0 4px 16px rgba(220, 39, 67, 0.25);
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.ibg-btn-generate:hover {
	background: var(--ibg-gradient-hover);
	transform: translateY(-1px);
	box-shadow: 0 6px 22px rgba(220, 39, 67, 0.35);
}

.ibg-btn-generate:active {
	transform: scale(0.99);
	box-shadow: 0 2px 10px rgba(220, 39, 67, 0.2);
}

.ibg-btn-generate:focus {
	outline: none;
	box-shadow: 0 0 0 4px rgba(188, 24, 136, 0.35);
}

.ibg-btn-generate:disabled {
	background: #dbdbdb;
	cursor: not-allowed;
	box-shadow: none;
	transform: none;
	filter: none;
}

/* Loading Spinner */
.ibg-spinner {
	width: 20px;
	height: 20px;
	border: 3px solid rgba(255, 255, 255, 0.35);
	border-radius: 50%;
	border-top-color: #ffffff;
	animation: ibg-spin 0.8s linear infinite;
	flex-shrink: 0;
}

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

/* Results Section */
.ibg-results-section {
	margin-top: 2.75rem;
	border-top: 1px solid var(--ibg-border-subtle);
	padding-top: 2rem;
	scroll-margin-top: 24px;
}

.ibg-results-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.75rem;
	margin-bottom: 1.5rem;
}

.ibg-results-title {
	font-size: clamp(1.2rem, 3.5vw, 1.5rem);
	font-weight: 700;
	line-height: 1.25;
	margin: 0;
	color: var(--ibg-text);
}

.ibg-btn-secondary {
	font-family: inherit;
	background-color: #ffffff;
	border: 1px solid var(--ibg-border);
	color: var(--ibg-text);
	border-radius: var(--ibg-radius-sm);
	padding: 0.6rem 1rem;
	min-height: 42px;
	font-weight: 600;
	font-size: 0.875rem;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.ibg-btn-secondary:hover {
	background-color: var(--ibg-bg-input);
	border-color: #c7c7c7;
}

.ibg-btn-secondary:active {
	transform: scale(0.98);
}

.ibg-btn-secondary:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.12);
}

.ibg-icon-refresh {
	transition: transform 0.4s ease;
	flex-shrink: 0;
}

.ibg-btn-secondary:hover .ibg-icon-refresh {
	transform: rotate(180deg);
}

/* Bios Cards Grid */
.ibg-bios-grid {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	margin-bottom: 2rem;
}

/* Bio Card */
.ibg-bio-card {
	background-color: #ffffff;
	border: 1px solid var(--ibg-border-subtle);
	border-radius: var(--ibg-radius-md);
	padding: 1.1rem 1.25rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	position: relative;
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
	animation: ibg-fade-in 0.3s ease forwards;
}

.ibg-bio-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
	border-color: rgba(204, 35, 102, 0.25);
}

.ibg-bio-left {
	display: flex;
	align-items: flex-start;
	gap: 0.9rem;
	flex-grow: 1;
	min-width: 0;
}

/* Instagram Avatar */
.ibg-avatar {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--ibg-gradient);
	padding: 2px;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.ibg-avatar-inner {
	background-color: #ffffff;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.2rem;
}

.ibg-bio-content {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	flex-grow: 1;
	min-width: 0;
}

.ibg-bio-text {
	font-size: 0.975rem;
	line-height: 1.55;
	color: var(--ibg-text);
	white-space: pre-line;
	word-break: break-word;
	overflow-wrap: break-word;
	margin: 0;
}

.ibg-bio-meta {
	font-size: 0.775rem;
	color: var(--ibg-text-muted);
	font-weight: 500;
	word-break: break-word;
}

/* Copy Button inside Card */
.ibg-btn-copy {
	background-color: var(--ibg-primary);
	color: #ffffff;
	border: none;
	border-radius: var(--ibg-radius-sm);
	padding: 0.55rem 1.1rem;
	min-height: 38px;
	font-weight: 600;
	font-size: 0.875rem;
	cursor: pointer;
	transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.ibg-btn-copy:hover {
	background-color: var(--ibg-primary-hover);
}

.ibg-btn-copy:active {
	transform: scale(0.98);
}

.ibg-btn-copy:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgba(0, 149, 246, 0.35);
}

.ibg-btn-copy.copied {
	background-color: #008a00 !important;
}

/* Footer Section */
.ibg-actions-footer {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
	margin-top: 1.5rem;
}

.ibg-btn-primary {
	background-color: var(--ibg-primary);
	color: #ffffff;
	border: none;
	border-radius: var(--ibg-radius-sm);
	padding: 0.85rem 2rem;
	min-height: 48px;
	font-size: 0.95rem;
	font-weight: 700;
	cursor: pointer;
	transition: background-color 0.2s ease, transform 0.15s ease;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

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

.ibg-btn-primary:active {
	transform: scale(0.98);
}

.ibg-btn-primary:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgba(0, 149, 246, 0.4);
}

.ibg-limit-info {
	font-size: 0.85rem;
	color: var(--ibg-text-muted);
	margin: 0;
	text-align: center;
}

/* Toast styling with Safe Area Inset support */
.ibg-toast {
	position: fixed;
	bottom: max(1.5rem, calc(1rem + env(safe-area-inset-bottom, 0px)));
	left: 50%;
	transform: translateX(-50%) translateY(80px);
	background-color: #1a1a1a;
	color: #ffffff;
	padding: 0.85rem 1.65rem;
	border-radius: 30px;
	font-size: 0.9rem;
	font-weight: 500;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
	z-index: 999999;
	opacity: 0;
	pointer-events: none;
	transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s ease;
	max-width: calc(100vw - 2rem);
	text-align: center;
	box-sizing: border-box;
}

.ibg-toast.show {
	transform: translateX(-50%) translateY(0);
	opacity: 1;
	pointer-events: auto;
}

/* Fade in Animation */
@keyframes ibg-fade-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS: Tablet & Mobile (Screens <= 768px)
   ========================================================================== */
@media (max-width: 768px) {
	.ibg-grid {
		grid-template-columns: 1fr;
		gap: 1rem;
	}

	.ibg-field-full {
		grid-column: span 1;
	}

	/* Stack Bio Cards Vertically for thumb reach on mobile */
	.ibg-bio-card {
		flex-direction: column;
		align-items: stretch;
		padding: 1rem;
		gap: 0.85rem;
	}

	.ibg-bio-left {
		gap: 0.75rem;
	}

	.ibg-btn-copy {
		width: 100%;
		min-height: 44px; /* Touch target recommended size */
		font-size: 0.925rem;
	}

	.ibg-btn-primary {
		width: 100%;
		max-width: 320px;
	}

	.ibg-btn-secondary {
		flex-grow: 1;
		justify-content: center;
	}

	.ibg-results-header {
		flex-direction: row;
		align-items: center;
	}
}

/* Ultra-Small Mobile Devices (Screens <= 480px, e.g. iPhone SE, 320-375px) */
@media (max-width: 480px) {
	.ibg-avatar {
		width: 38px;
		height: 38px;
	}

	.ibg-avatar-inner {
		font-size: 1.05rem;
	}

	.ibg-bio-text {
		font-size: 0.925rem;
	}

	.ibg-results-header {
		flex-direction: column;
		align-items: stretch;
		gap: 0.65rem;
	}

	.ibg-results-title {
		text-align: center;
	}

	.ibg-btn-secondary {
		width: 100%;
	}
}

/* ==========================================================================
   CONTAINER QUERIES (Adapts if embedded inside sidebars or columns)
   ========================================================================== */
@supports (container-type: inline-size) {
	@container ibg-container (max-width: 600px) {
		.ibg-grid {
			grid-template-columns: 1fr;
			gap: 1rem;
		}

		.ibg-field-full {
			grid-column: span 1;
		}

		.ibg-bio-card {
			flex-direction: column;
			align-items: stretch;
			padding: 1rem;
		}

		.ibg-btn-copy {
			width: 100%;
			min-height: 44px;
		}

		.ibg-btn-primary {
			width: 100%;
			max-width: 320px;
		}
	}

	@container ibg-container (max-width: 400px) {
		.ibg-avatar {
			width: 36px;
			height: 36px;
		}

		.ibg-avatar-inner {
			font-size: 1rem;
		}

		.ibg-results-header {
			flex-direction: column;
			align-items: stretch;
		}

		.ibg-btn-secondary {
			width: 100%;
		}
	}
}
