/* ============================================
   MACHINE FINDER STYLES
   ============================================ */

.machine-finder-container {
  min-height: 100vh;
  padding-top: 80px;
  background: var(--navy);
}

.machine-finder-header {
  background: rgba(12, 26, 42, 0.95);
  padding: 2rem;
  border-bottom: 1px solid rgba(0, 119, 200, 0.2);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  text-align: center;
}

.machine-finder-header h1 {
  color: var(--white);
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.machine-finder-header p {
  color: var(--grey-medium);
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.back-to-machinery {
  display: inline-block;
  color: var(--homag-blue);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.back-to-machinery:hover {
  color: var(--white);
}

/* Search Bar */
.machine-search {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 2rem;
  display: flex;
  gap: 1rem;
}

.search-input {
  flex: 1;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(0, 119, 200, 0.3);
  border-radius: 4px;
  color: var(--white);
  font-size: 1rem;
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--homag-blue);
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 0 2px rgba(0, 119, 200, 0.2);
}

.search-input::placeholder {
  color: var(--grey-medium);
}

.search-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.search-btn {
  padding: 1rem;
  min-width: 56px;
  height: 56px;
  background: var(--homag-blue);
  border: none;
  border-radius: 4px;
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.search-btn:hover {
  background: #005fa3;
}

.search-btn:focus {
  outline: 2px solid var(--homag-blue);
  outline-offset: 2px;
}

.search-btn svg {
  width: 20px;
  height: 20px;
}

/* Main Content Layout */
.machine-finder-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2rem;
}

/* Filter Sidebar */
.filter-sidebar {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 119, 200, 0.2);
  border-radius: 8px;
  padding: 0;
  height: fit-content;
  max-height: calc(100vh - 120px);
  position: sticky;
  top: 100px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.filter-sidebar-content {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  padding: 0;
}

.filter-sidebar-content::-webkit-scrollbar {
  width: 8px;
}

.filter-sidebar-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.filter-sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(0, 119, 200, 0.3);
  border-radius: 4px;
}

.filter-sidebar-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 119, 200, 0.5);
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid rgba(0, 119, 200, 0.2);
}

.filter-header h3 {
  color: var(--white);
  font-size: 1.3rem;
  margin: 0;
}

/* Filter Actions */
.filter-actions {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(0, 119, 200, 0.2);
}

.btn-reset-all {
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: 1px solid rgba(0, 119, 200, 0.3);
  border-radius: 4px;
  color: var(--white);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-reset-all:hover:not(:disabled) {
  background: rgba(0, 119, 200, 0.1);
  border-color: var(--homag-blue);
}

.btn-reset-all:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-reset-all:focus {
  outline: 2px solid var(--homag-blue);
  outline-offset: 2px;
}

.filter-count-badge {
  display: inline-block;
  background: var(--homag-blue);
  color: var(--white);
  border-radius: 12px;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: 0.5rem;
  min-width: 20px;
  text-align: center;
}

/* Accordion Structure */
.filter-accordion {
  padding: 0;
}

.accordion-item {
  border-top: 1px solid rgba(0, 119, 200, 0.1);
}

.accordion-item:last-child {
  border-bottom: 1px solid rgba(0, 119, 200, 0.1);
}

.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: none;
  color: var(--white);
  font-size: 0.875rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.accordion-header:hover {
  background: rgba(0, 119, 200, 0.05);
}

.accordion-header span {
  flex: 1;
}

.accordion-icon {
  width: 12px;
  height: 8px;
  transition: transform 0.25s ease;
  transform: rotate(-90deg);
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.accordion-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.25s ease, padding 0.25s ease;
  padding: 0 1.5rem;
}

.accordion-content.active {
  max-height: 1000px;
  opacity: 1;
  padding: 0.5rem 1.5rem 1rem;
}

/* Accordion icon rotation handled by JavaScript */
.accordion-item.active .accordion-icon {
  transform: rotate(0deg) !important;
}

.filter-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0.5rem 0;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--grey-medium);
  cursor: pointer;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  transition: var(--transition);
  user-select: none;
}

.filter-option:hover {
  color: var(--white);
}

.filter-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--homag-blue);
  flex-shrink: 0;
  margin: 0;
}

.filter-option span {
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--grey-medium);
  transition: var(--transition);
}

.filter-option:hover span,
.filter-option input[type="checkbox"]:checked + span {
  color: var(--white);
}

/* Nested Hierarchy Styles */
.filter-category-items {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.checkable-category-item {
  margin: 0.5rem 0;
}

.checkable-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.filter-option-checkable-category {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  cursor: pointer;
  padding: 0;
}

.checkable-category-name {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--white);
}

.nested-accordion-toggle {
  background: transparent;
  border: none;
  color: var(--white);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nested-filter-groups {
  padding-left: 1.5rem;
  margin-top: 0.5rem;
  border-left: 2px solid rgba(0, 119, 200, 0.2);
}

.nested-filter-group {
  margin: 0.5rem 0;
}

.nested-filter-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.5rem 0;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  border-radius: 4px;
  color: var(--white);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 0.25rem;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.nested-filter-group-header:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nested-filter-group-header span {
  flex: 1;
}

.nested-filter-group-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.25s ease, padding 0.25s ease;
  padding: 0;
  padding-left: 0.75rem;
}

.nested-filter-group-content.active {
  max-height: 1000px;
  opacity: 1;
  padding: 0.5rem 0 0.5rem 0.75rem;
}

