/**
 * Smith Literature Finder – frontend base styles
 * Layout and appearance are now provided by Bootstrap 5 utility classes.
 * Brand-specific overrides live in slf-overrides.css.
 */

/* variablse overrides */
:root {
  --slf-color-primary: #006bb3;
}

/* ── Finder container ────────────────────────────────────────────────── */
.slf-finder {
  z-index: 333;

  h2,
  h4 {
    color: var(--slf-color-primary);
  }
}

/* ── Form elements ────────────────────────────────── */
.slf-form {
  .slf-field {
    label.form-label {
      font-weight: 600;
      color: var(--slf-color-primary);
    }
  }

  .form-select,
  .form-control {
    border-color: var(--slf-color-primary);
    min-height: 50px;

    &::placeholder {
      color: #6c757d;
    }
  }
  .form-select:invalid {
    color: #6c757d !important; /* placeholder color */
  }
}

/* ── Result section ────────────────────────────────── */
.slf-results {
  &[aria-busy='true'] {
    cursor: progress;
  }
}

/* Results header */
.slf-results-header {
  flex: 1;
  background-color: #eee;
  padding: 1rem;
  border-radius: 5px;
  margin-bottom: 3rem;
}

/* Result model image */
.slf-model-image {
  flex: 1;
  width: 100%;
  background: #fff;
  border-radius: 5px;
  border: 2px solid #ddd;
  box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.08);

  @media (min-width: 992px) {
    width: auto;
    max-width: 300px;
  }

  img {
    height: auto;
    filter: brightness(110%);
  }
}

/* Results subheading */
.slf-results-subheading {
  display: none;
  width: 100%;
  color: #000;
  padding: 0.5rem 0;
  margin: 2rem 0 0 0;
}

/* Card */
.slf-result-item {
  display: flex;
  gap: 3rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px solid rgba(43, 54, 66, 0.16);
  border-radius: 3px;
  background-color: #fff;
  padding: 2rem;
  margin-top: 1rem;
  box-shadow: 0 0.75rem 1.5rem rgba(43, 54, 66, 0.08);

  /* Card desktop styles */
  @media (min-width: 576px) {
    flex-flow: row nowrap;
    align-items: center;
    text-align: left;
    justify-content: space-between;
    border: none;
    border-radius: 0;
    padding: 15px 10px;
    margin: 0;
    background-color: transparent;
    box-shadow: none;
    border: 1px solid #eee;
    border-top: none;
  }
}

/* Card heading */
.slf-results-list {
  .slf-result-title {
    display: flex;
    flex-flow: column nowrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-size: 14px;

    .heading-icon {
      display: block;
      height: 45px;
      width: auto;
    }

    @media (min-width: 576px) {
      flex-flow: row nowrap;
      gap: 15px;
      align-items: center;
      justify-content: flex-start;
      width: 100%;
      max-width: 250px;
      font-size: 14px;

      .heading-icon {
        display: inline-block;
        height: 35px;
        width: auto;
      }
    }
  }
}

/* ── Result groups (one section per file type) ─── */
.slf-result-group {
  padding: 0;
  margin-bottom: 3rem;

  @media (min-width: 576px) {
    border-radius: 3px;
    overflow: hidden;
  }
}

.slf-result-group-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slf-color-primary);
  background-color: #eee;
  margin: 0;
  padding: 0.5rem;
  position: sticky;
  top: 70px;

  @media (min-width: 576px) {
    position: static;
  }

  &::before {
    content: '•';
    position: relative;
    top: 2px;
    display: inline-block;
    color: var(--slf-color-primary);
    font-size: 17px;
    line-height: 0;
    margin-right: 0.25rem;
  }
}

/* Per-row file-type badge */
.slf-result-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slf-color-primary);
  background: rgba(0, 107, 179, 0.08);
  border: 1px solid rgba(0, 107, 179, 0.25);
  border-radius: 2px;
  padding: 2px 6px;
  margin-left: 0.5rem;
  vertical-align: middle;
  white-space: nowrap;
}

/* Card download button */
.slf-button-download,
.slf-button-submit {
  display: block;
  border-radius: 3px;
  color: #fff;
  background: var(--slf-color-primary);
  font-size: 1rem;
  padding: 10px 5px;
  height: auto;
  min-height: 40px;
  width: 140px;
  border: none;
  border-radius: 3px !important;
  transition: all 0.3s ease;

  &:hover {
    color: #fff;
    background: #0089e6;
  }
}

.slf-button i {
  font-size: inherit;
}

/* ── Pagination ────────────────────────────────── */
.slf-pagination {
  .pagination {
    --slf-pagination-active-bg: #1293e6;
    --slf-pagination-bg: var(--slf-color-primary);
    gap: 4px !important;
  }

  .page-link {
    min-height: 44px;
    padding: 10px 20px;
    border: 0;
    border-radius: 3px !important;
    background-color: var(--slf-pagination-bg);
    color: #fff;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    transition: background-color 0.2s ease;
  }

  .page-item.active .page-link,
  .page-link:hover,
  .page-link:focus {
    background-color: var(--slf-pagination-active-bg);
    color: #fff;
  }

  .page-link:focus-visible {
    outline: 3px solid rgba(18, 147, 230, 0.35);
    outline-offset: 2px;
  }

  .page-item.disabled {
    .slf-pagination-button {
      display: none;
    }

    > span.page-link {
      min-width: auto;
      padding: 0 8px;
    }
  }

  @media (max-width: 575.98px) {
    width: 100%;

    .pagination {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      gap: 8px !important;
    }

    .slf-pagination-page-item {
      display: none;
    }

    .slf-pagination-previous,
    .slf-pagination-next {
      min-width: 0;
    }

    .slf-pagination-button {
      width: 100%;
      min-height: 44px;
      margin-left: 0;
      padding-right: 12px;
      padding-left: 12px;
    }

    .page-item.disabled .slf-pagination-button {
      display: inline-flex;
      opacity: 0.45;
    }
  }
}

