/* Design tokens + component styles copied verbatim from
   fda_scraper/public/styles.css (header, filter-panel, search-wrap, btn,
   results-bar, filter-grid). Keep these byte-identical to that source so a
   visitor can't tell they crossed a Worker boundary — see CLAUDE.md.
   Exception: .app-container is NOT verbatim (see that rule's own comment) —
   the live site's version is entangled with its data-table/regulation-tree
   layout (calc(100dvh - ...), #dataTableTab children, etc.) that has no
   equivalent on this simple search+modal page; only the width/gutter
   behavior was matched, not copied wholesale. */
:root {
  --app-header-h: 52px;
  --bg: #F7F8FA;
  --bg-raised: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F9FAFB;
  --bg-input: #FFFFFF;
  --border: #D8DDE5;
  --border-focus: #2D3F86;
  --text: #5E5E5E;
  --text-dim: #6B7280;
  --text-bright: #2D3F86;
  --accent: #2D3F86;
  --accent-dim: rgba(45,63,134,0.1);
  --accent-glow: rgba(45,63,134,0.05);
  --applied: #F97316;
  --green: #16a34a;
  --red: #E85036;
  --blue: #2D3F86;
  --slate: #9CA3AF;
  --font-display: 'Poppins', system-ui, sans-serif;
  --font-body: 'Poppins', system-ui, sans-serif;
  --font-mono: 'Menlo', 'Consolas', monospace;
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

::selection { background: var(--accent); color: #fff; }

/* ── Header: /shared/site-header.css on the shared host (one copy for all
   three apps, loaded after this file). Not duplicated here. ── */

/* Full-bleed, matching fda.innolitics.com's current .app-container (that
   site now uses width:100%/max-width:none with a small side gutter, not a
   fixed-width centered card — see repo CLAUDE.md). A centered 1100px card
   here read as visibly narrower/different from the main site on anything
   wider than a laptop. */
.app-container {
  width: 100%;
  padding: 20px 28px 60px;
}

@media (max-width: 640px) {
  .app-container {
    padding: 16px 16px 48px;
  }
}

/* ── Filter panel — copied from fda_scraper .filter-panel / .filter-header / .filter-body ── */
.filter-panel {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
  transition: border-color 0.2s;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.filter-panel:focus-within { border-color: var(--border-focus); }
.filter-header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #E3E7EF;
  background: #F3F5FA;
  color: var(--text-bright);
}
.filter-header h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-bright);
  flex: 1;
  margin: 0;
}
.filter-body { padding: 16px 20px 20px; }

.search-wrap { position: relative; margin-bottom: 14px; }
.search-wrap .search-wrap-icon {
  position: absolute; left: 14px; top: 13px;
  color: var(--text-dim); pointer-events: none;
}
.search-everything {
  width: 100%;
  padding: 11px 14px 11px 40px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-bright);
  font-family: var(--font-body);
  font-size: 15px;
  transition: all 0.2s;
  margin-bottom: 0;
}
.search-everything::placeholder { color: #C0C5CC; font-style: italic; }
.search-everything:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: var(--bg-input);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 12px;
  margin-bottom: 4px;
}
.filter-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.filter-grid input, .filter-grid select {
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
.filter-grid select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
}
.filter-grid input:focus, .filter-grid select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.filter-actions { display: flex; gap: 8px; margin-top: 14px; }

/* ── Buttons — copied from fda_scraper .btn / .btn-primary ── */
.btn {
  padding: 7px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}
.btn:hover { border-color: var(--text-dim); color: var(--text-bright); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}
.btn-primary:hover { background: #E85036; border-color: #E85036; color: #FFFFFF; }

/* ── Results bar — copied from fda_scraper .results-bar ── */
.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 14px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: none;
  background: var(--bg-raised);
  flex-shrink: 0;
}
.results-bar h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 300;
  color: var(--text-bright);
  letter-spacing: -0.02em;
  margin: 0;
}
.results-bar h2 strong {
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.results-bar .meta { color: var(--text-dim); font-size: 13px; }

/* ── Tabular view — new for this source; styled with the same tokens ── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--bg-raised);
  overflow-x: auto;
}
table.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.results-table thead th {
  position: sticky;
  top: 0;
  background: #F3F5FA;
  color: var(--text-dim);
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.results-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  cursor: pointer;
}
.results-table tbody tr:last-child { border-bottom: none; }
.results-table tbody tr:hover { background: var(--bg-card-hover); }
.results-table td {
  padding: 12px 16px;
  vertical-align: top;
  color: var(--text);
}
.results-table td.col-company {
  color: var(--text-bright);
  font-weight: 600;
  max-width: 260px;
}
.results-table td.col-date { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-dim); }
.results-table td.col-subject { color: var(--text-dim); }
.results-table .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(22,163,74,0.1);
  color: var(--green);
}
.empty-state, .loading-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

/* ── Letter detail modal — copied from fda_scraper .modal-overlay/.modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  overflow-y: auto;
  padding: 40px 20px;
}
.modal-overlay.open { display: block; }
.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  max-width: 820px;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  padding: 28px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 14px; right: 18px;
  font-size: 20px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-dim);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.modal-close:hover { color: var(--text-bright); background: #F6F6F6; }
.modal h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  color: var(--text-bright);
  margin: 0 0 4px;
  padding-right: 32px;
}
.modal .modal-subtitle { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }
.modal-section { margin-bottom: 20px; }
.modal-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.modal-section table { width: 100%; border-collapse: collapse; font-size: 14px; }
.modal-section td, .modal-section th {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.modal-section th {
  color: var(--text-dim);
  font-weight: 500;
  width: 140px;
  white-space: nowrap;
}
.modal-section td { color: var(--text); word-break: break-word; }
.modal-section .letter-body {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow-y: auto;
  line-height: 1.6;
}
.modal-section .cfr-chip {
  display: inline-block;
  padding: 2px 8px;
  margin: 0 6px 6px 0;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 10px;
  font-size: 12px;
  font-family: var(--font-mono);
}
.modal-footer-link { font-size: 13px; color: var(--text-dim); }
.modal-footer-link a { color: var(--accent); }

/* Visually hidden, still read by screen readers and search engines (the
   page's <h1>). Same rule as fda_scraper's public/styles.css .sr-only. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
