/* Product Browser Page */
.browser-page {
  max-width: 1600px;
  margin: 0 auto;
  padding: 40px;
  min-height: calc(100vh - 143px - 200px);
}

.browser-header {
  text-align: center;
  margin-bottom: 48px;
}

.browser-header h1 {
  font-size: 42px;
  font-weight: 800;
  color: #0a0a0a;
  letter-spacing: -1px;
  margin-bottom: 16px;
}

.browser-header p {
  font-size: 18px;
  color: #64748b;
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.6;
}

.browser-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 32px;
  align-items: start;
}

/* Sidebar */
.browser-sidebar {
  position: sticky;
  top: 183px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-search {
  display: block;
  position: relative;
  overflow: hidden;
}

.sidebar-search input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  color: #334155;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.2s;
}

.sidebar-search input:hover {
  border-color: #1e40af;
}

.sidebar-search input:focus {
  outline: none;
  border-color: #1e40af;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.sidebar-search input::placeholder {
  color: #94a3b8;
}

/* Filters Box */
.browser-filters {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
  max-height: calc(100vh - 280px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.filters-header {
  padding: 20px 24px 16px;
  border-bottom: 2px solid #e2e8f0;
  flex-shrink: 0;
}

.filters-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: #0a0a0a;
  margin: 0;
}

.filters-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.filters-footer {
  padding: 16px 24px;
  border-top: 1px solid #e2e8f0;
  background: #fafafa;
  flex-shrink: 0;
}

.filters-footer .btn-clear {
  width: 100%;
}

.filter-group {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f1f5f9;
}

.filter-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.filter-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  padding: 8px 0;
  user-select: none;
}

.filter-header:hover {
  color: #1e40af;
}

.filter-label {
  flex: 1;
}

.filter-header .selected-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #6b7280;
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 9px;
  flex-shrink: 0;
}

.btn-clear .clear-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #6b7280;
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 9px;
  margin-left: 8px;
}

.category-header .selected-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #6b7280;
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-label {
  flex: 1;
}

.filter-toggle {
  font-size: 12px;
  width: 16px;
  transition: transform 0.2s;
}

.filter-content {
  margin-top: 12px;
  transition: all 0.2s;
}

.filter-content.collapsed {
  display: none;
}

.category-functions {
  transition: all 0.2s;
}

.category-functions.collapsed {
  display: none;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  cursor: pointer;
  font-size: 14px;
  color: #334155;
  transition: color 0.2s;
}

.checkbox-label:hover {
  color: #1e40af;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #1e40af;
}

.function-category {
  margin-bottom: 16px;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 13px;
  color: #334155;
  transition: all 0.2s;
}

.category-header:hover {
  background: #e8e9f5;
  color: #2e368f;
}

.category-header .toggle {
  font-size: 10px;
  width: 14px;
  transition: transform 0.2s;
}

.category-functions {
  padding-left: 24px;
  margin-top: 8px;
}

.function-item {
  font-size: 13px;
  padding: 6px 0;
}

/* Function Search */
.function-search {
  margin-bottom: 12px;
}

.function-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  transition: all 0.2s;
}

.function-search input:hover {
  border-color: #cbd5e1;
}

.function-search input:focus {
  outline: none;
  border-color: #1e40af;
  background: white;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.function-search input::placeholder {
  color: #94a3b8;
}

.filter-content .no-results {
  padding: 16px 0;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  font-style: italic;
}

.count {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
}

/* Depth Filter */
.depth-filter-info {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 8px;
  font-style: italic;
}

.checkbox-label input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #1e40af;
}

.btn-clear {
  width: 100%;
  padding: 12px 20px;
  background: white;
  color: #334155;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
  transition: all 0.2s;
}

.btn-clear:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: #fef2f2;
}

/* Products Grid Area */
.browser-products {
  background: white;
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
  min-height: 600px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e2e8f0;
}

.results-count {
  font-size: 16px;
  font-weight: 600;
  color: #334155;
}

.results-sort {
  display: flex;
  align-items: center;
  gap: 12px;
}

.results-sort label {
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
}

