/* ==========================================================================
   Cottage Label Generator — front-end styles (clg-app.css)

   Everything is scoped under .clg-app so the Flatsome theme and the label
   generator never fight each other. Brand colours arrive as CSS variables
   set inline by PHP from the plugin settings; the fallbacks below are the
   CottageBakerSupply "Candy Brights" palette:

     --brand-primary    #0F8B8D  teal  — primary buttons / downloads
     --brand-secondary  #22384F  navy  — stepper tabs / toggles
     --brand-accent     #F97066  coral — affiliate callout highlights
     --brand-bg         #D9F2F0  aqua  — form panel background

   Rules honoured throughout: no purple, no yellow/gold; every interactive
   element is at least 48px tall; base text is 17px (which also stops iOS
   Safari from auto-zooming when an input is focused).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Root, variables, scoped reset
   -------------------------------------------------------------------------- */
.clg-app {
	--brand-primary: #0F8B8D;
	--brand-secondary: #22384F;
	--brand-accent: #F97066;
	--brand-bg: #D9F2F0;
	--clg-primary-dark: #0B6E70;
	--clg-ink: #22384F;
	--clg-ink-soft: #4A6076;
	--clg-line: #D8E2E6;
	--clg-cream: #FFF9F2;
	--clg-alert-border: #E8A13A;
	--clg-alert-bg: #FFF7EA;
	--clg-accent-soft: #FDECEA;
	--clg-error: #9C3D2E;
	--clg-error-bg: #FBEAE6;
	--clg-success-bg: #E7F4EA;
	--clg-radius: 16px;
	--clg-shadow: 0 6px 24px rgba(34, 56, 79, 0.10);
	font-family: inherit;
	font-size: 17px;
	line-height: 1.55;
	color: var(--clg-ink);
	-webkit-text-size-adjust: 100%;
}
.clg-app *, .clg-app *::before, .clg-app *::after { box-sizing: border-box; }
.clg-app h1, .clg-app h2, .clg-app h3, .clg-app h4, .clg-app p { margin: 0 0 0.6em; }
.clg-app img { max-width: 100%; height: auto; }
.clg-app :focus-visible {
	outline: 3px solid var(--brand-primary);
	outline-offset: 2px;
	border-radius: 4px;
}
.clg-app .clg-sr-only {
	position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
	overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.clg-app .clg-muted { color: var(--clg-ink-soft); }
.clg-app .clg-small { font-size: 15px; }
.clg-app .clg-mt { margin-top: 18px; }
.clg-app .clg-mb { margin-bottom: 18px; }
.clg-app .clg-text-center { text-align: center; }

/* --------------------------------------------------------------------------
   2. Stepper (Step 1 / 2 / 3 tabs)
   -------------------------------------------------------------------------- */
.clg-app .clg-steps {
	display: flex;
	gap: 8px;
	margin: 0 0 18px;
	padding: 0;
	list-style: none;
}
.clg-app .clg-step {
	flex: 1 1 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 48px;
	padding: 8px 10px;
	border: 1.5px solid var(--brand-secondary);
	border-radius: 999px;
	background: #fff;
	color: var(--brand-secondary);
	font: inherit;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.25;
	text-align: center;
	cursor: pointer;
	transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.clg-app .clg-step:hover { border-color: var(--clg-primary-dark); color: var(--clg-primary-dark); }
.clg-app .clg-step.is-active {
	background: var(--brand-secondary);
	border-color: var(--brand-secondary);
	color: #fff;
}
.clg-app .clg-step.is-active:hover { color: #fff; }
.clg-app .clg-step-num {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--brand-bg);
	color: var(--brand-secondary);
	font-size: 14px;
	font-weight: 800;
}
.clg-app .clg-step.is-active .clg-step-num { background: #fff; color: var(--brand-secondary); }
/* Completed steps swap the number for a check mark. */
.clg-app .clg-step.is-done .clg-step-num { background: var(--brand-primary); color: #fff; }
.clg-app .clg-step.is-done .clg-step-num-text { font-size: 0; }
.clg-app .clg-step.is-done .clg-step-num-text::after {
	content: "✓";
	font-size: 15px;
	font-weight: 800;
}
.clg-app .clg-step-label { display: inline-block; }

/* --------------------------------------------------------------------------
   3. Layout — form + sticky live preview
   Mobile: single column; the preview sticks to the top of the viewport in
   a compact frame. Desktop (>= 960px): two columns, form on the left and
   the preview on the right, still sticky while the form scrolls.
   -------------------------------------------------------------------------- */
.clg-app .clg-layout { display: block; }
.clg-app .clg-form-col { min-width: 0; }
.clg-app .clg-preview-panel {
	position: sticky;
	top: 8px;
	z-index: 5;
	margin-bottom: 18px;
	padding: 12px;
	background: #fff;
	border: 1px solid var(--clg-line);
	border-radius: var(--clg-radius);
	box-shadow: var(--clg-shadow);
}
.clg-app .clg-preview-title {
	margin: 0 0 8px;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--clg-ink-soft);
	text-align: center;
}
.clg-app .clg-preview-frame {
	max-height: 38vh;
	overflow: hidden;
	display: flex;
	align-items: flex-start;
	justify-content: center;
}
.clg-app .clg-preview-canvas {
	width: 100%;
	height: auto;
	display: block;
	background: #fff;
	border: 1px solid #D8E2E6;
	border-radius: 8px;
}
.clg-app .clg-preview-note {
	margin: 8px 0 0;
	font-size: 14px;
	color: var(--clg-ink-soft);
	text-align: center;
}
@media (min-width: 960px) {
	.clg-app .clg-layout {
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(320px, 460px);
		gap: 28px;
		align-items: start;
	}
	.clg-app .clg-preview-panel { top: 24px; margin-bottom: 0; padding: 18px; }
	.clg-app .clg-preview-frame { max-height: none; overflow: visible; }
}

/* --------------------------------------------------------------------------
   4. Panels & cards
   -------------------------------------------------------------------------- */
.clg-app .clg-panel {
	background: var(--brand-bg);
	border-radius: var(--clg-radius);
	padding: 22px 20px;
	margin-bottom: 20px;
}
.clg-app .clg-card {
	background: #fff;
	border: 1px solid var(--clg-line);
	border-radius: var(--clg-radius);
	box-shadow: var(--clg-shadow);
	padding: 22px 20px;
	margin-bottom: 20px;
}
.clg-app .clg-card-soft {
	background: var(--clg-cream);
	border: 1px solid var(--clg-line);
	border-radius: var(--clg-radius);
	padding: 18px;
}
.clg-app .clg-card-title {
	font-size: 22px;
	font-weight: 800;
	line-height: 1.3;
	color: var(--clg-ink);
	margin-bottom: 4px;
}
.clg-app .clg-card-subtitle { font-size: 16px; color: var(--clg-ink-soft); margin-bottom: 14px; }
.clg-app .clg-divider { border: 0; border-top: 1px solid var(--clg-line); margin: 20px 0; }

/* --------------------------------------------------------------------------
   5. Form fields & controls (all >= 48px touch height, 17px text)
   -------------------------------------------------------------------------- */
.clg-app .clg-field { margin-bottom: 16px; }
.clg-app .clg-label {
	display: block;
	margin-bottom: 6px;
	font-size: 16px;
	font-weight: 700;
	color: var(--clg-ink);
}
.clg-app .clg-label-note { font-weight: 400; color: var(--clg-ink-soft); }
.clg-app .clg-help { margin: 6px 0 0; font-size: 15px; line-height: 1.5; color: #4A6076; }
.clg-app .clg-input,
.clg-app .clg-select,
.clg-app .clg-textarea {
	display: block;
	width: 100%;
	min-height: 48px;
	padding: 10px 12px;
	font: inherit;
	font-size: 17px;
	line-height: 1.4;
	color: var(--clg-ink);
	background: #fff;
	border: 1.5px solid #D8E2E6;
	border-radius: 10px;
	appearance: none;
	-webkit-appearance: none;
}
.clg-app .clg-input::placeholder, .clg-app .clg-textarea::placeholder { color: #8AA0B4; }
.clg-app .clg-input:focus,
.clg-app .clg-select:focus,
.clg-app .clg-textarea:focus {
	border-color: var(--brand-primary);
	box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.22);
	outline: none;
}
.clg-app .clg-input:disabled,
.clg-app .clg-select:disabled,
.clg-app .clg-textarea:disabled {
	background: #F1F5F6;
	color: var(--clg-ink-soft);
	cursor: not-allowed;
}
/* Selects: the native arrow is replaced by a soft chevron. */
.clg-app .clg-select {
	padding-right: 40px;
	cursor: pointer;
	background-image: linear-gradient(45deg, transparent 50%, var(--clg-ink-soft) 50%),
		linear-gradient(135deg, var(--clg-ink-soft) 50%, transparent 50%);
	background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%;
	background-size: 6px 6px, 6px 6px;
	background-repeat: no-repeat;
}
.clg-app .clg-select-inline {
	display: inline-block;
	width: auto;
	min-width: 150px;
	vertical-align: middle;
}
.clg-app .clg-textarea { min-height: 110px; resize: vertical; }
.clg-app .clg-textarea-tall { min-height: 150px; }
.clg-app .clg-input-group { display: flex; align-items: stretch; }
.clg-app .clg-input-group .clg-input { border-radius: 10px 0 0 10px; }
.clg-app .clg-input-suffix {
	display: inline-flex;
	align-items: center;
	padding: 0 12px;
	background: var(--clg-cream);
	border: 1.5px solid var(--clg-line);
	border-left: 0;
	border-radius: 0 10px 10px 0;
	font-size: 15px;
	color: var(--clg-ink-soft);
	white-space: nowrap;
}
.clg-app .clg-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 640px) {
	.clg-app .clg-grid { grid-template-columns: 1fr 1fr; }
}
/* Checkboxes & radios — big, thumb-friendly. */
.clg-app .clg-check {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	min-height: 48px;
	padding: 10px 2px;
	font-size: 16px;
	line-height: 1.45;
	cursor: pointer;
}
.clg-app .clg-check input[type="checkbox"],
.clg-app .clg-check input[type="radio"] {
	flex: 0 0 auto;
	width: 24px;
	height: 24px;
	margin: 1px 0 0;
	accent-color: var(--brand-primary);
	cursor: pointer;
}

/* --------------------------------------------------------------------------
   6. Allergen chips (FDA Big 9)
   -------------------------------------------------------------------------- */
.clg-app .clg-allergen-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	margin-top: 6px;
}
.clg-app .clg-allergen-chip {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 48px;
	padding: 10px 12px;
	border: 1.5px solid var(--clg-line);
	border-radius: 999px;
	background: #fff;
	color: var(--clg-ink);
	font-size: 16px;
	font-weight: 600;
	text-align: center;
	cursor: pointer;
	transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.clg-app .clg-allergen-chip input[type="checkbox"] {
	width: 22px;
	height: 22px;
	margin: 0;
	accent-color: var(--brand-primary);
	cursor: pointer;
}
.clg-app .clg-allergen-chip:hover { border-color: var(--brand-primary); }
.clg-app .clg-allergen-chip.is-on {
	background: var(--brand-primary);
	border-color: var(--brand-primary);
	color: #fff;
}
.clg-app .clg-allergen-chip.is-on input[type="checkbox"] { accent-color: #fff; }
@media (min-width: 640px) {
	.clg-app .clg-allergen-grid { grid-template-columns: repeat(3, 1fr); }
}

/* --------------------------------------------------------------------------
   7. Buttons, link buttons & segmented toggles
   -------------------------------------------------------------------------- */
.clg-app .clg-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 48px;
	padding: 11px 22px;
	border: 1.5px solid transparent;
	border-radius: 999px;
	font: inherit;
	font-size: 17px;
	font-weight: 700;
	line-height: 1.3;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}
.clg-app .clg-btn:active { transform: translateY(1px); }
.clg-app .clg-btn-primary { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.clg-app .clg-btn-primary:hover {
	background: var(--clg-primary-dark);
	border-color: var(--clg-primary-dark);
	color: #fff;
}
.clg-app .clg-btn-ghost { background: #fff; border-color: var(--brand-secondary); color: var(--brand-secondary); }
.clg-app .clg-btn-ghost:hover { background: var(--brand-bg); color: var(--brand-secondary); }
.clg-app .clg-btn-accent { background: var(--brand-accent); border-color: var(--brand-accent); color: #fff; }
.clg-app .clg-btn-accent:hover { background: #E85A50; border-color: #E85A50; color: #fff; }
.clg-app .clg-btn-small { min-height: 48px; padding: 8px 16px; font-size: 15px; }
.clg-app .clg-btn-block { display: flex; width: 100%; }
.clg-app .clg-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.clg-app .clg-link-btn {
	display: inline;
	min-height: 0;
	padding: 2px 0;
	border: 0;
	background: none;
	font: inherit;
	font-size: 16px;
	font-weight: 600;
	color: var(--clg-primary-dark);
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}
.clg-app .clg-link-btn:hover { color: var(--brand-primary); }
/* Segmented toggle (e.g. Address vs Registration ID, sheet vs thermal). */
.clg-app .clg-toggle {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 5px;
	background: #fff;
	border: 1.5px solid var(--clg-line);
	border-radius: 999px;
}
.clg-app .clg-toggle-btn {
	min-height: 48px;
	padding: 9px 18px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	font: inherit;
	font-size: 16px;
	font-weight: 700;
	color: var(--brand-secondary);
	cursor: pointer;
	transition: background-color 0.18s ease, color 0.18s ease;
}
.clg-app .clg-toggle-btn:hover { background: var(--brand-bg); }
.clg-app .clg-toggle-btn.is-active { background: var(--brand-secondary); color: #fff; }
.clg-app .clg-toggle-btn.is-active:hover { background: var(--brand-secondary); }

/* --------------------------------------------------------------------------
   8. Step navigation row (Back / Next)
   -------------------------------------------------------------------------- */
.clg-app .clg-nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: 20px;
}
.clg-app .clg-nav .clg-btn { flex: 0 1 auto; }
.clg-app .clg-nav-spacer { flex: 1 1 auto; }

/* --------------------------------------------------------------------------
   9. State rules card & verbatim statement preview
   -------------------------------------------------------------------------- */
.clg-app .clg-state-rules {
	background: #fff;
	border: 1px solid var(--clg-line);
	border-radius: var(--clg-radius);
	box-shadow: var(--clg-shadow);
	padding: 20px;
	margin-bottom: 20px;
}
.clg-app .clg-state-rules-title { font-size: 19px; font-weight: 800; margin-bottom: 8px; }
.clg-app .clg-state-rules ul { margin: 0; padding-left: 20px; }
.clg-app .clg-state-rules li { margin-bottom: 6px; }
.clg-app .clg-statement-preview {
	margin-top: 12px;
	padding: 14px 16px;
	background: var(--brand-bg);
	border: 1.5px solid var(--brand-primary);
	border-radius: 10px;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.55;
	color: var(--clg-ink);
}
.clg-app .clg-statement-label {
	display: block;
	margin-bottom: 6px;
	font-size: 13px;
	font-weight: 800;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--clg-primary-dark);
}
/* Identity toggle area: full address vs state registration / ID number. */
.clg-app .clg-identity { margin-bottom: 18px; }
.clg-app .clg-identity .clg-toggle { margin-bottom: 14px; }
.clg-app .clg-identity-note { font-size: 15px; color: var(--clg-ink-soft); }

/* --------------------------------------------------------------------------
   10. Alerts & notices (incl. the human-in-the-loop triage message)
   -------------------------------------------------------------------------- */
.clg-app .clg-alert {
	border: 1.5px solid var(--clg-alert-border);
	background: var(--clg-alert-bg);
	color: #5C4322;
	border-radius: 12px;
	padding: 16px 18px;
	margin-bottom: 18px;
	font-size: 16px;
	line-height: 1.55;
}
.clg-app .clg-alert-title {
	display: block;
	margin-bottom: 4px;
	font-size: 17px;
	font-weight: 800;
	color: #4A3413;
}
.clg-app .clg-notice-success {
	border: 1.5px solid var(--brand-primary);
	background: var(--clg-success-bg);
	color: #14532D;
	border-radius: 12px;
	padding: 14px 16px;
	margin-bottom: 18px;
	font-size: 16px;
	font-weight: 600;
}
.clg-app .clg-notice-error {
	border: 1.5px solid var(--clg-error);
	background: var(--clg-error-bg);
	color: var(--clg-error);
	border-radius: 12px;
	padding: 14px 16px;
	margin-bottom: 18px;
	font-size: 16px;
	font-weight: 600;
}
.clg-app .clg-field-error { margin-top: 6px; font-size: 15px; font-weight: 600; color: var(--clg-error); }
.clg-app .clg-helper-link { margin-top: 8px; font-size: 16px; } /* helper link under the ingredients box */

/* --------------------------------------------------------------------------
   11. Baker's Hardware & Supply Matching Center (affiliate area)
   -------------------------------------------------------------------------- */
.clg-app .clg-matching {
	background: #fff;
	border: 1px solid var(--clg-line);
	border-left: 6px solid var(--brand-accent);
	border-radius: var(--clg-radius);
	box-shadow: var(--clg-shadow);
	padding: 20px;
	margin: 22px 0;
}
.clg-app .clg-matching-title { font-size: 20px; font-weight: 800; color: var(--clg-ink); margin-bottom: 6px; }
.clg-app .clg-matching-sub { font-size: 15px; color: var(--clg-ink-soft); margin-bottom: 12px; }
.clg-app .clg-matching-banner {
	background: var(--clg-accent-soft);
	border: 1.5px solid var(--brand-accent);
	border-radius: 12px;
	padding: 14px 16px;
	margin-bottom: 12px;
	font-size: 16px;
	line-height: 1.55;
	color: var(--clg-ink);
}
.clg-app .clg-matching-banner a {
	color: var(--clg-primary-dark);
	font-weight: 800;
	text-decoration: underline;
	text-underline-offset: 3px;
}
.clg-app .clg-matching-banner a:hover { color: var(--brand-primary); }
.clg-app .clg-matching-banner:last-child { margin-bottom: 0; }
/* "Edit Design in Canva" button — accent outline style, beside Download. */
.clg-app .clg-canva-btn { background: #fff; border-color: var(--brand-accent); color: #C7432F; }
.clg-app .clg-canva-btn:hover {
	background: var(--clg-accent-soft);
	border-color: var(--brand-accent);
	color: #C7432F;
}

/* --------------------------------------------------------------------------
   12. Download / action row under the preview
   -------------------------------------------------------------------------- */
.clg-app .clg-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.clg-app .clg-actions .clg-btn { flex: 1 1 200px; }

/* --------------------------------------------------------------------------
   13. Modal (ingredient-formatting helper + print alignment warning)
   -------------------------------------------------------------------------- */
.clg-app .clg-modal {
	position: fixed;
	inset: 0;
	z-index: 999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(34, 56, 79, 0.55);
}
.clg-app .clg-modal-card {
	width: 100%;
	max-width: 520px;
	max-height: 88vh;
	overflow-y: auto;
	background: #fff;
	border-radius: var(--clg-radius);
	box-shadow: 0 18px 50px rgba(34, 56, 79, 0.30);
	padding: 24px 22px;
}
.clg-app .clg-modal-title { font-size: 21px; font-weight: 800; line-height: 1.3; margin-bottom: 10px; }
.clg-app .clg-modal-body { font-size: 16px; line-height: 1.6; }
.clg-app .clg-modal-body code {
	display: inline-block;
	padding: 1px 6px;
	background: var(--brand-bg);
	border-radius: 6px;
	font-size: 15px;
}
.clg-app .clg-modal-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	justify-content: flex-end;
	margin-top: 20px;
}

/* --------------------------------------------------------------------------
   14. Loading state
   -------------------------------------------------------------------------- */
.clg-app .clg-loading {
	padding: 28px 12px;
	text-align: center;
	font-size: 16px;
	font-weight: 600;
	color: var(--clg-ink-soft);
}

/* --------------------------------------------------------------------------
   15. Small-screen tweaks (<= 640px)
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
	.clg-app .clg-panel { padding: 18px 14px; }
	.clg-app .clg-card, .clg-app .clg-state-rules, .clg-app .clg-matching { padding: 18px 14px; }
	.clg-app .clg-card-title { font-size: 20px; }
	/* Step tabs: keep the number, shrink the words so all three fit. */
	.clg-app .clg-step { padding: 8px 6px; font-size: 13.5px; gap: 6px; }
	.clg-app .clg-step-num { width: 24px; height: 24px; font-size: 13px; }
	.clg-app .clg-nav { flex-wrap: wrap; }
	.clg-app .clg-nav .clg-btn { flex: 1 1 140px; }
	.clg-app .clg-toggle { display: flex; width: 100%; }
	.clg-app .clg-toggle-btn { flex: 1 1 0; padding-left: 10px; padding-right: 10px; }
	.clg-app .clg-modal { padding: 10px; align-items: flex-end; }
	.clg-app .clg-modal-card { max-height: 92vh; border-radius: 16px 16px 10px 10px; }
}

/* --------------------------------------------------------------------------
   16. Print helpers — the generator UI never prints, only the sheet does.
   -------------------------------------------------------------------------- */
@media print {
	.clg-app .clg-no-print { display: none !important; }
}

/* --------------------------------------------------------------------------
   17. Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.clg-app *, .clg-app *::before, .clg-app *::after {
		transition: none !important;
		animation: none !important;
		scroll-behavior: auto !important;
	}
}
