/* ============================================
   RJA Opportunities — Design System
   ============================================ */

/* -- Color Palette (Slate) -- */
:root {
  --pico-font-size: 15px;
  --pico-line-height: 1.45;
  --pico-spacing: 0.6rem;

  --c-bg: #ffffff;
  --c-bg-subtle: #f8fafc;
  --c-bg-muted: #f1f5f9;
  --c-border: #e2e8f0;
  --c-border-light: #f1f5f9;
  --c-text: #1e293b;
  --c-text-secondary: #475569;
  --c-text-muted: #94a3b8;
  --c-text-faint: #cbd5e1;
  --c-brand: #3b82f6;
  --c-brand-dark: #2563eb;

  --c-excellent: #16a34a;
  --c-excellent-bg: #f0fdf4;
  --c-excellent-border: #bbf7d0;
  --c-good: #d97706;
  --c-good-bg: #fffbeb;
  --c-good-border: #fde68a;
  --c-fair: #dc2626;
  --c-fair-bg: #fef2f2;
  --c-fair-border: #fecaca;
  --c-soon: #ea580c;
  --c-soon-bg: #fff7ed;
  --c-soon-border: #fed7aa;
  --c-action: #7c3aed;
  --c-action-bg: #f5f3ff;
  --c-action-border: #ddd6fe;
}

body {
  font-size: 15px;
  color: var(--c-text);
  background: var(--c-bg-subtle);
}

/* -- Header -- */
.site-header {
  padding: 0.25rem 0;
  border-bottom: 2px solid var(--c-brand);
}
.site-header nav { padding: 0.25rem 0; }
.brand {
  font-size: 1.1rem;
  color: var(--c-brand-dark);
}
.logout-link {
  font-size: 0.82rem;
  color: var(--c-text-muted);
}

/* -- Main container -- */
main.container {
  max-width: 1400px;
  padding-top: 0.5rem;
}

/* -- Footer -- */
.site-footer {
  padding: 0.6rem 0;
  font-size: 0.78rem;
  color: var(--c-text-muted);
  border-top: 1px solid var(--c-border);
}

/* ============================================
   Stats Strip
   ============================================ */
.stat-btn {
  display: inline-flex;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
}
.stat-btn.stat-soon {
  background: var(--c-soon-bg);
  color: var(--c-soon);
  border: 1px solid var(--c-soon-border);
}
.stat-btn.stat-soon:hover,
.stat-btn.stat-soon.stat-active {
  background: var(--c-soon);
  color: #fff;
}
.stat-btn.stat-new {
  background: var(--c-excellent-bg);
  color: var(--c-excellent);
  border: 1px solid var(--c-excellent-border);
}
.stat-btn.stat-new:hover,
.stat-btn.stat-new.stat-active {
  background: var(--c-excellent);
  color: #fff;
}

/* ============================================
   Toolbar
   ============================================ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

.row-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--c-text-secondary);
  white-space: nowrap;
}

/* -- Filters -- */
.filter-group {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-left: auto;
}
.filter-group select {
  font-size: 0.82rem;
  padding: 0.3rem 0.5rem;
  margin-bottom: 0;
  height: auto;
  border-radius: 6px;
  width: 120px;
  border: 1px solid var(--c-border);
  background: var(--c-bg);
  color: var(--c-text);
}
.search-wrapper {
  position: relative;
}
.search-wrapper input[type="search"] {
  font-size: 0.82rem;
  padding: 0.3rem 2rem 0.3rem 2.2rem;
  margin-bottom: 0;
  height: auto;
  border-radius: 6px;
  width: 260px;
  border: 1px solid var(--c-border);
}
.clear-filters {
  font-size: 0.82rem;
  color: var(--c-text);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--c-border);
  border-radius: 6px;
}
.clear-filters:hover {
  color: var(--c-fair);
  background: var(--c-fair-bg);
}

/* ============================================
   Table
   ============================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--c-border);
  background: var(--c-bg);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

/* -- Sticky header -- */
thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-text-secondary);
  padding: 0.55rem 0.5rem;
  border-bottom: 2px solid var(--c-border);
  background: var(--c-bg-muted);
  white-space: nowrap;
}

/* -- Column widths -- */
.col-sol { width: 12%; }
.col-date { width: 8%; white-space: nowrap; }
.col-added { width: 7%; }
.col-updated { width: 7%; }
.col-rel { width: 7%; }
.col-source { width: 7%; }
.col-type { width: 8%; }
.col-action { width: 9%; }
.col-org { width: 14%; }
.col-contact { width: 12%; }
.col-assess { width: 12%; }

/* -- Sort headers -- */
.sort-header {
  display: block;
  text-decoration: none;
  color: var(--c-text-secondary);
  padding: 0.45rem 0.5rem;
  margin: -0.55rem -0.5rem;
}
.sort-header:hover { color: var(--c-text); }
.sort-active { color: var(--c-text); font-weight: 700; }
.sort-arrow { font-size: 0.65rem; }

