/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps.
 */

/* --- Design tokens -------------------------------------------------------- */
:root {
  --color-bg:          #f9fafb;
  --color-surface:     #fff;
  --color-border:      #e5e7eb;
  --color-border-light: #f3f4f6;
  --color-text:        #111;
  --color-text-muted:  #6b7280;
  --color-text-subtle: #9ca3af;
  --color-label:       #374151;
  --color-blue:        #2563eb;
  --color-blue-dark:   #1d4ed8;
  --color-blue-focus:  #93c5fd;
  --color-blue-ring:   rgba(37, 99, 235, 0.15);
  --color-nav-bg:      #1e293b;
  --color-nav-text:    #f8fafc;
  --color-nav-muted:   #94a3b8;
  --color-nav-border:  #475569;
  --radius-sm:         4px;
  --radius-md:         6px;
  --radius-lg:         8px;
}

/* --- Accessibility utility ----------------------------------------------- */
.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;
}

/* --- Reset & base -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: #111;
  background: #f9fafb;
}

/* --- Auth layout --------------------------------------------------------- */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f9fafb;
}

.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 1.5rem;
}

.auth-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 2rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
  text-align: center;
}

/* --- Forms --------------------------------------------------------------- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
}

.form-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 1rem;
  width: 100%;
}

.form-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* --- Buttons ------------------------------------------------------------- */
.btn-primary {
  display: block;
  width: 100%;
  padding: 0.625rem 1.25rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  margin-top: 0.5rem;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-primary:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

/* --- Flash messages ------------------------------------------------------ */
.flash {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.flash-notice {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.flash-alert {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* --- Admin nav ----------------------------------------------------------- */
.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: #1e293b;
  color: #f8fafc;
}

.admin-nav-brand {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.admin-nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-nav-link {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.875rem;
}

.admin-nav-link:hover {
  color: #f8fafc;
}

.admin-nav-link:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
  border-radius: 2px;
}

.admin-nav-link[aria-current="page"] {
  color: #f8fafc;
  font-weight: 600;
}

.admin-nav-logout {
  display: inline;
}

.admin-nav-logout input,
.admin-nav-logout button {
  background: transparent;
  border: 1px solid #475569;
  color: #94a3b8;
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.admin-nav-logout input:hover,
.admin-nav-logout button:hover {
  color: #f8fafc;
  border-color: #94a3b8;
}

.admin-nav-logout input:focus-visible,
.admin-nav-logout button:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Admin main ---------------------------------------------------------- */
.admin-main {
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* --- Report layout ------------------------------------------------------- */
.report-body {
  margin: 0;
  padding: 0;
  background: #fff;
  overflow: hidden;
}

.report-container {
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0;
}

.report-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* --- Admin page header --------------------------------------------------- */
.admin-page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

/* Override block btn-primary to inline when used inside the page header (e.g. "New Audit" link) */
.admin-page-header .btn-primary {
  display: inline-block;
  width: auto;
  margin-top: 0;
}

.admin-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

/* --- Admin card ---------------------------------------------------------- */
.admin-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  /* WHY: overflow-x allows wide tables (e.g. 8-column prospects table) to scroll
     horizontally on narrow screens instead of breaking the layout. */
  overflow-x: auto;
  overflow-y: hidden;
  margin-bottom: 1.5rem;
}

/* --- Admin table --------------------------------------------------------- */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  color: #374151;
}

.admin-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  color: #111;
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: #f9fafb;
}

.audit-url {
  font-size: 0.8125rem;
  color: #6b7280;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-table td.admin-table__empty-cell {
  text-align: center;
  color: #9ca3af;
  padding: 2rem 1rem;
}

/* --- Badges -------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-pending {
  background: #f3f4f6;
  color: #4b5563;
}

.badge-processing {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-ready {
  background: #d1fae5;
  color: #065f46;
}

.badge-delivered {
  background: #ede9fe;
  color: #5b21b6;
}

/* --- Detail card --------------------------------------------------------- */
.detail-card {
  padding: 1.5rem;
}

.detail-list {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.75rem 1rem;
  margin: 0;
  font-size: 0.9375rem;
}

.detail-list dt {
  font-weight: 600;
  color: #374151;
  align-self: center;
}

.detail-list dd {
  margin: 0;
  color: #111;
  align-self: center;
}

/* --- Admin actions ------------------------------------------------------- */
.admin-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* Override block btn-primary to inline when inside .admin-actions (e.g. form submit buttons) */
.admin-actions .btn-primary {
  display: inline-block;
  width: auto;
  margin-top: 0;
}

.detail-delivered-note {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0;
}

/* --- Buttons (secondary + link) ------------------------------------------ */
.btn-secondary {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #fff;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.btn-secondary:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.btn-secondary:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

.btn-link {
  color: #2563eb;
  text-decoration: none;
  font-size: 0.875rem;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-link:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Upload form --------------------------------------------------------- */
.upload-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.5rem;
  border-top: 1px solid #e5e7eb;
  margin-top: 1rem;
  max-width: 640px;
}

.upload-form .form-input {
  font-family: inherit;
}

/* --- Pending report ------------------------------------------------------ */
.pending-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f9fafb;
  padding: 2rem;
}

.pending-card {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 2.5rem 2rem;
  text-align: center;
}

.pending-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.pending-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1rem;
  color: #111;
}

.pending-body {
  font-size: 1rem;
  color: #374151;
  margin: 0 0 0.75rem;
  line-height: 1.6;
}

.pending-email {
  font-size: 0.9375rem;
  color: #6b7280;
  margin: 0;
  line-height: 1.6;
}

/* --- Outreach table ------------------------------------------------------ */
.outreach-row--sent { color: #9ca3af; }

/* --- Prospector badges --------------------------------------------------- */
.badge-scraped {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-enriched {
  background: #dcfce7;
  color: #15803d;
}

.badge-emailed {
  background: #ede9fe;
  color: #6d28d9;
}

.badge-skipped {
  background: #f3f4f6;
  color: #6b7280;
}

/* --- Prospect row state -------------------------------------------------- */
.prospect-skipped td {
  opacity: 0.55;
}

/* --- Fieldset / Legend --------------------------------------------------- */
fieldset {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin: 0 0 1.25rem;
}

legend {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  padding: 0 0.25rem;
}

/* --- Form checkbox group ------------------------------------------------- */
.form-checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Email preview body -------------------------------------------------- */
.email-preview-body {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
}

/* --- Admin card content -------------------------------------------------- */
.admin-card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
  margin: 0;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.admin-card p {
  padding: 0.75rem 1rem;
  margin: 0;
  font-size: 0.875rem;
  color: #374151;
}

.admin-card .admin-actions {
  padding: 0 1rem 1rem;
}

/* --- Admin nav list (e.g. Prospector dashboard navigation) --------------- */
.admin-card nav ul,
.admin-card .admin-nav-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0;
}

.admin-card nav ul li {
  border-bottom: 1px solid #f3f4f6;
}

.admin-card nav ul li:last-child {
  border-bottom: none;
}

.admin-card nav ul li a {
  display: block;
  padding: 0.625rem 1rem;
  color: #2563eb;
  text-decoration: none;
  font-size: 0.875rem;
}

.admin-card nav ul li a:hover {
  background: #f9fafb;
}

.admin-card nav ul li a:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Inline filter form -------------------------------------------------- */
.admin-card .filter-form {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.admin-card .filter-form label {
  font-weight: 500;
  color: #374151;
  white-space: nowrap;
}

.admin-card .filter-form select {
  padding: 0.375rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  background: #fff;
}

.admin-card .filter-form select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* --- Prospector dashboard stats cards ------------------------------------ */
.prospector-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
}

.stat-card__value {
  font-size: 2rem;
  font-weight: 700;
  color: #111;
  line-height: 1;
}

.stat-card__label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* --- Btn danger ---------------------------------------------------------- */
.btn-danger {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-danger:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

/* --- Btn small ----------------------------------------------------------- */
.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
}

/* --- Pagination ---------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0;
}

.pagination__info {
  font-size: 0.8125rem;
  color: #6b7280;
}

/* --- PDF download button (floating, outside iframe) ---------------------- */
.report-pdf-btn {
  position: fixed;
  bottom: 1.5rem;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  right: 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.125rem;
  background: #fff;
  color: #1f2937;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
  z-index: 100;
}

@media (prefers-reduced-motion: no-preference) {
  .report-pdf-btn { transition: background 0.15s, box-shadow 0.15s; }
}

.report-pdf-btn:hover {
  background: #f9fafb;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
}

.report-pdf-btn:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}
