/* ==========================================================================
   ISJ SEARCH PAGE REDESIGN
   Aesthetics: Premium, Editorial, Calm (Stripe/Linear/Vercel inspired).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Page Layout & Header
   -------------------------------------------------------------------------- */
.isj-page--search {
  padding: var(--space-16) 0 var(--space-24) 0;
}

.isj-page-header {
  margin-bottom: var(--space-12);
  text-align: center;
}

/* Redefined locally to ensure purely isolated, beautiful typography */
.isj-page-header .isj-page-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: var(--weight-bold);
  letter-spacing: -0.03em;
  color: var(--color-text-primary);
  margin: 0;
  line-height: var(--leading-tight);
}

/* --------------------------------------------------------------------------
   2. Search Input & Hero Area
   -------------------------------------------------------------------------- */
.isj-search-form {
  position: relative;
  max-width: 800px;
  margin: 0 auto var(--space-16) auto;
  z-index: 10;
}

.isj-search-form__main {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

@media (min-width: 768px) {
  .isj-search-form__main {
    flex-direction: row;
    align-items: stretch;
    gap: var(--space-4);
  }
}

.isj-search-form__input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-3) var(--space-5);
  box-shadow: 0 4px 20px -8px rgba(0, 0, 0, 0.05);
  transition: all var(--transition-medium) cubic-bezier(0.16, 1, 0.3, 1);
}

.isj-search-form__input-wrapper:hover {
  border-color: var(--color-border-hover);
  box-shadow: 0 8px 30px -8px rgba(0, 0, 0, 0.08);
}

.isj-search-form__input-wrapper:focus-within {
  border-color: var(--color-primary);
  box-shadow:
    0 0 0 2px rgba(46, 125, 50, 0.2),
    0 8px 30px -8px rgba(0, 0, 0, 0.1);
}

.isj-search-form__icon {
  width: 20px;
  height: 20px;
  color: var(--color-text-muted);
  margin-right: var(--space-3);
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.isj-search-form__input-wrapper:focus-within .isj-search-form__icon {
  color: var(--color-primary);
}

.isj-search-form__input-wrapper .isj-search-form__input {
  width: 100%;
  border: none !important;
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
  outline: none !important;
  box-shadow: none !important;
  padding: 0;
  line-height: var(--leading-normal);
}

.isj-search-form__input-wrapper .isj-search-form__input:focus {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.isj-search-form__input-wrapper .isj-search-form__input::placeholder {
  color: var(--color-text-muted);
  font-weight: var(--weight-regular);
}

.isj-search-form__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-10);
  min-height: 56px;
  font-size: var(--text-base);
  font-weight: var(--weight-semi);
  white-space: nowrap;
  color: var(--color-white);
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-xl);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.2);
  transition: all var(--transition-medium) cubic-bezier(0.16, 1, 0.3, 1);
}

.isj-search-form__submit:hover {
  transform: none !important;
  background: var(--color-primary-dark);
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.25);
}

.isj-search-form__submit:active {
  box-shadow: 0 2px 8px rgba(46, 125, 50, 0.15);
}

.isj-search-form__submit .isj-search-form__icon {
  display: none;
}

/* --------------------------------------------------------------------------
   3. Advanced Filters (Progressive Disclosure)
   -------------------------------------------------------------------------- */
.isj-search-form__advanced {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.05),
    0 2px 4px -1px rgba(0, 0, 0, 0.03);
  overflow: visible;
  margin-top: var(--space-6);
}

.isj-search-form__advanced-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--color-text-secondary);
  cursor: pointer;
  user-select: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all var(--transition-fast);
  background: transparent;
  list-style: none;
  border-bottom: 1px solid transparent;
}

.isj-search-form__advanced-toggle::-webkit-details-marker {
  display: none;
}

.isj-search-form__advanced-toggle:hover {
  color: var(--color-text-primary);
  background: rgba(0, 0, 0, 0.02);
}

.isj-search-form__advanced[open] .isj-search-form__advanced-toggle {
  color: var(--color-text-primary);
  border-bottom-color: var(--color-border);
  background: rgba(0, 0, 0, 0.01);
}

.isj-search-form__advanced[open] .isj-search-form__advanced-icon {
  transform: rotate(180deg);
}

.isj-search-form__advanced-icon {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-medium) cubic-bezier(0.16, 1, 0.3, 1);
}

.isj-search-form__advanced-content {
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
}

/* Grid Layout for rows */
.isj-search-form__row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

@media (min-width: 768px) {
  .isj-search-form__row {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-8);
  }
}

.isj-date-range {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  margin-top: var(--space-2);
}

.isj-date-range > .isj-form-group__date-selects {
  flex: 1;
}

