/*
 * ════════════════════════════════════════════════════════
 * NODEDIFF — APP.CSS
 * Dashboard-specific styles.
 * global.css owns: tokens, typography, reset, report layout.
 * This file owns: navbar, sidebar, generator, table, dialogs.
 * ════════════════════════════════════════════════════════
 *
 * Font scale (dashboard only — 4 sizes, no exceptions):
 *   22px — view headings (Lora)
 *   15px — body text, input text
 *   14px — labels, sidebar links, button text
 *   13px — table data (mono), helper / meta text
 */


/* ── 01 · App Variables ─────────────────────────────────────── */
/* These extend global.css :root without overriding it.         */

:root {
  --nav-h:       56px;
  --sidebar-w:   200px;
  --red-action:  #991B1B;   /* Delete button — muted red, matches global error tone */
  --green-action: #2D6A4F;  /* Email button  — muted forest green                  */
}

/* ── 01.5 · Scrollbar ───────────────────────────────────────── */
body {
  scrollbar-width: none;
  -ms-overflow-style: none;
  overflow-x: hidden;
}
::-webkit-scrollbar {
  display: none;
}


/* ── 02 · Navbar ────────────────────────────────────────────── */
/* Only glassmorphism element in the entire app.                */

.lp-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--nav-h);
  background: rgba(254, 252, 244, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.lp-nav-inner {
  height: 100%;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lp-nav-logo {
  font-family: var(--font-headings);
  font-size: 22px;
  font-weight: 500;
  text-decoration: none;
  flex-shrink: 0;
}

/* Logo word marks — reused on auth screen too */
.logo-node { color: var(--text); }
.logo-diff { color: var(--purple); }

.lp-nav-right {
  display: flex;
  align-items: center;
}


/* ── 03 · App Shell ─────────────────────────────────────────── */
/* Authenticated layout: sidebar + main, below the navbar.      */

#appLayout {
  display: flex;
  min-height: calc(100vh - var(--nav-h));
}


/* ── 04 · Sidebar ───────────────────────────────────────────── */

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 32px 16px;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  display: block;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--gray);
  text-decoration: none;
  border-radius: 4px;
  transition: color 0.15s;
}

.sidebar-link:hover {
  color: var(--text);
}

/* Active state: dark pill, text flips to page bg color */
.sidebar-link.active {
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
}


/* ── 05 · View Headings ─────────────────────────────────────── */
/* Shared across Dashboard, Billing, and any future views.      */

.view-heading {
  font-family: var(--font-headings);
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.view-subtext {
  font-size: 14px;
  color: var(--gray);
  margin-bottom: 0;   /* Sibling spacing handled by parent margins */
}


/* ── 06 · Main Content Area ─────────────────────────────────── */

.app-main {
  flex: 1;
  min-width: 0;           /* Prevents flex child overflow */
  padding: 32px 48px 120px;
  max-width: 1200px;      /* Allow more room for tables */
}


/* ── 07 · Dashboard: Generator Form ────────────────────────── */

.dashboard-generator {
  max-width: 480px;
}

.dashboard-generator .view-subtext {
  margin-bottom: 24px;
}



/* Each field row — label + input */
.app-artifact-input {
  margin-bottom: 16px;
}

/* Field label */
.app-artifact-input-label {
  display: block;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

/* Painted input with monospace font */
.app-input-clean {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  outline: none;
  background: var(--fix-bg);
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
  padding: 6px 14px;
}

.app-input-clean::placeholder {
  color: #9CA3AF;
  font-size: 13px;
}

.app-input-clean:focus {
  border-color: var(--purple);
}


/* ── 08 · Action Buttons ────────────────────────────────────── */

/* Row that holds Audit + View Report */
.generator-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

/* Primary CTA — solid purple */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease;
}

.btn-action:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.btn-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Secondary — purple ghost, always visible, faded until ready */
.btn-action--ghost {
  background: var(--purple);
  border: none;
  color: #fff;
  opacity: 0.4;
  pointer-events: none;
}

/*
 * JS agent note: add class 'is-ready' to #btnViewReport
 * instead of using display:none/block, to enable this transition.
 */
.btn-action--ghost.is-ready {
  opacity: 1;
  pointer-events: auto;
}

.btn-action--ghost.is-ready:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

/* Generator status / error — uses .error-msg from global.css */
#generatorStatus {
  margin-top: 12px;
}


/* ── 09 · Dashboard: History Table ─────────────────────────── */

.history-section {
  margin-top: 64px;
}

/* Header row: heading left, bulk actions right */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* Loading and empty states */
#historyLoadingState,
#historyEmptyState {
  padding: 40px 0;
  text-align: center;
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray);
}

/* Scroll container — scrollbar fully hidden */
.history-scroll-wrap {
  max-height: 520px;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.history-scroll-wrap::-webkit-scrollbar {
  display: none;
}

/* Table header: pink fill + Jakarta font (overrides global.css defaults) */
#historyTable thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--fix-bg);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* Table body: mono font for data rows */
#historyTable tbody {
  font-family: var(--mono);
  font-size: 13px;
}