/* Level-based styling for visual hierarchy */
.level-1 {
  /* Main category level */
}

.level-2 {
  /* Sub-category / filter item level */
}

.level-2.filter-option {
  padding-left: 0.5rem;
}

.level-3 {
  /* Nested filter group level */
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  padding: 0.25rem;
}

.level-4 {
  /* Individual filter option level */
}

.level-4.filter-option {
  padding-left: 1rem;
  font-size: 0.8rem;
}

/* Results Area */
.machine-finder-content {
  min-height: 500px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(0, 119, 200, 0.2);
}

.results-count {
  color: var(--grey-medium);
  font-size: 1rem;
}

.view-options {
  display: flex;
  gap: 0.5rem;
}

.view-btn {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(0, 119, 200, 0.3);
  border-radius: 4px;
  color: var(--grey-medium);
  cursor: pointer;
  transition: var(--transition);
}

.view-btn:hover,
.view-btn.active {
  background: var(--homag-blue);
  border-color: var(--homag-blue);
  color: var(--white);
}

/* Machines Grid */
.machines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
}

.machine-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 119, 200, 0.2);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  opacity: 0;
  transform: translateY(20px);
}

.machine-card:hover {
  transform: translateY(-5px) scale(1.02);
  border-color: var(--homag-blue);
  box-shadow: 0 10px 30px rgba(0, 119, 200, 0.3);
}

.machine-card-image,
.machine-card-image-placeholder {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--homag-blue) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.machine-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.machine-card:hover .machine-card-image img {
  transform: scale(1.1);
}

.machine-card-image-placeholder .machine-icon {
  font-size: 4rem;
  opacity: 0.5;
  color: var(--white);
}

.machine-card-content {
  padding: 1.5rem;
}

.machine-brand {
  color: var(--homag-blue);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
}

.machine-name {
  color: var(--white);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.machine-description {
  color: var(--grey-medium);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.machine-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
}

.watchlist-btn {
  background: transparent;
  border: 1px solid var(--homag-blue);
  color: var(--homag-blue);
}

.watchlist-btn:hover,
.watchlist-btn.active {
  background: var(--homag-blue);
  color: var(--white);
}

/* Category Selector */
.category-selector {
  padding: 2rem;
}

.category-selector h2 {
  color: var(--white);
  text-align: center;
  margin-bottom: 2rem;
  font-size: 2rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.category-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 119, 200, 0.2);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.category-card:hover {
  transform: translateY(-5px);
  border-color: var(--homag-blue);
  box-shadow: 0 10px 30px rgba(0, 119, 200, 0.3);
}

.category-card h3 {
  color: var(--white);
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.category-card p {
  color: var(--grey-medium);
  font-size: 0.9rem;
}

/* No Results */
.no-results {
  text-align: center;
  color: var(--grey-medium);
  font-size: 1.1rem;
  padding: 4rem 2rem;
}

.no-results p {
  margin: 0;
  font-size: 1.2rem;
}

/* Loading State */
.loading-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--grey-medium);
}

.loading-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 119, 200, 0.2);
  border-top-color: var(--homag-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 968px) {
  .machine-finder-main {
    grid-template-columns: 1fr;
  }

  .filter-sidebar {
    position: fixed;
    top: 80px;
    left: -100%;
    width: 280px;
    height: calc(100vh - 80px);
    z-index: 999;
    transition: left 0.3s ease;
    max-height: none;
  }

  .filter-sidebar.mobile-open {
    left: 0;
  }

  .filter-toggle {
    display: block;
  }

  .machines-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
  
  /* Mobile overlay */
  .filter-sidebar.mobile-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
  }
}

@media (max-width: 640px) {
  .machine-finder-container {
    padding-top: 60px;
  }
  
  .machine-finder-header {
    padding: 1.5rem 1rem;
  }
  
  .machine-finder-header h1 {
    font-size: 1.75rem;
  }
  
  .machine-finder-header p {
    font-size: 1rem;
  }
  
  .back-to-machinery {
    font-size: 0.9rem;
  }

  .machine-search {
    flex-direction: column;
    gap: 0.75rem;
    padding: 0 1rem;
  }
  
  .search-input {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 48px;
    padding: 0.875rem 1rem;
    width: 100%;
  }
  
  .search-btn {
    width: 100%;
    min-height: 48px;
    padding: 1rem;
  }

  .machines-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0 1rem;
  }
  
  .machine-card {
    min-height: auto;
  }
  
  .machine-card-image {
    min-height: 200px;
  }
  
  .machine-card-title {
    font-size: 1.2rem;
  }
  
  .machine-card-description {
    font-size: 0.9rem;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
  }
  
  .filter-toggle {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
  }
  
  .filter-sidebar {
    width: 100%;
    left: -100%;
    top: 60px;
    height: calc(100vh - 60px);
  }
  
  .filter-sidebar.mobile-open::before {
    left: 0;
  }
  
  .btn-reset-all {
    min-height: 48px;
    font-size: 1rem;
  }
  
  .filter-option {
    min-height: 44px;
    padding: 1rem;
    font-size: 1rem;
  }
  
  .accordion-header {
    min-height: 48px;
    padding: 1rem;
    font-size: 1rem;
  }
}

.mobile-only {
  display: none;
}

@media (max-width: 968px) {
  .mobile-only {
    display: block;
  }
}

