/**
 * WC Search Popup - Styles v1.1
 * עיצוב כפתור חיפוש ופופאפ למוצרי ווקומרס
 *
 * תיקונים בגרסה זו:
 * - הכפתור תמיד עיגול שחור (גם בתוך grid/flex של theme)
 * - תיקון מיקום ה-X וה-icon ב-RTL (X משמאל, icon מימין)
 * - אין יותר חפיפה בין placeholder לאייקון
 */

/* ============================================
   כפתור חיפוש - עיגול שחור עם זכוכית מגדלת לבנה
   force-set כדי לעקוף עיצוב של theme
   ============================================ */

.wcsp-trigger-button,
button.wcsp-trigger-button,
a.wcsp-trigger-button {
	/* שחזור מאפס - מנטרל סגנון של theme */
	all: unset;
	box-sizing: border-box;

	/* גיאומטריה */
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 56px !important;
	height: 56px !important;
	min-width: 56px !important;
	min-height: 56px !important;
	max-width: 56px !important;
	max-height: 56px !important;
	padding: 0 !important;
	margin: 0;

	/* צורה */
	border-radius: 50% !important;
	border: 1.5px solid rgba(255, 255, 255, 0.3) !important;
	background-color: #000000 !important;
	background-image: none !important;
	color: #ffffff !important;

	/* התנהגות */
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	font-family: inherit;
	font-size: inherit;
	line-height: 1;
	text-decoration: none !important;
	vertical-align: middle;
}

.wcsp-trigger-button:hover {
	transform: scale(1.05);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25) !important;
	background-color: #000000 !important;
	color: #ffffff !important;
}

.wcsp-trigger-button:active {
	transform: scale(0.98);
}

.wcsp-trigger-button:focus,
.wcsp-trigger-button:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 3px;
}

.wcsp-trigger-button svg {
	width: 22px !important;
	height: 22px !important;
	display: block !important;
	stroke: currentColor;
	fill: none;
}

/* גודל קטן */
.wcsp-trigger-button.wcsp-size-small {
	width: 42px !important;
	height: 42px !important;
	min-width: 42px !important;
	min-height: 42px !important;
	max-width: 42px !important;
	max-height: 42px !important;
}
.wcsp-trigger-button.wcsp-size-small svg {
	width: 16px !important;
	height: 16px !important;
}

/* גודל גדול */
.wcsp-trigger-button.wcsp-size-large {
	width: 72px !important;
	height: 72px !important;
	min-width: 72px !important;
	min-height: 72px !important;
	max-width: 72px !important;
	max-height: 72px !important;
}
.wcsp-trigger-button.wcsp-size-large svg {
	width: 28px !important;
	height: 28px !important;
}

/* ============================================
   רקע מטושטש (Overlay)
   ============================================ */

.wcsp-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(0, 0, 0, 0.6);
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
	z-index: 99999;
	display: none;
	align-items: flex-start;
	justify-content: center;
	padding: 80px 20px 20px;
	opacity: 0;
	transition: opacity 0.25s ease;
	overflow-y: auto;
}

.wcsp-overlay.wcsp-active {
	display: flex;
	opacity: 1;
}

/* ============================================
   הפופאפ עצמו
   ============================================ */

.wcsp-popup {
	position: relative;
	background-color: #ffffff;
	width: 100%;
	max-width: 640px;
	border-radius: 16px;
	box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
	overflow: hidden;
	transform: translateY(-20px);
	opacity: 0;
	transition: transform 0.3s ease, opacity 0.3s ease;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Heebo", "Assistant", Roboto, Arial, sans-serif;
	direction: rtl;
}

html[dir="ltr"] .wcsp-popup {
	direction: ltr;
}

.wcsp-overlay.wcsp-active .wcsp-popup {
	transform: translateY(0);
	opacity: 1;
}

/* טקסט מוסתר לקוראי מסך בלבד */
.wcsp-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ============================================
   טופס חיפוש - layout חדש
   ה-input הוא הקונטיינר הראשי, האייקונים בתוכו עם padding בקצוות
   ============================================ */

.wcsp-search-form {
	padding: 20px 20px 16px;
	border-bottom: 1px solid #f3f4f6;
}

.wcsp-input-wrapper {
	position: relative;
	display: block;
	width: 100%;
}

/* אייקון זכוכית מגדלת - בצד התחלת הטקסט (ימין ב-RTL) */
.wcsp-search-icon {
	position: absolute;
	top: 50%;
	right: 16px;
	transform: translateY(-50%);
	width: 20px;
	height: 20px;
	color: #9ca3af;
	pointer-events: none;
	z-index: 2;
}

html[dir="ltr"] .wcsp-search-icon {
	right: auto;
	left: 16px;
}

/* כפתור סגירה X - בצד הנגדי לאייקון (שמאל ב-RTL) */
.wcsp-close {
	position: absolute;
	top: 50%;
	left: 8px;
	transform: translateY(-50%);
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background-color: transparent;
	border: none;
	color: #6b7280;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.15s ease, color 0.15s ease;
	z-index: 3;
	padding: 0;
	margin: 0;
}

html[dir="ltr"] .wcsp-close {
	left: auto;
	right: 8px;
}

.wcsp-close:hover {
	background-color: #f3f4f6;
	color: #111827;
}

.wcsp-close svg {
	width: 18px;
	height: 18px;
	display: block;
}

