/* THEME VARIABLES */
:root {
	--primary: #2563eb;
	--primary-hover: #1d4ed8;
	--success: #10b981;

	/* Light Mode Defaults */
	--bg: #f8fafc;
	--surface: #ffffff;
	--surface-border: #e2e8f0;
	--text: #1e293b;
	--text-secondary: #64748b;
	--input-bg: #ffffff;
	--input-border: #cbd5e1;
	--shadow: rgba(0, 0, 0, 0.05);
	--card-hover: -5px;
}

[data-theme='dark'] {
	--bg: #0f172a;
	--surface: #1e293b;
	--surface-border: #334155;
	--text: #f8fafc;
	--text-secondary: #94a3b8;
	--input-bg: #334155;
	--input-border: #475569;
	--shadow: rgba(0, 0, 0, 0.3);
	--card-hover: -5px;
}

body {
	font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
	max-width: 1200px;
	margin: 0 auto;
	padding: 20px;
	background: var(--bg);
	color: var(--text);
	user-select: none;
	-webkit-user-select: none;
	transition: background 0.3s ease, color 0.3s ease;
}

/* HEADER & LOGO */
.app-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 40px;
	padding-bottom: 20px;
	border-bottom: 1px solid var(--surface-border);
}

.logo-container {
	display: flex;
	align-items: center;
	gap: 12px;
	text-decoration: none;
}

.logo-icon {
	font-size: 32px;
}

.logo-text {
	font-size: 1.5rem;
	font-weight: 800;
	background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	letter-spacing: -0.5px;
}

/* THEME TOGGLE */
.theme-toggle {
	background: var(--surface);
	border: 1px solid var(--surface-border);
	color: var(--text);
	padding: 10px;
	border-radius: 50%;
	cursor: pointer;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s;
	font-size: 20px;
}
.theme-toggle:hover {
	background: var(--surface-border);
	transform: rotate(15deg);
}

/* MAIN CONTAINER */
.container {
	background: var(--surface);
	border-radius: 16px;
	padding: 40px;
	box-shadow: 0 10px 40px var(--shadow);
	border: 1px solid var(--surface-border);
	transition: background 0.3s ease, border-color 0.3s ease;
}

/* Ad Container Style */
.ad-banner-slot {
	width: 100%;
	min-height: 90px;
	background: var(--input-bg);
	display: flex;
	justify-content: center;
	align-items: center;
	margin-bottom: 30px;
	border-radius: 8px;
	border: 2px dashed var(--surface-border);
	color: var(--text-secondary);
	font-size: 14px;
	overflow: hidden;
}

/* Mode Selector */
.mode-selector {
	display: flex;
	margin-bottom: 30px;
	background: var(--surface-border);
	padding: 5px;
	border-radius: 12px;
}

.mode-btn {
	flex: 1;
	padding: 12px;
	background: none;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	font-size: 15px;
	font-weight: 600;
	color: var(--text-secondary);
	transition: all 0.2s;
}

.mode-btn:hover {
	color: var(--primary);
}
.mode-btn.active {
	background: var(--surface);
	color: var(--primary);
	box-shadow: 0 2px 10px var(--shadow);
}

.mode-content {
	display: none;
}
.mode-content.active {
	display: block;
	animation: slideUp 0.4s ease-out;
}

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

/* Inputs */
textarea,
input,
select {
	width: 100%;
	padding: 14px;
	margin: 8px 0;
	box-sizing: border-box;
	border: 2px solid var(--input-border);
	border-radius: 10px;
	font-size: 15px;
	background: var(--input-bg);
	color: var(--text);
	transition: all 0.2s;
	user-select: text;
	-webkit-user-select: text;
}

textarea:focus,
input:focus,
select:focus {
	border-color: var(--primary);
	outline: none;
	box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

textarea {
	min-height: 120px;
	font-family: 'JetBrains Mono', monospace;
	line-height: 1.6;
	resize: vertical;
}
.batch-textarea {
	min-height: 250px;
}

.form-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 20px;
	margin-bottom: 20px;
}

label {
	display: block;
	margin-bottom: 6px;
	font-weight: 600;
	color: var(--text-secondary);
	font-size: 0.95rem;
}

/* Buttons */
button {
	cursor: pointer;
}
.primary-btn {
	background: linear-gradient(135deg, var(--primary), var(--primary-hover));
	color: white;
	border: none;
	padding: 18px;
	font-size: 18px;
	font-weight: 700;
	border-radius: 12px;
	transition: all 0.2s;
	margin-top: 20px;
	width: 100%;
	letter-spacing: 0.5px;
	box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.primary-btn:hover {
	transform: translateY(-2px);
	box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.secondary-btn {
	background: var(--success);
	color: white;
	border: none;
	padding: 12px 24px;
	border-radius: 8px;
	font-weight: 600;
	transition: 0.2s;
}
.secondary-btn:hover {
	filter: brightness(1.1);
	transform: translateY(-1px);
}

/* Loading */
.loading {
	display: none;
	text-align: center;
	padding: 50px;
	background: var(--bg);
	border-radius: 16px;
	margin: 30px 0;
	border: 2px dashed var(--surface-border);
}

.spinner {
	width: 50px;
	height: 50px;
	border: 4px solid var(--surface-border);
	border-top: 4px solid var(--primary);
	border-radius: 50%;
	animation: spin 1s linear infinite;
	margin: 0 auto 20px;
}
@keyframes spin {
	0% {
		transform: rotate(0deg);
	}
	100% {
		transform: rotate(360deg);
	}
}

/* Results */
#result {
	margin-top: 40px;
}
.images-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 30px;
}

