/**
 * Smart WooCommerce Search - Frontend Styles v2
 * Unique classes to prevent conflicts
 */

/* ========================================
   DASHICONS SUPPORT
======================================== */

/* Ensure Dashicons display correctly */
.dashicons {
	display: inline-block;
	font-family: dashicons;
	font-style: normal;
	font-weight: normal;
	font-variant: normal;
	text-transform: none;
	line-height: 1;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-decoration: none;
	vertical-align: middle;
}

/* ========================================
   BASE SEARCH CONTAINER
======================================== */

.codesws-wrapper {
	position: relative;
	width: 100%;
	max-width: 600px;
	margin: 0 auto;
}

/* Trigger button removed - no longer needed */

/* Fullscreen Mode - Inline Search Box (Always Visible) */
.codesws-mode-fullscreen .codesws-inline-search-box {
	display: block;
	width: 100%;
}

.codesws-mode-fullscreen .codesws-inline-search-box .codesws-search-box {
	cursor: pointer;
	transition: all 0.2s ease;
	position: relative;
}

.codesws-mode-fullscreen .codesws-inline-search-box .codesws-search-box:hover {
	border-color: var(--codesws-primary, #2196f3);
	box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.codesws-mode-fullscreen .codesws-inline-search-box .codesws-input-field {
	cursor: pointer;
	background: #ffffff;
	user-select: none;
}

.codesws-mode-fullscreen .codesws-inline-search-box .codesws-input-field::placeholder {
	color: #999999;
}

/* Hide overlay initially for fullscreen */
.codesws-mode-fullscreen .codesws-overlay-container {
	display: none !important;
}

.codesws-mode-fullscreen .codesws-overlay-container.is-active {
	display: flex !important;
}

/* ========================================
   SEARCH OVERLAY CONTAINER
======================================== */

.codesws-overlay-container {
	display: none;
}

.codesws-overlay-container.is-active {
	display: flex;
}

/* Fullscreen Mode - Base styles (overridden by doofinder-exact.css for DooFinder style) */
.codesws-mode-fullscreen .codesws-overlay-container.is-active {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: #ffffff;
	z-index: 999999;
	flex-direction: column;
}

/* Inline Mode - Always visible */
.codesws-mode-inline .codesws-overlay-container {
	display: block;
	position: relative;
}

/* ========================================
   CLOSE BUTTON
======================================== */

.codesws-btn-close {
	position: absolute;
	top: 16px;
	right: 16px;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #f0f0f0;
	border: none;
	border-radius: 50%;
	color: #666666;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	transition: all 0.2s ease;
	z-index: 10;
}

.codesws-btn-close:hover {
	background: #e0e0e0;
	color: #333333;
	transform: rotate(90deg);
}

/* Hide close button in inline mode */
.codesws-mode-inline .codesws-btn-close {
	display: none;
}

/* ========================================
   SEARCH FORM
======================================== */

.codesws-search-box {
	position: relative;
	display: flex;
	align-items: center;
	background: var(--codesws-bg, #ffffff);
	border: 2px solid var(--codesws-border, #e0e0e0);
	border-radius: var(--codesws-radius, 4px);
	transition: border-color 0.3s ease;
	width: 100%;
	max-width: 600px;
}

.codesws-mode-fullscreen .codesws-search-box {
	max-width: 100%;
}

.codesws-search-box:focus-within {
	border-color: var(--codesws-primary, #2196f3);
	box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.codesws-input-field {
	flex: 1;
	padding: 12px 16px;
	border: none;
	background: transparent;
	font-size: var(--codesws-font-size, 16px);
	font-family: var(--codesws-font, inherit);
	font-weight: var(--codesws-font-weight, normal);
	color: var(--codesws-text, #333333);
	outline: none;
	height: var(--codesws-input-height, 48px);
}

.codesws-input-field::placeholder {
	color: #999999;
}

.codesws-btn-search {
	padding: 8px 16px;
	background: transparent;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease;
}

.codesws-btn-search:hover {
	background: #f5f5f5;
	border-radius: 0 var(--codesws-radius, 4px) var(--codesws-radius, 4px) 0;
}

.codesws-btn-search .dashicons {
	width: 24px;
	height: 24px;
	font-size: 24px;
	color: #666666;
}

/* ========================================
   RESULTS CONTAINER
======================================== */

.codesws-results-wrapper {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	background: var(--codesws-bg, #ffffff);
	border: 1px solid var(--codesws-border, #e0e0e0);
	border-radius: var(--codesws-radius, 4px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	max-height: 500px;
	overflow-y: auto;
	z-index: 999;
	display: none;
}

.codesws-results-wrapper.is-visible {
	display: block;
}

/* Fullscreen - Static positioning */
.codesws-mode-fullscreen .codesws-results-wrapper {
	position: static;
	margin-top: 16px;
	box-shadow: none;
	border: 1px solid var(--codesws-border, #e0e0e0);
}

/* Fullscreen Search Box - Base styles (overridden by doofinder-exact.css) */
.codesws-mode-fullscreen .codesws-overlay-container.is-active .codesws-search-box {
	position: sticky;
	top: 0;
	z-index: 1000000;
	background: #ffffff;
}

.codesws-mode-fullscreen .codesws-overlay-container.is-active .codesws-input-field {
	font-size: 16px;
}

.codesws-mode-fullscreen .codesws-overlay-container.is-active .codesws-btn-close {
	position: absolute;
	z-index: 1000001;
}

.codesws-results-list {
	padding: 8px 0;
}

/* ========================================
   RESULT ITEM - LIST VIEW (Default)
======================================== */

.codesws-result-item {
	display: flex;
	align-items: flex-start;
	padding: 12px 16px;
	text-decoration: none;
	color: inherit;
	border-bottom: 1px solid #f0f0f0;
	transition: background 0.2s ease;
	cursor: pointer;
}

.codesws-result-item:last-child {
	border-bottom: none;
}

.codesws-result-item:hover {
	background: var(--codesws-hover, #f5f5f5);
}

.codesws-result-link {
	display: flex;
	align-items: flex-start;
	flex: 1;
	text-decoration: none;
	color: inherit;
	min-width: 0;
}

.codesws-result-thumb {
	width: 60px;
	height: 60px;
	flex-shrink: 0;
	margin-right: 12px;
	border-radius: var(--codesws-radius, 4px);
	overflow: hidden;
	background: #f0f0f0;
}

.codesws-result-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.codesws-no-image {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	background: #f0f0f0;
	color: #999999;
	font-size: 11px;
}

.codesws-result-content {
	flex: 1;
	min-width: 0;
}

.codesws-result-name {
	font-weight: 600;
	font-size: 14px;
	margin: 0 0 4px 0;
	color: var(--codesws-text, #333333);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.codesws-result-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	font-size: 12px;
	margin-top: 4px;
}

.codesws-meta-price {
	font-weight: 600;
	color: var(--codesws-primary, #2196f3);
}

.codesws-meta-sku {
	color: #999999;
}

.codesws-meta-rating {
	display: flex;
	align-items: center;
	gap: 4px;
	color: #ffa500;
}

.codesws-badge {
	padding: 2px 6px;
	border-radius: 3px;
	font-size: 11px;
	font-weight: 500;
}

.codesws-badge-stock {
	background: #e8f5e9;
	color: #2e7d32;
}

.codesws-badge-outofstock {
	background: #ffebee;
	color: #c62828;
}

.codesws-badge-sale {
	background: #fff3e0;
	color: #e65100;
}

.codesws-btn-addtocart {
	padding: 6px 12px;
	background: var(--codesws-primary, #2196f3);
	color: #ffffff;
	border: none;
	border-radius: var(--codesws-radius, 4px);
	font-size: 12px;
	cursor: pointer;
	transition: background 0.2s ease;
	white-space: nowrap;
	margin-left: 8px;
	flex-shrink: 0;
}

.codesws-btn-addtocart:hover {
	background: var(--codesws-secondary, #1976d2);
}

.codesws-btn-addtocart:disabled {
	background: #cccccc;
	cursor: not-allowed;
}

.codesws-btn-addtocart.is-loading {
	opacity: 0.7;
	pointer-events: none;
}

.codesws-btn-addtocart.is-added {
	background: #4caf50;
}

/* ========================================
   RESULT LAYOUT - GRID
======================================== */

.codesws-layout-grid .codesws-results-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 16px;
	padding: 16px;
}

.codesws-layout-grid .codesws-result-item {
	flex-direction: column;
	text-align: center;
	border: 1px solid var(--codesws-border, #e0e0e0);
	border-radius: var(--codesws-radius, 4px);
	padding: 16px;
}

.codesws-layout-grid .codesws-result-link {
	flex-direction: column;
	text-align: center;
	width: 100%;
}

.codesws-layout-grid .codesws-result-thumb {
	width: 100%;
	height: 150px;
	margin: 0 0 12px 0;
}

.codesws-layout-grid .codesws-result-name {
	white-space: normal;
	text-overflow: initial;
	overflow: visible;
}

.codesws-layout-grid .codesws-btn-addtocart {
	width: 100%;
	margin: 12px 0 0 0;
}

/* ========================================
   RESULT LAYOUT - COMPACT
======================================== */

.codesws-layout-compact .codesws-result-item {
	padding: 8px 12px;
}

.codesws-layout-compact .codesws-result-thumb {
	width: 40px;
	height: 40px;
}

.codesws-layout-compact .codesws-result-name {
	font-size: 13px;
}

.codesws-layout-compact .codesws-result-meta {
	font-size: 11px;
	gap: 6px;
}

/* ========================================
   RESULT LAYOUT - DETAILED
======================================== */

.codesws-layout-detailed .codesws-result-item {
	flex-direction: column;
	padding: 20px;
	border-bottom: 2px solid #f0f0f0;
}

.codesws-layout-detailed .codesws-result-link {
	width: 100%;
	margin-bottom: 12px;
}

.codesws-layout-detailed .codesws-result-thumb {
	width: 120px;
	height: 120px;
	margin-right: 20px;
}

.codesws-layout-detailed .codesws-result-name {
	font-size: 16px;
	white-space: normal;
}

.codesws-layout-detailed .codesws-btn-addtocart {
	align-self: flex-start;
	padding: 10px 20px;
	margin: 0;
}

/* ========================================
   LOADING & EMPTY STATES
======================================== */

.codesws-loading {
	padding: 24px;
	text-align: center;
}

.codesws-no-results {
	padding: 24px 16px;
	text-align: center;
	color: #666666;
	font-size: 14px;
}

/* ========================================
   BACKDROP
======================================== */

/* Backdrop removed - not needed for inline or fullscreen modes */

/* ========================================
   ANIMATIONS
======================================== */

/* Animations - only fade-in kept (for inline mode), fullscreen uses slide-down from doofinder-exact.css */
@keyframes codesws-fade-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

/* ========================================
   RESPONSIVE
======================================== */

@media (max-width: 768px) {
	.codesws-layout-grid .codesws-results-list {
		grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
		gap: 12px;
		padding: 12px;
	}

	.codesws-layout-grid .codesws-result-thumb {
		height: 120px;
	}
}

/* ========================================
   HIGHLIGHT
======================================== */

.codesws-highlight {
	background: #fff176;
	font-weight: 600;
	padding: 0 2px;
}
