/**
 * SmartSearch – Dolibarr Module CSS
 * Copyright (C) 2024 SmartSearch
 * GNU General Public License v3.0
 *
 * Responsive design that integrates with Dolibarr themes
 */

/* ═══ LAYOUT & HEADER ═══ */

#smartsearch-app {
	max-width: 960px;
	margin: 0 auto;
	padding: 20px 15px;
}

.smartsearch-header {
	text-align: center;
	margin-bottom: 24px;
}

.smartsearch-title {
	font-size: 1.8em;
	font-weight: 700;
	margin: 0 0 6px 0;
	letter-spacing: -0.02em;
}

.smartsearch-subtitle {
	font-size: 0.95em;
	color: #7f8c8d;
	margin: 0;
}

/* ═══ SEARCH INPUT ═══ */

.smartsearch-input-wrapper {
	position: relative;
	margin-bottom: 16px;
}

.smartsearch-input {
	display: block;
	width: 100%;
	padding: 14px 18px;
	font-size: 1.1em;
	border: 2px solid #dfe6e9;
	border-radius: 12px;
	background: #fff;
	color: #2c3e50;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
	outline: none;
	box-sizing: border-box;
}

.smartsearch-input:focus {
	border-color: #3498db;
	box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.12);
}

.smartsearch-input::placeholder {
	color: #b2bec3;
	font-size: 0.92em;
}

.smartsearch-input-hint {
	display: flex;
	gap: 16px;
	justify-content: center;
	margin-top: 8px;
	flex-wrap: wrap;
}

.smartsearch-hint-item {
	font-size: 0.78em;
	color: #636e72;
	cursor: help;
	padding: 2px 8px;
	background: #f8f9fa;
	border-radius: 4px;
}

/* ═══ FILTER BAR ═══ */

.smartsearch-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 16px;
	padding: 0;
	justify-content: center;
}

.smartsearch-filter {
	padding: 6px 14px;
	font-size: 0.82em;
	font-weight: 500;
	border: 1px solid #dfe6e9;
	border-radius: 20px;
	background: #fff;
	color: #636e72;
	cursor: pointer;
	transition: all 0.15s ease;
	outline: none;
	white-space: nowrap;
}

.smartsearch-filter:hover {
	background: #f1f3f5;
	border-color: #b2bec3;
}

.smartsearch-filter.active {
	background: #3498db;
	color: #fff;
	border-color: #3498db;
}

/* ═══ STATUS BAR ═══ */

.smartsearch-status {
	font-size: 0.82em;
	padding: 6px 12px;
	border-radius: 6px;
	margin-bottom: 12px;
	text-align: center;
}

