@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap');

:root {
	/* Light Mode Colors */
	--primary-color: #4a90e2;
	--secondary-color: #50e3c2;
	--background-color: #f4f7f6;
	--container-bg: #ffffff;
	--text-color: #333;
	--muted-text-color: #666;
	--input-border: #d1d1d1;
	--input-focus-border: var(--primary-color);
	--input-bg: #fdfdfd;
	--output-bg: #f0f3f2;
	--button-text: #ffffff;
	--shadow-color: rgba(0, 0, 0, 0.1);
	--success-color: #28a745;
	--error-color: #dc3545;
	--icon-color: var(--primary-color);
	--toggle-bg: #e0e0e0;
	--toggle-icon-color: var(--primary-color);
	--gradient-start: #ece9e6;
	--gradient-end: #ffffff;
}

body.dark-mode {
	/* Dark Mode Colors */
	--primary-color: #58a6ff;
	--secondary-color: #50e3c2;
	--background-color: #1c1c1e;
	--container-bg: #2c2c2e;
	--text-color: #e1e1e1;
	--muted-text-color: #a0a0a0;
	--input-border: #444;
	--input-focus-border: var(--primary-color);
	--input-bg: #3a3a3c;
	--output-bg: #363638;
	--button-text: #ffffff;
	--shadow-color: rgba(0, 0, 0, 0.4);
	--success-color: #34c759;
	--error-color: #ff453a;
	--icon-color: var(--primary-color);
	--toggle-bg: #444;
	--toggle-icon-color: #ffcc00;
	--gradient-start: #2c2c2e;
	--gradient-end: #1c1c1e;
}


* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

body {
	font-family: 'Poppins', sans-serif;
	background-color: var(--background-color);
	color: var(--text-color);
	display: flex;
	justify-content: center;
	align-items: flex-start;
	/* Align container top */
	min-height: 100vh;
	padding: 20px;
	background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
	transition: background-color 0.3s ease, color 0.3s ease;
}

/* Optional main wrapper for very large screens */
.main-container {
	width: 100%;
	display: flex;
	justify-content: center;
}

.container {
	background-color: var(--container-bg);
	padding: 30px 40px;
	border-radius: 12px;
	box-shadow: 0 10px 30px var(--shadow-color);
	max-width: 960px;
	/* Adjust max-width for desktop */
	width: 95%;
	/* Use percentage for flexibility */
	text-align: center;
	transition: background-color 0.3s ease, box-shadow 0.3s ease;
	margin-top: 20px;
	/* Add some top margin */
	margin-bottom: 20px;
	/* Add bottom margin */
}

.header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 35px;
	/* Slightly more space */
}

h1 {
	color: var(--primary-color);
	font-weight: 600;
	font-size: 1.9rem;
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	flex-grow: 1;
	justify-content: center;
	text-align: left;
	padding-left: 30px;
	/* Adjust to center visually */
	transition: color 0.3s ease;
}

.theme-toggle-btn {
	background: var(--toggle-bg);
	border: none;
	color: var(--toggle-icon-color);
	border-radius: 50%;
	width: 40px;
	height: 40px;
	font-size: 1.1rem;
	cursor: pointer;
	display: flex;
	justify-content: center;
	align-items: center;
	transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
	flex-shrink: 0;
}

.theme-toggle-btn:hover {
	transform: scale(1.1);
}

.theme-toggle-btn:active {
	transform: scale(1.0);
}

/* Fieldset Styling */
.options-section {
	border: 1px solid var(--input-border);
	border-radius: 8px;
	padding: 15px 20px 20px 20px;
	margin-bottom: 25px;
	transition: border-color 0.3s ease;
	text-align: left;
	/* Align content left */
	display: flex;
	/* Use flex for better internal alignment */
	flex-direction: column;
	/* Stack legend, options, button vertically */
	justify-content: space-between;
	/* Push button to bottom */
	height: 100%;
	/* Make fieldsets equal height in grid/flex */
}

/* Exception for modifier fieldset height */
.modifier-options {
	height: auto;
	justify-content: flex-start;
	/* Align items top */
}

.options-section legend {
	padding: 0 10px;
	font-weight: 600;
	color: var(--primary-color);
	margin-left: 10px;
	transition: color 0.3s ease;
	font-size: 1rem;
	/* Ensure legend size is appropriate */
}

/* Options Layout (Random & Word-based) */
.options {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 20px;
	margin-bottom: 20px;
	/* Space before button */
	flex-grow: 1;
	/* Allow options area to grow */
}

