/**
 * Neuroon Widget Wrapper Styles
 *
 * Minimal wrapper styles for the widget container.
 * The widget itself is styled by the CDN bundle.
 *
 * @package Neuroon_Search
 * @since 1.1.0
 */

.neuroon-widget-wrapper {
	position: relative;
	width: 100%;
	min-height: 50px;
}

.neuroon-widget-wrapper:not(.neuroon-initialized):empty::before {
	content: '';
	display: block;
	height: 50px;
	background: linear-gradient(90deg, #ecfeff 25%, #cffafe 50%, #ecfeff 75%);
	background-size: 200% 100%;
	animation: neuroon-skeleton 1.5s ease-in-out infinite;
	border-radius: 8px;
}

@keyframes neuroon-skeleton {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

.neuroon-layout-full {
	max-width: 100%;
}

.neuroon-layout-compact {
	max-width: 600px;
}

.neuroon-layout-minimal {
	max-width: 400px;
}

.neuroon-layout-icon {
	max-width: 50px;
}

/* Center alignment utility */
.neuroon-widget-wrapper.neuroon-center {
	margin-left: auto;
	margin-right: auto;
}

/* Responsive: Tablet (768px and below) */
@media (max-width: 768px) {
	.neuroon-layout-full {
		max-width: 100%;
		padding: 0 10px;
	}

	.neuroon-layout-compact {
		max-width: 100%;
		padding: 0 10px;
	}

	.neuroon-layout-minimal {
		max-width: 100%;
		padding: 0 10px;
	}
}

/* Responsive: Mobile (480px and below) */
@media (max-width: 480px) {
	.neuroon-widget-wrapper {
		padding: 0;
	}

	.neuroon-layout-full,
	.neuroon-layout-compact,
	.neuroon-layout-minimal {
		max-width: 100%;
		padding: 0 5px;
	}

	.neuroon-layout-icon {
		max-width: 44px; /* Touch-friendly minimum */
	}

	/* Menu widget adjustments for mobile */
	.neuroon-menu-widget {
		max-width: 100% !important;
	}

	/* Reduce skeleton height on mobile */
	.neuroon-widget-wrapper:not(.neuroon-initialized):empty::before {
		height: 44px;
		border-radius: 6px;
	}
}

/* Responsive: Very small screens (320px and below) */
@media (max-width: 320px) {
	.neuroon-layout-full,
	.neuroon-layout-compact,
	.neuroon-layout-minimal {
		padding: 0;
	}

	.neuroon-layout-icon {
		max-width: 40px;
	}
}

/* ========================================
   SEAMLESS REPLACEMENT OVERRIDES
   ========================================
   When the widget replaces a theme's native search form,
   it becomes a GUEST inside the theme's container.
   These overrides make the widget a passive flex child
   that inherits dimensions from the parent container
   instead of imposing its own standalone layout.
   ======================================== */

/* Core: become a passive flex child */
.neuroon-seamless-replacement,
.neuroon-seamless-js {
	width: auto;
	min-height: 0;
	min-width: 0;
	margin: 0;
	padding: 0;
	flex: 1 1 auto;
	box-sizing: border-box;
}

/* Skeleton loader: match typical search input height, not standalone */
.neuroon-seamless-replacement:not(.neuroon-initialized):empty::before,
.neuroon-seamless-js:not(.neuroon-initialized):empty::before {
	height: 36px;
	min-height: 0;
	border-radius: 4px;
}

/* WordPress block theme: respect constrained content width.
   In block themes, .is-layout-constrained sets max-width on children
   via :where() at specificity 0,1,0. Our base seamless rules override
   that with max-width:none. This rule restores WP's content width
   for direct children of constrained layouts while still allowing
   flex contexts (headers, toolbars) to use max-width:none. */
.is-layout-constrained > .neuroon-seamless-replacement,
.is-layout-constrained > .neuroon-seamless-js {
	width: 100%;
	max-width: var(--wp--style--global--content-size, 100%);
	margin-left: auto;
	margin-right: auto;
	flex: none;
}

/* Responsive: seamless always inherits parent, never adds padding */
@media (max-width: 768px) {
	.neuroon-seamless-replacement,
	.neuroon-seamless-js {
		padding: 0;
	}
}

@media (max-width: 480px) {
	.neuroon-seamless-replacement,
	.neuroon-seamless-js {
		padding: 0;
	}

	.neuroon-seamless-replacement:not(.neuroon-initialized):empty::before,
	.neuroon-seamless-js:not(.neuroon-initialized):empty::before {
		height: 36px;
	}
}

/* Print styles */
@media print {
	.neuroon-widget-wrapper {
		display: none;
	}
}

.neuroon-widget-notice,
.neuroon-widget-error {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	padding: 16px 20px;
	border-radius: 4px;
	margin: 10px 0;
}

.neuroon-widget-notice {
	background: #f0f6fc;
	border: 1px solid #c3c4c7;
}

.neuroon-widget-notice a {
	color: #0073aa;
	text-decoration: underline;
}

.neuroon-widget-notice a:hover {
	color: #005177;
}

.neuroon-widget-error {
	background: #f8d7da;
	border: 1px solid #f5c6cb;
}

/* ========================================
   WIDGET FALLBACK UI
   ======================================== */
.neuroon-fallback-container {
	max-width: 320px;
	margin: 20px auto;
	padding: 24px 20px;
	text-align: center;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	color: #475569;
}

.neuroon-fallback-icon {
	width: 48px;
	height: 48px;
	margin: 0 auto 12px;
	background: #e2e8f0;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.neuroon-fallback-icon svg {
	width: 24px;
	height: 24px;
	stroke: #64748b;
	fill: none;
}

.neuroon-fallback-title {
	margin: 0 0 8px;
	font-size: 16px;
	font-weight: 600;
	color: #334155;
}

.neuroon-fallback-description {
	margin: 0 0 16px;
	font-size: 14px;
	color: #64748b;
	line-height: 1.5;
}

.neuroon-fallback-button {
	padding: 10px 20px;
	font-size: 14px;
	font-weight: 500;
	color: #fff;
	background: #0891b2;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	transition: background 0.2s ease;
}

.neuroon-fallback-button:hover,
.neuroon-fallback-button:focus {
	background: #0e7490;
}

.neuroon-fallback-button:focus-visible {
	outline: 2px solid #0891b2;
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.neuroon-widget-wrapper:not(.neuroon-initialized):empty::before {
		animation: none;
		background: #ecfeff;
	}
}
