/**
 * Property Search Component Styles
 * 
 * @package TF_Real_Estate
 * @since 1.0.6
 */

/* ========================================
   Search Wrapper
   ======================================== */
.tfre-property-search-wrapper {
	margin-bottom: 30px;
}

/* Placeholder keeps layout stable when filter goes fixed */
.tfre-search-placeholder {
	display: none;
}

/* Sticky state: pinned to top, slides in/out */
/* top: 42px = 32px WP admin bar + 10px breathing room */
.tfre-property-search-wrapper.is-sticky {
	position: fixed;
	top: 42px;
	z-index: 999;
	margin-bottom: 0;
	padding: 0;
	transform: translateY(0);
	transition: transform 0.25s ease;
	/* left and width set by JS to match parent */
}

/* WP admin bar is 46px on mobile (<782px) */
@media screen and (max-width: 782px) {
	.tfre-property-search-wrapper.is-sticky {
		top: 56px;
	}
}

.tfre-property-search-wrapper.is-sticky + .tfre-search-placeholder {
	display: block;
}

/* Hidden state: slid off-screen above */
.tfre-property-search-wrapper.is-hidden {
	transform: translateY(-100%);
}

.tfre-property-search {
	background: #fff;
	padding: 20px;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Tighter padding when sticky */
.tfre-property-search-wrapper.is-sticky .tfre-property-search {
	padding: 12px 16px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
	border-radius: 0 0 8px 8px;
}

/* ========================================
   Search Input with Icon
   ======================================== */
.search-input-wrapper {
	position: relative;
}

.search-input-wrapper .search-icon {
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: #999;
	font-size: 16px;
	pointer-events: none;
}

#tfre-search-input {
	padding-right: 40px;
}

/* ========================================
   Advanced Filters Toggle Button
   ======================================== */
.tfre-toggle-filters-btn {
	position: relative;
	transition: all 0.3s ease;
}

.tfre-toggle-filters-btn .toggle-arrow {
	margin-left: 8px;
	transition: transform 0.3s ease;
	display: inline-block;
}

.tfre-toggle-filters-btn.active {
	background-color: #0056b3;
	border-color: #0056b3;
}

.tfre-toggle-filters-btn.active .toggle-arrow {
	transform: rotate(180deg);
}

/* ========================================
   Advanced Filters Panel
   ======================================== */
.tfre-search-advanced {
	padding-top: 20px;
	border-top: 1px solid #e5e5e5;
	margin-top: 20px;
}

.tfre-search-advanced label {
	font-weight: 500;
	font-size: 13px;
	color: #333;
	margin-bottom: 5px;
	display: block;
}

.tfre-search-advanced .form-control {
	font-size: 14px;
}

/* ========================================
   Search Actions
   ======================================== */
.tfre-search-actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 15px;
	padding-top: 15px;
	border-top: 1px solid #f0f0f0;
}

.tfre-search-actions .btn {
	min-width: 120px;
}

/* ========================================
   Active Filter Tags
   ======================================== */
.tfre-active-filters {
	margin-top: 15px;
	padding-top: 15px;
	border-top: 1px solid #f0f0f0;
}

.filter-tags-wrapper {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.filter-tags-wrapper strong {
	color: #333;
	font-size: 14px;
	flex-shrink: 0;
}

.filter-tags {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	flex: 1;
}

.filter-tag {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: #e3f2fd;
	color: #1976d2;
	padding: 4px 12px;
	border-radius: 16px;
	font-size: 13px;
	font-weight: 500;
	transition: all 0.2s ease;
}

.filter-tag:hover {
	background: #bbdefb;
}

.filter-tag .remove-tag {
	cursor: pointer;
	font-weight: bold;
	font-size: 16px;
	line-height: 1;
	opacity: 0.7;
	transition: opacity 0.2s ease;
}

.filter-tag .remove-tag:hover {
	opacity: 1;
}

/* ========================================
   Autocomplete Dropdown
   ======================================== */
.tfre-autocomplete-dropdown {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	background: #fff;
	border: 1px solid #ddd;
	border-top: none;
	border-radius: 0 0 4px 4px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	max-height: 300px;
	overflow-y: auto;
	z-index: 1000;
	margin-top: -1px;
}

.autocomplete-item {
	padding: 12px 15px;
	cursor: pointer;
	border-bottom: 1px solid #f5f5f5;
	transition: background-color 0.2s ease;
	position: relative;
}

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

.autocomplete-item:hover {
	background-color: #f8f9fa;
}

.autocomplete-title {
	font-weight: 600;
	color: #333;
	margin-bottom: 4px;
	font-size: 14px;
}

.autocomplete-address {
	font-size: 12px;
	color: #666;
	margin-bottom: 4px;
}

.autocomplete-address i {
	margin-right: 4px;
	color: #999;
}

.autocomplete-price {
	font-size: 13px;
	color: #1976d2;
	font-weight: 600;
	margin-bottom: 4px;
}

.autocomplete-status {
	position: absolute;
	top: 12px;
	right: 12px;
	font-size: 11px;
	padding: 2px 8px;
	border-radius: 3px;
	text-transform: uppercase;
	font-weight: 600;
}

.autocomplete-status.status-publish {
	background: #d4edda;
	color: #155724;
}

.autocomplete-status.status-pending {
	background: #fff3cd;
	color: #856404;
}

.autocomplete-status.status-sold {
	background: #f8d7da;
	color: #721c24;
}

.autocomplete-status.status-hidden {
	background: #e2e3e5;
	color: #383d41;
}

/* ========================================
   Results Info Bar
   ======================================== */
.tfre-search-results-info {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 15px 0;
	margin-top: 20px;
	border-bottom: 2px solid #e5e5e5;
}

.results-count {
	font-size: 15px;
	color: #666;
}

.results-count b {
	color: #333;
	font-size: 18px;
}

.search-loading {
	color: #1976d2;
	font-size: 14px;
}

.search-loading i {
	margin-right: 6px;
	animation: spin 1s linear infinite;
}

@keyframes spin {
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(360deg);
	}
}