.smartsearch-status-loading { background: #ffeaa7; color: #6c5b00; }
.smartsearch-status-success { background: #d5f5e3; color: #1e6e3e; }
.smartsearch-status-warning { background: #fdebd0; color: #7e5109; }
.smartsearch-status-error   { background: #fadbd8; color: #922b21; }
.smartsearch-status-info    { background: #d6eaf8; color: #1b4f72; }

/* ═══ RESULTS ═══ */

.smartsearch-results {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.smartsearch-result-item {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 12px 16px;
	background: #fff;
	border: 1px solid #ecf0f1;
	border-radius: 10px;
	text-decoration: none;
	color: inherit;
	transition: all 0.15s ease;
	cursor: pointer;
}

.smartsearch-result-item:hover {
	border-color: #3498db;
	box-shadow: 0 2px 12px rgba(52, 152, 219, 0.1);
	transform: translateY(-1px);
	background: #f8fbff;
}

.smartsearch-result-icon {
	flex-shrink: 0;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 10px;
	font-size: 1.3em;
}

.smartsearch-result-content {
	flex: 1;
	min-width: 0;
	overflow: hidden;
}

.smartsearch-result-title {
	font-size: 0.95em;
	font-weight: 600;
	color: #2c3e50;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin-bottom: 2px;
}

.smartsearch-result-ref {
	font-size: 0.82em;
	font-weight: 400;
	color: #7f8c8d;
	margin-left: 6px;
}

.smartsearch-result-desc {
	font-size: 0.82em;
	color: #636e72;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin-bottom: 4px;
}

.smartsearch-result-meta {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
}

.smartsearch-result-type {
	font-size: 0.72em;
	font-weight: 600;
	padding: 1px 8px;
	border-radius: 10px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.smartsearch-result-category { font-size: 0.75em; color: #7f8c8d; }
.smartsearch-result-price    { font-size: 0.8em; font-weight: 600; color: #27ae60; }
.smartsearch-result-matchinfo { font-size: 0.72em; color: #b2bec3; font-style: italic; }

/* Score badge */
.smartsearch-result-score {
	flex-shrink: 0;
	font-size: 0.72em;
	font-weight: 700;
	padding: 4px 8px;
	border-radius: 6px;
	min-width: 38px;
	text-align: center;
}

.smartsearch-result-score.high   { background: #d5f5e3; color: #1e8449; }
.smartsearch-result-score.medium { background: #fdebd0; color: #b7700a; }
.smartsearch-result-score.low    { background: #f5f5f5; color: #999; }

/* Highlight */
.smartsearch-highlight {
	background: #fef9c3;
	color: #92400e;
	padding: 0 2px;
	border-radius: 2px;
	font-weight: inherit;
}

/* ═══ EMPTY & NO RESULTS ═══ */

.smartsearch-empty {
	text-align: center;
	padding: 40px 20px;
	color: #b2bec3;
}

.smartsearch-empty-icon { font-size: 3em; margin-bottom: 12px; opacity: 0.5; }
.smartsearch-empty-hint { font-size: 0.88em; color: #b2bec3; }
.smartsearch-empty-hint em {
	background: #f0f0f0;
	padding: 1px 6px;
	border-radius: 3px;
	font-style: normal;
	color: #636e72;
}

.smartsearch-no-results { text-align: center; padding: 40px 20px; color: #636e72; }
.smartsearch-no-results-icon { font-size: 2.5em; margin-bottom: 8px; }
.smartsearch-no-results-hint { font-size: 0.85em; color: #b2bec3; }

/* ═══ RESPONSIVE ═══ */

@media (max-width: 600px) {
	#smartsearch-app { padding: 12px 10px; }
	.smartsearch-title { font-size: 1.4em; }
	.smartsearch-input { padding: 12px 14px; font-size: 1em; }
	.smartsearch-result-item { padding: 10px 12px; gap: 10px; }
	.smartsearch-result-icon { width: 36px; height: 36px; font-size: 1.1em; }
	.smartsearch-result-score { display: none; }
	.smartsearch-hint-item { font-size: 0.7em; }
}

/* ═══ DARK MODE (Dolibarr Eldy Dark) ═══ */

body.theme-eldy-dark .smartsearch-input,
body[class*="dark"] .smartsearch-input {
	background: #2d2d2d;
	border-color: #444;
	color: #ecf0f1;
}

body.theme-eldy-dark .smartsearch-result-item,
body[class*="dark"] .smartsearch-result-item {
	background: #2d2d2d;
	border-color: #3d3d3d;
}

body.theme-eldy-dark .smartsearch-result-item:hover,
body[class*="dark"] .smartsearch-result-item:hover {
	background: #353535;
	border-color: #3498db;
}

body.theme-eldy-dark .smartsearch-result-title,
body[class*="dark"] .smartsearch-result-title {
	color: #ecf0f1;
}

body.theme-eldy-dark .smartsearch-filter,
body[class*="dark"] .smartsearch-filter {
	background: #2d2d2d;
	border-color: #444;
	color: #aaa;
}

body.theme-eldy-dark .smartsearch-highlight,
body[class*="dark"] .smartsearch-highlight {
	background: #614a00;
	color: #fef08a;
}
