/* ==========================================================================
   page.css — search workspace page layout + spacing
   Keep this file for PAGE LAYOUT, STICKY POSITIONING, and PAGE RHYTHM only.
   Component visuals belong in components/_*.css or base.css.
   ========================================================================== */

/* ==========================================================================
   Legacy sticky search helper
   ========================================================================== */

.search-sticky {
  position: sticky;
  top: var(--header-h, 72px);
  z-index: 20;
  background: var(--bg);
  padding-top: 10px;
  padding-bottom: 10px;
  margin-bottom: var(--space-4);
}

.search-sticky::after {
  content: "";
  display: block;
  height: 1px;
  background: rgba(255, 255, 255, 0.10);
  margin-top: 10px;
}

.search-section {
  margin-bottom: var(--space-6);
}

/* ==========================================================================
   Search workspace layout
   ========================================================================== */

.app-searchPage {
  background: var(--bg);
}

.app-searchMain .container {
  min-width: 0;
}

.search-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

.search-sidebar {
  min-width: 0;
}

.search-sidebar--sticky {
  position: sticky;
  top: calc(var(--header-h) + 12px);
  align-self: start;
}

.search-sidebarInner {
  display: grid;
  gap: var(--space-4);
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.search-content {
  min-width: 0;
  display: grid;
  gap: var(--space-4);
}

.search-content--stacked {
  align-content: start;
}

/* ==========================================================================
   Search toolbar row
   ========================================================================== */

.search-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-4);
  align-items: flex-start;
  padding: var(--space-4);
}

.search-toolbar--shell {
  background: linear-gradient(180deg, #3d2877 0%, #342166 100%);
  border: 1px solid rgba(79, 70, 229, 0.18);
  border-radius: 26px;
  box-shadow:
    0 10px 28px rgba(18, 24, 28, 0.12),
    0 3px 10px rgba(79, 70, 229, 0.12);
  transition:
    border-radius 180ms ease,
    padding 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.search-toolbar--shell.is-scrolled {
  border-radius: 0;
  padding-top: 12px;
  padding-bottom: 12px;
  border-color: rgba(79, 70, 229, 0.24);
  box-shadow:
    0 14px 32px rgba(18, 24, 28, 0.16),
    0 4px 14px rgba(79, 70, 229, 0.14);
}

.search-toolbarMain {
  min-width: 0;
}

.search-toolbarMain--grow {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.search-toolbarMain .search-block {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 0;
}

.search-toolbar--shell .search-composer,
.search-toolbar--shell .search-composer--polished {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}

.search-toolbar--shell .search-composer:hover,
.search-toolbar--shell .search-composer--polished:hover {
  border-color: rgba(79, 70, 229, 0.25);
}

.search-toolbar--shell .search-composer:focus-within,
.search-toolbar--shell .search-composer--polished:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18), var(--shadow-1);
}

.search-toolbar--shell .search-input {
  color: var(--text);
}

.search-toolbar--shell .search-input::placeholder {
  color: var(--muted);
}

.search-toolbar--shell .search-tokens-row {
  border-top-color: var(--rule);
}

.search-toolbarSide {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  min-width: 0;
}

.search-toolbarSide--topAligned {
  align-items: flex-start;
}

.sort-block--stacked {
  width: auto;
  max-width: none;
  margin-left: auto;
}

.search-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: 10px;
}

.search-row .search-block {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 0;
}

.search-stateBar {
  padding: 0 var(--space-1);
}

.search-stateBar--inline {
  margin-top: -6px;
}

.search-stateSummary {
  font-size: var(--text-sm);
}

/* ==========================================================================
   Sort control layout only
   ========================================================================== */

.sort-block {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-top: 0;
  margin-top: 0;
}

.sort-block--stacked {
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.sort-block--topAligned {
  align-items: flex-start;
}

.sort-inline-label {
  font-size: 12px;
  font-weight: 600;
  color: color-mix(in srgb, var(--muted) 82%, white 18%);
  line-height: 1;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.sort-inline-label--polished {
  margin-bottom: 0;
  opacity: 0.78;
}

.sort-select {
  height: 56px;
  width: auto;
  min-width: 0;
  padding: 0 12px;
  line-height: 56px;
}

/* ==========================================================================
   Results / feedback / modal helpers
   ========================================================================== */

.results-section {
  margin-top: 0;
  min-width: 0;
}

.app-footer .btn-primary {
  min-width: 140px;
}

.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.error-banner {
  margin-top: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid rgba(180, 35, 24, 0.25);
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 50;
}

.modal {
  width: 100%;
  max-width: 540px;
  padding: var(--space-5);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 800;
  margin-bottom: var(--space-4);
}

.modal-grid {
  display: grid;
  gap: var(--space-4);
}

.field {
  display: grid;
  gap: var(--space-2);
}

.field-label {
  font-size: var(--text-sm);
  color: var(--muted);
}

.modal-hint {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
}

.modal-actions {
  margin-top: var(--space-5);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

.toast {
  position: fixed;
  right: var(--space-4);
  bottom: calc(var(--footer-h) + var(--space-4));
  z-index: 60;
  padding: 10px 12px;
  font-size: var(--text-sm);
}

.load-more-row {
  display: flex;
  justify-content: center;
  padding: var(--space-5) 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 960px) {
  .search-layout {
    grid-template-columns: 1fr;
  }

  .search-sidebar--sticky,
  .search-toolbar--sticky {
    position: static;
  }

  .search-sidebarInner {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .search-toolbarSide {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .search-sticky {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .search-layout {
    gap: var(--space-4);
  }

  .search-toolbar {
    padding: var(--space-3);
  }

  .search-toolbar--shell,
  .search-toolbar--shell.is-scrolled {
    border-radius: var(--radius-lg);
  }

  .filters-panel {
    gap: var(--space-3);
  }

  .search-row {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 8px;
  }

  .sort-block,
  .sort-block--stacked {
    width: 100%;
    height: auto;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
  }

  .sort-select {
    width: 100%;
  }

  .modal-actions {
    flex-direction: column;
  }

  .toast {
    right: var(--space-3);
    left: var(--space-3);
    bottom: calc(var(--footer-h) + var(--space-3));
  }

  .search-sidebarInner {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

.search-toolbar--sticky {
  position: sticky;
  top: calc(var(--header-h) + 12px);
  z-index: 25;
}

.search-toolbar--sticky.is-scrolled {
  border-radius: 0;
}