.isj-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.isj-form-label {
  font-size: 0.75rem;
  font-weight: var(--weight-bold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-1);
}

/* Elevate the Publication Date section as a distinct block */
.isj-search-form__advanced-content > .isj-form-group {
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-border);
}

.isj-search-form__advanced-content > .isj-form-group > .isj-form-label {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: var(--space-6);
}

/* Inputs & Selects: Polished layout */
.isj-input,
.isj-select {
  width: 100%;
  padding: var(--space-4) var(--space-5);
  min-height: 48px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  background: var(--color-surface);
  transition: all var(--transition-fast);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  appearance: none;
}

/* Custom dropdown arrow for standard selects */
.isj-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 16px;
  padding-right: var(--space-10);
}

.isj-input:hover,
.isj-select:hover {
  border-color: var(--color-border-hover);
}

.isj-input:focus,
.isj-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.15);
}

.isj-form-group__date-selects fieldset {
  border: none;
  padding: 0 !important;
  margin: 0 !important;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap; /* Wraps the selects under the legend */
  gap: var(--space-4);
  width: 100%;
  align-items: baseline; /* Ensures label text aligns cleanly with input text */
}

.isj-form-group__date-selects legend {
  position: static;
  width: 100%;
  height: auto;
  overflow: visible;
  clip: auto;
  font-size: 0.8125rem;
  font-weight: var(--weight-semi);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: var(--leading-tight);
  margin: 0 0 var(--space-4) 0 !important;
  padding: 0 !important;
}

.isj-form-group__date-selects select {
  flex: 1;
  min-width: 60px; /* Gives them a consistent bottom line length */
  padding: 0 0 var(--space-2) 0;
  border: none;
  border-bottom: 1px solid var(--color-border-hover);
  border-radius: 0;
  background-color: transparent;
  font-size: var(--text-base); /* Slightly larger for easier reading of dates */
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
  outline: none;
  box-shadow: none;
  transition: all var(--transition-medium);
  appearance: none;
  background-image: none; /* Strip chevron for pure minimalism matching the image */
}

/* Since the empty placeholder is now an `&nbsp;` natively, we don't need `:has` tricks! */

.isj-form-group__date-selects select:hover {
  border-color: var(--color-text-primary);
}

.isj-form-group__date-selects select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 1px 0 var(--color-primary); /* subtle line thickness increase */
}

/* --------------------------------------------------------------------------
   4. Search Results Feed
   -------------------------------------------------------------------------- */

.isj-search-meta {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
}

/* Relying entirely on `.isj-article-card` from articles.css for visuals. */
.isj-search-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

@media (min-width: 768px) {
  .isj-search-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .isj-search-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

.isj-search-list__item {
  /* Stripped of borders/backgrounds to prevent nested-card noise! */
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   5. Overrides for Search Card Specifics (if any)
   -------------------------------------------------------------------------- */
/* We don't overwrite the core card geometry, just ensure text layout holds up. */
.isj-search-list__item .isj-article-card__title a {
  /* Ensuring line height is optimal for scanning */
  line-height: var(--leading-snug);
}

/* --------------------------------------------------------------------------
   6. Empty States
   -------------------------------------------------------------------------- */
.isj-search-empty {
  padding: var(--space-24) var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: transparent;
  border-radius: var(--radius-xl);
  border: 1px dashed var(--color-border-hover);
  margin-top: var(--space-8);
}

.isj-search-empty__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.isj-search-empty__icon {
  width: 48px;
  height: 48px;
  color: var(--color-border-hover);
  margin-bottom: var(--space-2);
}

.isj-search-empty__title {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  color: var(--color-text-primary);
  margin: 0;
}

.isj-search-empty__text {
  font-size: var(--text-md);
  color: var(--color-text-secondary);
  max-width: 480px;
  line-height: var(--leading-loose);
  margin-bottom: var(--space-8);
}

.isj-search-empty__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: var(--space-8);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.isj-search-empty__action:hover {
  transform: none !important;
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.1);
}

/* --------------------------------------------------------------------------
   7. Pagination
   -------------------------------------------------------------------------- */
.isj-pagination {
  margin-top: var(--space-16);
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
}

@media (min-width: 768px) {
  .isj-pagination {
    flex-direction: row;
    justify-content: space-between;
  }
}

.isj-pagination__info {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
}

.isj-pagination__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.isj-pagination__links a,
.isj-pagination__links span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.isj-pagination__links a {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.isj-pagination__links a:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-border-hover);
  color: var(--color-primary-dark);
}

.isj-pagination__links .current,
.isj-pagination__links strong /* In case OJS uses strong for current */ {
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
  border: 1px solid var(--color-primary-light);
}

.isj-pagination__links .disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