/* שדה החיפוש עם padding משני הצדדים בשביל האייקונים */
.wcsp-search-input {
	width: 100% !important;
	box-sizing: border-box !important;
	padding: 14px 50px 14px 56px !important; /* RTL: ימין=אייקון חיפוש, שמאל=כפתור X */
	border: 2px solid #e5e7eb !important;
	border-radius: 12px !important;
	font-size: 16px !important;
	color: #111827 !important;
	background-color: #f9fafb !important;
	transition: border-color 0.2s ease, background-color 0.2s ease;
	font-family: inherit !important;
	direction: rtl !important;
	text-align: right !important;
	margin: 0 !important;
	height: auto !important;
	min-height: 0 !important;
	line-height: 1.4 !important;
	box-shadow: none !important;
	outline: none !important;
}

html[dir="ltr"] .wcsp-search-input {
	padding: 14px 56px 14px 50px !important;
	direction: ltr !important;
	text-align: left !important;
}

.wcsp-search-input:focus {
	border-color: #111827 !important;
	background-color: #ffffff !important;
	outline: none !important;
}

.wcsp-search-input::placeholder {
	color: #9ca3af !important;
	opacity: 1;
}

/* ספינר טעינה - מופיע במקום אייקון החיפוש בזמן טעינה */
.wcsp-spinner {
	position: absolute;
	top: 50%;
	right: 16px;
	transform: translateY(-50%);
	width: 18px;
	height: 18px;
	border: 2px solid #e5e7eb;
	border-top-color: #111827;
	border-radius: 50%;
	animation: wcsp-spin 0.8s linear infinite;
	display: none;
	z-index: 2;
}

html[dir="ltr"] .wcsp-spinner {
	right: auto;
	left: 16px;
}

.wcsp-popup.wcsp-loading .wcsp-spinner {
	display: block;
}

.wcsp-popup.wcsp-loading .wcsp-search-icon {
	display: none;
}

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

/* ============================================
   תוצאות
   ============================================ */

.wcsp-results {
	max-height: 60vh;
	overflow-y: auto;
	padding: 8px;
}

/* מצב ריק */
.wcsp-empty-state {
	padding: 48px 24px;
	text-align: center;
	color: #9ca3af;
}

.wcsp-empty-state svg {
	width: 48px;
	height: 48px;
	margin: 0 auto 12px;
	opacity: 0.4;
	display: block;
}

.wcsp-empty-state p {
	margin: 0;
	font-size: 14px;
}

/* רשימת תוצאות */
.wcsp-results-list {
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
}

.wcsp-result-item {
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
}

.wcsp-result-item::before {
	content: none !important;
}

.wcsp-result-link {
	display: flex !important;
	align-items: center;
	gap: 14px;
	padding: 12px 16px;
	border-radius: 10px;
	text-decoration: none !important;
	color: inherit !important;
	transition: background-color 0.15s ease;
}

.wcsp-result-link:hover,
.wcsp-result-link:focus,
.wcsp-result-item.wcsp-active .wcsp-result-link {
	background-color: #f3f4f6;
	text-decoration: none !important;
	outline: none;
}

.wcsp-result-image {
	flex-shrink: 0;
	width: 56px;
	height: 56px;
	border-radius: 8px;
	background-color: #f3f4f6;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wcsp-result-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.wcsp-result-info {
	flex: 1;
	min-width: 0;
}

.wcsp-result-title {
	font-size: 14px !important;
	font-weight: 500 !important;
	color: #111827 !important;
	margin: 0 0 4px !important;
	padding: 0 !important;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	line-height: 1.4 !important;
}

.wcsp-result-price {
	font-size: 13px;
	color: #6b7280;
	font-weight: 500;
	margin: 0;
	line-height: 1.3;
}

.wcsp-result-price ins {
	text-decoration: none;
	color: #111827;
	font-weight: 600;
}

.wcsp-result-price del {
	color: #9ca3af;
	margin-inline-start: 6px;
	font-weight: 400;
}

/* כפתור "הצג את כל התוצאות" */
.wcsp-view-all {
	display: block;
	margin: 8px;
	padding: 12px 16px;
	background-color: #111827 !important;
	color: #ffffff !important;
	text-align: center;
	border-radius: 10px;
	text-decoration: none !important;
	font-size: 14px;
	font-weight: 500;
	transition: background-color 0.2s ease;
}

.wcsp-view-all:hover {
	background-color: #374151 !important;
	color: #ffffff !important;
	text-decoration: none !important;
}

/* הודעת "לא נמצאו תוצאות" */
.wcsp-no-results {
	padding: 48px 24px;
	text-align: center;
	color: #6b7280;
}

.wcsp-no-results strong {
	display: block;
	color: #111827;
	font-size: 16px;
	margin-bottom: 4px;
}

.wcsp-no-results span {
	font-size: 14px;
}

/* ============================================
   רספונסיביות - מובייל
   ============================================ */

@media (max-width: 600px) {
	.wcsp-overlay {
		padding: 16px;
		align-items: flex-start;
	}

	.wcsp-popup {
		max-width: 100%;
		border-radius: 12px;
	}

	.wcsp-search-form {
		padding: 16px 16px 12px;
	}

	.wcsp-search-input {
		font-size: 16px !important; /* חשוב למובייל - מונע zoom אוטומטי ב-iOS */
	}

	.wcsp-results {
		max-height: 65vh;
	}
}

/* ============================================
   הפחתת אנימציות עבור משתמשים שמעדיפים
   ============================================ */

@media (prefers-reduced-motion: reduce) {
	.wcsp-trigger-button,
	.wcsp-overlay,
	.wcsp-popup,
	.wcsp-spinner {
		transition: none;
		animation: none;
	}
}
