/* "Tạo thiệp bằng AI" on the create form (inc/ai-scan.php, assets/js/create-ai.js). */

.create-ai-root {
	--ai-gold: #b08d4c;
	--ai-gold-soft: color-mix(in srgb, #b08d4c 12%, #fff);
	--ai-gold-line: color-mix(in srgb, #b08d4c 45%, #fff);
	--ai-brand: var(--brand, #b51637);
	--ai-error: #991b1b;
	--ai-ease: cubic-bezier(0.16, 1, 0.3, 1);
	margin-top: 22px;
	scroll-margin-top: calc(var(--header-h, 80px) + 24px);
}

/* Mode switch: a segmented control, the selected half lifts out of the track. */
.create-mode {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 4px;
	padding: 4px;
	background: var(--tint);
	border: 1px solid var(--line);
	border-radius: 12px;
}
.create-mode__tab {
	min-height: 44px;
	padding: 8px 12px;
	border: 0;
	border-radius: 9px;
	background: none;
	color: var(--muted);
	font: inherit;
	font-size: 15px;
	font-weight: 500;
	cursor: pointer;
	transition: background-color .2s var(--ai-ease), color .2s ease, box-shadow .2s ease, transform .15s ease;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}
.create-mode__tab:hover { color: var(--ink); }
.create-mode__tab:active { transform: scale(.98); }
.create-mode__tab[aria-selected="true"] {
	background: var(--white);
	color: var(--ink);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .06);
}
.create-mode__tab[data-ai-mode="ai"][aria-selected="true"] { color: var(--ai-gold); box-shadow: inset 0 0 0 1px var(--ai-gold-line), 0 4px 14px color-mix(in srgb, #b08d4c 18%, transparent); }
.create-mode__tab:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* AI panel */
.create-ai {
	position: relative;
	margin-top: 16px;
	padding: 22px 20px 20px;
	background:
		radial-gradient(120% 80% at 100% 0%, var(--ai-gold-soft) 0%, transparent 60%),
		var(--white);
	border: 1px solid var(--ai-gold-line);
	border-radius: 14px;
	box-shadow: var(--shadow-card);
	animation: create-ai-in .35s var(--ai-ease);
}
.create-ai[hidden] { display: none; }
@keyframes create-ai-in { from { opacity: 0; transform: translateY(6px); } }

.create-ai__title { margin: 0; font-family: var(--font-serif); font-size: clamp(1.15rem, 1rem + .6vw, 1.4rem); font-weight: 600; line-height: 1.3; color: var(--heading); }
.create-ai__lead { margin: 6px 0 0; font-size: 14px; line-height: 1.55; color: var(--text); }

.create-ai__steps { display: grid; gap: 14px; margin: 18px 0 0; padding: 0; list-style: none; }
.create-ai__step[hidden] { display: none; }
.create-ai__row { display: flex; align-items: flex-end; gap: 10px; }
.create-ai__row .form-field { flex: 1; min-width: 0; margin: 0; }
.create-ai__row .form-field small { font-weight: 400; color: var(--muted); }
.create-ai__row input { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .04em; text-transform: uppercase; }
.create-ai__row input::placeholder { text-transform: none; letter-spacing: 0; }
.create-ai__row .btn { flex: none; min-height: 46px; }
.create-ai__hint, .create-ai__privacy { margin: 8px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.create-ai__hint a { color: var(--ai-brand); font-weight: 500; }

/* Key accepted: the step collapses into one confirmed line. */
.create-ai__step.is-done .create-ai__row,
.create-ai__step.is-done .create-ai__hint { display: none; }
.create-ai__ok { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.create-ai__ok::before { content: "✓"; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--mint-soft); color: var(--mint); font-weight: 700; font-size: 13px; }
.create-ai__ok button { margin-left: auto; padding: 4px 8px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }

/* Photo drop zone */
.create-ai__drop {
	position: relative;
	display: grid;
	place-items: center;
	min-height: 168px;
	padding: 18px;
	border: 1.5px dashed var(--ai-gold-line);
	border-radius: 12px;
	background: color-mix(in srgb, var(--ai-gold-soft) 60%, #fff);
	text-align: center;
	cursor: pointer;
	overflow: hidden;
	transition: border-color .2s ease, background-color .2s ease;
}
.create-ai__drop:hover, .create-ai__drop.is-over { border-color: var(--ai-gold); background: var(--ai-gold-soft); }
.create-ai__drop:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.create-ai__file { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.create-ai__drop-text { display: grid; gap: 4px; pointer-events: none; }
.create-ai__drop-text b { font-size: 15px; font-weight: 600; color: var(--ink); }
.create-ai__drop-text b::before { content: ""; display: block; width: 40px; height: 40px; margin: 0 auto 8px; border-radius: 50%; background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b08d4c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8h3l2-3h6l2 3h3v11H4z'/%3E%3Ccircle cx='12' cy='13' r='3.5'/%3E%3C/svg%3E") center / 22px no-repeat; box-shadow: 0 2px 8px rgba(0, 0, 0, .06); }
.create-ai__drop-text small { font-size: 12.5px; color: var(--muted); }
.create-ai__drop.has-image { min-height: 0; padding: 10px; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; justify-items: start; text-align: left; }
.create-ai__drop.has-image .create-ai__drop-text b { overflow-wrap: anywhere; }
.create-ai__drop.has-image .create-ai__drop-text b::before { display: none; }
.create-ai__thumb { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.create-ai__thumb[hidden] { display: none; }

.create-ai__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 12px; }
.create-ai__actions .btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.create-ai__left { font-size: 13px; color: var(--muted); }

/* Busy */
.create-ai__busy { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--ai-gold-soft); font-size: 14px; color: var(--ink); }
.create-ai__busy[hidden] { display: none; }
.create-ai__spinner { flex: none; width: 20px; height: 20px; border: 2.5px solid var(--ai-gold-line); border-top-color: var(--ai-gold); border-radius: 50%; animation: create-ai-spin .8s linear infinite; }
@keyframes create-ai-spin { to { transform: rotate(360deg); } }
.create-ai.is-busy .create-ai__steps { opacity: .5; pointer-events: none; }

.create-ai__note { margin: 14px 0 0; padding: 11px 14px; border-radius: 8px; background: var(--tint); font-size: 14px; line-height: 1.5; color: var(--ink); }
.create-ai__note[hidden] { display: none; }
.create-ai__note.is-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--ai-error); }
.create-ai__note button { margin-left: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }

/* Manual form while the AI tab is open */
.create-form.is-ai-hidden { display: none; }

/* After a scan: banner and gold outline on every field the AI filled. */
.create-ai-banner {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin-top: 16px;
	padding: 12px 14px;
	border: 1px solid var(--ai-gold-line);
	border-left: 4px solid var(--ai-gold);
	border-radius: 10px;
	background: var(--ai-gold-soft);
	font-size: 14px;
	line-height: 1.5;
	color: var(--ink);
	animation: create-ai-in .35s var(--ai-ease);
}
.create-ai-banner[hidden] { display: none; }
.create-ai-banner b { color: var(--ai-gold); }
.create-ai-banner button { flex: none; margin-left: auto; width: 28px; height: 28px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; }
.create-ai-banner button:hover { background: rgba(0, 0, 0, .05); color: var(--ink); }

.create-form .is-ai-filled input {
	border-color: var(--ai-gold, #b08d4c);
	background: color-mix(in srgb, #b08d4c 7%, #fff);
	box-shadow: 0 0 0 3px color-mix(in srgb, #b08d4c 16%, transparent);
}
.create-form .is-ai-filled > span::after { content: " ✨"; font-size: .85em; }

@media (max-width: 479px) {
	.create-ai { padding: 18px 14px 16px; }
	.create-ai__row { flex-direction: column; align-items: stretch; }
	.create-ai__row .btn { width: 100%; }
	.create-ai__actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
	.create-ai, .create-ai-banner { animation: none; }
	.create-mode__tab { transition: none; }
	.create-ai__spinner { animation-duration: 2.4s; }
}
