/* invoice generator: the form on one side and the preview on the other */
.ig { --ig-ink: #1c1c1c; --ig-muted: #6c757d; --ig-line: #e6e6e6; --ig-soft: #f8f9fa; --ig-accent: #ffc107; --ig-accent-soft: #fff6da; }
.ig { background: var(--ig-soft); padding: 72px 0 64px; }
.ig-hero { text-align: center; max-width: 720px; margin: 0 auto 32px; }
.ig-hero h1 { font-size: 3rem; color: var(--ig-ink); margin-bottom: 12px; }
.ig-hero p { font-size: 1.15rem; color: var(--ig-muted); margin: 0; }
.ig-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.ig-card { position: relative; background: #fff; border: 1px solid var(--ig-line); border-radius: 14px; padding: 20px 24px 24px; margin: 56px 0 16px; min-width: 0; }
.ig-card:first-of-type { margin-top: 38px; }
/* positioned so the title sits above the card, since a browser otherwise draws a fieldset's legend on its border */
.ig-card legend { position: absolute; bottom: 100%; left: 0; float: none; font-size: 1.2rem; color: var(--ig-ink); margin: 0 0 8px; padding: 0; width: auto; }
.ig-card .form-label { font-size: .875rem; margin-bottom: 4px; color: #444; }
.ig-subheading { font-size: 1rem; font-weight: 700; color: var(--ig-ink); margin: 24px 0 10px; }
.ig-help { color: var(--ig-muted); font-size: .9rem; }
.ig-help a { color: var(--ig-ink); }

.ig-templates { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.ig-template { cursor: pointer; text-align: center; font-size: .8rem; color: var(--ig-muted); margin: 0; }
.ig-template input { position: absolute; opacity: 0; width: 0; height: 0; }
.ig-template img { display: block; width: 100%; aspect-ratio: 1 / 1.3; object-fit: cover; object-position: top; border: 2px solid var(--ig-line); border-radius: 8px; margin-bottom: 4px; background: #fff; }
.ig-template:hover img { border-color: #bdbdbd; }
.ig-template input:checked + img { border-color: var(--ig-ink); box-shadow: 0 0 0 2px var(--ig-accent); }
.ig-template input:checked ~ span { color: var(--ig-ink); font-weight: 700; }
.ig-template input:focus-visible + img { outline: 2px solid var(--ig-ink); outline-offset: 2px; }

.ig-swatches { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.ig-swatch { cursor: pointer; margin: 0; line-height: 0; }
.ig-swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ig-swatch span { display: block; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--ig-line); }
.ig-swatch input:checked + span { box-shadow: 0 0 0 2px var(--ig-ink); }
.ig-swatch input:focus-visible + span { outline: 2px solid var(--ig-accent); outline-offset: 2px; }

.ig-lines-head, .ig-line { display: grid; grid-template-columns: minmax(0, 1fr) 84px 110px 68px; gap: 8px; align-items: center; }
.ig-lines-head { font-size: .875rem; color: #444; margin-bottom: 4px; }
.ig-line { margin-bottom: 8px; }
.ig-line-label { display: none; font-size: .875rem; color: #444; margin-bottom: 4px; }
.ig-remove { padding-left: 0; padding-right: 0; }

/* the column stretches to the form's height so the panel has room to stay in view. The preview is as tall as the invoice page, or shrinks to fit a shorter window */
.ig-side { min-width: 0; align-self: stretch; padding-top: 38px; } /* the same space as the title above the first card, so the preview lines up with that card */
.ig-sticky { position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.ig-preview { position: relative; background: #fff; border: 1px solid var(--ig-line); border-radius: 14px; overflow: hidden; flex: 0 1 auto; width: 100%; aspect-ratio: var(--ig-page-ratio, 210 / 297); min-height: 320px; }
.ig-preview iframe { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.ig-pages { position: absolute; inset: 0; overflow: hidden auto; background: #fff; scrollbar-width: thin; }
.ig-pages canvas { display: block; width: 100%; height: auto; }
.ig-pages canvas + canvas { border-top: 1px solid var(--ig-line); }
.ig-preview-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #fff; color: var(--ig-muted); padding: 24px; text-align: center; }
.ig-status { min-height: 1.3em; margin: 8px 0 0; font-size: .85rem; color: var(--ig-muted); }
.ig-error { background: #fdecea; border: 1px solid #f5c6c2; color: #842029; border-radius: 10px; padding: 10px 14px; margin-top: 8px; font-size: .9rem; }
.ig-error a { color: #842029; font-weight: 700; }
.ig-actions { display: flex; gap: 8px; margin-top: 10px; }
.ig-actions .btn { flex: 1; padding: 12px 16px; }
.ig-note { margin: 8px 0 0; font-size: .85rem; color: var(--ig-muted); }
.ig-note a { color: var(--ig-ink); }
.ig .ig-only-phone { display: none; }
.ig-form .ig-note { margin: 0 0 8px; }

.ig [hidden] { display: none !important; }
.ig .form-control.is-invalid, .ig .form-select.is-invalid { border-color: #dc3545; }
.ig-required::after { content: " *"; }

@media (max-width: 991.98px) {
    .ig { padding: 48px 0 24px; }
    .ig-hero h1 { font-size: 2.4rem; }
    .ig-layout { grid-template-columns: minmax(0, 1fr); }
    .ig-preview { display: none; }
    .ig .ig-only-phone { display: block; }
    .ig-side { position: sticky; bottom: 0; z-index: 10; margin: 0 -12px; padding-top: 0; }
    .ig-sticky { position: static; max-height: none; display: block; background: #fff; border-top: 1px solid var(--ig-line); padding: 8px 16px 12px; box-shadow: 0 -6px 18px rgba(0, 0, 0, .06); }
    .ig-side .ig-status { display: none; }
    .ig-actions { margin-top: 0; }
    .ig-actions .btn { padding: 8px 10px; font-size: .95rem; }
    .ig-error { margin: 0 0 8px; }
    .ig-card { padding: 16px; }
}

@media (max-width: 575.98px) {
    .ig-templates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ig-lines-head { display: none; }
    .ig-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding-bottom: 8px; border-bottom: 1px solid var(--ig-line); }
    .ig-line > div:first-child { grid-column: 1 / -1; }
    .ig-line-label { display: block; }
    .ig-remove { grid-column: 1 / -1; text-align: left; }
}
