/* Search page styles */

.search-page {
  display: none;
  height: 100vh;
  flex-direction: column;
  background: linear-gradient(180deg, #f5f7fa 0%, #eef1f5 100%);
}

/* Page header */
.search-page-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem 0.75rem 4.5rem;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-back {
  background: none;
  border: none;
  cursor: pointer;
  color: #374151;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  border-radius: 0.375rem;
  transition: background 0.15s;
}

.search-back:hover {
  background: #f3f4f6;
}

/* Search input */
.search-input-wrapper {
  flex: 1;
  position: relative;
}

.search-input-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  box-sizing: border-box;
}

.search-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* View toggle */
.search-view-toggle {
  display: flex;
  gap: 0.25rem;
  background: #f3f4f6;
  border-radius: 0.375rem;
  padding: 2px;
  flex-shrink: 0;
}

.search-view-btn {
  padding: 0.375rem 0.5rem;
  border: none;
  background: transparent;
  border-radius: 0.25rem;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.15s;
  display: flex;
  align-items: center;
}

.search-view-btn.active {
  background: white;
  color: #374151;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.search-view-btn:hover:not(.active) {
  color: #374151;
}

/* Summary bar */
.search-summary {
  padding: 0.5rem 1.5rem;
  font-size: 0.813rem;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
  min-height: 1.25rem;
  background: white;
}

.search-summary:empty {
  display: none;
}

/* Results container */
.search-results {
  flex: 1;
  padding: 1rem 1.5rem;
  overflow-y: auto;
}

/* === PRINTING LIST VIEW === */
.search-printing-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

/* Row wrapper - contains main row + expandable detail */
.search-row-wrapper {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  overflow: hidden;
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

.search-row-wrapper:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  border-color: #d1d5db;
}

.search-row-wrapper.expanded {
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.07),
    0 2px 4px -1px rgba(0, 0, 0, 0.04);
  border-color: #d1d5db;
}

/* Main clickable row */
.search-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: none;
}

.search-row:hover {
  background: #fafbfc;
}

/* Thumbnail cell */
.search-row-thumb-cell {
  flex-shrink: 0;
  width: 36px;
}

.search-row-thumb {
  border-radius: 3px;
  object-fit: cover;
  display: block;
  width: 36px;
  height: 50px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.search-row-thumb-placeholder {
  width: 36px;
  height: 50px;
  background: #f3f4f6;
  border-radius: 3px;
}

/* Info section (name + meta) - takes remaining space */
.search-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.search-row-name-line {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.search-row-name {
  font-weight: 500;
  font-size: 0.875rem;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-row-qty {
  color: #9ca3af;
  font-size: 0.75rem;
  font-weight: 500;
}

.search-row-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: #6b7280;
}

.search-row-set {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
}

/* Rarity color coding */
.search-row-set.rarity-common {
  color: #374151;
}
.search-row-set.rarity-uncommon {
  color: #71717a;
}
.search-row-set.rarity-rare {
  color: #b8860b;
}
.search-row-set.rarity-mythic {
  color: #cc3700;
}
.search-row-set.rarity-special {
  color: #7c3aed;
}

.search-row-collector {
  color: #9ca3af;
}

/* Set symbol icon */
.search-set-symbol {
  height: 1em;
  width: auto;
  vertical-align: middle;
  display: inline-block;
}

/* Finish badges */
.search-finish-badge {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 9999px;
  line-height: 1.5;
  white-space: nowrap;
}

.search-finish-badge.foil {
  background: linear-gradient(135deg, #fef3c7 0%, #ddd6fe 50%, #ccfbf1 100%);
  color: #4b5563;
  border: 1px solid #e5e7eb;
}

.search-finish-badge.etched {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #d1d5db;
}

/* Price column */
.search-row-price {
  flex-shrink: 0;
  font-size: 0.813rem;
  font-weight: 500;
  color: #374151;
  min-width: 60px;
  text-align: right;
}

/* Binders column */
.search-row-binders {
  flex-shrink: 0;
}

/* Binder count badge (shared between list and grid) */
.search-list-binder-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  background: #ede9fe;
  color: #7c3aed;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  cursor: default;
}

/* Expand chevron */
.search-row-expand {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: #9ca3af;
  transition: color 0.15s;
}

.search-row:hover .search-row-expand {
  color: #6b7280;
}

.search-row-chevron {
  transition: transform 0.25s ease;
}

.search-row-wrapper.expanded .search-row-chevron {
  transform: rotate(180deg);
}

/* === EXPANDABLE DETAIL PANEL === */
.search-row-detail {
  max-height: 0;
  overflow: hidden;
  transition:
    max-height 0.25s ease,
    padding 0.25s ease;
  background: #f9fafb;
  border-top: 0 solid #e5e7eb;
  padding: 0 0.75rem 0 3.5rem;
}

.search-row-wrapper.expanded .search-row-detail {
  max-height: 300px;
  border-top-width: 1px;
  padding: 0.625rem 0.75rem 0.625rem 3.5rem;
}

/* Binder list inside detail */
.search-binder-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.search-binder-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.813rem;
}

.search-binder-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-binder-link {
  color: var(--binder-link-color, #374151);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.15s;
}

.search-binder-link:hover {
  opacity: 0.75;
  text-decoration: underline;
}

.search-binder-name {
  color: #374151;
  font-weight: 500;
}

.search-binder-owner {
  color: #9ca3af;
  font-size: 0.75rem;
  font-weight: 400;
}

.search-binder-qty {
  color: #9ca3af;
  font-size: 0.75rem;
  margin-left: auto;
}

/* === GRID VIEW === */
.search-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

/* Binder count badge on grid cards */
.search-binder-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(124, 58, 237, 0.9);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 0.75rem;
  z-index: 10;
  pointer-events: none;
  line-height: 1.2;
}

/* Set code badge on grid cards */
.search-grid-set-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 0.5rem;
  z-index: 10;
  pointer-events: none;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* === PAGINATION === */
.search-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0;
  margin-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
}

