/* ============================================================
   Invoice Viewer — Styles

   Design philosophy: refined document aesthetic.
   - Editorial serif (Newsreader) for the rendered invoice content
     so it reads like a real document.
   - Modern sans (DM Sans) for the UI chrome.
   - Monospace (JetBrains Mono) for IDs, codes, and amounts.
   - Warm cream + deep ink + a single confident accent (forest green).
   ============================================================ */

:root {
  /* Color palette */
  --bg-page: #FBFAF7;            /* warm cream — like good paper */
  --bg-elevated: #FFFFFF;        /* document surface */
  --bg-subtle: #F4F1EA;          /* hover, soft section bg */
  --bg-tint: #ECE7DC;            /* very soft accent backgrounds */

  --ink-strong: #161513;         /* deep ink for body text */
  --ink-medium: #4A4641;         /* secondary text, labels */
  --ink-soft: #837E76;           /* meta, hints */
  --ink-faint: #B8B2A7;          /* dividers, disabled */

  --accent: #1B4D43;             /* deep forest — verification, trust */
  --accent-hover: #143A33;
  --accent-soft: #E8EFEC;        /* accent-tinted backgrounds */

  --danger: #8B2E2E;
  --danger-soft: #F5E8E5;

  --border: #E5E2DC;             /* primary border */
  --border-strong: #D6D1C6;      /* emphasized border */

  /* Typography
     Poppins is used everywhere (matches the verifical.com site font).
     --font-serif is kept as an alias for backward-compat with existing
     rules; both resolve to Poppins now. */
  --font-sans: "Poppins", system-ui, -apple-system, sans-serif;
  --font-serif: "Poppins", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;

  /* Scale */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(22, 21, 19, 0.04);
  --shadow-md: 0 4px 16px rgba(22, 21, 19, 0.06);
  --shadow-lg: 0 8px 32px rgba(22, 21, 19, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--ink-strong);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ============================================================
   INPUT VIEW
   ============================================================ */

.input-header {
  text-align: center;
  margin-bottom: 40px;
}

.input-header h1 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  color: var(--ink-strong);
}

.subtitle {
  font-size: 1.0625rem;
  color: var(--ink-medium);
  max-width: 560px;
  margin: 0 auto 24px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.tab {
  background: none;
  border: none;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab:hover {
  color: var(--ink-strong);
}

.tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Drop zone */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  background: var(--bg-elevated);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  text-align: center;
}

.drop-zone:hover,
.drop-zone--active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-icon {
  width: 48px;
  height: 48px;
  color: var(--ink-soft);
  margin-bottom: 16px;
  transition: color 0.2s ease;
}

.drop-zone:hover .upload-icon,
.drop-zone--active .upload-icon {
  color: var(--accent);
}

.drop-zone-text {
  font-size: 1.0625rem;
  font-weight: 500;
  margin: 0 0 4px;
  color: var(--ink-strong);
}

.drop-zone-hint {
  font-size: 0.875rem;
  color: var(--ink-soft);
  margin: 0;
}

/* Paste area */
.paste-area {
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--ink-strong);
  resize: vertical;
  min-height: 240px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.paste-area:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.paste-area + .btn {
  margin-top: 12px;
}

/* Samples */
.samples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.samples-label {
  margin-right: 4px;
}

.sample-link {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--ink-medium);
  cursor: pointer;
  transition: all 0.15s ease;
}

.sample-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Error banner */
.error-banner {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  color: var(--danger);
  font-size: 0.9375rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn--primary {
  background: var(--accent);
  color: white;
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-medium);
  border-color: var(--border);
}

.btn--ghost:hover {
  background: var(--bg-subtle);
  color: var(--ink-strong);
  border-color: var(--border-strong);
}

/* ============================================================
   INVOICE VIEW
   ============================================================ */

.invoice-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.format-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
}

/* The rendered invoice "document" */
.invoice-doc {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 56px 56px 48px;
  font-family: var(--font-serif);
  color: var(--ink-strong);
  box-shadow: var(--shadow-md);
}

@media (max-width: 640px) {
  .invoice-doc {
    padding: 32px 24px 28px;
  }
}

.invoice-doc h2 {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-medium);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Document header (number + dates) */
.doc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--ink-strong);
  flex-wrap: wrap;
}

.doc-title {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.doc-number {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--ink-medium);
  margin: 0;
}

.doc-dates {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  text-align: right;
  color: var(--ink-medium);
  min-width: 200px;
}

.doc-dates dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 16px;
  justify-content: end;
}

.doc-dates dt {
  color: var(--ink-soft);
  font-weight: 400;
}

.doc-dates dd {
  margin: 0;
  font-weight: 500;
  color: var(--ink-strong);
}

/* Parties grid (supplier + customer) */
.parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 40px;
}

