/* ============================================================
   WERIS GovContracts — styles.css
   Brand palette:
     Navy   #426480  (Pantone 5405 CP)
     Teal   #6bc9cb  (Pantone 325 CP)
     Gold   #e6ce75  (Pantone 7403 CP)
     Coral  #ee6a48  (Pantone 7416 CP)
     Pink   #d76d81  (Pantone 1777 CP)
     Gray   #939694  (Pantone 423 CP)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Weris brand ── */
  --navy:        #426480;
  --navy-dark:   #2e4a60;
  --navy-light:  #edf2f6;
  --teal:        #6bc9cb;
  --teal-dark:   #4aa9ab;
  --teal-light:  #e8f8f8;
  --gold:        #e6ce75;
  --gold-dark:   #c9ae50;
  --gold-light:  #fdf8e7;
  --coral:       #ee6a48;
  --coral-light: #fdf0ec;
  --pink:        #d76d81;
  --pink-light:  #fbeef1;
  --gray:        #939694;
  --gray-light:  #f3f4f3;

  /* ── Surfaces ── */
  --bg:          #f5f7f9;
  --surface:     #ffffff;
  --surface2:    #f0f4f7;
  --border:      #dce4eb;
  --border2:     #c2d0da;

  /* ── Text ── */
  --text:        #1c2b36;
  --text2:       #5a6e7a;
  --text3:       #93a3ad;

  /* ── Semantic — mapped to brand ── */
  --accent:      var(--navy);
  --accent-bg:   var(--navy-light);
  --accent-bd:   #c2d0da;
  --success:     var(--teal-dark);
  --success-bg:  var(--teal-light);
  --success-bd:  #b8e8e9;
  --warn:        var(--gold-dark);
  --warn-bg:     var(--gold-light);
  --warn-bd:     #f0dfa0;
  --danger:      var(--coral);
  --danger-bg:   var(--coral-light);
  --danger-bd:   #f5c0b0;

  /* ── Misc ── */
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 4px rgba(66,100,128,.10), 0 1px 2px rgba(66,100,128,.06);
  --shadow-md:   0 4px 16px rgba(66,100,128,.12), 0 2px 4px rgba(66,100,128,.06);
  --mono:        'IBM Plex Mono', monospace;
  --sans:        'Lato', system-ui, sans-serif;
  --display:     'Zilla Slab', Georgia, serif;
}

/* ── Base ─────────────────────────────────────────────────── */
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ───────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-rows: 62px 1fr;
  grid-template-columns: 296px 1fr;
  grid-template-areas:
    "header header"
    "sidebar main";
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────── */
header {
  grid-area: header;
  background: var(--navy);
  border-bottom: 1px solid var(--navy-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(66,100,128,.25);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo img {
  height: 34px;
  width: auto;
  display: block;
  border-radius: 4px;
  padding: 3px 8px;
}

.logo-divider {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,.25);
}

.logo-app-name {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,.90);
  letter-spacing: .02em;
  white-space: nowrap;
}

.logo-badge {
  font-size: 10px;
  font-weight: 600;
  background: var(--teal);
  color: var(--navy-dark);
  border-radius: 20px;
  padding: 2px 9px;
  letter-spacing: .04em;
  margin-left: 6px;
}

/* Header right */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.proxy-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255,255,255,.65);
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,.3);
  transition: background .3s;
  flex-shrink: 0;
}

.status-dot.ok    { background: var(--teal); box-shadow: 0 0 0 2px rgba(107,201,203,.3); }
.status-dot.error { background: var(--coral); }

.proxy-url-input {
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius);
  background: rgba(255,255,255,.10);
  color: rgba(255,255,255,.90);
  width: 210px;
  transition: border-color .15s, background .15s;
}

.proxy-url-input::placeholder { color: rgba(255,255,255,.40); }
.proxy-url-input:focus {
  outline: none;
  border-color: var(--teal);
  background: rgba(255,255,255,.15);
}

.check-btn {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius);
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.90);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all .15s;
  white-space: nowrap;
}

.check-btn:hover {
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.40);
}

/* ── Sidebar ───────────────────────────────────────────────── */
aside {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.375rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 62px;
  height: calc(100vh - 62px);
  overflow-y: auto;
}

.section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 7px;
}

.divider { height: 1px; background: var(--border); }

/* Source chips */
.source-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  color: var(--text2);
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chip:hover:not(.disabled) {
  border-color: var(--teal);
  color: var(--navy);
  background: var(--teal-light);
}