.option-group {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.option-group label {
	font-weight: 400;
	font-size: 0.95rem;
	color: var(--muted-text-color);
	display: flex;
	align-items: center;
	gap: 8px;
	transition: color 0.3s ease;
	cursor: pointer;
	/* Make label clickable for input */
}

.option-group label i {
	color: var(--icon-color);
	width: 16px;
	text-align: center;
	transition: color 0.3s ease;
}

input[type="number"],
input[type="text"],
select {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--input-border);
	border-radius: 6px;
	font-size: 1rem;
	font-family: inherit;
	background-color: var(--input-bg);
	color: var(--text-color);
	transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

/* Style placeholder specifically for number inputs */
input[type="number"]::placeholder {
	color: var(--muted-text-color);
	opacity: 0.8;
	font-size: 0.95rem;
}

/* Style for number input spinners (browser dependent) */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
	opacity: 0.5;
	/* Make spinners slightly less prominent */
}

input[type="number"] {
	-moz-appearance: textfield;
	/* Firefox */
}


input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
	outline: none;
	border-color: var(--input-focus-border);
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color) 20%, transparent);
}

input:disabled,
select:disabled {
	background-color: color-mix(in srgb, var(--input-bg) 80%, var(--muted-text-color) 20%);
	cursor: not-allowed;
	opacity: 0.7;
}

/* Uniform Generate Button Style */
.generate-button {
	background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
	color: var(--button-text);
	border: none;
	padding: 12px 25px;
	border-radius: 25px;
	font-size: 1.05rem;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.3s ease;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	box-shadow: 0 4px 10px color-mix(in srgb, var(--primary-color) 30%, transparent);
	width: 100%;
	/* Make button full width by default (mobile) */
	margin-top: auto;
	/* Push button to bottom of flex container (fieldset) */
}

.generate-button:hover:not(:disabled) {
	opacity: 0.9;
	box-shadow: 0 6px 15px color-mix(in srgb, var(--primary-color) 40%, transparent);
	transform: translateY(-2px);
}

.generate-button:active:not(:disabled) {
	transform: translateY(0);
	box-shadow: 0 4px 10px color-mix(in srgb, var(--primary-color) 30%, transparent);
}

.generate-button:disabled {
	background: var(--muted-text-color);
	cursor: not-allowed;
	box-shadow: none;
	color: #eee;
	transform: none;
	opacity: 0.7;
}

.generate-button .fa-spinner {
	font-size: 1em;
}


/* Modifier Section Styling */
.modifier-items {
	/* Container for all modifiers */
	display: flex;
	flex-wrap: wrap;
	gap: 20px;
	/* Gap between all items */
	justify-content: flex-start;
	/* Align items left */
	align-items: center;
	/* Align items vertically */
	margin-top: 15px;
	padding-left: 10px;
	padding-right: 10px;
}

.toggle-group {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
	/* Prevent toggles from shrinking too much */
}

.toggle-group label {
	color: var(--text-color);
	cursor: pointer;
	gap: 6px;
}

.modifier-toggle {
	accent-color: var(--primary-color);
	width: 16px;
	height: 16px;
	cursor: pointer;
	flex-shrink: 0;
}

.modifier-toggle:disabled+label {
	color: var(--muted-text-color);
	cursor: not-allowed;
}

.modifier-toggle:disabled+label i {
	color: var(--muted-text-color);
}

/* Style the length inputs within modifiers */
.modifier-items .option-group.length-modifier {
	flex-basis: 120px;
	/* Give length inputs a base width */
	flex-grow: 1;
	/* Allow them to grow */
	max-width: 150px;
	/* But limit max width */
}

.modifier-items .option-group.length-modifier label {
	font-size: 0.9rem;
	/* Slightly smaller label */
}


/* Status Message Styling */
.status-message {
	margin-top: 15px;
	font-size: 0.9rem;
	color: var(--muted-text-color);
	min-height: 20px;
	transition: color 0.3s ease;
	text-align: center;
	/* Center status messages */
}

.status-message .fa-spinner {
	color: var(--primary-color);
}

/* Output Area Styling */
.output-area {
	display: flex;
	align-items: stretch;
	gap: 10px;
	margin-top: 25px;
	/* More space before output */
	position: relative;
}

#passphraseOutput.passphrase-display {
	flex-grow: 1;
	padding: 12px 15px;
	border: 1px solid var(--input-border);
	border-radius: 6px;
	font-size: 1.1rem;
	font-family: 'Courier New', Courier, monospace;
	background-color: var(--output-bg);
	color: var(--text-color);
	min-height: 50px;
	/* Ensure minimum height */
	word-wrap: break-word;
	word-break: break-all;
	/* More aggressive wrapping */
	text-align: left;
	display: flex;
	align-items: center;
	transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Style placeholder text */
#passphraseOutput:empty::before,
#passphraseOutput:not(:empty):not(:focus):not(:active):not([data-placeholder-active="false"])::before {
	content: 'Your passphrase will appear here...';
	color: var(--muted-text-color);
	font-style: italic;
	font-family: 'Poppins', sans-serif;
	font-size: 1rem;
	width: 100%;
	text-align: center;
}