.slf-pagination-status {
  display: none;

  @media (max-width: 575.98px) {
    display: block;
    margin-top: 10px;
    color: #6c757d;
    font-size: 0.95rem;
    line-height: 1.3;
    text-align: center;
  }
}

/* ── Zip download ────────────────────────────────── */

/* Zip download button */
.slf-button-zip {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--slf-color-primary);
  color: #fff;
  border: none;
  border-radius: 3px !important;
  padding: 10px 20px;
  text-transform: uppercase;
  font-size: 0.9rem;
  transition: background-color 0.3s ease;

  &:hover {
    color: #fff;
    background: #0089e6;
  }

  .btn-icon {
    height: 30px;
    width: auto;
  }
}

/* ── Empty state: dashed border ──────────────────────────────────────── */
.slf-empty {
  border-style: dashed !important;
}

/* ── Feedback area: reserve vertical space to prevent layout shift ───── */
.slf-feedback {
  min-height: 1.5rem;
}

/* ── Model suggestions ──────────────────────────────────────────────── */
.slf-model-combobox {
  z-index: 20;
}

.slf-model-suggestions {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  z-index: 1050;
  max-height: min(18rem, 45vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
  border: 1px solid rgba(43, 54, 66, 0.2);
  border-radius: 3px;
  box-shadow: 0 0.75rem 1.5rem rgba(43, 54, 66, 0.16);

  @media (max-width: 575.98px) {
    max-height: min(16rem, 50vh);
  }
}

.slf-model-suggestion {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  color: #1e2830;
  background: #fff;
  border-bottom: 1px solid rgba(43, 54, 66, 0.08);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.25;

  &:last-child {
    border-bottom: 0;
  }

  &:hover,
  &.is-active {
    color: #fff;
    background: var(--slf-color-primary);
  }

  @media (max-width: 575.98px) {
    min-height: 48px;
    padding: 0.75rem;
    font-size: 1rem;
  }
}

.slf-model-suggestion-empty,
.slf-model-suggestion-empty:hover {
  color: #6c757d;
  background: #fff;
  cursor: default;
}

/* ── Results loading skeleton ───────────────────────────────────────── */
.slf-results-loading {
  pointer-events: none;
}

.slf-skeleton-card {
  overflow: hidden;

  @media (max-width: 575.98px) {
    align-items: stretch !important;
  }
}

.slf-skeleton-main {
  min-width: 0;

  @media (max-width: 575.98px) {
    flex-direction: column !important;
    gap: 0.5rem !important;
    width: 100%;
  }
}

.slf-skeleton-line,
.slf-skeleton-download,
.slf-skeleton-preview {
  display: block;
  background: linear-gradient(90deg, #d7e9f6 0%, #f4f9fd 48%, #d7e9f6 100%);
  background-size: 220% 100%;
  border-radius: 3px;
  animation: slf-skeleton-shimmer 1.2s ease-in-out infinite;
}

.slf-skeleton-title {
  width: clamp(6rem, 18vw, 10rem);
  height: 1rem;
  flex: 0 0 auto;
  margin-top: 0.1rem;

  @media (max-width: 575.98px) {
    width: 100%;
    max-width: 16rem;
  }
}

.slf-skeleton-description {
  width: clamp(9rem, 30vw, 18rem);
  height: 0.85rem;
  margin-top: 0.18rem;
  opacity: 0.72;

  @media (max-width: 575.98px) {
    width: 100%;
    max-width: 16rem;
  }
}

.slf-skeleton-download {
  width: 5.4rem;
  height: 1.35rem;
  background: linear-gradient(
    90deg,
    rgba(0, 107, 179, 0.22) 0%,
    rgba(0, 137, 230, 0.08) 48%,
    rgba(0, 107, 179, 0.22) 100%
  );
  background-size: 220% 100%;
}

.slf-skeleton-preview {
  width: 5rem;
  height: 2.35rem;
  background: transparent;
  border: 1px solid rgba(43, 54, 66, 0.32);
  position: relative;

  &::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3rem;
    height: 0.7rem;
    background: linear-gradient(
      90deg,
      rgba(43, 54, 66, 0.18) 0%,
      rgba(43, 54, 66, 0.08) 48%,
      rgba(43, 54, 66, 0.18) 100%
    );
    background-size: 220% 100%;
    border-radius: 3px;
    transform: translate(-50%, -50%);
    animation: slf-skeleton-shimmer 1.2s ease-in-out infinite;
  }
}

@keyframes slf-skeleton-shimmer {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .slf-skeleton-line,
  .slf-skeleton-download,
  .slf-skeleton-preview,
  .slf-skeleton-preview::before {
    animation: none;
  }
}