/* ============================================
   Title Row (full-width topic name)
   ============================================ */
.title-row {
  cursor: pointer;
}
.title-row td {
  padding: 0.55rem 0.5rem 0.1rem 0.5rem;
  border: none;
  border-left: 3px solid var(--c-brand);
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.35;
  background: var(--c-bg);
}
.title-row:hover td {
  background: var(--c-bg-muted);
}
.title-cell a {
  color: var(--c-brand-dark);
  text-decoration: none;
}
.title-cell a:hover { text-decoration: underline; }
.row-num {
  display: inline-block;
  width: 1.4em;
  color: var(--c-text-faint);
  font-weight: 400;
  font-size: 0.78rem;
  text-align: right;
  margin-right: 0.4rem;
}

/* ============================================
   Data Row
   ============================================ */
.data-row {
  cursor: pointer;
}
.data-row td {
  padding: 0.15rem 0.5rem 0.5rem 0.5rem;
  border: none;
  border-bottom: 1px solid var(--c-border-light);
  font-size: 0.82rem;
  color: var(--c-text-secondary);
  vertical-align: middle;
  background: var(--c-bg);
}
.data-row:hover td { background: var(--c-bg-muted); }
.title-row:hover + .data-row td {
  background: var(--c-bg-muted);
}

/* Pair grouping: stronger border after data row */
.detail-row + .title-row td {
  border-top: 2px solid var(--c-border);
}

/* -- Org cell -- */
.org-cell {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================
   Badges (soft pill style)
   ============================================ */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-excellent {
  background: var(--c-excellent-bg);
  color: var(--c-excellent);
  border: 1px solid var(--c-excellent-border);
}
.badge-good {
  background: var(--c-good-bg);
  color: var(--c-good);
  border: 1px solid var(--c-good-border);
}
.badge-fair {
  background: var(--c-fair-bg);
  color: var(--c-fair);
  border: 1px solid var(--c-fair-border);
}

/* -- Action tag (soft pill) -- */
.action-cell { white-space: nowrap; }
.action-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--c-action-bg);
  color: var(--c-action);
  border: 1px solid var(--c-action-border);
}

/* -- Next action box in detail view -- */
.next-action-box {
  background: var(--c-good-bg);
  border-left: 3px solid var(--c-good);
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.6rem;
  border-radius: 0 6px 6px 0;
}
.next-action-box p {
  margin: 0.15rem 0 0 0;
  font-weight: 600;
  color: #92400e;
}

/* -- Source tag (soft pill) -- */
.source-tag {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--c-text-secondary);
  background: var(--c-bg-muted);
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid var(--c-border);
}

/* -- Dates -- */
.date-added {
  color: var(--c-text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}
.date-updated {
  color: var(--c-text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}
.date-updated:not(:empty) {
  color: var(--c-action);
  font-weight: 600;
}
.date-soon {
  color: var(--c-soon);
  font-weight: 600;
  white-space: nowrap;
}
.date-past {
  color: var(--c-fair);
  text-decoration: line-through;
  opacity: 0.6;
}

/* ============================================
   Assessment + Expand Buttons (ghost style)
   ============================================ */
.assess-cell { white-space: nowrap; }
.assess-btn {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  text-decoration: none;
  background: transparent;
  color: var(--c-brand);
  border: 1px solid var(--c-brand);
  margin-right: 0.3rem;
}
.assess-btn:hover {
  background: var(--c-brand);
  color: #fff;
}
.opp-dir-btn {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  text-decoration: none;
  background: transparent;
  color: var(--c-excellent);
  border: 1px solid var(--c-excellent);
  margin-right: 0.3rem;
}
.opp-dir-btn:hover {
  background: var(--c-excellent);
  color: #fff;
}
.expand-btn {
  all: unset;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--c-text-muted);
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  line-height: 1;
}
.expand-btn:hover {
  background: var(--c-bg-muted);
  color: var(--c-text-secondary);
}

/* ============================================
   Detail Row
   ============================================ */
.detail-row td {
  padding: 0.6rem 0.5rem 0.8rem 0.5rem;
  border-bottom: 2px solid var(--c-border);
  background: var(--c-bg-subtle);
}
.detail-content { font-size: 0.84rem; }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.detail-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.1rem;
}
.detail-content p {
  margin: 0 0 0.4rem 0;
  line-height: 1.45;
  color: var(--c-text);
}

/* -- Loading spinner -- */
.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--c-border);
  border-top-color: var(--c-brand);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 0.35rem;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Assessment Page
   ============================================ */
article { font-size: 0.88rem; line-height: 1.55; }
article table { width: auto; }
article table td,
article table th {
  padding: 0.35rem 0.6rem;
  font-size: 0.84rem;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-group { margin-left: 0; }
  .filter-group input[type="search"] {
    flex: 1;
    width: auto;
  }
  .search-wrapper input[type="search"] {
    width: 100%;
  }
  .detail-grid { grid-template-columns: 1fr; }
}
