/* ============================================================
   Renew Pilates — Invoice Generator
   Bundled fonts (offline) + editor UI + invoice/print design
   ============================================================ */

@import url("assets/fonts/fonts.css");

:root {
  /* Brand palette (sampled from the original invoice) */
  --ink:        #435c64;   /* dark slate-teal: title, labels, body */
  --ink-strong: #33474e;   /* bolder ink: TOTAL, bank details */
  --bar:        #7aa3b2;   /* muted blue-teal bars */
  --bar-text:   #ffffff;
  --rule:       #cdd8db;   /* faint horizontal rules */
  --brand:      #7aa3b2;

  /* Editor chrome */
  --bg:      #eef1f2;
  --panel:   #ffffff;
  --line:    #dfe5e7;
  --muted:   #7c8a90;
  --danger:  #c0625a;

  --serif: "Cormorant Garamond", "Hoefler Text", Georgia, serif;
  --sans:  "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--sans);
  color: #2c3a3f;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------------- App shell ---------------- */
.app { display: flex; flex-direction: column; height: 100vh; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.toolbar .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; color: var(--ink); margin-right: auto;
}
.toolbar .brand img { height: 34px; width: auto; }
.toolbar .brand small { color: var(--muted); font-weight: 400; }

.workspace { flex: 1 1 auto; display: flex; min-height: 0; }

.form-pane {
  flex: 0 0 420px;
  overflow-y: auto;
  padding: 20px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.preview-pane {
  flex: 1 1 auto;
  overflow: auto;
  padding: 28px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: #dde3e5;
}

/* ---------------- Buttons & controls ---------------- */
button {
  font-family: var(--sans);
  font-size: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
}
button:hover { background: #f3f6f7; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: #6b96a5; }
button.ghost { border-color: transparent; background: transparent; }
button.danger { color: var(--danger); border-color: #e7c9c6; }
button.danger:hover { background: #fbf1f0; }
button.small { padding: 5px 10px; font-size: 13px; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--muted);
        text-transform: uppercase; letter-spacing: .04em; margin: 0 0 5px; }

.toolbar-import {
  display: inline-flex; align-items: center;
  font-family: var(--sans); font-size: 14px; font-weight: 400;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  transition: background .12s; text-transform: none; letter-spacing: 0; margin: 0;
}
.toolbar-import:hover { background: #f3f6f7; }

input[type=text], input[type=date], input[type=number], textarea, select {
  width: 100%;
  font-family: var(--sans);
  font-size: 14px;
  color: #2c3a3f;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid #bcd2d9; border-color: var(--brand); }
textarea { resize: vertical; min-height: 64px; line-height: 1.4; }

.field { margin-bottom: 16px; }
.row2 { display: flex; gap: 12px; }
.row2 > .field { flex: 1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400;
        text-transform: none; letter-spacing: 0; }

.section-title {
  font-size: 13px; font-weight: 700; color: var(--ink);
  text-transform: uppercase; letter-spacing: .06em;
  margin: 22px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.section-title:first-child { margin-top: 0; }

/* ---------------- Line items editor ---------------- */
.items-editor { display: flex; flex-direction: column; gap: 8px; }
.item-row { display: grid; grid-template-columns: 1fr 56px 80px 28px; gap: 8px; align-items: center; }
.item-row .col-head { font-size: 11px; color: var(--muted); font-weight: 600;
                      text-transform: uppercase; letter-spacing: .04em; }
.item-row input { padding: 7px 8px; }
.item-row .remove { border: none; background: transparent; color: var(--muted);
                    font-size: 18px; line-height: 1; padding: 2px; cursor: pointer; }
.item-row .remove:hover { color: var(--danger); }
#addItem { margin-top: 4px; align-self: flex-start; }

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(40,55,60,.45);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal h2 { margin: 0 0 4px; font-size: 20px; color: var(--ink); }
.modal .modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.logo-preview { display: flex; align-items: center; gap: 14px; }
.logo-preview img { height: 64px; width: 64px; object-fit: contain;
                    border: 1px solid var(--line); border-radius: 10px; padding: 4px; background:#fff; }

/* ---------------- History list ---------------- */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.history-item .h-main { flex: 1; }
.history-item .h-num { font-weight: 600; color: var(--ink); }
.history-item .h-meta { font-size: 12px; color: var(--muted); }
.history-item .h-total { font-weight: 600; color: var(--ink-strong); margin-right: 6px; }
.history-empty { color: var(--muted); text-align: center; padding: 24px; }

/* ============================================================
   THE INVOICE  (preview on screen + printed PDF)
   ============================================================ */
.invoice-scaler { /* JS sets transform scale for on-screen fit */
  transform-origin: top center;
}
.invoice {
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 24px rgba(0,0,0,.15);
}
.invoice .pad { padding: 20mm 16mm 0; }

/* Head */
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10mm; }
.inv-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 58px;
  letter-spacing: .14em;
  color: var(--ink);
  margin: 0 0 10px;
  line-height: 1;
}
.inv-meta { display: flex; gap: 34px; font-size: 13px; color: var(--ink); margin-bottom: 2px; }
.inv-number { font-size: 13px; color: var(--ink); margin-bottom: 14px; }
.inv-block { margin-bottom: 12px; }
.inv-block .label { font-size: 14px; color: var(--ink); margin-bottom: 2px; }
.inv-block .lines { font-size: 13px; line-height: 1.5; color: var(--ink); white-space: pre-line; }
.bill-to .lines { font-size: 15px; letter-spacing: .02em; }

.inv-logo { flex: 0 0 auto; }
.inv-logo img { width: 62mm; height: auto; display: block; }

/* Items table */
.items-wrap { margin-top: 6mm; flex: 1 1 auto; display: flex; flex-direction: column; }
table.items { width: 100%; border-collapse: collapse; }
table.items thead th {
  background: var(--bar);
  color: var(--bar-text);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: left;
  padding: 10px 16px;
}
table.items thead th.num { text-align: right; width: 26mm; }
table.items tbody td {
  font-size: 14px;
  color: var(--ink);
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
table.items tbody td.num { text-align: right; white-space: nowrap; }
table.items tbody tr:first-child td { padding-top: 22px; }

/* Totals + bank */
.totals-section {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10mm; margin-top: 8mm; padding: 0 0 12mm;
}
.bank { font-size: 15px; color: var(--ink-strong); line-height: 1.55; text-align: center;
        align-self: flex-end; padding-left: 6mm; }
.bank .bank-head { margin-bottom: 2px; }
.totals { width: 70mm; }
.totals .trow { display: flex; justify-content: space-between; font-size: 14px;
                color: var(--ink); padding: 6px 0; }
.totals .trow.subtotal { padding-bottom: 14px; }
.totals .trow.grand {
  border-top: 1px solid var(--rule); margin-top: 6px; padding-top: 14px;
  font-weight: 700; font-size: 18px; color: var(--ink-strong);
  font-family: var(--sans);
}

/* Footer bar */
.footer-bar {
  margin-top: auto;
  background: var(--bar);
  color: var(--bar-text);
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 16mm;
}
.footer-bar .thanks { font-family: var(--serif); font-size: 30px; font-weight: 500; letter-spacing: .02em; }
.footer-bar .contact { font-size: 12px; text-align: right; line-height: 1.6; opacity: .95; }

/* ---------------- Print ---------------- */
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff; height: auto; }
  .toolbar, .form-pane, .modal-backdrop { display: none !important; }
  .app, .workspace, .preview-pane { display: block; height: auto; overflow: visible; padding: 0; }
  .preview-pane { background: #fff; }
  .invoice-scaler { transform: none !important; }
  .invoice {
    box-shadow: none;
    width: 210mm;
    min-height: 297mm;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
