/* ============================================
   SHENPAI Product Finder - Styles
   Matches existing theme: dark blue #2c4170,
   accent gold #DFB163, orange #f95e00, dark #353535
   ============================================ */

/* --- Page Header Banner --- */
.sp-finder-banner {
  /* Bản gốc để CSS cạnh thư mục static nên '../static/image/' trỏ đúng. Theme
     này xếp ảnh ở assets/img/image/ và CSS ở assets/css/lib/, nên giữ nguyên
     đường dẫn gốc sẽ ra 404 và banner mất ảnh nền, chỉ còn lớp phủ xanh phẳng. */
  background: url('../../img/image/banner_nei3.jpg') no-repeat center center;
  background-size: cover;
  padding: 60px 0;
  text-align: center;
  color: #fff;
  position: relative;
}
.sp-finder-banner::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(27, 99, 181, 0.7);
}
.sp-finder-banner h1 {
  position: relative;
  z-index: 1;
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 10px;
}
.sp-finder-banner p {
  position: relative;
  z-index: 1;
  font-size: 16px;
  max-width: 700px;
  margin: 0 auto;
  opacity: 0.9;
}

/* --- Breadcrumb --- */
.sp-breadcrumb {
  padding: 12px 0;
  background: #f8f8f8;
  border-bottom: 1px solid #e8e8e8;
  font-size: 14px;
}
.sp-breadcrumb a {
  color: #1b63b5;
  text-decoration: none;
}
.sp-breadcrumb a:hover {
  color: #f95e00;
}
.sp-breadcrumb span {
  color: #999;
  margin: 0 6px;
}

/* --- Tab Navigation --- */
.sp-tabs {
  background: #fff;
  border-bottom: 2px solid #e8e8e8;
  margin-bottom: 0;
}
.sp-tabs .sp-tab-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
}
.sp-tabs .sp-tab-item {
  flex: 1;
  text-align: center;
  cursor: pointer;
  padding: 20px 15px;
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
  position: relative;
}
.sp-tabs .sp-tab-item:hover {
  background: #f8f9fa;
}
.sp-tabs .sp-tab-item.active {
  border-bottom-color: #1b63b5;
  background: #fff;
}
.sp-tabs .sp-tab-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  display: block;
  margin-bottom: 4px;
}
.sp-tabs .sp-tab-item.active .sp-tab-title {
  color: #1b63b5;
}
.sp-tabs .sp-tab-desc {
  font-size: 12px;
  color: #999;
  display: block;
}

/* --- Tab Content Panels --- */
.sp-tab-panels {
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
}
.sp-tab-panel {
  display: none;
  padding: 25px 30px;
}
.sp-tab-panel.active {
  display: block;
}

/* Product Type Panel */
.sp-type-group {
  margin-bottom: 20px;
}
.sp-type-group h4 {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sp-type-group h4 i {
  color: #1b63b5;
}
.sp-type-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sp-type-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  transition: all 0.2s;
  background: #fff;
}
.sp-type-options label:hover {
  border-color: #1b63b5;
  color: #1b63b5;
}
.sp-type-options input[type="radio"]:checked + span,
.sp-type-options label.selected {
  background: #1b63b5;
  color: #fff;
  border-color: #1b63b5;
}
.sp-type-options input[type="radio"] {
  display: none;
}
.sp-type-options label.selected {
  background: #1b63b5;
  color: #fff;
  border-color: #1b63b5;
}

/* Series Panel */
.sp-series-select {
  max-width: 500px;
}
.sp-series-select select {
  width: 100%;
  padding: 10px 15px;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #333;
  cursor: pointer;
}

/* Application Conditions Panel */
.sp-conditions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}
.sp-conditions-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border: 1px solid #eee;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  transition: all 0.2s;
}
.sp-conditions-grid label:hover {
  border-color: #1b63b5;
  background: #f0f5ff;
}
.sp-conditions-grid input[type="checkbox"]:checked + span {
  color: #1b63b5;
  font-weight: 600;
}

/* --- Main Content Layout --- */
.sp-finder-body {
  display: flex;
  gap: 0;
  background: #f5f5f5;
  min-height: 600px;
}