/* ========================================
   No Results State
   ======================================== */
.tfre-no-results {
	padding: 40px 20px;
	text-align: center;
	color: #666;
}

.tfre-no-results i {
	display: block;
	margin-bottom: 15px;
}

.tfre-no-results p {
	margin: 8px 0;
}

.tfre-no-results small {
	color: #999;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 991px) {
	.tfre-search-actions {
		flex-direction: column;
	}
	
	.tfre-search-actions .btn {
		width: 100%;
	}
	
	.filter-tags-wrapper {
		flex-direction: column;
		align-items: flex-start;
	}
}

@media (max-width: 767px) {
	.tfre-property-search {
		padding: 15px;
	}
	
	.tfre-search-basic .col-sm-6,
	.tfre-search-basic .col-md-3 {
		margin-bottom: 10px;
	}
	
	.tfre-search-advanced .col-lg-3,
	.tfre-search-advanced .col-md-6 {
		margin-bottom: 15px;
	}
	
	.tfre-search-results-info {
		flex-direction: column;
		align-items: flex-start;
		gap: 10px;
	}
}

/* ========================================
   Integration with Existing Styles
   ======================================== */
.tfre-property-search .form-group {
	margin-bottom: 0;
}

.tfre-property-search .form-control,
.tfre-property-search .btn {
	height: 42px;
	border-radius: 4px;
}

.tfre-property-search select.form-control {
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%23666'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	padding-right: 32px;
}

/* Date picker icon positioning */
.group-input-icon {
	position: relative;
}

.group-input-icon .datepicker-icon {
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	pointer-events: none;
	color: #999;
}

.group-input-icon input {
	padding-right: 40px;
}

/* Loading state for table */
.tfre-table-content {
	transition: opacity 0.3s ease;
}

/* Button hover effects */
.tfre-search-actions .btn-primary {
	background-color: #1976d2;
	border-color: #1976d2;
}

.tfre-search-actions .btn-primary:hover {
	background-color: #1565c0;
	border-color: #1565c0;
}

.tfre-search-actions .btn-outline-secondary:hover {
	background-color: #6c757d;
	border-color: #6c757d;
	color: #fff;
}

/* ========================================
   Client Autocomplete Styles
   ======================================== */
.autocomplete-section-header {
	padding: 8px 12px;
	background-color: #f5f5f5;
	font-weight: 600;
	font-size: 11px;
	text-transform: uppercase;
	color: #666;
	border-top: 1px solid #e0e0e0;
}

.autocomplete-section-header:first-child {
	border-top: none;
}

.autocomplete-client {
	border-left: 3px solid #17a2b8 !important;
}

.autocomplete-client-info {
	font-size: 12px;
	color: #666;
	margin-top: 2px;
}

.autocomplete-client-info i {
	margin-right: 5px;
	color: #999;
	font-size: 11px;
}

.autocomplete-client-type {
	display: inline-block;
	background-color: #e3f2fd;
	color: #1976d2;
	padding: 2px 8px;
	border-radius: 10px;
	font-size: 10px;
	font-weight: 600;
	margin-top: 5px;
}

.autocomplete-item.autocomplete-client:hover {
	background-color: #f0f9ff;
	border-left-color: #0d6efd !important;
}

/* ========================================
   Infinite Scroll Styles
   ======================================== */

/* Table layout - ensure columns align properly */
.tfre-table-listing .table {
	table-layout: fixed;
	width: 100%;
}

/* Table header and body alignment */
.tfre-table-listing .table thead,
.tfre-table-listing .table tbody {
	display: table;
	width: 100%;
}

/* Ensure consistent column widths */
.tfre-table-listing .table th,
.tfre-table-listing .table td {
	vertical-align: middle;
}

/* Loading more row styling */
.tfre-loading-more-row {
	background-color: #f8f9fa !important;
}

.tfre-loading-more-row td {
	padding: 20px !important;
	color: #666;
	font-size: 14px;
}

.tfre-loading-more-row i {
	margin-right: 8px;
	color: #1976d2;
}

/* Load More button wrapper */
.tfre-load-more-wrapper {
	padding: 20px 0;
	margin-top: 10px;
}

#tfre-load-more-btn {
	min-width: 200px;
	padding: 10px 30px;
	font-size: 14px;
	font-weight: 500;
	background-color: #1976d2;
	border-color: #1976d2;
	transition: all 0.3s ease;
}

#tfre-load-more-btn:hover {
	background-color: #1565c0;
	border-color: #1565c0;
}

#tfre-load-more-btn:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

/* Table column width definitions to ensure alignment */
.tfre-table-listing .table th:nth-child(1),
.tfre-table-listing .table td:nth-child(1) {
	width: 60%;
}

.tfre-table-listing .table th:nth-child(2),
.tfre-table-listing .table td:nth-child(2) {
	width: 15%;
}

.tfre-table-listing .table th:nth-child(3),
.tfre-table-listing .table td:nth-child(3) {
	width: 25%;
}

/* Ensure table cells don't break layout */
.tfre-table-listing .table td {
	overflow: hidden;
}

/* Results count with loading state */
.results-count.loading {
	color: #1976d2;
}