#historyTable tbody tr:hover {
  background: rgba(107, 33, 168, 0.025);
}

/* Column widths — table-layout: fixed (set in global.css .data-table) */
#historyTable .col-check  { width: 40px; }
#historyTable .col-term   { width: 35%; }
#historyTable .col-url    { width: 35%; }
#historyTable .col-score  { width: 72px; }
#historyTable .col-date   { width: 110px; }
#historyTable .col-action { width: 72px; text-align: center; }

/* Checkbox styling */
#historyTable input[type="checkbox"],
#selectAllCheckbox {
  accent-color: var(--purple);
  cursor: pointer;
  width: 15px;
  height: 15px;
  vertical-align: middle;
  margin: 0;
}

/*
 * View button inside each tbody row.
 * JS agent: apply class 'btn-table-view' to the view button it renders.
 */
.btn-table-view {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--purple);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}

.btn-table-view:hover {
  text-decoration: underline;
}


/* ── 10 · Bulk Actions ──────────────────────────────────────── */

/* Opacity is controlled via inline style by JS (#bulkActions) */
.bulk-actions {
  display: flex;
  gap: 10px;
  transition: opacity 0.2s;
}

/* Base ghost button */
.btn-bulk {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 4px;
  background: transparent;
  border: 1px solid;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-bulk:hover {
  opacity: 0.75;
}

.btn-bulk--green {
  background: var(--green-action);
  color: #fff;
  border: none;
}

.btn-bulk--red {
  background: var(--red-action);
  color: #fff;
  border: none;
}


/* ── 11 · Billing View ──────────────────────────────────────── */
/*
 * Reused — no new CSS needed for:
 *   .view-heading, .view-subtext (§05)
 *   .error-msg, .hidden (global)
 *   .btn-action (§08)
 *   .score-number, .score-bar-track, .score-bar-fill (global)
 *   .data-table, .table-caption (global)
 * Only layout and value-display rules live below.
 */

/* ══════════════════════════════════════════════
   BILLING — AUDIT STATS STRIP
   Four read-only numbers above the cards.
   Flex row → stacks vertically below 720px.
══════════════════════════════════════════════ */

.billing-stats-strip {
  display: flex;
  max-width: 1000px;
  margin-top: 32px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--fix-bg);
  overflow: hidden; /* keeps border-radius crisp on children */
}

.billing-stat-slot {
  flex: 1;
  padding: 20px 24px;
  border-right: 1px solid var(--border);
}

.billing-stat-slot:last-child {
  border-right: none;
}

.billing-stat-label {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray);
  margin: 0 0 8px 0;
}

.billing-stat-number {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
  margin: 0;
}


/* ══════════════════════════════════════════════
   BILLING — CARDS GRID
   Two equal cards. CSS Grid handles equal height
   so no height hacks are needed.
══════════════════════════════════════════════ */

.billing-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 1000px;
  margin-bottom: 64px;
}

/* Each card is a flex column so margin-top: auto
   on .billing-action-row legitimately pushes the
   CTA to the card bottom — grid provides equal height. */
.billing-card {
  display: flex;
  flex-direction: column;
  background: var(--fix-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 32px 24px;
}

/* Black uppercase badge label */
.billing-pill-label {
  align-self: flex-start;
  display: inline-flex;
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 24px;
}


/* ── Subscription Card ── */

/* "● Active" / "● Inactive" line */
.billing-status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

@keyframes pulse-dot {
  0% { opacity: 1; }
  50% { opacity: 0.4; }
  100% { opacity: 1; }
}

/* Small status indicator dot.
   Default: inactive (red).
   JS adds .is-active for green (subscribed). */
.billing-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #dc2626;
  animation: pulse-dot 2s infinite ease-in-out;
}

.billing-status-dot.is-active {
  background: #16a34a;
}

/* Renewal date or subscribe prompt.
   Also used for packs descriptive copy. */
.billing-renewal-text {
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray);
  line-height: 1.6;
  margin: 0 0 20px 0;
}

/* Price display — $19/month */
.billing-price-line {
  font-family: var(--font-headings);
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 4px;
}

.billing-price-unit {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  color: var(--gray);
}

/* Small grey note line, reused across both cards */
.billing-card-hint {
  font-family: var(--font);
  font-size: 13px;
  color: var(--gray);
  margin: 0;
}

/* CTA wrapper — pushed to card bottom via margin-top: auto */
.billing-action-row {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}


/* ── Rollover Packs Card ── */

/* "$10 for 25 audits" heading */
.billing-pack-pricing {
  font-family: var(--font-headings);
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 4px;
}

.billing-pack-pricing span {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  color: var(--gray);
}

/* "Packs [input]" row */
.billing-pack-qty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  margin-bottom: 6px;
}

/* Quantity input — uses design system vars, no hardcoded colours */
.billing-pack-input {
  width: 52px;
  padding: 5px 8px;
  font-family: var(--mono);
  font-size: 14px;
  text-align: center;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease;
}