.chip.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.chip.disabled { opacity: .38; cursor: not-allowed; }

/* Form fields */
.field { display: flex; flex-direction: column; gap: 5px; }

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: .01em;
}

.field select,
.field input[type="date"],
.field input[type="text"] {
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  appearance: auto;
}

.field select:focus,
.field input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(107,201,203,.18);
}

/* NAICS tags */
.naics-grid { display: flex; flex-direction: column; gap: 4px; }

.naics-tag {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface2);
  color: var(--text2);
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.naics-tag:hover {
  border-color: var(--teal);
  background: var(--teal-light);
  color: var(--navy);
}

.naics-tag.selected {
  background: var(--navy-light);
  color: var(--navy);
  border-color: var(--accent-bd);
  font-weight: 500;
}

.naics-code {
  font-family: var(--mono);
  font-size: 10px;
  opacity: .65;
  flex-shrink: 0;
}

.naics-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text3);
  margin-top: 8px;
  margin-bottom: 2px;
  padding-left: 2px;
}

/* Search button */
.run-btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: none;
  background: var(--teal);
  color: var(--navy-dark);
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all .15s;
  letter-spacing: .01em;
  box-shadow: 0 2px 6px rgba(107,201,203,.35);
}

.run-btn:hover {
  background: var(--teal-dark);
  box-shadow: 0 4px 12px rgba(107,201,203,.40);
  transform: translateY(-1px);
}

.run-btn:active { transform: translateY(0); }
.run-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Main content ─────────────────────────────────────────── */
main {
  grid-area: main;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.results-count { font-size: 13px; color: var(--text2); }
.results-count strong { color: var(--navy); font-weight: 700; }

/* ── Cards ─────────────────────────────────────────────────── */
.cards { display: flex; flex-direction: column; gap: .75rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}

.card:hover {
  border-color: var(--teal);
  border-left-color: var(--navy);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  color: var(--navy);
}

/* Type badges — mapped to Weris brand colors */
.type-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.badge-o, .badge-k { background: var(--navy-light);  color: var(--navy);      border: 1px solid var(--accent-bd); }
.badge-a           { background: var(--teal-light);  color: var(--teal-dark); border: 1px solid var(--success-bd); }
.badge-p           { background: var(--gold-light);  color: var(--gold-dark); border: 1px solid var(--warn-bd); }
.badge-r, .badge-s { background: var(--gray-light);  color: var(--gray);      border: 1px solid #d0d4d2; }

/* Card meta */
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 18px;
  font-size: 12px;
  color: var(--text2);
  align-items: center;
}

.meta-item { display: flex; align-items: center; gap: 5px; }
.meta-item i { font-size: 13px; color: var(--text3); }

.deadline-warn { color: var(--coral) !important; font-weight: 600; }
.deadline-warn i { color: var(--coral) !important; }

.source-pill {
  font-size: 10px;
  font-family: var(--mono);
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--navy-light);
  color: var(--navy);
  border: 1px solid var(--accent-bd);
  font-weight: 500;
}

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: .5rem;
  flex-wrap: wrap;
}

.page-btn {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all .15s;
}

.page-btn:hover:not(:disabled) {
  background: var(--navy-light);
  color: var(--navy);
  border-color: var(--accent-bd);
}

.page-btn:disabled { opacity: .35; cursor: not-allowed; }
.page-info { font-size: 12px; color: var(--text2); padding: 0 4px; }

/* ── State panels ─────────────────────────────────────────── */
.state-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .625rem;
  color: var(--text3);
  text-align: center;
}

.state-panel i { font-size: 40px; margin-bottom: 4px; color: var(--teal); }
.state-panel p { font-size: 14px; color: var(--text2); }
.state-panel small { font-size: 12px; }
.state-panel code {
  font-family: var(--mono);
  background: var(--surface2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--navy);
}

.error-panel {
  background: var(--danger-bg);
  border: 1px solid var(--danger-bd);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  font-size: 13px;
  color: var(--danger);
  line-height: 1.6;
}

/* ── Spinner ──────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}

/* ── Scrollbar ────────────────────────────────────────────── */
aside::-webkit-scrollbar { width: 4px; }
aside::-webkit-scrollbar-track { background: transparent; }
aside::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
aside::-webkit-scrollbar-thumb:hover { background: var(--teal); }

/* ── Sidebar action buttons ───────────────────────────────── */
.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

/* Clear filters button */
.clear-btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all .15s;
  letter-spacing: .01em;
}