.image-card {
	background: var(--surface);
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 4px 6px -1px var(--shadow);
	transition: transform 0.3s, box-shadow 0.3s;
	border: 1px solid var(--surface-border);
}

.image-card:hover {
	transform: translateY(var(--card-hover));
	box-shadow: 0 20px 25px -5px var(--shadow);
}

.image-card img {
	width: 100%;
	height: 280px;
	object-fit: cover;
	display: block;
}

.image-info {
	padding: 16px;
}
.image-info .prompt {
	font-weight: 600;
	margin-bottom: 10px;
	color: var(--text);
	font-size: 0.9rem;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.image-actions {
	display: flex;
	gap: 10px;
}
.small-btn {
	flex: 1;
	padding: 10px;
	font-size: 13px;
	border-radius: 6px;
	border: none;
	color: white;
	font-weight: 500;
}
.download-btn {
	background: var(--success);
}
.view-btn {
	background: var(--text-secondary);
}

.batch-progress {
	margin: 25px 0;
	background: var(--surface-border);
	border-radius: 20px;
	overflow: hidden;
	height: 12px;
}

.progress-bar {
	height: 100%;
	background: linear-gradient(90deg, var(--primary), #60a5fa);
	width: 0%;
	transition: width 0.3s ease;
}

.status-message {
	text-align: center;
	color: var(--text-secondary);
	padding: 40px;
	border: 2px dashed var(--surface-border);
	border-radius: 12px;
}

/* --- ANTI ADBLOCK WALL --- */
#adblock-wall {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: var(--surface);
	color: var(--text);
	z-index: 10000;
	display: none;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	text-align: center;
	padding: 40px;
}

.adblock-emoji {
	font-size: 80px;
	margin-bottom: 20px;
}
.ad-banner {
	height: 1px;
	width: 1px;
	position: absolute;
	left: -9999px;
}

footer {
	margin-top: 60px;
	text-align: center;
	color: var(--text-secondary);
	font-size: 13px;
	padding-bottom: 20px;
}

/* =========================================
   RESPONSIVE DESIGN (MOBILE/TABLET)
   ========================================= */
@media (max-width: 768px) {
	.container {
		padding: 20px;
	}

	.app-header {
		flex-direction: row;
		margin-bottom: 25px;
	}

	.logo-icon {
		font-size: 28px;
	}
	.logo-text {
		font-size: 1.25rem;
	}

	.form-row {
		grid-template-columns: 1fr; /* Stack inputs vertically */
		gap: 15px;
	}

	.ad-banner-slot {
		/* Allow horizontal scrolling for wide banners on small screens */
		display: block;
		overflow-x: auto;
		white-space: nowrap;
		text-align: center;
	}

	.ad-banner-slot > * {
		display: inline-block;
	}

	.images-grid {
		grid-template-columns: 1fr; /* Single column results */
	}

	.image-card img {
		height: auto;
		max-height: 400px;
	}
}

/* =========================================
   RESPONSIVE FONT SIZES
   ========================================= */

/* 1. Base font scaling */
html {
	font-size: 16px;
}

/* 2. Update existing font sizes to use REM units */
.logo-text {
	font-size: clamp(1.25rem, 4vw, 1.8rem);
}

.mode-btn {
	font-size: 0.9375rem; /* 15px */
}

.primary-btn {
	font-size: clamp(1rem, 2vw, 1.125rem); /* 16px-18px */
}

textarea,
input,
select {
	font-size: 0.9375rem; /* 15px */
}

.image-info .prompt {
	font-size: 0.875rem; /* 14px */
}

.small-btn {
	font-size: 0.8125rem; /* 13px */
}

footer {
	font-size: 0.8125rem; /* 13px */
}

/* 3. Responsive breakpoints for fonts */
@media (max-width: 1024px) {
	html {
		font-size: 15px;
	}
}

@media (max-width: 768px) {
	html {
		font-size: 14px;
	}

	/* Update your existing mobile styles to include these: */
	.logo-text {
		font-size: 1.25rem; /* 20px */
	}

	.primary-btn {
		font-size: 1rem; /* 16px */
	}

	.image-info .prompt {
		font-size: 0.8125rem; /* 13px */
		-webkit-line-clamp: 3;
	}
}

@media (max-width: 480px) {
	html {
		font-size: 13px;
	}

	.logo-text {
		font-size: 1.125rem; /* 18px */
	}

	.logo-icon {
		font-size: 1.5rem; /* 24px */
	}

	.theme-toggle {
		width: 40px;
		height: 40px;
		font-size: 1.125rem; /* 18px */
	}
}
/* =========================================
   AD BANNER MOBILE FIXES
   ========================================= */
@media (max-width: 768px) {
	.ad-banner-slot {
		min-height: 100px !important;
		display: flex !important;
		justify-content: center !important;
		align-items: center !important;
		white-space: normal !important;
		overflow: hidden !important;
		position: relative;
	}

	/* Hide script text */
	.ad-banner-slot script {
		display: none !important;
	}

	/* Ensure iframe fits properly */
	.ad-banner-slot iframe {
		max-width: 100% !important;
		height: 90px !important;
		transform: scale(0.95);
		transform-origin: center;
	}
}

@media (max-width: 480px) {
	.ad-banner-slot {
		min-height: 80px !important;
		padding: 5px !important;
	}

	.ad-banner-slot iframe {
		transform: scale(0.85);
	}
}
