/*
 * TiorAI Engine – Shared Base Stylesheet
 *
 * Contains design tokens and shared UI component styles used by every tool.
 * Loaded conditionally: only when at least one tool shortcode is present
 * on the current page. Never enqueued globally across the site.
 *
 * Scope strategy:
 *   - Tokens declared on :root so they cascade to every .te-tool root and
 *     can be overridden per-tool via the tool-specific root selector.
 *   - Component rules are scoped under .te-tool to prevent bleed into
 *     theme styles. Every tool wrapper carries "te-tool" plus its own
 *     tool-specific class (e.g. "te-tool te-case-converter").
 *
 * Handle: tiorai-base
 * Enqueued by: _TEngine_Assets::enqueue_tool_assets()
 */

/* ==========================================================================
   Design tokens – global defaults; override per-tool root if needed
   ========================================================================== */

:root {
	/* Theme-aware tokens: inherit from WP theme or fall back to currentColor mixes */
	--te-color-primary: var(--wp--preset--color--primary, var(--wp--preset--color--vivid-cyan-blue, currentColor));
	--te-color-primary-hover: var(--wp--preset--color--primary, var(--wp--preset--color--vivid-cyan-blue, currentColor));
	--te-color-secondary: color-mix(in srgb, currentColor 12%, transparent);
	--te-color-secondary-fg: inherit;
	--te-color-secondary-hover: color-mix(in srgb, currentColor 20%, transparent);
	--te-color-success: color-mix(in srgb, currentColor 60%, transparent);
	--te-color-success-hover: color-mix(in srgb, currentColor 70%, transparent);
	--te-color-border: color-mix(in srgb, currentColor 25%, transparent);
	--te-color-border-light: color-mix(in srgb, currentColor 15%, transparent);
	--te-color-text-muted: color-mix(in srgb, currentColor 60%, transparent);
	--te-color-alert-bg: color-mix(in srgb, currentColor 8%, transparent);
	--te-color-alert-border: color-mix(in srgb, currentColor 20%, transparent);
	--te-color-alert-text: inherit;
	--te-color-input-bg: transparent;
	--te-color-output-bg: color-mix(in srgb, currentColor 5%, transparent);
	--te-color-output-text: inherit;
	--te-color-surface: color-mix(in srgb, currentColor 5%, transparent);
	--te-color-bg-secondary: color-mix(in srgb, currentColor 8%, transparent);
	--te-color-text: inherit;
	--te-color-muted: color-mix(in srgb, currentColor 60%, transparent);
	--te-color-text-secondary: color-mix(in srgb, currentColor 60%, transparent);
	--te-radius: 6px;
	--te-font: inherit;
}

/* ==========================================================================
   Tool container
   ========================================================================== */

.te-tool {
	box-sizing: border-box;
	font-family: var(--te-font);
	max-width: 800px;
	margin: 0 auto 2rem;
}

/* Propagate box-sizing to all children without resetting the global box model */
.te-tool *,
.te-tool *::before,
.te-tool *::after {
	box-sizing: inherit;
}

/* ==========================================================================
   Label
   ========================================================================== */

.te-tool .te-label {
	display: block;
	font-weight: 600;
	font-size: 0.875rem;
	margin-bottom: 0.4rem;
}

/* ==========================================================================
   Input & Textarea – shared base styles
   ========================================================================== */

.te-tool .te-input,
.te-tool .te-textarea {
	display: block;
	width: 100%;
	padding: 0.625rem 0.75rem;
	border: 1px solid var(--te-color-border);
	border-radius: var(--te-radius);
	font-size: 1rem;
	transition: border-color 0.15s ease;
	background: var(--te-color-input-bg);
	color: inherit;
}

/* Textarea-specific additions (multi-line resize & font consistency) */
.te-tool .te-textarea {
	font-family: var(--te-font);
	line-height: 1.5;
	resize: vertical;
}

/* Focus ring */
.te-tool .te-input:focus,
.te-tool .te-textarea:focus {
	outline: none;
	border-color: var(--te-color-primary);
}

/* Read-only / output state */
.te-tool .te-input[readonly],
.te-tool .te-textarea[readonly] {
	background: var(--te-color-output-bg);
	color: var(--te-color-output-text);
}

/* ==========================================================================
   Action button row
   ========================================================================== */

.te-tool .te-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.625rem;
	margin-top: 1rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.te-tool .te-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.5rem 1.25rem;
	font-size: 0.9375rem;
	font-weight: 600;
	font-family: var(--te-font);
	line-height: 1.4;
	border-radius: var(--te-radius);
	border: none;
	cursor: pointer;
	transition: background-color 0.15s ease, opacity 0.15s ease;
	white-space: nowrap;
}

/* Primary */
.te-tool .te-button--primary {
	background-color: var(--te-color-primary);
	color: var(--wp--preset--color--base, #fff);
}

.te-tool .te-button--primary:hover,
.te-tool .te-button--primary:focus-visible {
	background-color: var(--te-color-primary-hover);
	filter: brightness(0.85);
}

/* Secondary */
.te-tool .te-button--secondary {
	background-color: var(--te-color-secondary);
	color: var(--te-color-secondary-fg);
}

.te-tool .te-button--secondary:hover,
.te-tool .te-button--secondary:focus-visible {
	background-color: var(--te-color-secondary-hover);
}

/* Copy / success */
.te-tool .te-button--copy {
	background-color: var(--te-color-success);
	color: var(--wp--preset--color--base, #fff);
}

.te-tool .te-button--copy:hover,
.te-tool .te-button--copy:focus-visible {
	background-color: var(--te-color-success-hover);
}

/* Disabled state */
.te-tool .te-button:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Keyboard focus ring for all buttons */
.te-tool .te-button:focus-visible {
	outline: 3px solid var(--te-color-primary);
	outline-offset: 2px;
}

/* ==========================================================================
   Alert / validation message
   ========================================================================== */

.te-tool .te-alert {
	background-color: var(--te-color-alert-bg);
	border: 1px solid var(--te-color-alert-border);
	border-radius: var(--te-radius);
	padding: 0.625rem 0.875rem;
	font-size: 0.875rem;
	color: var(--te-color-alert-text);
	margin-top: 0.75rem;
}

/* ==========================================================================
   Output section
   ========================================================================== */

.te-tool .te-tool__output {
	margin-top: 1.5rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--te-color-border-light);
}

/* ==========================================================================
   Responsive – shared breakpoint rules
   ========================================================================== */

@media (max-width: 480px) {
	.te-tool .te-actions {
		flex-direction: column;
		align-items: stretch;
	}

	.te-tool .te-button {
		width: 100%;
		justify-content: center;
	}
}