/**
 * ML Research & Writing (Standalone) widget styles.
 *
 * @package Magiclamp
 */

.mlrw-widget {
	--mlrw-blue: #4a4fc4;
	--mlrw-text: #1a1a2e;
	--mlrw-muted: #6b6b7d;
	--mlrw-border: #e2e2ea;
	--mlrw-navy: #002642;
}

.mlrw-widget__title {
	font-size: 28px;
	margin-bottom: 20px;
	color: var(--mlrw-text);
}

.mlrw-widget__controls {
	display: flex;
	gap: 16px;
	margin-bottom: 20px;
	flex-wrap: wrap;
}

.mlrw-widget__search {
	display: flex;
	flex: 1 1 320px;
	border: 1px solid var(--mlrw-border);
	border-radius: 4px;
	overflow: hidden;
	background: #fff;
}

.mlrw-search-input {
	flex: 1;
	border: none;
	padding: 12px 16px;
	font-size: 14px;
	outline: none;
}

.mlrw-search-btn {
	font-family: "source-sans-pro", sans-serif;
	font-size: 16px;
	font-weight: 700;
	color: var(--e-global-color-kadence9);
	background-color: #006dc1;
	border-style: solid;
	border-width: 1px 1px 1px 1px;
	border-color: #006dc1;
	border-radius: 0px 0px 0px 0px;
	padding: 0 24px;
	cursor: pointer;
	transition: background 0.2s ease;
}

.mlrw-search-btn:hover {
	background-color: #00508f;
	border-color: #00508f;
}

.mlrw-widget__filter {
	flex: 0 1 50%;
	width: 50%;
	display: flex;
	align-items: center;
	gap: 10px;
}

.mlrw-filter-label {
	color: #002642;
	white-space: nowrap;
	font-family: "source-sans-pro", sans-serif;
	font-size: 0.85rem;
	text-transform: uppercase;
	font-weight: 600;
}

/* Native select stays in the DOM as the source of truth for the current
   value; the combobox below is what's actually shown/interacted with. */
.mlrw-product-type-select {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	opacity: 0;
	pointer-events: none;
}

.mlrw-combobox {
	position: relative;
	flex: 1;
	min-width: 0;
}

.mlrw-combobox__input {
	width: 100%;
	border: 1px solid var(--mlrw-border);
	border-radius: 4px;
	padding: 12px 14px;
	font-size: 14px;
	background: #fff;
	cursor: pointer;
}

.mlrw-combobox__panel {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	background: #fff;
	border: 1px solid var(--mlrw-border);
	border-radius: 4px;
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
	max-height: 240px;
	overflow-y: auto;
	z-index: 20;
}

.mlrw-combobox__option {
	padding: 10px 14px;
	font-size: 14px;
	cursor: pointer;
}

.mlrw-combobox__option:hover {
	background: #f0f1fb;
}

.mlrw-combobox__empty {
	padding: 10px 14px;
	font-size: 13px;
	color: var(--mlrw-muted);
}

/* Active filter chips */
.mlrw-widget__active-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-bottom: 24px;
}

.mlrw-widget__active-filters:empty {
	display: none;
	margin-bottom: 0;
}

.mlrw-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: #fff;
	border-radius: 20px;
	padding: 6px 10px 6px 14px;
	font-size: 13px;
	color: var(--mlrw-text);
	border: none;
}

.mlrw-chip__remove {
	background: transparent;
	border: none;
	cursor: pointer;
	font-size: 16px;
	line-height: 1;
	color: var(--mlrw-muted);
	padding: 2px;
}

.mlrw-chip__remove:hover {
	background: transparent;
	color: var(--mlrw-text);
}

.mlrw-chip--clear-all {
	background: #ffffff;
	border: none;
	cursor: pointer;
	color: #006dc1;
	font-weight: 600;
	font-size: 13px;
	padding: 6px 4px;
}

.mlrw-widget__grid-wrap {
	position: relative;
	min-height: 120px;
}

.mlrw-widget__grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 24px;
	transition: opacity 0.2s ease;
}

.mlrw-widget__grid.is-loading {
	opacity: 0.4;
	pointer-events: none;
}

.mlrw-card {
	background: transparent;
	border: none;
	border-bottom: 1px dotted #002642 !important;
	display: flex;
	flex-direction: column;
	transition: transform 0.2s ease;
}

.mlrw-card:hover {
	transform: translateY(-4px);
}

.mlrw-card__image-link {
	display: block;
}

.mlrw-card__image {
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: #eef0f5;
}

.mlrw-card__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.mlrw-card__body {
	background: transparent;
	padding: 16px 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
	flex: 1;
}

.mlrw-card__type {
	font-family: "source-sans-pro", sans-serif;
	font-size: 0.85rem;
	font-weight: bold;
	text-transform: uppercase;
	color: var(--mlrw-navy);
}

.mlrw-card__title {
	font-family: "freight-display-pro", sans-serif;
	font-size: 1.5rem;
	font-weight: 400;
	line-height: 1.3em;
	color: var(--mlrw-navy);
	margin: 0;
}

.mlrw-card__title a {
	color: inherit;
	text-decoration: none;
}

.mlrw-card__title a:hover {
	text-decoration: none;
}

.mlrw-card__meta {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-top: auto;
	padding-top: 8px;
}

.mlrw-card__date,
.mlrw-card__people {
	font-family: "freight-display-pro", sans-serif;
	font-size: 0.85rem;
	font-weight: 600;
	line-height: 1em;
	color: #002642 !important;
}

.mlrw-no-results {
	grid-column: 1 / -1;
	text-align: center;
	color: var(--mlrw-muted);
	padding: 40px 0;
}

.mlrw-loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2;
}

.mlrw-spinner {
	width: 32px;
	height: 32px;
	border: 3px solid var(--mlrw-border);
	border-top-color: var(--mlrw-blue);
	border-radius: 50%;
	animation: mlrw-spin 0.7s linear infinite;
}

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

.mlrw-load-more {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 32px 0 8px;
	color: var(--mlrw-muted);
	font-size: 14px;
}

.mlrw-load-more__spinner {
	display: none;
	width: 18px;
	height: 18px;
	border: 2px solid var(--mlrw-border);
	border-top-color: var(--mlrw-blue);
	border-radius: 50%;
	animation: mlrw-spin 0.7s linear infinite;
}

.mlrw-load-more.is-loading .mlrw-load-more__spinner {
	display: inline-block;
}

@media (max-width: 991px) {
	.mlrw-widget__grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* Tablet: stack search + filter full-width before they get cramped at a
   fixed 50/50 split — independent of the grid's own column breakpoints. */
@media (max-width: 900px) {
	.mlrw-widget__controls {
		flex-direction: column;
		gap: 12px;
	}

	.mlrw-widget__search {
		flex-basis: auto;
		width: 100%;
	}

	.mlrw-widget__filter {
		width: 100%;
	}

	.mlrw-combobox {
		flex: 1;
		width: 100%;
	}
}

@media (max-width: 600px) {
	.mlrw-widget__grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 400px) {
	.mlrw-search-btn {
		padding: 0 16px;
	}

	.mlrw-widget__title {
		font-size: 22px;
	}
}
