/**
 * Afoomart Master Search Component & Results Stylesheet
 *
 * Implements Chapter 07: Search Results & Advanced Product Listing
 * - Desktop search bar, category picker & clear button
 * - Live autocomplete dropdown (Products, Categories, Trending)
 * - Recent Searches with individual deletion and Clear History
 * - Keyboard navigation highlight states
 * - Mobile search overlay & suggestions
 * - Empty search query landing page
 * - Zero search results page with alternative discovery
 *
 * @package Afoomart
 */

/* ==========================================================================
   1. HEADER SEARCH COMPONENT
   ========================================================================== */

.af-header-search-component {
	position: relative;
	width: 100%;
}

.af-search-box {
	display: flex;
	align-items: stretch;
	background-color: var(--af-color-surface, #ffffff);
	border: 2px solid var(--af-color-primary, #113F6D);
	border-radius: var(--af-radius-md, 8px);
	overflow: hidden;
	height: 44px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
	transition: border-color 0.2s, box-shadow 0.2s;
}

.af-search-box:focus-within {
	border-color: var(--af-color-danger, #DE2C27);
	box-shadow: 0 0 0 3px rgba(222, 44, 39, 0.15);
}

/* Category Selector inside Search Bar */
.af-search-cat-picker-wrap {
	position: relative;
	display: flex;
	align-items: center;
	background-color: var(--af-color-bg, #f8fafc);
	border-right: 1px solid var(--af-color-border, #e5e7eb);
	padding: 0 24px 0 12px;
	flex-shrink: 0;
}

.af-search-cat-picker {
	appearance: none;
	-webkit-appearance: none;
	background: transparent;
	border: none;
	font-family: inherit;
	font-size: var(--af-font-size-xs, 12px);
	font-weight: 600;
	color: var(--af-color-text, #334155);
	cursor: pointer;
	outline: none;
	max-width: 140px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.af-search-cat-arrow {
	position: absolute;
	right: 8px;
	pointer-events: none;
	color: var(--af-color-text-muted, #64748b);
}

/* Input Field Wrapper */
.af-search-field-wrap {
	position: relative;
	flex: 1;
	display: flex;
	align-items: center;
}

.af-search-input-field {
	width: 100%;
	height: 100%;
	border: none;
	padding: 0 36px 0 14px;
	font-family: inherit;
	font-size: var(--af-font-size-sm, 14px);
	color: var(--af-color-text, #1e293b);
	outline: none;
	background: transparent;
}

/* Clear Input Button */
.af-search-clear-btn {
	position: absolute;
	right: 12px;
	background: none;
	border: none;
	color: var(--af-color-text-muted, #94a3b8);
	cursor: pointer;
	padding: 4px;
	display: none;
	align-items: center;
	justify-content: center;
	transition: color 0.15s;
}

.af-search-clear-btn:hover {
	color: var(--af-color-danger, #DE2C27);
}

.af-search-clear-btn.is-visible {
	display: inline-flex;
}

/* Search Spinner */
.af-search-spinner {
	display: none;
	position: absolute;
	right: 36px;
	width: 16px;
	height: 16px;
	border: 2px solid #e2e8f0;
	border-top-color: var(--af-color-primary, #113F6D);
	border-radius: 50%;
	animation: af-search-spin 0.6s linear infinite;
}

.af-search-spinner.is-active {
	display: block;
}

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

/* Search Submit Button */
.af-search-submit-btn {
	background-color: var(--af-color-danger, #DE2C27);
	color: #ffffff;
	border: none;
	padding: 0 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--af-space-2, 8px);
	cursor: pointer;
	font-weight: 600;
	font-size: var(--af-font-size-sm, 14px);
	transition: background-color 0.2s;
	flex-shrink: 0;
}

.af-search-submit-btn:hover {
	background-color: #b91c1c;
}

/* ==========================================================================
   2. SUGGESTIONS & AUTOCOMPLETE DROPDOWN
   ========================================================================== */

.af-search-dropdown {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	background-color: var(--af-color-surface, #ffffff);
	border: 1px solid var(--af-color-border, #e5e7eb);
	border-radius: var(--af-radius-lg, 12px);
	box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
	z-index: 1000;
	overflow: hidden;
	max-height: 480px;
	overflow-y: auto;
}

.af-search-section {
	border-bottom: 1px solid var(--af-color-border, #f1f5f9);
}

.af-search-section:last-child {
	border-bottom: none;
}

.af-search-section-header {
	padding: 8px 14px;
	background-color: var(--af-color-bg, #f8fafc);
	font-size: 11px;
	font-weight: 700;
	color: var(--af-color-text-muted, #64748b);
	text-transform: uppercase;
	letter-spacing: 0.05em;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.af-clear-history-btn {
	background: none;
	border: none;
	font-size: 11px;
	color: var(--af-color-danger, #DE2C27);
	cursor: pointer;
	padding: 0;
	text-decoration: underline;
}

/* Suggestion List Items */
.af-search-suggestions-list {
	display: flex;
	flex-direction: column;
}

.af-search-suggestion-item {
	display: flex;
	align-items: center;
	gap: var(--af-space-3, 12px);
	padding: 10px 14px;
	border-bottom: 1px solid #f8fafc;
	text-decoration: none;
	color: var(--af-color-text, #1e293b);
	transition: background-color 0.15s;
}

.af-search-suggestion-item:hover,
.af-search-suggestion-item.af-highlighted {
	background-color: rgba(17, 63, 109, 0.06);
	color: var(--af-color-primary, #113F6D);
}

.af-search-suggestion-thumb img {
	border-radius: var(--af-radius-sm, 4px);
	object-fit: cover;
	display: block;
	background: #f1f5f9;
}

.af-search-suggestion-info {
	flex: 1;
}

.af-search-suggestion-title {
	font-size: var(--af-font-size-sm, 14px);
	font-weight: 500;
	line-height: 1.3;
}

.af-search-suggestion-price {
	font-size: var(--af-font-size-xs, 12px);
	color: var(--af-color-danger, #DE2C27);
}

.af-highlight {
	color: var(--af-color-danger, #DE2C27);
	font-weight: 700;
}

/* Recent & Trending Pills */
.af-search-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 10px 14px;
}

.af-search-pill-wrapper {
	display: inline-flex;
	align-items: center;
	background: var(--af-color-bg, #f1f5f9);
	border: 1px solid var(--af-color-border, #e2e8f0);
	border-radius: var(--af-radius-full, 9999px);
	padding: 2px 4px 2px 10px;
}

.af-search-pill {
	font-size: var(--af-font-size-xs, 12px);
	color: var(--af-color-text, #334155);
	text-decoration: none;
}

.af-remove-recent-btn {
	background: none;
	border: none;
	color: var(--af-color-text-muted, #94a3b8);
	cursor: pointer;
	padding: 0 4px;
	font-size: 14px;
	line-height: 1;
}

.af-remove-recent-btn:hover {
	color: var(--af-color-danger, #DE2C27);
}

.af-search-dropdown-footer {
	padding: 8px 14px;
	background: var(--af-color-bg, #f8fafc);
	border-top: 1px solid var(--af-color-border, #e5e7eb);
	text-align: right;
}

.af-search-view-all-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: none;
	border: none;
	font-size: var(--af-font-size-xs, 12px);
	font-weight: 600;
	color: var(--af-color-primary, #113F6D);
	text-decoration: none;
	cursor: pointer;
}

.af-search-view-all-btn:hover {
	color: var(--af-color-danger, #DE2C27);
}

/* ==========================================================================
   3. EMPTY SEARCH QUERY LANDING STATE
   ========================================================================== */

.af-search-empty-landing {
	background: var(--af-color-surface, #ffffff);
	border: 1px solid var(--af-color-border, #e5e7eb);
	border-radius: var(--af-radius-xl, 16px);
	padding: var(--af-space-10, 40px) var(--af-space-6, 24px);
	text-align: center;
}

.af-search-empty-landing-inner {
	max-width: 640px;
	margin: 0 auto;
}

.af-search-empty-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 80px;
	height: 80px;
	border-radius: var(--af-radius-full, 9999px);
	background: rgba(17, 63, 109, 0.06);
	color: var(--af-color-primary, #113F6D);
	margin-bottom: var(--af-space-4, 16px);
}

.af-search-empty-title {
	font-size: var(--af-font-size-2xl, 24px);
	font-weight: 700;
	color: var(--af-color-text, #1e293b);
	margin-bottom: var(--af-space-2, 8px);
}

.af-search-empty-subtitle {
	font-size: var(--af-font-size-sm, 14px);
	color: var(--af-color-text-muted, #64748b);
	margin-bottom: var(--af-space-6, 24px);
}

.af-search-landing-box {
	margin-bottom: var(--af-space-4, 16px);
}

.af-search-landing-input-wrap {
	display: flex;
	align-items: center;
	gap: var(--af-space-2, 8px);
	background: #ffffff;
	border: 2px solid var(--af-color-primary, #113F6D);
	border-radius: var(--af-radius-lg, 12px);
	padding: 4px 6px 4px 16px;
	box-shadow: 0 4px 12px rgba(17, 63, 109, 0.08);
}

.af-search-landing-input {
	flex: 1;
	border: none;
	font-size: var(--af-font-size-base, 16px);
	color: var(--af-color-text, #1e293b);
	outline: none;
}

.af-search-trending-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--af-space-2, 8px);
	flex-wrap: wrap;
}

.af-search-trending-label {
	font-size: var(--af-font-size-xs, 12px);
	font-weight: 600;
	color: var(--af-color-text-muted, #64748b);
}

/* ==========================================================================
   4. ZERO SEARCH RESULTS STATE
   ========================================================================== */

.af-search-zero-results {
	background: var(--af-color-surface, #ffffff);
	border: 1px solid var(--af-color-border, #e5e7eb);
	border-radius: var(--af-radius-lg, 12px);
	padding: var(--af-space-10, 40px) var(--af-space-6, 24px);
	text-align: center;
}

.af-zero-results-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 72px;
	height: 72px;
	border-radius: var(--af-radius-full, 9999px);
	background: #fee2e2;
	color: var(--af-color-danger, #DE2C27);
	margin-bottom: var(--af-space-4, 16px);
}

/* ==========================================================================
   5. MOBILE SEARCH RESPONSIVENESS (< 768px)
   ========================================================================== */

@media (max-width: 767px) {
	.af-search-box {
		height: 40px;
	}

	.af-search-cat-picker-wrap {
		display: none;
	}

	.af-search-submit-btn {
		padding: 0 14px;
	}

	.af-search-btn-text {
		display: none;
	}
}