.results-sort select {
  padding: 8px 32px 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: white;
  color: #334155;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23334155' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.results-sort select:hover {
  border-color: #1e40af;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.results-sort select:focus {
  outline: none;
  border-color: #1e40af;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

/* Product Card */
.product-card {
  position: relative;
  background: #fafafa;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.product-card-link {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

.product-card:hover {
  border-color: #1e40af;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.15);
  transform: translateY(-4px);
}

.product-card-image {
  width: 100%;
  height: 180px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.product-card-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.product-card-content {
  padding: 20px;
}

.product-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.product-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: #0a0a0a;
  line-height: 1.3;
  margin: 0;
}

.product-card-price {
  font-size: 16px;
  font-weight: 700;
  color: #0a0a0a;
  white-space: nowrap;
}

.product-card-price.call-for-price {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

.product-card-meta {
  margin-bottom: 8px;
}

.product-case,
.product-depth {
  display: inline-block;
  font-size: 12px;
  color: #475569;
  font-weight: 500;
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 4px;
  margin-right: 6px;
}

.product-desc {
  font-size: 14px;
  color: #64748b;
  line-height: 1.5;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-functions {
  margin: 12px 0;
}

.product-functions strong {
  font-size: 13px;
  color: #334155;
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

.function-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.function-list li {
  padding: 4px 0;
  font-size: 12px;
  color: #64748b;
}

.function-provider-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.function-provider-list li {
  padding: 4px 0;
  font-size: 13px;
  color: #0a0a0a;
  line-height: 1.5;
}

.function-provider-list .function-name {
  font-weight: 500;
  color: #0a0a0a;
}

.function-provider-list .function-with {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 400;
  margin: 0 6px;
}

.function-provider-list .module-names {
  font-size: 13px;
  color: #64748b;
}

.function-provider-list .module-link {
  color: #1e40af;
  text-decoration: none;
  font-weight: 500;
}

.function-provider-list .module-link:hover {
  text-decoration: underline;
}

.function-provider-list .built-in-text {
  color: #64748b;
  font-weight: 500;
}

/* Input modules section - collapsible */
.input-modules-section {
  margin-top: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
  overflow: hidden;
}

.input-modules-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.input-modules-summary:hover {
  background: #f1f5f9;
}

.input-modules-summary .expand-icon {
  font-size: 10px;
  color: #64748b;
  transition: transform 0.2s;
}

.input-modules-section.expanded .expand-icon {
  transform: rotate(90deg);
}

.input-modules-summary .summary-text {
  font-size: 12px;
  font-weight: 500;
  color: #475569;
}

.input-modules-detail {
  display: none;
  border-top: 1px solid #e2e8f0;
  background: white;
}

.input-modules-section.expanded .input-modules-detail {
  display: block;
}

.input-module-item {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
}

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

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.module-header .module-link {
  font-size: 13px;
  font-weight: 600;
  color: #1e40af;
  text-decoration: none;
}

.module-header .module-link:hover {
  text-decoration: underline;
}

.module-header .module-name.built-in {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.module-header .channel-count {
  font-size: 11px;
  font-weight: 600;
  color: white;
  background: #64748b;
  padding: 2px 6px;
  border-radius: 4px;
}

.channel-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.channel-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
  color: #64748b;
  padding-left: 4px;
}

.channel-row .channel-qty {
  font-weight: 600;
  color: #475569;
  min-width: 20px;
}

.channel-row .channel-name {
  color: #64748b;
}

.function-list li {
  padding: 4px 0;
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

.more-functions {
  margin-top: 8px;
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
}

.product-outputs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.output-badge {
  display: inline-block;
  padding: 4px 10px;
  background: #f0fdf4;
  color: #10b981;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 80px 40px;
  color: #94a3b8;
}

.empty-state svg {
  margin-bottom: 24px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 20px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 15px;
  color: #94a3b8;
}

/* Responsive */
@media (max-width: 1024px) {
  .browser-layout {
    grid-template-columns: 1fr;
  }

  .browser-sidebar {
    position: static;
  }

  .browser-filters {
    position: static;
    max-height: none;
  }

  .filters-scroll {
    max-height: 400px;
  }

  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  .browser-page {
    padding: 24px 16px;
  }

  .browser-header {
    margin-bottom: 24px;
  }

  .browser-header h1 {
    font-size: 28px;
  }

  .browser-header p {
    font-size: 15px;
  }

  .browser-layout {
    gap: 20px;
  }

  .browser-sidebar {
    position: static;
  }

  .sidebar-search input {
    padding: 10px 14px;
    font-size: 16px; /* Prevents iOS zoom */
  }

  .browser-filters {
    border-radius: 8px;
  }

  .filters-header {
    padding: 16px;
  }

  .filters-header h2 {
    font-size: 16px;
  }

  .filters-scroll {
    padding: 16px;
    max-height: 300px;
  }

  .filters-footer {
    padding: 12px 16px;
  }

  .products-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .browser-products {
    padding: 16px;
    border-radius: 8px;
  }
}

/* Pagination */
.pagination {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid #e2e8f0;
}

.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pagination-btn {
  padding: 8px 14px;
  border: 1px solid #e2e8f0;
  background: white;
  color: #334155;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
  border-color: #1e40af;
  color: #1e40af;
  background: #eff6ff;
}

.pagination-btn.active {
  background: #1e40af;
  border-color: #1e40af;
  color: white;
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-ellipsis {
  color: #94a3b8;
  padding: 0 4px;
}

/* Unified function support section */
.function-support-section {
  position: relative;
  z-index: 2;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.function-support-item {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}

.function-support-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f8fafc;
  font-size: 13px;
}

.function-support-item.has-modules .function-support-header {
  cursor: pointer;
  transition: background 0.15s;
}

.function-support-item.has-modules .function-support-header:hover {
  background: #f1f5f9;
}

.function-support-header .support-check {
  color: #16a34a;
  font-weight: 600;
  font-size: 12px;
}

.function-support-header .function-name {
  flex: 1;
  font-weight: 500;
  color: #0a0a0a;
}

.function-support-header .built-in-badge {
  font-size: 11px;
  color: #64748b;
  background: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
}

.function-support-header .module-count {
  font-size: 11px;
  color: #64748b;
}

.function-support-header .expand-icon {
  font-size: 10px;
  color: #64748b;
  transition: transform 0.2s;
}

.function-support-item.expanded .expand-icon {
  transform: rotate(90deg);
}

.function-modules-list {
  display: none;
  padding: 8px 12px;
  background: white;
  border-top: 1px solid #e2e8f0;
  flex-wrap: wrap;
  gap: 6px;
}

.function-support-item.expanded .function-modules-list {
  display: flex;
}

.function-modules-list .module-item {
  font-size: 12px;
  color: #1e40af;
  text-decoration: none;
  padding: 4px 8px;
  background: #eff6ff;
  border-radius: 4px;
  font-weight: 500;
}

.function-modules-list .module-item:hover {
  background: #dbeafe;
  text-decoration: none;
}

.function-modules-list .module-item.built-in {
  color: #64748b;
  background: #f1f5f9;
}
