/* ---------------------------------------------------------------
 * extract.css — /extract tool styling.
 * Form / modal layout reuses base.css + wordgraph.css (.input-panel,
 * .setting-card, .file-input-label, .modal, etc.). This file owns:
 *   - the category-checkbox grid in the form,
 *   - the result-card grid (one card per extracted category),
 *   - the chip styling for the top values,
 *   - the drill-down panel that lists per-item occurrences.
 * --------------------------------------------------------------- */

/* ---------- category checkboxes (form) ---------- */

.cat-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.btn-pill {
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  border-radius: 999px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cat-grid {
  /* 3 per row → the 6 categories land in a clean 3×2 grid. */
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 0.6rem;
}
@media (max-width: 720px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
}

.cat-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
}
.cat-choice:hover { border-color: #cbd5e1; background: #f8fafc; }
.cat-choice:active { transform: scale(0.99); }
.cat-choice input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: #0f172a;
  flex: 0 0 auto;
}
.cat-choice .cat-icon { font-size: 1.05rem; line-height: 1; flex: 0 0 auto; }
.cat-choice .cat-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}
.cat-choice:has(input:checked) {
  border-color: #0f172a;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
}

/* ---------- result stats strip ---------- */

.ex-stats-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.ex-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 18px;
  flex: 1 1 auto;
}

.ex-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ex-stat-num {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
  word-break: break-word;
}
.ex-stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.ex-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- result cards (one per category) ---------- */

.ex-cards {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.ex-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 140px;
}
.ex-card.is-empty { opacity: 0.55; }

.ex-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ex-card-icon {
  font-size: 1.4rem;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: #f1f5f9;
  border-radius: 10px;
  flex: 0 0 auto;
}
.ex-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.ex-card-total {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text);
  background: #e2e8f0;
  padding: 3px 9px;
  border-radius: 999px;
}

.ex-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ex-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  cursor: pointer;
  max-width: 100%;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.ex-chip:hover,
.ex-chip:focus-visible {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
  outline: none;
}
.ex-chip-value {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.ex-chip-count {
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.7;
}

.ex-empty {
  font-size: 0.85rem;
  color: var(--text-faint);
  font-style: italic;
}

/* ---------- drill-down panel ---------- */

.ex-drilldown-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 0.4rem;
}
.ex-drilldown-cat {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.ex-drilldown-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  word-break: break-word;
}

.ex-drilldown-list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ex-drilldown-list li {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.ex-drilldown-idx {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.ex-drilldown-preview {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  /* Same scroll cap as the item card preview, plus the <mark>'d match
   * highlights stay visible inside the scroll area. */
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
.ex-drilldown-preview mark {
  background: #fde68a;
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

/* ---------- view tabs (By category / By item) ---------- */

.ex-view-tabs {
  display: inline-flex;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.ex-tab {
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.01em;
  padding: 0.45rem 1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.ex-tab:hover { color: var(--text); }
.ex-tab.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* ---------- per-item view ---------- */

#ex-items-wrap { margin-top: 1rem; }

.ex-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin: 8px 0;
}
.ex-pager-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}
.ex-pager-nav {
  display: flex;
  gap: 8px;
}
.ex-pager-nav .btn-pill[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.ex-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ex-item-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ex-item-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.ex-item-idx {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}
.ex-item-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  background: #e2e8f0;
  padding: 2px 9px;
  border-radius: 999px;
}

.ex-item-preview {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
  /* Full item text is here; cap visible height + scroll so a 5000-char PDF
   * page doesn't make one card own the whole viewport. */
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.ex-item-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
/* Per-item chips: not clickable (they live next to the source text already),
 * the icon serves as the category badge so the user can scan by symbol. */
.ex-item-chip {
  cursor: default;
}
.ex-item-chip:hover {
  background: #f1f5f9;
  color: inherit;
  border-color: #cbd5e1;
}
.ex-chip-icon {
  font-size: 0.95rem;
  line-height: 1;
}

@media (max-width: 600px) {
  .ex-stats-card { flex-direction: column; align-items: stretch; }
  .ex-actions { justify-content: flex-end; }
  .ex-cards { grid-template-columns: 1fr; }
}