.clear-btn:hover {
  background: var(--danger-bg);
  border-color: var(--danger-bd);
  color: var(--danger);
}

/* ── Sort controls ────────────────────────────────────────── */
.sort-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.sort-label {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
}

.sort-select {
  font-family: var(--sans);
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  appearance: auto;
}

.sort-select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(107,201,203,.18);
}

.sort-dir-btn {
  font-size: 13px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}

.sort-dir-btn:hover {
  background: var(--navy-light);
  border-color: var(--accent-bd);
  color: var(--navy);
}

/* View posting link inside card */
.view-link {
  font-size: 12px;
  color: var(--teal-dark);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 500;
  transition: color .15s;
}

.view-link:hover { color: var(--navy); }
.view-link i { font-size: 13px; }

/* ── Typography — Weris brand fonts ──────────────────────────
   Zilla Slab Bold  → headers, card titles, logo app name,
                      results count strong, section labels
   Lato Regular     → all body copy (already set on body via --sans)
   ─────────────────────────────────────────────────────────── */

/* Card titles — primary heading on each contract */
.card-title {
  font-family: var(--display);
  font-weight: 700;
}

/* Results count — "80,893 contracts found" */
.results-count strong {
  font-family: var(--display);
  font-weight: 700;
}

/* Section labels in sidebar */
.section-label {
  font-family: var(--sans);   /* stays Lato — too small for slab serif */
}

/* Logo app name in header */
.logo-app-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;             /* slightly larger to suit the slab serif */
}

/* State panel heading (empty state / loading) */
.state-panel p {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  color: var(--navy);
}

/* NAICS group labels */
.naics-group-label {
  font-family: var(--sans);   /* stays Lato — uppercase label style */
}

/* Search button — keep Lato for UI controls */
.run-btn,
.clear-btn,
.check-btn,
.page-btn,
.sort-select,
.sort-label {
  font-family: var(--sans);
}

/* ── NAICS selected state — stronger visual distinction ───── */
.naics-tag.selected {
  background: var(--navy) !important;
  color: #ffffff !important;
  border-color: var(--navy) !important;
  font-weight: 600;
}

.naics-tag.selected .naics-code {
  opacity: .75;
  color: rgba(255,255,255,.85);
}

.naics-tag.selected:hover {
  background: var(--navy-dark) !important;
  border-color: var(--navy-dark) !important;
}

/* ── Source chips as links ────────────────────────────────── */
a.chip {
  text-decoration: none;
  cursor: pointer;
}

a.chip.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

a.chip.active:hover {
  background: var(--navy-dark);
  border-color: var(--navy-dark);
  color: #fff;
}

/* Small external link icon inside chip */
.chip-ext {
  font-size: 10px;
  opacity: .65;
  margin-left: 1px;
}

.feedback-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.feedback-btn {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.feedback-btn:hover {
  transform: translateY(-1px);
}

.feedback-btn.positive:hover {
  background: var(--teal-light);
  border-color: var(--success-bd);
  color: var(--teal-dark);
}

.feedback-btn.negative:hover {
  background: var(--danger-bg);
  border-color: var(--danger-bd);
  color: var(--danger);
}

.feedback-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

/* ── Relevance ranking UI ─────────────────────────────────── */

/* Wrapper for score pill + type badge in the card header */
.card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* "85% match" pill — filled teal to stand out from type badges */
.score-pill {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: .03em;
  background: var(--teal);
  color: var(--navy-dark);
  border: 1px solid var(--teal-dark);
}

/* "Why ranked:" row beneath the card meta */
.relevance-reasons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.reason-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text3);
  margin-right: 2px;
}

/* Individual reason chip, e.g. "Preferred NAICS 541611 (+20.0)" */
.reason-chip {
  font-size: 11px;
  font-family: var(--mono);
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.reason-chip strong {
  color: var(--navy);
  font-weight: 700;
}

/* ── Card description ─────────────────────────────────────── */
.card-description {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.desc-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text2);
  white-space: normal;
  word-break: break-word;
}

.desc-toggle {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--teal-dark);
  background: none;
  border: none;
  padding: 4px 0 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color .15s;
}

.desc-toggle:hover {
  color: var(--navy);
}

/* ── AI summary ───────────────────────────────────────────── */
.card-ai-summary {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.ai-summary-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--teal-dark);
  margin: 0 0 4px;
}

.ai-summary-label i {
  font-size: 12px;
}

.ai-summary-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text2);
  white-space: normal;
  word-break: break-word;
  margin: 0;
}