/* --- Filter Sidebar --- */
.sp-filter-sidebar {
  width: 320px;
  min-width: 320px;
  background: #fff;
  border-right: 1px solid #e8e8e8;
  padding: 20px;
  overflow-y: auto;
  max-height: calc(100vh - 200px);
  position: sticky;
  top: 80px;
}
.sp-filter-section {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid #f0f0f0;
}
.sp-filter-section:last-child {
  border-bottom: none;
}
.sp-filter-section h5 {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Unit Toggle */
.sp-unit-toggle {
  display: flex;
  gap: 4px;
  background: #f0f0f0;
  border-radius: 4px;
  padding: 3px;
  margin-bottom: 20px;
}
.sp-unit-toggle button {
  flex: 1;
  padding: 6px 12px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}
.sp-unit-toggle button.active {
  background: #1b63b5;
  color: #fff;
}

/* Range Slider */
.sp-range-filter {
  margin-bottom: 16px;
}
.sp-range-filter label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
  font-weight: 500;
}
.sp-range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sp-range-inputs input {
  width: 80px;
  padding: 5px 8px;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-size: 12px;
  text-align: center;
  color: #333;
}
.sp-range-inputs .sp-range-sep {
  color: #999;
  font-size: 12px;
}
.sp-range-slider {
  margin-top: 8px;
  position: relative;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
}
.sp-range-slider .sp-range-track {
  position: absolute;
  height: 100%;
  background: #1b63b5;
  border-radius: 3px;
}
.sp-range-slider .sp-range-thumb {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  background: #fff;
  border: 2px solid #1b63b5;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 2;
  transition: box-shadow 0.2s;
}
.sp-range-slider .sp-range-thumb:hover,
.sp-range-slider .sp-range-thumb.dragging {
  box-shadow: 0 0 0 4px rgba(27, 99, 181, 0.2);
}

/* Dropdown Filter */
.sp-dropdown-filter select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-size: 12px;
  color: #333;
  background: #fff;
  cursor: pointer;
  margin-bottom: 6px;
}

/* Checkbox Group */
.sp-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sp-checkbox-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #555;
  cursor: pointer;
  padding: 3px 0;
}
.sp-checkbox-group input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #1b63b5;
}

/* --- Results Area --- */
.sp-results-area {
  flex: 1;
  padding: 20px 25px;
  min-width: 0;
}

/* Results Header */
.sp-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.sp-results-count {
  font-size: 14px;
  color: #555;
}
.sp-results-count strong {
  color: #1b63b5;
  font-size: 18px;
}
.sp-results-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #666;
}
.sp-results-sort select {
  padding: 5px 10px;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-size: 12px;
  background: #fff;
  cursor: pointer;
}

/* Mobile Filter Toggle */
.sp-filter-toggle {
  display: none;
  padding: 10px 16px;
  background: #1b63b5;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 15px;
  width: 100%;
}
.sp-filter-toggle i {
  margin-right: 6px;
}

/* --- Product Cards Grid --- */
.sp-products-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* Product Card */
.sp-product-card {
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: box-shadow 0.3s, transform 0.3s;
  display: flex;
  flex-direction: column;
}
.sp-product-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

/* Card Header */
.sp-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 15px 0;
}
.sp-card-name {
  font-size: 14px;
  font-weight: 700;
  color: #333;
  margin: 0;
}
.sp-card-bookmark {
  color: #ccc;
  cursor: pointer;
  font-size: 16px;
  transition: color 0.2s;
}
.sp-card-bookmark:hover {
  color: #f95e00;
}

/* Card Image */
.sp-card-image {
  padding: 15px;
  text-align: center;
  background: #fafafa;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sp-card-image img {
  max-width: 100%;
  max-height: 140px;
  object-fit: contain;
}
.sp-card-placeholder {
  width: 120px;
  height: 120px;
  background: #e8e8e8;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 40px;
}
.sp-card-badges {
  display: flex;
  gap: 4px;
  position: absolute;
  top: 8px;
  left: 8px;
}
.sp-card-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: #e3f2fd;
  color: #1565c0;
  font-weight: 600;
}

/* Card Info */
.sp-card-info {
  padding: 0 15px;
  font-size: 12px;
  color: #888;
}
.sp-card-info span {
  margin-right: 12px;
}

