/* Four Star POS — Free Invoice Generator: single editable-invoice document.
   The invoice IS the editor. Tailwind (CDN) covers the surrounding page; this
   file owns the printable document, the inline-edit affordances, and the
   export/print "clean" state that strips all editing chrome. */

/* ---- toolbar + stage (screen only) ---- */
.inv-btn { min-height: 46px; padding: 9px 18px; border-radius: 10px; font-size: 15px; font-weight: 600;
  border: 1px solid #cbd5e1; background: #fff; color: #334155; cursor: pointer; transition: all .15s; }
.inv-btn:hover { background: #f8fafc; }
.inv-btn-primary { border: 0; color: #0f172a; font-weight: 800; background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.inv-btn-primary:hover { opacity: .9; background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.inv-btn-ghost { background: #fff; }
.inv-btn-sm { min-height: 40px; padding: 7px 14px; font-size: 14px; }
.inv-btn-lg { min-height: 54px; padding: 12px 26px; font-size: 16px; }

/* top bar: document actions (left) + options (right) */
.inv-topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-bottom: 12px; }
.inv-doc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inv-options { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.inv-saved { font-size: 13px; color: #16a34a; }
.inv-hint { font-size: 14px; color: #64748b; margin-bottom: 14px; }

/* export card: sits after the invoice, where the user is done */
.inv-export { margin-top: 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 16px; padding: 18px 22px; background: #fff; border: 1px solid #e2e8f0; border-radius: 16px; }
.inv-export-title { font-weight: 800; font-size: 16px; color: #0f172a; }
.inv-export-sub { font-size: 13px; color: #64748b; margin-top: 2px; }
.inv-export-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.inv-file { display: none; }
.inv-stage { background: #e2e8f0; border-radius: 16px; padding: 22px; overflow-x: auto; }

/* settings row: currency + header colour */
.inv-settings { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; margin: 4px 0 12px; }
.inv-setting { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: #334155; }
.inv-setting select { min-height: 40px; padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; font-size: 14px; }
.inv-setting input[type=color] { width: 40px; height: 40px; padding: 0; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; cursor: pointer; }
.inv-swatches { display: inline-flex; gap: 6px; }
.inv-swatch { width: 24px; height: 24px; border-radius: 6px; border: 2px solid #fff; box-shadow: 0 0 0 1px #cbd5e1; cursor: pointer; padding: 0; }
.inv-swatch:hover { box-shadow: 0 0 0 2px #f59e0b; }

/* the static output node used for print (kept off-screen until printing) */
.inv-print-root { position: absolute; left: -99999px; top: 0; }

/* sticky mobile action bar (desktop: hidden; shown on phones while editing) */
.inv-mobilebar { display: none; }

/* ---- the paper ---- */
.invoice-paper { width: 820px; max-width: 100%; margin: 0 auto; background: #fff; border-radius: 6px;
  box-shadow: 0 10px 30px rgba(15,23,42,.12); }
/* Flex column + min-height so the contact footer sits at the bottom of the page
   when the invoice is short (true "footer" feel on screen). */
.ip { box-sizing: border-box; width: 100%; padding: 40px; color: #0f172a;
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, Arial, sans-serif; font-size: 15px; line-height: 1.6;
  display: flex; flex-direction: column; min-height: 980px; }
.ip * { box-sizing: border-box; }

/* header */
.ip-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 3px solid var(--ip-accent, #0f172a); padding-bottom: 20px; }
.ip-brand { display: flex; gap: 14px; align-items: flex-start; }
.ip-logo-btn { position: relative; padding: 0; border: 0; background: transparent; cursor: pointer; flex: 0 0 auto; }
.ip-logo { width: 68px; height: 68px; object-fit: contain; border-radius: 8px; display: block; }
.ip-logo-ph { display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 68px; height: 68px; border: 2px dashed #cbd5e1; border-radius: 8px; color: #64748b; font-size: 22px; line-height: 1; background: #f8fafc; }
.ip-logo-ph small { font-size: 9px; margin-top: 3px; }
.ip-logo-btn:hover .ip-logo-ph { border-color: #f59e0b; color: #d97706; }
.ip-logo-x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: #ef4444; color: #fff; font-size: 14px; line-height: 20px; text-align: center; opacity: 0; transition: opacity .15s; }
.ip-logo-btn:hover .ip-logo-x { opacity: 1; }
.ip-shop { font-size: 22px; font-weight: 800; color: #0f172a; margin-bottom: 4px; }
.ip-meta { font-size: 13px; color: #64748b; margin-bottom: 3px; }
.ip-title { text-align: right; }
.ip-doc { font-size: 28px; font-weight: 800; letter-spacing: 1px; color: #0f172a; }

/* parties */
.ip-parties { display: flex; justify-content: space-between; gap: 32px; margin: 22px 0; align-items: flex-start; }
.ip-billto { flex: 1; max-width: 320px; }
.ip-billto .ip-label { display: block; margin-bottom: 6px; }
.ip-metafields { flex: 0 0 auto; display: grid; grid-template-columns: auto 170px; gap: 10px 12px; align-items: center; }
.ip-metafields .ip-label { justify-self: end; }
.ip-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #64748b; }
.ip-strong, .ip-field-strong { font-weight: 700; }

/* items table */
.ip-items { width: 100%; border-collapse: collapse; margin-top: 6px; }
.ip-items th { background: var(--ip-accent, #0f172a); color: var(--ip-th-text, #fff); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; padding: 11px 12px; text-align: left; }
.ip-items th.ip-num { text-align: right; }
.ip-items td { padding: 9px 12px; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }
.ip-items .ip-num { text-align: right; white-space: nowrap; }
.ip-item .ip-desc { position: relative; }
.ip-del { position: absolute; left: -26px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px;
  border: 0; border-radius: 50%; background: #fee2e2; color: #ef4444; font-size: 14px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s; }
.ip-item:hover .ip-del, .ip-item:focus-within .ip-del { opacity: 1; }
.ip-additem { margin: 12px 0 0; border: 1px dashed #cbd5e1; background: #f8fafc; color: #b45309;
  font-size: 14px; font-weight: 700; padding: 10px 16px; border-radius: 8px; cursor: pointer; }
.ip-additem:hover { background: #fff7ed; border-color: #f59e0b; }

/* bottom */
.ip-bottom { display: flex; justify-content: space-between; gap: 24px; margin-top: 20px; }
.ip-notes { flex: 1; font-size: 13px; color: #475569; }
.ip-note-block { margin-bottom: 12px; }
.ip-totals { width: 320px; flex: 0 0 auto; border-collapse: collapse; }
.ip-totals td { padding: 7px 0; vertical-align: middle; }
.ip-totals td.ip-num { text-align: right; font-weight: 600; }
.ip-totals .ip-grand td { border-top: 2px solid var(--ip-accent, #0f172a); padding-top: 10px; font-size: 19px; font-weight: 800; color: #0f172a; }

/* footer */
.ip-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 34px; }
.ip-sign { min-width: 200px; }
.ip-sign-line { min-width: 180px; padding-top: 4px; }
.ip-thanks { font-size: 11px; color: #94a3b8; }

/* ---- editable-field affordances (persistent, so it reads as editable) ---- */
.ip-ce { outline: none; background: #f1f5f9; border: 1px dashed #cbd5e1; border-radius: 6px;
  padding: 4px 9px; min-height: 32px; min-width: 40px; cursor: text; display: inline-block;
  vertical-align: middle; transition: background .12s, border-color .12s; }
.ip-ce-multi { display: block; white-space: pre-wrap; min-height: 46px; width: 100%; }
.ip-ce:hover { background: #fff7ed; border-color: #f8c46b; }
.ip-ce:focus { background: #fff7ed; border-color: #f59e0b; border-style: solid; }
.ip-ce:empty:before { content: attr(data-ph); color: #94a3b8; pointer-events: none; }
.ip-shop .ip-ce { font-weight: 800; font-size: 22px; }

.ip-inp { font: inherit; color: inherit; text-align: right; border: 1px dashed #cbd5e1; background: #f1f5f9;
  border-radius: 6px; padding: 6px 9px; min-height: 34px; outline: none; transition: background .12s, border-color .12s;
  -moz-appearance: textfield; }
.ip-inp::-webkit-outer-spin-button, .ip-inp::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ip-inp:hover { background: #fff7ed; border-color: #f8c46b; }
.ip-inp:focus { background: #fff7ed; border-color: #f59e0b; border-style: solid; }
.ip-inp::placeholder { color: #94a3b8; }
.ip-inp-qty { width: 72px; }
.ip-inp-rate { width: 118px; }
.ip-inp-amt { width: 128px; }
.ip-inp-pct { width: 62px; text-align: center; }

.ip-select { font: inherit; color: inherit; border: 1px dashed #cbd5e1; background: #f1f5f9; cursor: pointer;
  border-radius: 6px; padding: 5px 8px; min-height: 32px; transition: background .12s, border-color .12s; }
.ip-select:hover { background: #fff7ed; border-color: #f8c46b; }
.ip-badge-select { margin-top: 8px; font-size: 12px; font-weight: 800; letter-spacing: 1px; padding: 6px 14px;
  border: 1px solid transparent; border-radius: 999px; cursor: pointer; text-transform: uppercase; }
.ip-badge-paid { background: #dcfce7; color: #166534; }
.ip-badge-unpaid { background: #fee2e2; color: #991b1b; }
.ip-badge-partial { background: #fef9c3; color: #854d0e; }

/* ---- consistent field metrics + aligned columns ---- */
.ip-ce, .ip-inp, .ip-select { min-height: 38px; border-radius: 8px; box-sizing: border-box; padding: 7px 11px; }
.ip-ce-multi { min-height: 44px; }
.ip-field { display: block; width: 100%; margin: 0 0 8px; }
.ip-seller { max-width: 320px; }
.ip-shop { margin-bottom: 8px; }
.ip-shop .ip-ce { font-size: 20px; }
.ip-seller .ip-field:last-child, .ip-billto .ip-field:last-child { margin-bottom: 0; }
.ip-metafields .ip-field { margin: 0; width: 100%; text-align: left; }

/* ---- searchable currency picker ---- */
.inv-setting-lbl { font-size: 14px; font-weight: 600; color: #334155; }
.inv-cur { position: relative; display: inline-block; }
.inv-cur-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px;
  border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; font-size: 14px; font-weight: 600; color: #334155; cursor: pointer; }
.inv-cur-btn:hover { background: #f8fafc; }
.inv-cur-caret { color: #94a3b8; }
.inv-cur-pop { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; width: 300px; max-width: 86vw;
  background: #fff; border: 1px solid #cbd5e1; border-radius: 12px; box-shadow: 0 12px 30px rgba(15,23,42,.16); padding: 8px; }
.inv-cur-search { width: 100%; box-sizing: border-box; min-height: 42px; padding: 9px 11px; border: 1px solid #cbd5e1;
  border-radius: 8px; font-size: 14px; outline: none; }
.inv-cur-search:focus { border-color: #f59e0b; box-shadow: 0 0 0 1px #f59e0b; }
.inv-cur-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 280px; overflow-y: auto; }
.inv-cur-opt { display: grid; grid-template-columns: 54px 46px 1fr; align-items: center; gap: 8px; padding: 9px 10px;
  border-radius: 8px; cursor: pointer; font-size: 14px; }
.inv-cur-opt:hover, .inv-cur-opt.is-active { background: #fff7ed; }
.inv-cur-opt[aria-selected="true"] { background: #f1f5f9; }
.inv-cur-code { font-weight: 700; color: #0f172a; }
.inv-cur-sym { color: #475569; }
.inv-cur-name { color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-cur-empty { padding: 12px; color: #94a3b8; font-size: 14px; }

/* ---- optional business-contact footer on the invoice ---- */
.ip-contact { margin-top: auto; padding-top: 14px; border-top: 1px dashed #e2e8f0; }
.ip-contact-lbl { display: block; margin-bottom: 8px; }
.ip-contact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.ip-contact-grid .ip-field { margin: 0; }

/* ---- mobile: let the invoice fill the phone width (no nested h-scroll) ---- */
@media (max-width: 640px) {
  .inv-stage { padding: 10px; overflow-x: visible; }
  .invoice-paper { width: 100%; box-shadow: 0 6px 18px rgba(15,23,42,.12); }
  .ip { padding: 18px; font-size: 13px; line-height: 1.5; }

  /* stack the two-column rows */
  .ip-top { flex-direction: column; gap: 14px; padding-bottom: 14px; }
  .ip-title { text-align: left; }
  .ip-parties { flex-direction: column; gap: 16px; margin: 16px 0; }
  .ip-seller, .ip-billto { max-width: none; }
  .ip-metafields { grid-template-columns: auto minmax(120px, 1fr); }
  .ip-bottom { flex-direction: column; gap: 16px; margin-top: 14px; }
  .ip-totals { width: 100%; }
  .ip-contact-grid { grid-template-columns: 1fr; }

  /* headings */
  .ip-shop, .ip-shop .ip-ce { font-size: 17px; }
  .ip-doc { font-size: 22px; }

  /* items table fits without horizontal scroll */
  .ip-items th, .ip-items td { padding: 7px 6px; font-size: 12px; }
  .ip-inp { padding: 6px 6px; }
  .ip-inp-qty { width: 42px; }
  .ip-inp-rate { width: 74px; }
  .ip-inp-amt { width: 100%; }

  /* delete control inline (was off the left edge on phones) */
  .ip-item .ip-desc { padding-left: 6px; }
  .ip-del { position: static; transform: none; opacity: 1; margin-top: 4px; }

  /* sticky bottom action bar */
  .inv-mobilebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: flex; align-items: center; gap: 12px; padding: 10px 14px;
    background: #fff; border-top: 1px solid #e2e8f0; box-shadow: 0 -4px 16px rgba(15,23,42,.12);
    transform: translateY(110%); visibility: hidden; transition: transform .2s ease, visibility .2s ease; }
  .inv-mobilebar.inv-mobilebar--show { transform: translateY(0); visibility: visible; }
  .inv-mb-label { font-size: 14px; color: #475569; white-space: nowrap; }
  .inv-mb-label b { font-size: 17px; color: #0f172a; }
  .inv-mb-btn { flex: 1; justify-content: center; }

  /* export card stacks full-width on phones */
  .inv-export { flex-direction: column; align-items: stretch; padding: 16px; }
  .inv-export-actions { flex-direction: column; }
  .inv-export-actions .inv-btn { width: 100%; text-align: center; }
}

/* ---- print: show only the static output node (.inv-print-root) ---- */
@media print {
  body { background: #fff !important; }
  body * { visibility: hidden !important; }
  .inv-print-root, .inv-print-root * { visibility: visible !important; }
  .inv-print-root { position: absolute; left: 0; top: 0; width: 100%; }
  .inv-print-root > .inv-doc { width: 100% !important; padding: 0 !important; }
  /* Repeating contact footer on every printed page */
  .inv-print-footer {
    position: fixed; left: 0; right: 0; bottom: 0;
    padding: 8px 12mm 10px; background: #fff;
    border-top: 1px solid #e2e8f0; text-align: center;
  }
  .inv-print-footer-inner {
    font-size: 11px; color: #64748b; line-height: 1.4;
  }
  @page { size: A4; margin: 12mm 12mm 18mm 12mm; }
}
