/**
 * Image Generator Form Styles
 *
 * Templates, prompt input, options panel, and generate button.
 *
 * @package AgenticWP
 */

/* ==========================================================================
   Generator Section Container (Bento Grid Layout)
   ========================================================================== */

.agenticwp-generator-section {
	margin-bottom: var(--agenticwp-space-xl);
	position: relative;
}

/* Right column flex container for stacking cards */
.agenticwp-prompt-column {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

/* Templates cell fills available height */
.agenticwp-templates-cell {
	display: flex;
	flex-direction: column;
	/* Subtle top border accent for visual hierarchy */
	border-top: 3px solid var(--agenticwp-primary);
}

.agenticwp-templates-cell h3 {
	margin: 0 0 var(--agenticwp-space-lg) 0;
	font-size: var(--agenticwp-text-base);
	font-weight: var(--agenticwp-font-semibold);
	color: var(--agenticwp-text-primary);
}

/* Prompt cell */
.agenticwp-prompt-cell {
	flex: 1;
	display: flex;
	flex-direction: column;
}

.agenticwp-prompt-cell .agenticwp-prompt-textarea {
	flex: 1;
	min-height: 100px;
}

/* Settings cell */
.agenticwp-settings-cell {
	display: flex;
	flex-direction: column;
	gap: var(--agenticwp-space-md);
}

/* Options 2x2 grid for settings */
.agenticwp-options-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: var(--agenticwp-space-sm) var(--agenticwp-space-lg);
}

.agenticwp-options-grid .agenticwp-option-compact {
	display: flex;
	flex-direction: column;
	gap: var(--agenticwp-space-xs);
}

.agenticwp-options-grid .agenticwp-option-compact label {
	font-size: var(--agenticwp-text-xs);
	font-weight: var(--agenticwp-font-medium);
	color: var(--agenticwp-text-secondary);
}

.agenticwp-options-grid .agenticwp-select-compact {
	width: 100%;
}

/* Full-width generate button in settings cell */
.agenticwp-generate-btn-full {
	width: 100%;
	justify-content: center;
}

/* ==========================================================================
   Template Cards
   ========================================================================== */

.agenticwp-template-cards {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: var(--agenticwp-space-md);
	flex: 1;
}

.agenticwp-template-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--agenticwp-space-xs);
	padding: var(--agenticwp-space-md) var(--agenticwp-space-sm);
	background: var(--agenticwp-bg-light);
	border: 1px solid var(--agenticwp-border-light);
	border-radius: var(--agenticwp-radius);
	cursor: pointer;
	text-align: center;
	/* Staggered fadeIn animation */
	animation: templateFadeIn 0.4s ease-out both;
	/* Smooth transitions for hover/active states */
	transition: background-color 0.2s ease,
	            border-color 0.2s ease,
	            box-shadow 0.2s ease,
	            transform 0.2s ease;
}

/* Staggered animation delays for template cards */
.agenticwp-template-card:nth-child(1) { animation-delay: 0s; }
.agenticwp-template-card:nth-child(2) { animation-delay: 0.05s; }
.agenticwp-template-card:nth-child(3) { animation-delay: 0.1s; }
.agenticwp-template-card:nth-child(4) { animation-delay: 0.15s; }
.agenticwp-template-card:nth-child(5) { animation-delay: 0.2s; }
.agenticwp-template-card:nth-child(6) { animation-delay: 0.25s; }

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

.agenticwp-template-card:hover {
	background: var(--agenticwp-bg-white);
	border-color: var(--agenticwp-primary);
	box-shadow: var(--agenticwp-shadow-sm);
	transform: translateY(-2px);
}

.agenticwp-template-card:focus {
	outline: 2px solid var(--agenticwp-primary);
	outline-offset: 2px;
}

.agenticwp-template-card:focus-visible {
	outline: 2px solid var(--agenticwp-primary);
	outline-offset: 2px;
	box-shadow: 0 0 0 4px var(--agenticwp-primary-light);
}

.agenticwp-template-card.active {
	background: var(--agenticwp-primary-light);
	border-color: var(--agenticwp-primary);
}

.agenticwp-template-card .dashicons {
	font-size: 24px;
	width: 24px;
	height: 24px;
	color: var(--agenticwp-text-secondary);
	transition: color 0.2s ease, transform 0.2s ease;
}