#passphraseOutput:not(:empty)::before {
	display: none;
}

#passphraseOutput.placeholder-text {
	color: var(--muted-text-color);
	font-style: italic;
	font-family: 'Poppins', sans-serif;
	font-size: 1rem;
	text-align: center;
}


#copyBtn {
	background-color: var(--secondary-color);
	color: var(--button-text);
	border: none;
	padding: 10px 15px;
	border-radius: 6px;
	font-size: 1rem;
	cursor: pointer;
	transition: background-color 0.3s ease, color 0.3s ease;
	flex-shrink: 0;
	align-self: center;
}

#copyBtn:hover:not(:disabled) {
	background-color: color-mix(in srgb, var(--secondary-color) 90%, black);
}

#copyBtn:disabled {
	background-color: var(--muted-text-color);
	cursor: not-allowed;
	opacity: 0.7;
}

.copy-status {
	font-size: 0.85rem;
	color: var(--success-color);
	margin-top: 5px;
	height: 18px;
	opacity: 0;
	transition: opacity 0.3s ease-in-out, color 0.3s ease;
}

.copy-status.visible {
	opacity: 1;
}

/* --- Desktop Layout Improvements --- */
@media (min-width: 768px) {
	.container {
		padding: 40px 50px;
	}

	/* Grid for Generation Methods */
	.generation-methods {
		display: grid;
		grid-template-columns: 1fr 1fr;
		/* Two equal columns */
		gap: 30px;
		margin-bottom: 30px;
	}

	.options-section {
		margin-bottom: 0;
	}

	/* Horizontal layout for random options */
	.options.random-options {
		display: flex;
		flex-wrap: wrap;
		align-items: flex-end;
		/* Align form elements bottom */
		gap: 15px;
	}

	.options.random-options .option-group {
		flex: 1 1 150px;
		/* Adjust flex-basis */
		min-width: 140px;
		/* Adjust min-width */
	}

	.options.random-options .custom-separator-group {
		flex-grow: 1;
		/* Allow custom separator to grow */
	}

	.generate-button {
		width: auto;
		/* Allow button to size naturally */
		padding: 12px 30px;
		align-self: flex-start;
		/* Align button to start */
		margin-top: 20px;
		/* Consistent space above button */
	}

	.modifier-items {
		gap: 25px;
		/* More gap on desktop */
		justify-content: center;
		/* Center items */
	}

	/* Give length inputs slightly more defined width on desktop */
	.modifier-items .option-group.length-modifier {
		flex-basis: 130px;
		max-width: 160px;
	}

	.output-area {
		flex-direction: row;
		align-items: center;
	}

	#passphraseOutput.passphrase-display {
		min-height: 50px;
		margin-bottom: 0;
	}

	#copyBtn {
		width: auto;
		align-self: center;
	}
}


/* --- Mobile Adjustments --- */
@media (max-width: 767px) {
	.container {
		padding: 20px 15px;
		/* Less padding on mobile */
	}

	.header {
		margin-bottom: 25px;
		flex-direction: column;
		/* Stack title and toggle */
		gap: 15px;
	}

	h1 {
		font-size: 1.6rem;
		padding-left: 0;
		/* Remove padding */
		text-align: center;
		justify-content: center;
	}

	.theme-toggle-btn {
		width: 36px;
		height: 36px;
		font-size: 1rem;
		align-self: flex-end;
		/* Position toggle right */
		margin-top: -45px;
		/* Pull toggle up slightly */
	}

	/* Stack generation methods */
	.generation-methods {
		display: block;
		margin-bottom: 0;
	}

	.options-section {
		margin-bottom: 25px;
		height: auto;
		/* Reset height */
	}

	.options.random-options {
		display: grid;
		/* Use grid for random options */
		grid-template-columns: 1fr;
		/* Stack random options */
		gap: 15px;
	}

	.options.random-options .option-group {
		min-width: unset;
		flex-basis: auto;
		grid-column: auto;
		/* Reset span */
	}

	.generate-button {
		width: 100%;
		margin-top: 15px;
		align-self: auto;
		/* Reset alignment */
		padding: 15px;
		/* Larger tap target */
	}

	.modifier-items {
		flex-direction: row;
		/* Keep side-by-side */
		justify-content: space-around;
		/* Space them out */
		gap: 15px;
		/* Adjust gap */
	}

	/* Adjust width of length inputs on mobile */
	.modifier-items .option-group.length-modifier {
		flex-basis: 100px;
		max-width: 120px;
		flex-grow: 0;
		/* Don't grow too much */
	}


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

	#passphraseOutput.passphrase-display {
		margin-bottom: 10px;
		text-align: center;
		min-height: 60px;
		justify-content: center;
	}

	#copyBtn {
		width: 100%;
		padding: 12px;
		align-self: auto;
	}
}