.search-pagination-btn {
  padding: 0.375rem 0.75rem;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 0.375rem;
  cursor: pointer;
  color: #374151;
  font-size: 0.813rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.search-pagination-btn:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.search-pagination-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.search-pagination-info {
  font-size: 0.813rem;
  color: #6b7280;
  font-weight: 500;
  min-width: 6rem;
  text-align: center;
}

/* === STATES === */
.search-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: #9ca3af;
}

.search-empty svg {
  margin: 0 auto 1rem;
  display: block;
}

.search-loading {
  text-align: center;
  padding: 2rem;
  color: #6b7280;
}

.search-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e5e7eb;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: search-spin 0.6s linear infinite;
  margin: 0 auto 0.75rem;
}

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

/* === DESKTOP === */
@media (min-width: 769px) {
  .search-page-header {
    padding: 1rem 3rem 1rem 4.5rem;
  }

  .search-input {
    max-width: 500px;
    font-size: 1rem;
  }

  .search-summary {
    padding: 0.5rem 3rem;
  }

  .search-results {
    padding: 1.5rem 3rem;
  }

  /* List view: wider rows with more info visible */
  .search-printing-list {
    max-width: 900px;
  }

  .search-row {
    padding: 0.625rem 1rem;
    gap: 1rem;
  }

  .search-row-thumb-cell {
    width: 48px;
  }

  .search-row-thumb {
    width: 48px;
    height: 67px;
  }

  .search-row-thumb-placeholder {
    width: 48px;
    height: 67px;
  }

  .search-row-name {
    font-size: 0.938rem;
  }

  .search-row-meta {
    font-size: 0.813rem;
    gap: 0.5rem;
  }

  .search-row-price {
    min-width: 80px;
    font-size: 0.875rem;
  }

  .search-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.25rem;
  }
}

/* Large desktop: more breathing room */
@media (min-width: 1024px) {
  .search-page-header {
    padding: 1rem 5vw 1rem 4.5rem;
  }

  .search-summary {
    padding: 0.5rem 5vw;
  }

  .search-results {
    padding: 1.5rem 5vw;
  }

  .search-input {
    max-width: 600px;
  }

  .search-printing-list {
    max-width: 1000px;
  }

  .search-card-grid {
    max-width: 1200px;
  }
}

/* Extra large screens: cap the content width */
@media (min-width: 1600px) {
  .search-page-header {
    padding: 1rem calc((100vw - 1400px) / 2) 1rem calc((100vw - 1400px) / 2 + 1.5rem);
  }

  .search-summary {
    padding: 0.5rem calc((100vw - 1400px) / 2);
  }

  .search-results {
    padding: 1.5rem calc((100vw - 1400px) / 2);
  }
}

/* === MOBILE === */
@media (max-width: 768px) {
  .search-page-header {
    padding: 0.5rem 1rem 0.5rem 3.5rem;
    gap: 0.5rem;
  }

  .search-results {
    padding: 0.75rem;
  }

  .search-row {
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
  }

  .search-row-price {
    display: none;
  }

  .search-row-wrapper.expanded .search-row-detail {
    padding-left: 0.75rem;
  }

  .search-row-name {
    font-size: 0.813rem;
  }

  .search-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
  }
}

@media (max-width: 480px) {
  .search-card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