.agenticwp-template-card:hover .dashicons {
	color: var(--agenticwp-primary);
	transform: scale(1.1);
}

.agenticwp-template-card.active .dashicons {
	color: var(--agenticwp-primary);
}

.agenticwp-template-name {
	font-size: var(--agenticwp-text-sm);
	font-weight: var(--agenticwp-font-medium);
	color: var(--agenticwp-text-primary);
	line-height: 1.2;
}

.agenticwp-template-desc {
	font-size: var(--agenticwp-text-xs);
	color: var(--agenticwp-text-muted);
	line-height: 1.3;
}

/* ==========================================================================
   Prompt Input
   ========================================================================== */

.agenticwp-prompt-input-section {
	margin-bottom: var(--agenticwp-space-lg);
}

.agenticwp-prompt-textarea {
	width: 100%;
	min-height: 120px;
	padding: var(--agenticwp-space-lg);
	font-size: var(--agenticwp-text-base);
	font-family: var(--agenticwp-font-family);
	line-height: var(--agenticwp-leading-relaxed);
	border: 1px solid var(--agenticwp-border);
	border-radius: var(--agenticwp-radius);
	background: var(--agenticwp-bg-white);
	color: var(--agenticwp-text-primary);
	resize: vertical;
	transition: var(--agenticwp-transition-fast);
}

.agenticwp-prompt-textarea:focus {
	outline: none;
	border-color: var(--agenticwp-primary);
	box-shadow: 0 0 0 3px var(--agenticwp-primary-light);
}

.agenticwp-prompt-textarea::placeholder {
	color: var(--agenticwp-text-muted);
}

/* Prompt Footer */
.agenticwp-prompt-footer {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: var(--agenticwp-space-sm);
}

.agenticwp-char-count {
	font-size: var(--agenticwp-text-xs);
	color: var(--agenticwp-text-muted);
}

.agenticwp-tips-toggle {
	display: flex;
	align-items: center;
	gap: var(--agenticwp-space-xs);
	padding: var(--agenticwp-space-xs) var(--agenticwp-space-sm);
	background: none;
	border: none;
	color: var(--agenticwp-text-secondary);
	font-size: var(--agenticwp-text-sm);
	cursor: pointer;
	border-radius: var(--agenticwp-radius-sm);
	transition: var(--agenticwp-transition-fast);
}

.agenticwp-tips-toggle:hover {
	background: var(--agenticwp-bg-light);
	color: var(--agenticwp-primary);
}

.agenticwp-tips-toggle .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
}

/* Prompt Tips */
.agenticwp-prompt-tips {
	margin-top: var(--agenticwp-space-md);
	padding: var(--agenticwp-space-lg);
	background: var(--agenticwp-bg-light);
	border-radius: var(--agenticwp-radius);
	animation: fadeIn 0.2s ease-out;
}

.agenticwp-prompt-tips ul {
	margin: 0;
	padding-left: var(--agenticwp-space-xl);
}

.agenticwp-prompt-tips li {
	font-size: var(--agenticwp-text-sm);
	color: var(--agenticwp-text-secondary);
	line-height: var(--agenticwp-leading-relaxed);
	margin-bottom: var(--agenticwp-space-xs);
}

.agenticwp-prompt-tips li:last-child {
	margin-bottom: 0;
}

/* ==========================================================================
   Options Bar (Compact Inline Layout)
   ========================================================================== */

.agenticwp-options-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--agenticwp-space-md);
	padding: var(--agenticwp-space-md) var(--agenticwp-space-lg);
	background: var(--agenticwp-bg-light);
	border-radius: var(--agenticwp-radius);
}

.agenticwp-options-inline {
	display: flex;
	align-items: center;
	gap: var(--agenticwp-space-lg);
	flex-wrap: wrap;
}

.agenticwp-option-compact {
	display: flex;
	align-items: center;
	gap: var(--agenticwp-space-xs);
}

.agenticwp-option-compact label {
	font-size: var(--agenticwp-text-xs);
	font-weight: var(--agenticwp-font-medium);
	color: var(--agenticwp-text-secondary);
	white-space: nowrap;
}

