/* ==========================================================================
   JSE AI Navigation Search Widget — Modern & Stylish Theme
   Matches JSE branding: Warm Red / Coral Accent + Refined Pill Aesthetic
   ========================================================================== */

:root {
	--jse-brand: #d9232d;         /* JSE Brand Red */
	--jse-brand-hover: #b91c1c;   /* Darker hover state */
	--jse-brand-light: #fef2f2;   /* Soft red background tint */
	--jse-border: #e2e8f0;        /* Subtle border */
	--jse-border-focus: #d9232d;  /* Focus accent */
	--jse-text-dark: #0f172a;     /* Deep slate text */
	--jse-text-muted: #64748b;    /* Secondary text */
	--jse-surface: #ffffff;       /* Card surface */
}

.jse-search-container {
	position: relative;
	width: 100%;
	max-width: 720px;
	margin: 1.5rem auto;
	font-family: inherit;
	box-sizing: border-box;
}

.jse-search-container * {
	box-sizing: border-box;
}

.jse-search-heading {
	font-size: 1.35rem;
	font-weight: 700;
	color: var(--jse-text-dark);
	margin: 0 0 0.875rem 0;
	letter-spacing: -0.02em;
}

/* --- Search Input Bar (Capsule Pill Shape) --- */
.jse-search-input-wrap {
	display: flex;
	align-items: center;
	position: relative;
	background-color: var(--jse-surface);
	border: 1.5px solid var(--jse-border);
	border-radius: 9999px;
	padding: 5px 6px 5px 18px;
	box-shadow: 0 4px 20px -3px rgba(15, 23, 42, 0.08), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
	transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.jse-search-input-wrap:focus-within {
	border-color: var(--jse-brand);
	box-shadow: 0 0 0 4px rgba(217, 35, 45, 0.12), 0 8px 24px -4px rgba(15, 23, 42, 0.1);
	background-color: #ffffff;
}

/* Hide standalone left icon — now bundled into the submit button */
.jse-search-icon {
	display: none !important;
}

.jse-search-input {
	flex: 1;
	min-width: 0;
	height: 44px;
	padding: 0 0.75rem 0 0;
	font-size: 0.975rem;
	font-weight: 450;
	color: var(--jse-text-dark);
	background: transparent;
	border: none;
	outline: none;
}

.jse-search-input::placeholder {
	color: #94a3b8;
	font-weight: 400;
}

.jse-search-input::-webkit-search-cancel-button {
	display: none;
}

.jse-search-clear-btn {
	background: none;
	border: none;
	padding: 6px;
	margin-right: 6px;
	cursor: pointer;
	color: #94a3b8;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: all 0.15s ease;
}

.jse-search-clear-btn:hover {
	color: var(--jse-text-dark);
	background-color: #f1f5f9;
}

/* --- Search Button with Integrated Icon --- */
.jse-search-submit-btn {
	background-color: var(--jse-brand);
	color: #ffffff;
	border: none;
	border-radius: 9999px;
	padding: 0 1.35rem 0 1.15rem;
	height: 42px;
	font-size: 0.9rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	box-shadow: 0 2px 8px rgba(217, 35, 45, 0.25);
	transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
	white-space: nowrap;
}

/* SVG Search Icon placed directly before text */
.jse-search-submit-btn::before {
	content: "";
	display: inline-block;
	width: 15px;
	height: 15px;
	background-color: currentColor;
	mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>') no-repeat center / contain;
	-webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>') no-repeat center / contain;
}

.jse-search-submit-btn:hover {
	background-color: var(--jse-brand-hover);
	transform: translateY(-1px);
	box-shadow: 0 4px 14px rgba(217, 35, 45, 0.35);
}

.jse-search-submit-btn:active {
	transform: translateY(0);
}

.jse-search-submit-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none;
}

/* --- Suggestion Chips --- */
.jse-search-suggestions {
	display: flex;
	align-items: center;
	gap: 0.625rem;
	margin-top: 0.75rem;
	padding: 0 0.5rem;
	flex-wrap: wrap;
	font-size: 0.8125rem;
}

