/* Colors/fonts come from assets/tokens.css (fieldstack-hub.trade-industrial,
   the Fieldstack suite-wide theme), motion from assets/motion.css -- edit
   the token/motion documents, not the values below. */

:root {
  color-scheme: light dark;
}

* {
  box-sizing: border-box;
}

/* .primary/.secondary below both set display:block at equal specificity to the
   browser's own [hidden] rule, and being declared later would otherwise win --
   an element toggled via .hidden = true (the paywall's downloadBtn) stayed
   visibly on screen despite the attribute being set. Force it explicitly. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--semantic-font-body);
  background: var(--semantic-surface-base);
  color: var(--semantic-text-default);
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

h1 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--semantic-font-heading);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--semantic-text-heading);
  margin-bottom: 0.5rem;
}

h1 img {
  width: 2rem;
  height: 2rem;
}

#status {
  color: var(--semantic-text-muted);
}

#status.ok {
  color: var(--semantic-status-success);
}

#status.error {
  color: var(--semantic-status-danger);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

th, td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--semantic-border-default);
}

th {
  font-family: var(--semantic-font-heading);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--semantic-text-heading);
}

td input,
td select {
  width: 100%;
  padding: 0.3rem;
  /* new token set (assets/tokens.css) has one border token, not a dedicated
     input-border component var -- semantic-border-default covers it. */
  border: 1px solid var(--semantic-border-default);
  border-radius: 4px;
  font: inherit;
}

td input:hover,
td input:focus,
td select:hover,
td select:focus {
  border-color: var(--semantic-accent-decorative);
}

td.lineAmount {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

td.lineAmount.credit {
  color: var(--semantic-status-danger);
}

.removeLine {
  border: none;
  background: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--semantic-status-danger);
}

#addLine {
  margin-top: 0.75rem;
  padding: 0.5rem 0.9rem;
  /* no dedicated secondary-button component tokens in the new token set --
     border/foreground fall back to the semantic border and default text. */
  border: 1px solid var(--semantic-border-default);
  border-radius: 6px;
  background: var(--component-card-background);
  color: var(--semantic-text-default);
  font-family: var(--semantic-font-body);
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms cubic-bezier(0.4, 0.0, 0.2, 1),
              filter 120ms cubic-bezier(0.4, 0.0, 0.2, 1),
              border-color 120ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

#addLine:hover {
  border-color: var(--semantic-accent-decorative);
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.rates {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.rates label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  color: var(--semantic-text-muted);
  gap: 0.25rem;
}

.rates input {
  padding: 0.4rem;
  border: 1px solid var(--semantic-border-default);
  border-radius: 4px;
  font: inherit;
  width: 8rem;
}

.rates input:hover,
.rates input:focus {
  border-color: var(--semantic-accent-decorative);
}

#summary {
  margin: 1.5rem 0 1rem;
}

#summary div {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  font-variant-numeric: tabular-nums;
}

#summary .total {
  border-top: 2px solid var(--semantic-text-heading);
  margin-top: 0.4rem;
  padding-top: 0.5rem;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--semantic-text-heading);
}

.card {
  background: var(--component-card-background);
  border: 1px solid var(--component-card-border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  font-family: var(--semantic-font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 0 0.75rem;
  color: var(--semantic-text-heading);
}

.card label {
  display: block;
  font-size: 0.85rem;
  color: var(--semantic-text-muted);
  margin-bottom: 0.75rem;
}

.card input[type="text"],
.card input[type="number"] {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.4rem;
  border: 1px solid var(--semantic-border-default);
  border-radius: 4px;
  font: inherit;
}

.card input[type="text"]:hover,
.card input[type="text"]:focus,
.card input[type="number"]:hover,
.card input[type="number"]:focus {
  border-color: var(--semantic-accent-decorative);
}

.branding {
  display: flex;
  flex-direction: column;
}

#logoPreview {
  max-width: 96px;
  max-height: 96px;
  margin: 0.5rem 0;
  border-radius: 4px;
}

#signaturePad {
  display: block;
  width: 100%;
  max-width: 360px;
  height: 140px;
  border: 1px dashed var(--semantic-border-default);
  border-radius: 6px;
  /* the pad needs a light, paper-like writing surface regardless of the
     app's dark theme -- the new token set has no dedicated "white" base, so
     bone-100 (its near-white) is the closest in-palette match. */
  background: var(--base-bone-100);
  touch-action: none;
  cursor: crosshair;
}

.primary {
  display: block;
  width: 100%;
  padding: 0.85rem;
  font-family: var(--semantic-font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  text-decoration: none;
  color: var(--component-button-primary-foreground);
  background: var(--component-button-primary-background);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-sizing: border-box;
  /* fieldstack-hub.trade-industrial motion, control.hover (state, 120ms,
     standard easing) -- a plain CSS transition rather than the generated
     assets/motion.css keyframe class, since hover is a continuous state that
     must reverse on pointer-leave, not a 1-shot trigger. The cta-press
     keyframe class is reserved for the actual download click (see script.js
     pulse()). Values match the motion library exactly. */
  transition: transform 120ms cubic-bezier(0.4, 0.0, 0.2, 1),
              filter 120ms cubic-bezier(0.4, 0.0, 0.2, 1),
              background 120ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.primary:hover {
  background: var(--component-button-primary-hover);
  transform: translateY(-2px);
  filter: brightness(1.08);
}

@media (prefers-reduced-motion: reduce) {
  .primary,
  #addLine,
  .secondary {
    transition: none;
  }
}

#pdfStatus.ok {
  color: var(--semantic-status-success);
}

#pdfStatus.error {
  color: var(--semantic-status-danger);
}

.hint {
  font-size: 0.85rem;
  color: var(--semantic-text-muted);
  margin: 0.5rem 0 0;
}

.paywall h2 {
  color: var(--semantic-text-heading);
}

.paywall p {
  color: var(--semantic-text-default);
  line-height: 1.5;
}

.secondary {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.6rem;
  font-family: var(--semantic-font-body);
  font-size: 0.9rem;
  /* no dedicated secondary-button component tokens in the new token set --
     border/foreground fall back to the semantic border and default text. */
  color: var(--semantic-text-default);
  background: transparent;
  border: 1px solid var(--semantic-border-default);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 120ms cubic-bezier(0.4, 0.0, 0.2, 1),
              filter 120ms cubic-bezier(0.4, 0.0, 0.2, 1),
              border-color 120ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.secondary:hover {
  border-color: var(--semantic-accent-decorative);
  transform: translateY(-2px);
  filter: brightness(1.08);
}
