/* Free Invoice Generator — page-specific styles.
   Reuses brand tokens from assets/style.css (--accent, --bg-card, etc.).
   No new colors are introduced here. */

/* ── Page hero ───────────────────────────────────────────────────────── */
.tool-hero {
  background: linear-gradient(180deg, #0E3FA3 0%, #1550C4 100%);
  color: #fff;
  padding: 56px 0 40px;
}
.tool-hero .wrap { max-width: 1120px; }
.tool-hero h1 {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 14px;
  max-width: 720px;
}
.tool-hero p {
  font-size: 16.5px;
  color: rgba(255,255,255,0.85);
  max-width: 640px;
  margin: 0;
}

/* ── Tool layout: form + live preview ───────────────────────────────── */
.tool-section { padding: 48px 0 64px; }
.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.form-card {
  background: var(--bg-card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 2px 4px rgba(0,0,0,.04);
}
.form-card h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin: 0 0 14px;
}
.form-card fieldset {
  border: none;
  padding: 0;
  margin: 0 0 24px;
}
.form-card fieldset:last-child { margin-bottom: 0; }

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-card input[type="text"],
.form-card input[type="number"],
.form-card input[type="email"],
.form-card input[type="tel"],
.form-card input[type="date"],
.form-card select,
.form-card textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  padding: 9px 11px;
  box-sizing: border-box;
}
.form-card input:focus,
.form-card select:focus,
.form-card textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.form-card textarea { resize: vertical; min-height: 64px; }

.field-hint { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }

.logo-upload {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-preview {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px dashed var(--stroke);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
  color: var(--text-tertiary);
  font-size: 10px;
  text-align: center;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }

/* ── Line items ──────────────────────────────────────────────────────── */
.items-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.items-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-tertiary);
  text-align: left;
  padding: 0 6px 6px 0;
}
.items-table td { padding: 0 6px 8px 0; vertical-align: top; }
.items-table td:first-child { padding-left: 0; }
.items-table input { width: 100%; }
.items-table .col-qty { width: 62px; }
.items-table .col-price { width: 100px; }
.items-table .col-remove { width: 30px; }

.btn-remove-row {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 8px 4px;
}
.btn-remove-row:hover { color: #C0392B; }

.btn-add-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #EDF4FF;
  color: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn-add-row:hover { background: #E0EDFF; }

.btn-print {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 20px;
}
.btn-print:hover { background: var(--accent-hover); }

/* ── Invoice preview (the printable document) ───────────────────────── */
.preview-wrap { position: sticky; top: 20px; }

.invoice-paper {
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(14,26,51,0.10);
  padding: 40px;
  max-width: 720px;
  margin: 0 auto;
  color: #16243B;
}

.inv-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  border-bottom: 3px solid var(--accent);
  padding-bottom: 20px;
  margin-bottom: 24px;
}
.inv-issuer { display: flex; gap: 14px; align-items: flex-start; }
.inv-logo {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
}
.inv-issuer-name { font-size: 19px; font-weight: 800; margin: 0 0 4px; color: #16243B; }
.inv-issuer-meta { font-size: 12.5px; color: var(--text-secondary); white-space: pre-line; line-height: 1.5; }

.inv-title { text-align: right; flex-shrink: 0; }
.inv-title h2 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--accent-dark);
  text-transform: uppercase;
}
.inv-title .inv-no { font-size: 13px; color: var(--text-secondary); }

.inv-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 26px;
}
.inv-meta-block h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin: 0 0 6px;
}
.inv-meta-block .name { font-weight: 700; font-size: 14.5px; margin-bottom: 2px; }
.inv-meta-block .addr { font-size: 12.5px; color: var(--text-secondary); white-space: pre-line; line-height: 1.5; }
.inv-dates { text-align: right; font-size: 13px; }
.inv-dates div { margin-bottom: 4px; }
.inv-dates .lbl { color: var(--text-tertiary); margin-right: 6px; }

.inv-items {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 13.5px;
}
.inv-items thead th {
  text-align: left;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 8px 10px;
}
.inv-items thead th.num { text-align: right; }
.inv-items tbody td { padding: 9px 10px; border-bottom: 1px solid var(--stroke); }
.inv-items tbody td.num { text-align: right; white-space: nowrap; }

.inv-totals { display: flex; justify-content: flex-end; margin-bottom: 24px; }
.inv-totals-box { width: 260px; font-size: 14px; }
.inv-totals-row { display: flex; justify-content: space-between; padding: 6px 0; color: var(--text-secondary); }
.inv-totals-row.grand {
  border-top: 2px solid var(--accent);
  margin-top: 6px;
  padding-top: 10px;
  font-size: 17px;
  font-weight: 800;
  color: var(--accent-dark);
}

.inv-notes {
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: pre-line;
  border-top: 1px solid var(--stroke);
  padding-top: 16px;
  margin-bottom: 20px;
  line-height: 1.6;
}

.inv-watermark {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-tertiary);
  border-top: 1px dashed var(--stroke);
  padding-top: 14px;
}
.inv-watermark a { color: var(--accent); font-weight: 600; }

/* ── CTA below preview (never printed) ─────────────────────────────── */
.tool-cta {
  max-width: 720px;
  margin: 24px auto 0;
  background: #EDF4FF;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.tool-cta p { margin: 0; font-size: 14.5px; color: var(--text-secondary); max-width: 480px; }
.tool-cta .btn { flex-shrink: 0; }

/* ── Supporting SEO content ─────────────────────────────────────────── */
.tool-content { background: var(--bg-card); padding: 64px 0; }
.tool-content .wrap { max-width: 780px; }
.tool-content h2 { font-size: 24px; font-weight: 800; margin: 40px 0 14px; }
.tool-content h2:first-child { margin-top: 0; }
.tool-content h3 { font-size: 18px; font-weight: 700; margin: 24px 0 8px; }
.tool-content p { color: var(--text-secondary); font-size: 15.5px; line-height: 1.7; margin: 0 0 14px; }

.faq-item {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 4px 16px;
  margin-bottom: 10px;
  background: var(--bg-card);
}
.faq-item summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 0;
  color: var(--text-primary);
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: "+"; color: var(--accent); font-weight: 800; margin-right: 10px; }
.faq-item[open] summary::before { content: "\2212"; }
.faq-item p { padding-bottom: 14px; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 880px) {
  .tool-grid { grid-template-columns: 1fr; }
  .preview-wrap { position: static; }
  .invoice-paper { padding: 24px; }
  .inv-head { flex-direction: column; }
  .inv-title { text-align: left; }
  .inv-meta-grid { grid-template-columns: 1fr; gap: 14px; }
  .inv-dates { text-align: left; }
}
@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
  .tool-hero h1 { font-size: 28px; }
}

/* ── Print: only the invoice paper should ever come out of the printer ── */
@media print {
  header.nav, footer, .tool-hero, .form-card, .tool-cta, .tool-content,
  .print-hide {
    display: none !important;
  }
  body { background: #fff; margin: 0; }
  .tool-section { padding: 0; }
  .tool-grid { display: block; }
  .preview-wrap { position: static; }
  .invoice-paper {
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0;
    max-width: none;
    margin: 0;
  }
  @page { size: A4; margin: 16mm; }
}