.jse-search-suggestions-label {
	color: var(--jse-text-muted);
	font-weight: 600;
	font-size: 0.775rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.jse-search-chips {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 0.45rem;
}

.jse-search-chip {
	background-color: #ffffff;
	color: #334155;
	border: 1px solid var(--jse-border);
	border-radius: 9999px;
	padding: 0.3rem 0.75rem;
	font-size: 0.8rem;
	font-weight: 500;
	cursor: pointer;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
	transition: all 0.15s ease;
}

.jse-search-chip:hover {
	background-color: var(--jse-brand-light);
	border-color: #fca5a5;
	color: var(--jse-brand);
	transform: translateY(-1px);
}

/* --- Results Panel / Dropdown --- */
.jse-search-panel {
	margin-top: 0.75rem;
	background-color: var(--jse-surface);
	border: 1px solid var(--jse-border);
	border-radius: 16px;
	box-shadow: 0 12px 36px -4px rgba(15, 23, 42, 0.12), 0 4px 12px -2px rgba(15, 23, 42, 0.04);
	overflow: hidden;
}

/* AI Summary Bar */
.jse-search-summary {
	padding: 0.75rem 1.125rem;
	background: linear-gradient(90deg, #f8fafc 0%, #ffffff 100%);
	border-bottom: 1px solid var(--jse-border);
	font-size: 0.8125rem;
	color: #334155;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.jse-search-summary-text {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-weight: 500;
}

.jse-search-summary-ai-icon {
	color: var(--jse-brand);
	font-weight: 700;
	font-size: 0.7rem;
	letter-spacing: 0.05em;
	background: var(--jse-brand-light);
	padding: 0.15rem 0.45rem;
	border-radius: 6px;
	border: 1px solid #fecaca;
}

.jse-search-summary-count {
	color: var(--jse-text-muted);
	font-size: 0.775rem;
	font-weight: 600;
}

/* Scrollable Container with Smooth Scrollbar */
.jse-search-results-list {
	max-height: 420px;
	overflow-y: auto;
	scroll-behavior: smooth;
	padding: 0.35rem 0;
}

.jse-search-results-list::-webkit-scrollbar {
	width: 6px;
}
.jse-search-results-list::-webkit-scrollbar-track {
	background: #f8fafc;
}
.jse-search-results-list::-webkit-scrollbar-thumb {
	background: #cbd5e1;
	border-radius: 4px;
}
.jse-search-results-list::-webkit-scrollbar-thumb:hover {
	background: #94a3b8;
}

/* Result Item Cards */
.jse-search-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.875rem 1.125rem;
	border-bottom: 1px solid #f1f5f9;
	text-decoration: none;
	color: inherit;
	transition: background-color 0.15s ease, transform 0.15s ease;
}

.jse-search-item:last-child {
	border-bottom: none;
}

.jse-search-item:hover,
.jse-search-item.is-selected {
	background-color: #f8fafc;
}

.jse-search-item-content {
	flex: 1;
	min-width: 0;
	padding-right: 0.875rem;
}

.jse-search-item-header {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.25rem;
}

/* Badges */
.jse-search-badge {
	display: inline-block;
	font-size: 0.675rem;
	font-weight: 700;
	padding: 0.15rem 0.5rem;
	border-radius: 9999px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	line-height: 1.3;
}

.jse-search-badge-quiz {
	background-color: #fff7ed;
	color: #c2410c;
	border: 1px solid #ffedd5;
}

.jse-search-badge-course {
	background-color: #eff6ff;
	color: #1d4ed8;
	border: 1px solid #dbeafe;
}

.jse-search-item-title {
	font-size: 0.95rem;
	font-weight: 600;
	color: var(--jse-text-dark);
	margin: 0;
	line-height: 1.35;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	transition: color 0.15s ease;
}

.jse-search-item:hover .jse-search-item-title {
	color: var(--jse-brand);
}

.jse-search-item-snippet {
	font-size: 0.8125rem;
	color: var(--jse-text-muted);
	margin: 0.25rem 0 0 0;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.jse-search-item-action {
	display: flex;
	align-items: center;
	color: #cbd5e1;
	transition: all 0.15s ease;
}

.jse-search-item:hover .jse-search-item-action {
	color: var(--jse-brand);
	transform: translateX(3px);
}

/* Footer / Load More */
.jse-search-footer {
	padding: 0.75rem 1.125rem;
	background-color: #f8fafc;
	border-top: 1px solid #f1f5f9;
	text-align: center;
}

.jse-search-load-more-btn {
	background-color: #ffffff;
	color: #334155;
	border: 1px solid var(--jse-border);
	border-radius: 9999px;
	padding: 0.45rem 1.25rem;
	font-size: 0.825rem;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
	transition: all 0.15s ease;
}

.jse-search-load-more-btn:hover {
	border-color: var(--jse-brand);
	color: var(--jse-brand);
	background-color: var(--jse-brand-light);
}

.jse-search-load-more-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* Loading & Empty States */
.jse-search-state-message {
	padding: 1.75rem 1rem;
	text-align: center;
	color: var(--jse-text-muted);
	font-size: 0.875rem;
}

.jse-search-state-title {
	font-weight: 600;
	color: var(--jse-text-dark);
	margin-bottom: 0.25rem;
}

.jse-search-empty-link {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-weight: 600;
	font-size: 0.875rem;
	color: var(--jse-brand);
	text-decoration: underline;
	transition: color 0.15s ease;
}

.jse-search-empty-link:hover {
	color: var(--jse-brand-hover);
}

.jse-search-spinner {
	display: inline-block;
	width: 22px;
	height: 22px;
	border: 2.5px solid #f1f5f9;
	border-top-color: var(--jse-brand);
	border-radius: 50%;
	animation: jse-search-spin 0.6s linear infinite;
	margin-bottom: 0.5rem;
}

@keyframes jse-search-spin {
	to { transform: rotate(360deg); }
}

.jse-search-skeleton-item {
	padding: 0.875rem 1.125rem;
	border-bottom: 1px solid #f1f5f9;
}

.jse-search-skeleton-line {
	height: 12px;
	background: #f1f5f9;
	border-radius: 9999px;
	margin-bottom: 0.5rem;
	animation: jse-skeleton-pulse 1.2s ease-in-out infinite;
}

.jse-search-skeleton-line.w-40 { width: 40%; }
.jse-search-skeleton-line.w-80 { width: 80%; }
.jse-search-skeleton-line.w-60 { width: 60%; }

@keyframes jse-skeleton-pulse {
	0%, 100% { opacity: 0.5; }
	50% { opacity: 1; }
}

@media (max-width: 480px) {
	.jse-search-input-wrap {
		padding: 4px 5px 4px 14px;
	}
	.jse-search-input {
		font-size: 0.9rem;
		height: 38px;
	}
	.jse-search-submit-btn {
		height: 36px;
		padding: 0 1rem;
		font-size: 0.825rem;
	}
	.jse-search-results-list {
		max-height: 320px;
	}
}