.agenticwp-select-compact {
	padding: var(--agenticwp-space-xs) var(--agenticwp-space-sm);
	padding-right: 28px;
	font-size: var(--agenticwp-text-xs);
	font-family: var(--agenticwp-font-family);
	border: 1px solid var(--agenticwp-border);
	border-radius: var(--agenticwp-radius-sm);
	background: var(--agenticwp-bg-white);
	color: var(--agenticwp-text-primary);
	cursor: pointer;
	transition: var(--agenticwp-transition-fast);
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 8px center;
	min-width: 90px;
}

.agenticwp-select-compact:hover {
	border-color: var(--agenticwp-border-dark);
}

.agenticwp-select-compact:focus {
	outline: none;
	border-color: var(--agenticwp-primary);
	box-shadow: 0 0 0 2px var(--agenticwp-primary-light);
}

.agenticwp-select-compact:disabled {
	background-color: var(--agenticwp-bg-gray);
	color: var(--agenticwp-text-muted);
	cursor: not-allowed;
}

/* ==========================================================================
   Generate Button (Inline with Options Bar)
   ========================================================================== */

#agenticwp-generate-btn {
	display: inline-flex;
	align-items: center;
	gap: var(--agenticwp-space-xs);
	padding: var(--agenticwp-space-sm) var(--agenticwp-space-lg);
	font-size: var(--agenticwp-text-sm);
	font-weight: var(--agenticwp-font-semibold);
	background: var(--agenticwp-primary);
	color: white;
	border: none;
	border-radius: var(--agenticwp-radius);
	cursor: pointer;
	transition: var(--agenticwp-transition);
	box-shadow: var(--agenticwp-shadow-primary);
	white-space: nowrap;
	flex-shrink: 0;
}

#agenticwp-generate-btn:hover {
	background: var(--agenticwp-primary-hover);
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

#agenticwp-generate-btn:active {
	transform: translateY(0);
}

#agenticwp-generate-btn:focus {
	outline: 2px solid var(--agenticwp-primary);
	outline-offset: 2px;
}

#agenticwp-generate-btn .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
}

#agenticwp-generate-btn:disabled {
	background: var(--agenticwp-text-muted);
	box-shadow: none;
	cursor: not-allowed;
	transform: none;
}

/* Loading State */
#agenticwp-generate-btn.agenticwp-button-loading {
	pointer-events: none;
	background: linear-gradient(135deg, var(--agenticwp-primary), #6366f1);
	box-shadow: 0 4px 15px rgba(0, 113, 227, 0.4);
}

/* Button Loader Animation */
.agenticwp-btn-loader {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	vertical-align: middle;
}

.agenticwp-btn-orb {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: white;
	box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
	animation: btnOrbPulse 1.5s ease-in-out infinite;
}

@keyframes btnOrbPulse {
	0%, 100% {
		transform: scale(1);
		opacity: 1;
	}
	50% {
		transform: scale(1.2);
		opacity: 0.8;
	}
}

.agenticwp-btn-ring {
	position: absolute;
	border-radius: 50%;
	border: 1px solid transparent;
	border-top-color: white;
}

.agenticwp-btn-ring:nth-child(2) {
	width: 10px;
	height: 10px;
	animation: ringRotate 1s linear infinite;
}

.agenticwp-btn-ring:nth-child(3) {
	width: 16px;
	height: 16px;
	border-top-color: rgba(255, 255, 255, 0.6);
	animation: ringRotate 1.5s linear infinite reverse;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media screen and (max-width: 960px) {
	/* Stack bento grid on tablet */
	.agenticwp-generator-section .agenticwp-bento-grid {
		display: flex;
		flex-direction: column;
		gap: 24px;
	}

	.agenticwp-templates-cell,
	.agenticwp-prompt-column {
		width: 100%;
	}

	.agenticwp-template-cards {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media screen and (max-width: 782px) {
	.agenticwp-template-cards {
		grid-template-columns: repeat(2, 1fr);
	}

	.agenticwp-prompt-column {
		gap: 16px;
	}
}

@media screen and (max-width: 480px) {
	.agenticwp-template-cards {
		grid-template-columns: repeat(2, 1fr);
	}

	.agenticwp-template-desc {
		display: none;
	}

	.agenticwp-options-grid {
		grid-template-columns: 1fr;
		gap: var(--agenticwp-space-sm);
	}
}