@media (max-width: 640px) {
  .parties {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

.party {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.party-name {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink-strong);
  margin: 0 0 6px;
}

.party-address {
  color: var(--ink-medium);
  margin: 0 0 8px;
  white-space: pre-line;
}

.party-ids {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-medium);
  margin: 0;
}

.party-ids div {
  margin-bottom: 2px;
}

.party-ids .label {
  color: var(--ink-soft);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 6px;
}

.party-contact {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--ink-medium);
  margin-top: 8px;
}

/* Section heading inside the doc */
.doc-section {
  margin-bottom: 32px;
}

.doc-section:last-child {
  margin-bottom: 0;
}

/* Line items table */
.lines-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
}

.lines-table thead th {
  text-align: left;
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-strong);
}

.lines-table tbody td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.lines-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lines-table .description {
  width: 100%;
}

/* Totals */
.totals {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

.totals-table {
  min-width: 320px;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
}

.totals-table .row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 6px 0;
}

.totals-table .label {
  color: var(--ink-medium);
}

.totals-table .value {
  font-variant-numeric: tabular-nums;
  color: var(--ink-strong);
  font-weight: 500;
}

.totals-table .vat-breakdown {
  font-size: 0.8125rem;
  color: var(--ink-soft);
  padding-top: 4px;
  padding-bottom: 4px;
}

.totals-table .grand-total {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 2px solid var(--ink-strong);
  font-family: var(--font-serif);
  font-size: 1.375rem;
  font-weight: 600;
}

.totals-table .grand-total .value {
  font-family: var(--font-serif);
}

/* Payment block */
.payment-block {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
}

.payment-block dl {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 6px 16px;
  margin: 0;
}

.payment-block dt {
  color: var(--ink-soft);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 2px;
}

.payment-block dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--ink-strong);
}

.payment-block dd.text {
  font-family: var(--font-sans);
}

@media (max-width: 640px) {
  .payment-block dl {
    grid-template-columns: 1fr;
    gap: 0 0;
  }
  .payment-block dt {
    margin-top: 8px;
  }
  .payment-block dd {
    margin-bottom: 4px;
  }
}

/* Attachments list */
.attachments-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: var(--font-sans);
}

.attachments-list li {
  padding: 8px 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 0.875rem;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.attachments-list .filename {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-strong);
}

.attachments-list .mimetype {
  color: var(--ink-soft);
  font-size: 0.75rem;
}

/* Expandable: technical details + raw XML */
.expandable {
  margin-top: 24px;
  font-family: var(--font-sans);
}

.expandable summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--ink-soft);
  padding: 6px 0;
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.expandable summary::-webkit-details-marker {
  display: none;
}

.expandable summary::before {
  content: "+";
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.expandable[open] summary::before {
  content: "−";
}

.expandable summary:hover {
  color: var(--ink-strong);
}

.expandable-content {
  margin-top: 8px;
  padding: 16px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-medium);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow: auto;
}

.tech-details {
  font-size: 0.8125rem;
  font-family: var(--font-mono);
}

.tech-details div {
  padding: 4px 0;
  display: flex;
  gap: 12px;
}

.tech-details .key {
  color: var(--ink-soft);
  min-width: 140px;
}

.tech-details .val {
  color: var(--ink-medium);
}

/* CTA card */
.cta-card {
  margin-top: 40px;
  padding: 32px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: white;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.cta-content h3 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.cta-content p {
  margin: 0;
  font-size: 0.9375rem;
  opacity: 0.9;
  max-width: 480px;
}

.cta-card .btn--primary {
  background: white;
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
}

.cta-card .btn--primary:hover {
  background: var(--bg-page);
}

/* ============================================================
   EMBED MODE
   When loaded via iframe with ?embed=true, the page-level title
   and subtitle are hidden because the WordPress page provides them.
   Top and bottom padding is tightened since the WordPress page
   already supplies its own surrounding spacing.
   ============================================================ */

.embed-mode .input-header {
  display: none;
}

.embed-mode .app {
  padding-top: 16px;
  padding-bottom: 24px;
}

/* ============================================================
   PRINT STYLES
   When printing, strip everything that isn't the invoice itself.
   ============================================================ */

@media print {
  body {
    background: white;
  }

  .app {
    max-width: none;
    padding: 0;
  }

  .no-print {
    display: none !important;
  }

  .invoice-doc {
    border: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
  }

  .expandable {
    display: none;
  }
}

/* ============================================================
   RESPONSIVE TWEAKS
   ============================================================ */

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

  .drop-zone {
    padding: 40px 20px;
  }

  .doc-header {
    flex-direction: column;
  }

  .doc-dates {
    text-align: left;
  }

  .doc-dates dl {
    justify-content: start;
  }
}