/* Card Specs - Icon Row */
.sp-card-specs {
  display: flex;
  justify-content: space-around;
  padding: 12px 10px;
  border-top: 1px solid #f0f0f0;
  margin-top: auto;
}
.sp-spec-item {
  text-align: center;
  font-size: 11px;
  color: #666;
}
.sp-spec-item .sp-spec-icon {
  display: block;
  font-size: 16px;
  color: #1b63b5;
  margin-bottom: 2px;
}
.sp-spec-item .sp-spec-value {
  display: block;
  font-weight: 700;
  color: #333;
  font-size: 13px;
}
.sp-spec-item .sp-spec-label {
  display: block;
  font-size: 10px;
  color: #999;
}

/* Card Actions */
.sp-card-actions {
  display: flex;
  border-top: 1px solid #f0f0f0;
}
.sp-card-actions a {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-size: 12px;
  color: #1b63b5;
  text-decoration: none;
  transition: all 0.2s;
  border-right: 1px solid #f0f0f0;
}
.sp-card-actions a:last-child {
  border-right: none;
}
.sp-card-actions a:hover {
  background: #1b63b5;
  color: #fff;
}
.sp-card-actions a.sp-btn-detail {
  flex: 2;
  font-weight: 600;
}

/* --- Pagination --- */
.sp-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 30px;
  padding: 20px 0;
}
.sp-pagination button {
  min-width: 36px;
  height: 36px;
  border: 1px solid #ddd;
  background: #fff;
  color: #555;
  font-size: 13px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sp-pagination button:hover {
  border-color: #1b63b5;
  color: #1b63b5;
}
.sp-pagination button.active {
  background: #1b63b5;
  color: #fff;
  border-color: #1b63b5;
}
.sp-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.sp-pagination .sp-page-info {
  font-size: 13px;
  color: #888;
  margin: 0 12px;
}

/* --- No Results --- */
.sp-no-results {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}
.sp-no-results i {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
  color: #ddd;
}
.sp-no-results h3 {
  font-size: 18px;
  color: #666;
  margin-bottom: 8px;
}
.sp-no-results p {
  font-size: 14px;
}
.sp-no-results button {
  margin-top: 16px;
  padding: 8px 24px;
  background: #1b63b5;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

/* --- Loading --- */
.sp-loading {
  text-align: center;
  padding: 40px;
}
.sp-loading .sp-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e8e8e8;
  border-top-color: #1b63b5;
  border-radius: 50%;
  animation: sp-spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes sp-spin {
  to { transform: rotate(360deg); }
}

/* --- Reset Filters Button --- */
.sp-reset-filters {
  display: block;
  width: 100%;
  padding: 8px;
  margin-top: 15px;
  background: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  color: #666;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.sp-reset-filters:hover {
  border-color: #f95e00;
  color: #f95e00;
}

/* --- Active Filter Tags --- */
.sp-active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 15px;
}
.sp-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #e3f2fd;
  color: #1565c0;
  border-radius: 12px;
  font-size: 11px;
}
.sp-filter-tag .sp-tag-remove {
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
}
.sp-filter-tag .sp-tag-remove:hover {
  opacity: 1;
}

/* --- Filter Contact Section --- */
.sp-filter-contact {
  margin-top: 20px;
  padding: 16px;
  background: #f0f5ff;
  border-radius: 6px;
  border: 1px solid #d0e0f5;
}
.sp-filter-contact h5 {
  font-size: 14px;
  font-weight: 700;
  color: #1b63b5;
  margin-bottom: 6px;
}
.sp-filter-contact p {
  font-size: 12px;
  color: #666;
  margin-bottom: 10px;
}
.sp-filter-contact a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #1b63b5;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s;
}
.sp-filter-contact a:hover {
  background: #154e91;
}

