/* accordion.css
   Enhanced, reusable accordion components for content lists, search results,
   record browsing, etc.

   Complements the base .content-accordion and related utilities in style.css.

   Recommended structure:

   <details class="content-accordion">
     <summary>
       <span class="acc-header">
         <span class="acc-icon"><!-- svg --></span>
         <span class="acc-title">Category or Group Title</span>
         <span class="acc-badge">148 RESULTS</span>
       </span>
       <span class="accordion-chevron">
         <span class="indicator-pipe">|</span>
         <span class="nav-indicator nav-indicator-on-gray"></span>
       </span>
     </summary>
     <div class="accordion-body">
       <table class="acc-table">
         <tbody>
           <tr>
             <td class="acc-title-cell">
               <span class="acc-entry-title">Item name</span>
             </td>
             <td class="acc-meta-cell">
               <svg class="acc-meta-icon">...</svg>
               <span>12,340 RECORDS</span>
             </td>
             <td class="acc-action-cell">
               <button class="acc-btn">VIEW</button>
             </td>
           </tr>
         </tbody>
       </table>
     </div>
   </details>
*/

.acc-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
}

.acc-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.acc-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
}

.acc-title {
  font-weight: 600;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acc-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-primary);
  color: var(--color-bg-white);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.08rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.35rem;
  flex-shrink: 0;
}



/* Improve summary layout + spacing when an acc-header is present */
.content-accordion > summary {
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  align-items: center;
  gap: 0.75rem;
}

.content-accordion .accordion-chevron {
  margin-left: 0.5rem;
}

/* make nested ones a lighter gray */
.content-accordion .content-accordion > summary {
  background: var(--color-bg-light-gray);
}

/* Body padding tuned for tabular/list content */
.content-accordion .accordion-body {
  padding: 0.25rem 0.6rem 0.7rem;
  background-color: var(--color-bg-white);
}

/* Entry table inside accordion bodies */
.acc-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 3px solid var(--color-primary);
  font-size: 0.9rem;
  font-family: var(--font-sans-condensed);
}

.acc-table td {
  padding: 0.5rem 0.4rem;
  vertical-align: middle;
}

.acc-table tr + tr td {
  border-top: 1px solid #f0f0f0;
}

.acc-table tr:nth-child(even) {
  background-color: #fafafa;
}

.acc-title-cell {
  width: 52%;
}

.acc-lock-cell {
  width: 28px;
  text-align: center;
  vertical-align: middle;
  padding-left: 0.1rem;
  padding-right: 0.1rem;
}

.acc-meta-cell {
  width: 20%;
  font-size: 0.72rem;
  color: var(--text-subtle);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.acc-action-cell {
  width: 22%;
  text-align: right;
}

/* For record data tables (search results inner tables):
   Use narrow action column sized to the "PAGE VIEW" button content.
   This prevents the action column from taking excessive space (22% was for
   the 3-column summary lists in collections that use acc-title-cell + acc-meta-cell).
   Other (data) columns now get more of the table width so they aren't squished. */
.acc-table th.acc-record-action,
.acc-table td.acc-record-action {
  width: auto;
  min-width: 5.5rem;
  white-space: nowrap;
  text-align: right;
}

/* Table header styles for search results (replaces previous inline styles) */
.acc-table th {
  font-weight: 700;
  background: var(--color-primary);
  border-right: 1px solid var(--color-bg-white);
  padding: 0.5rem 0.4rem;
  vertical-align: middle;
  text-align: left;
  color: var(--color-bg-white);
}

/* Consistent message styling inside accordions (no inline styles) */
.acc-table-message,
.dataset-loading {
  padding: 0.5rem 0.6rem;
  color: var(--text-subtle);
}

.acc-table-error {
  padding: 0.5rem 0.6rem;
  color: #b33;
}

/* Search results loading states */
.search-loading {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.search-loading .search-spinner {
  width: 16px;
  height: 16px;
  vertical-align: middle;
}

.search-loading span {
  margin-left: 0.5rem;
  color: var(--text-muted);
}

.acc-entry-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-strong);
  line-height: 1.3;
  display: block;
  white-space: normal;
}

.acc-meta-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--text-subtle);
}

.acc-btn {
  background-color: var(--color-secondary);
  color: var(--color-bg-white);
  border: none;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.32rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.acc-btn:hover {
  background-color: #6f9a2e;
}

/* Make .accordion-body horizontally scrollable *only* when it directly
   contains an .acc-table. This gives us scrolling for the table pattern
   without an extra wrapper div and without affecting generic accordion
   bodies (paragraphs, lists, etc. from style.css). */
.content-accordion .accordion-body:has(> .acc-table) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.content-accordion .accordion-body > .acc-table {
  min-width: 480px;
  padding-left: 0.6rem;
  padding-right: 0.6rem;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .acc-title {
    font-size: 0.9rem;
  }

  .acc-entry-title {
    font-size: 0.82rem;
  }

  .content-accordion .accordion-body > .acc-table {
    min-width: 420px;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .acc-table td {
    padding: 0.4rem 0.25rem;
  }

  .acc-meta-cell {
    font-size: 0.65rem;
    gap: 0.2rem;
  }

  .acc-btn {
    font-size: 0.6rem;
    padding: 0.22rem 0.6rem;
    letter-spacing: 0.02em;
  }

  .content-accordion .accordion-body:has(> .acc-table) {
    /* Pull the table closer to the panel edges while scrolling */
    padding-left: 0;
    padding-right: 0;
  }
}

/* "Learn More" link shown inside category accordion summaries (after the badge) */
.acc-learn-more {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
  white-space: nowrap;
  margin-left: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.acc-learn-more:hover {
  text-decoration: underline;
}

.acc-learn-more svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
}

.acc-learn-more-text {
  display: inline;
}

@media (max-width: 768px) {
  .acc-icon {
    display: none;
  }

  .content-accordion > summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    column-gap: 0.6rem;
    padding: 0.5rem 0.65rem;
  }

  .acc-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    column-gap: 0.3rem;
  }

  .acc-title {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.25;
  }

  .acc-badge {
    display: none;
  }

  .acc-learn-more-text {
    display: none;
  }

  .acc-learn-more {
    margin-left: 0;
    margin-right: 0;
    gap: 0;
    align-self: start;
  }

  .content-accordion .accordion-chevron {
    margin-left: 0;
    flex-shrink: 0;
  }
}