.billing-pack-input:focus {
  border-color: var(--purple);
}

/* Dynamic helper text updated by JS as qty changes */
.billing-pack-price-text {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--gray);
  margin: 0;
}


/* ══════════════════════════════════════════════
   BILLING — TRANSACTION HISTORY TABLE
══════════════════════════════════════════════ */

.billing-tx-section {
  margin-bottom: 48px;
  max-width: 840px;
}

.billing-tx-section .view-heading {
  margin-bottom: 16px;
}

/* overflow-x: auto ensures horizontal scroll
   on narrow screens instead of content clipping */
.billing-tx-wrap {
  max-height: 320px;
  overflow-y: auto;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.billing-tx-wrap::-webkit-scrollbar {
  display: none;
}

/* min-width prevents column crush below ~480px */
#billingTxTable {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

#billingTxTable thead th {
  background: var(--fix-bg);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding: 12px 16px;
  text-align: left;
}

#billingTxTable tbody {
  font-family: var(--mono);
  font-size: 13px;
}

#billingTxTable tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

#billingTxTable tbody tr:hover {
  background: rgba(107, 33, 168, 0.025);
}

#billingTxTable .billing-tx-empty {
  text-align: center;
  color: var(--gray);
  padding: 40px 0 !important;
}


/* ══════════════════════════════════════════════
   BILLING — POLICY SECTION
══════════════════════════════════════════════ */

.billing-policy-section {
  margin-top: 48px;
}

.billing-policy-list {
  margin-left: 20px;
  color: var(--text);
  font-size: 14px;
  padding-left: 0;
}

.billing-policy-list li {
  margin-bottom: 12px;
  line-height: 1.6;
}


/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */

/* ── 720px: tablet and below ── */
@media (max-width: 720px) {

  /* Strip stacks vertically — dividers swap from right to bottom */
  .billing-stats-strip {
    flex-direction: column;
  }

  .billing-stat-slot {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
  }

  .billing-stat-slot:last-child {
    border-bottom: none;
  }

  /* Cards stack into a single column */
  .billing-overview {
    grid-template-columns: 1fr;
  }

}

/* ── 480px: mobile ── */
@media (max-width: 480px) {

  .billing-stats-strip {
    margin-top: 24px;
  }

  .billing-stat-slot {
    padding: 14px 16px;
  }

  .billing-stat-number {
    font-size: 20px;
  }

  .billing-card {
    padding: 24px 16px;
  }

}

.billing-policy-list li:last-child {
  margin-bottom: 0;
}


/* ── 12 · Report View ───────────────────────────────────────── */
/* Full-width under navbar, outside the sidebar layout shell.   */
/* Inner layout uses .layout, .toc, .main-content from global.  */

/* Container taking 0 height to hold the floating sticky back button */
.report-floating-actions {
  position: sticky;
  top: calc(var(--nav-h) + 24px);
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  height: 0; 
  z-index: 50;
  pointer-events: none;
  padding: 0 40px; /* Match main layout padding */
}



/* Ensure sticky sidebar correctly offsets the navbar in the dashboard */
#viewReport .toc {
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
}


/* ── 13 · Dialogs ───────────────────────────────────────────── */
/* Both dialogs share this base. No white, no shadow — flat.    */

dialog {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 28px;
  box-shadow: none;
  max-width: 400px;
  width: calc(100% - 32px);
  font-family: var(--font);
  /* Fallback centering */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}

/* Noticeable dark overlay behind the dialog */
dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog-heading {
  font-family: var(--font-headings);
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 10px;
}

.dialog-body {
  font-size: 15px;
  color: var(--gray);
  margin-bottom: 24px;
}

.dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Shared button base for dialog buttons */
.btn-dialog-cancel,
.btn-dialog-danger,
.btn-dialog-primary,
.btn-dialog-success {
  font-family: var(--font);
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-dialog-cancel {
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--gray);
}

.btn-dialog-danger {
  font-weight: 600;
  background: var(--red-action);
  border: none;
  color: #fff;
}

.btn-dialog-success {
  font-weight: 600;
  background: var(--green-action);
  border: none;
  color: #fff;
}



/* Override global.css input-group background inside dialogs */
dialog .input-group {
  margin-bottom: 0;
}

dialog .input-group input {
  background: var(--bg);
  font-size: 15px;
}


/* ── 14 · Toast ─────────────────────────────────────────────── */
/* JS controls visibility — this sets the visual only.          */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 4px;
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
}

.toast.show {
  opacity: 1;
}


/* ── 15 · Unauthenticated Screen ────────────────────────────── */
/* .input-screen base is in global.css. These are overrides.    */

/* "node" span inside the h1 inherits purple from global.css;
   this corrects "node" back to dark text. */
.input-screen .logo-node {
  color: var(--text);
}

.input-screen {
  min-height: calc(100vh - var(--nav-h));
}

#unauthSignInMount {
  margin-top: 24px;
  width: 100%;
  display: flex;
  justify-content: center;
}