/* --- Availability Indicator --- */
.sp-avail-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 8px;
  vertical-align: middle;
}
.sp-avail-instock { background: #4caf50; }
.sp-avail-limited { background: #ff9800; }
.sp-avail-outofstock { background: #ccc; }

/* --- Product Detail Modal --- */
.sp-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}
.sp-modal {
  background: #fff;
  border-radius: 8px;
  max-width: 900px;
  width: 100%;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.sp-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  color: #999;
  cursor: pointer;
  z-index: 10;
  line-height: 1;
}
.sp-modal-close:hover {
  color: #333;
}
.sp-modal-body {
  padding: 30px;
}
.sp-modal-image {
  text-align: center;
  padding: 20px;
  background: #f8f8f8;
  border-radius: 6px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sp-modal-badges {
  margin: 8px 0;
}
.sp-modal-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.sp-modal-actions a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}
.sp-btn-inquiry {
  background: #1b63b5;
  color: #fff !important;
}
.sp-btn-inquiry:hover {
  background: #154e91;
}
.sp-btn-pdf {
  background: #e74c3c;
  color: #fff !important;
}
.sp-btn-pdf:hover {
  background: #c0392b;
}
.sp-modal-section {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}
.sp-modal-section h4 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #333;
}

/* Rating Bars */
.sp-rating-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.sp-rating-label {
  width: 160px;
  font-size: 13px;
  color: #555;
  flex-shrink: 0;
}
.sp-rating-bar {
  flex: 1;
  height: 8px;
  background: #e8e8e8;
  border-radius: 4px;
  overflow: hidden;
}
.sp-rating-fill {
  height: 100%;
  background: #1b63b5;
  border-radius: 4px;
  transition: width 0.5s;
}
.sp-rating-value {
  width: 70px;
  font-size: 12px;
  color: #888;
  text-align: right;
  flex-shrink: 0;
}

/* Specs Table */
.sp-specs-table {
  width: 100%;
  border-collapse: collapse;
}
.sp-specs-table td {
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid #f0f0f0;
}
.sp-specs-table td:first-child {
  color: #666;
  width: 40%;
  font-weight: 500;
}
.sp-specs-table td:last-child {
  color: #333;
  font-weight: 600;
}
.sp-specs-table tr:hover {
  background: #f8f9fa;
}

/* Related Products */
.sp-modal-related {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.sp-related-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  border: 1px solid #eee;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 12px;
  color: #555;
  text-align: center;
  width: 120px;
}
.sp-related-item:hover {
  border-color: #1b63b5;
  background: #f0f5ff;
}

/* --- Compare Tray --- */
.sp-compare-tray {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #353535;
  color: #fff;
  padding: 12px 0;
  z-index: 999;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}
.sp-compare-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 14px;
}
.sp-compare-clear {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 4px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}
.sp-compare-clear:hover {
  border-color: #f95e00;
  color: #f95e00;
}
.sp-compare-items {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.sp-compare-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.1);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
}
.sp-compare-item button {
  background: none;
  border: none;
  color: #f95e00;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
.sp-compare-now {
  background: #1b63b5;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  margin-left: 12px;
  transition: background 0.2s;
}
.sp-compare-now:hover {
  background: #f95e00;
}

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

@media (max-width: 1200px) {
  .sp-filter-sidebar {
    width: 280px;
    min-width: 280px;
  }
}

@media (max-width: 991px) {
  .sp-finder-body {
    flex-direction: column;
  }
  .sp-filter-sidebar {
    width: 100%;
    min-width: auto;
    max-height: none;
    position: static;
    display: none;
    border-right: none;
    border-bottom: 1px solid #e8e8e8;
  }
  .sp-filter-sidebar.show {
    display: block;
  }
  .sp-filter-toggle {
    display: block;
  }
  .sp-products-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .sp-filter-sidebar {
    width: 260px;
    min-width: 260px;
  }
  .sp-tabs .sp-tab-list {
    flex-direction: column;
  }
  .sp-tabs .sp-tab-item {
    border-bottom: none;
    border-left: 3px solid transparent;
    text-align: left;
    padding: 12px 15px;
  }
  .sp-tabs .sp-tab-item.active {
    border-left-color: #1b63b5;
    border-bottom: none;
  }
}

@media (max-width: 767px) {
  .sp-products-grid {
    grid-template-columns: 1fr;
  }
  .sp-finder-banner {
    padding: 30px 0;
  }
  .sp-finder-banner h1 {
    font-size: 24px;
  }
  .sp-results-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
  .sp-card-specs {
    flex-wrap: wrap;
    gap: 8px;
  }
  .sp-spec-item {
    width: calc(33% - 8px);
  }
  .sp-conditions-grid {
    grid-template-columns: 1fr;
  }
  .sp-type-options {
    flex-direction: column;
  }
  .sp-type-options label {
    width: 100%;
  }
}
