/* ===== Invoice Generator — scoped design tokens ===== */
.inv-app {
    --inv-bg: #f6f7fb;
    --inv-card-bg: #ffffff;
    --inv-soft: #f2f4f8;
    --inv-text: #14181f;
    --inv-muted: #6b7280;
    --inv-border: #e3e7ee;
    --inv-primary: #003d93;
    --inv-accent: #0d6efd;
    --inv-danger: #d92d20;
    --inv-shadow: 0 10px 30px rgba(16, 24, 40, .06);
    --inv-shadow-lg: 0 20px 50px rgba(16, 24, 40, .10);
    --inv-radius: 1.8rem;
    --inv-radius-sm: 1rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--inv-text);
    padding-bottom: 4rem;
}

.inv-app :focus-visible {
    outline: 3px solid var(--inv-accent);
    outline-offset: 2px;
    border-radius: .4rem;
}

.inv-app h1, .inv-app h2, .inv-app h3, .inv-app h4 {
    font-family: inherit;
}

.tool-heading .inv-btn-lg { margin-top: 1rem; }

/* Mirrors Bootstrap's own .container breakpoints (used by the navbar/footer)
   so the tool's edges line up with them at every viewport width, not just
   the very widest one. */
.inv-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 2rem 1.6rem 0;
    box-sizing: border-box;
}
@media (min-width: 576px)  { .inv-container { max-width: 54rem; } }
@media (min-width: 768px)  { .inv-container { max-width: 72rem; } }
@media (min-width: 992px)  { .inv-container { max-width: 96rem; } }
@media (min-width: 1200px) { .inv-container { max-width: 114rem; } }
@media (min-width: 1400px) { .inv-container { max-width: 132rem; } }

.inv-hint {
    font-size: 1.25rem;
    color: var(--inv-muted);
    margin: 1rem 0 0;
}

/* ===== Layout ===== */
.inv-form-col { display: flex; flex-direction: column; gap: 2rem; }

/* Business Information + Customer Information side by side in one row */
.inv-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: stretch;
}
@media (max-width: 820px) {
    .inv-two-col { grid-template-columns: 1fr; }
}

/* Business Information and Customer Information stretch to match each
   other's height; whichever card has less content lets its last field
   (the address) grow to fill the extra space instead of leaving a gap. */
.inv-two-col .inv-card { display: flex; flex-direction: column; min-height: 0; }
.inv-two-col .inv-form-grid { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.inv-two-col .inv-field-grow { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.inv-two-col .inv-field-grow textarea { flex: 1; min-height: 8rem; resize: none; }

/* ===== Cards ===== */
.inv-card {
    background: var(--inv-card-bg);
    border: 1px solid var(--inv-border);
    border-radius: var(--inv-radius);
    box-shadow: var(--inv-shadow);
    padding: 2.6rem;
    transition: box-shadow .2s ease;
}
.inv-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.8rem;
}
.inv-card-head h2 {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--inv-primary);
    margin: 0;
}

/* ===== Fields ===== */
.inv-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
    gap: 1.8rem 2rem;
}
.inv-field-full { grid-column: 1 / -1; }

/* Pairs two fields (e.g. Email + Phone) into one row within a full-width slot */
.inv-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.8rem 2rem; }
@media (max-width: 480px) { .inv-field-row { grid-template-columns: 1fr; } }

.inv-field label {
    display: block;
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: .6rem;
    color: var(--inv-text);
}
.inv-req { color: var(--inv-danger); }

.inv-field input[type="text"],
.inv-field input[type="email"],
.inv-field input[type="tel"],
.inv-field input[type="number"],
.inv-field input[type="date"],
.inv-field select,
.inv-field textarea {
    width: 100%;
    border: 1.5px solid var(--inv-border);
    border-radius: var(--inv-radius-sm);
    background: #fff;
    color: var(--inv-text);
    font-family: inherit;
    font-size: 1.5rem;
    padding: 1.1rem 1.3rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.inv-field textarea { resize: vertical; min-height: 6rem; }

.inv-field input:hover, .inv-field select:hover, .inv-field textarea:hover { border-color: #c7cee0; }
.inv-field input:focus, .inv-field select:focus, .inv-field textarea:focus {
    outline: none;
    border-color: var(--inv-accent);
    box-shadow: 0 0 0 4px rgba(13, 110, 253, .12);
}
.inv-field input.inv-invalid, .inv-field textarea.inv-invalid { border-color: var(--inv-danger); }

.inv-error { display: block; min-height: 1.6rem; color: var(--inv-danger); font-size: 1.2rem; margin-top: .4rem; grid-column: 1 / -1; }

.inv-input-with-btn { display: flex; gap: .8rem; }
.inv-input-with-btn input { flex: 1; }

.inv-link-btn {
    border: none; background: none; color: var(--inv-accent); font-size: 1.25rem; font-weight: 600;
    cursor: pointer; padding: .4rem 0; margin-top: .6rem;
}
.inv-link-btn:hover { text-decoration: underline; }

/* Logo upload */
.inv-logo-upload {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    border: 2px dashed var(--inv-border);
    border-radius: var(--inv-radius-sm);
    padding: 2rem;
    min-height: 8rem;
    text-align: center;
    background: var(--inv-soft);
    transition: border-color .15s ease, background .15s ease;
}
.inv-logo-upload:hover { border-color: var(--inv-accent); background: #eef4ff; }
.inv-logo-upload img { max-height: 6rem; max-width: 16rem; object-fit: contain; border-radius: .6rem; }
.inv-logo-upload span { font-size: 1.3rem; color: var(--inv-muted); }
.inv-logo-upload input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ===== Items table ===== */
.inv-table-wrap { overflow-x: auto; margin: 0 -.4rem; }
.inv-items-table { width: 100%; border-collapse: collapse; min-width: 66rem; }
.inv-items-table th {
    text-align: left; font-size: 1.15rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--inv-muted); padding: 1rem .6rem; border-bottom: 2px solid var(--inv-border);
}
.inv-items-table td { padding: .6rem; border-bottom: 1px solid var(--inv-border); vertical-align: middle; }
.inv-items-table input {
    width: 100%; border: 1.5px solid transparent; background: transparent; border-radius: .7rem;
    font-size: 1.4rem; padding: .8rem .7rem; font-family: inherit; color: var(--inv-text);
}
.inv-items-table input:hover { border-color: var(--inv-border); background: #fff; }
.inv-items-table input:focus {
    outline: none; border-color: var(--inv-accent); background: #fff; box-shadow: 0 0 0 3px rgba(13, 110, 253, .12);
}
.inv-items-table input.inv-invalid { border-color: var(--inv-danger); background: #fff; }
.inv-items-table .inv-item-desc { font-size: 1.2rem; margin-top: .2rem; color: var(--inv-muted); }
.inv-col-qty, .inv-col-tax, .inv-col-discount { width: 8.5rem; }
.inv-col-price, .inv-col-amount { width: 11rem; }
.inv-col-actions { width: 8rem; }
.inv-amount-cell { font-weight: 700; text-align: right; padding-right: 1.2rem !important; white-space: nowrap; }

.inv-row-actions { display: flex; gap: .3rem; }
.inv-btn-icon {
    width: 3rem; height: 3rem; padding: 0; display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.4rem; line-height: 1;
}

/* Mini totals */
.inv-mini-totals { background: var(--inv-soft); border-radius: var(--inv-radius-sm); padding: 1.8rem 2rem; margin-top: 2.2rem; }
.inv-mini-row { display: flex; flex-wrap: nowrap; align-items: baseline; justify-content: space-between; gap: 1.2rem; font-size: 1.4rem; padding: .5rem 0; color: var(--inv-muted); }
.inv-mini-row strong { color: var(--inv-text); font-weight: 600; }
.inv-mini-total { border-top: 1.5px solid var(--inv-border); margin-top: .6rem; padding-top: 1.1rem; font-size: 1.6rem; }
.inv-mini-total span { color: var(--inv-text); font-weight: 700; }
.inv-mini-total strong { color: var(--inv-primary); font-size: 1.9rem; }

/* ===== Buttons ===== */
.inv-btn {
    display: inline-flex; align-items: center; gap: .6rem;
    border: 1.5px solid var(--inv-border); background: #fff; color: var(--inv-text);
    font-family: inherit; font-size: 1.4rem; font-weight: 600;
    padding: 1.1rem 2rem; border-radius: 1.1rem; cursor: pointer;
    white-space: nowrap; transition: transform .12s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.inv-btn:hover { border-color: var(--inv-primary); color: var(--inv-primary); box-shadow: var(--inv-shadow); }
.inv-btn:active { transform: translateY(1px); }
.inv-btn:disabled { opacity: .6; cursor: wait; }
.inv-btn-primary { background: var(--inv-primary); border-color: var(--inv-primary); color: #fff; }
.inv-btn-primary:hover { color: #fff; opacity: .92; box-shadow: var(--inv-shadow-lg); }
.inv-btn-danger { color: var(--inv-danger); }
.inv-btn-danger:hover { border-color: var(--inv-danger); color: var(--inv-danger); }
.inv-btn-lg { font-size: 1.6rem; padding: 1.4rem 2.8rem; border-radius: 1.3rem; }

/* ===== Action bar ===== */
.inv-actionbar {
    display: flex; flex-wrap: wrap; gap: 1.2rem;
    background: var(--inv-card-bg); border: 1px solid var(--inv-border); border-radius: var(--inv-radius);
    box-shadow: var(--inv-shadow); padding: 2rem 2.2rem; margin: 2.4rem 0 0;
}

@media (max-width: 900px) {
    .inv-actionbar {
        position: sticky; bottom: 0; z-index: 40; margin: 1.6rem -1.6rem 0;
        border-radius: 0; flex-wrap: nowrap; overflow-x: auto; padding: 1.2rem 1.6rem;
        box-shadow: 0 -8px 24px rgba(16, 24, 40, .12);
    }
}

/* ===== Preview modal ===== */
.inv-modal-backdrop {
    position: fixed; inset: 0; background: rgba(16, 24, 40, .55); align-items: flex-start;
    justify-content: center; padding: 3rem 1.6rem; overflow-y: auto; z-index: 300;
}
/* [hidden] must win while closed; only lay out as flex once the attribute is removed. */
.inv-modal-backdrop:not([hidden]) { display: flex; }
.inv-modal {
    background: #fff; border-radius: var(--inv-radius); padding: 2rem; max-width: 80rem; width: 100%;
    box-shadow: var(--inv-shadow-lg); margin-top: 4rem;
}
.inv-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.6rem; }
.inv-modal-head h2 { font-size: 2rem; color: var(--inv-primary); margin: 0; }

/* ===== Invoice preview surface (rendered inside the modal) =====
   Colors below are hardcoded (not var(--inv-*)) on purpose: this subtree is
   captured by html2canvas for the PDF export, which clones only this element
   — custom properties defined up on .inv-app would not resolve in that clone. */
.inv-preview-surface {
    position: relative;
    background-color: #fff;
    border: 1px solid #e3e7ee; border-radius: 1rem; padding: 3.2rem;
}
.inv-doc-empty { color: #6b7280; font-size: 1.3rem; text-align: center; padding: 4rem 1rem; }

/* TechGeekBuzz watermark — real DOM nodes (regenerated with the rest of the
   preview HTML on every render, see invoicegenerator.js), each individually
   positioned with plain top/left percentages. Generated content (::before/
   ::after), SVG background-images, and negative-inset/flex-wrap tiling all
   render unreliably under html2canvas, which draws this surface into the
   exported PDF — plain absolutely-positioned child elements are the one
   technique that survives that capture intact. */
.inv-watermark span {
    position: absolute; z-index: 5; pointer-events: none;
    font-size: 3.6rem; font-weight: 800; color: rgba(0, 61, 147, 0.1); white-space: nowrap;
    transform: rotate(-30deg);
}

/* ===== Injected invoice document ===== */
.inv-doc {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-size: 1.35rem; line-height: 1.55; color: #1a1d24;
}
.inv-doc-topbar { height: .6rem; border-radius: 99px; background: #003d93; margin-bottom: 2rem; }
.inv-doc-header { display: flex; justify-content: space-between; gap: 2rem; align-items: flex-start; margin-bottom: 2.4rem; flex-wrap: wrap; }
.inv-doc-logo img { max-height: 5.6rem; max-width: 18rem; object-fit: contain; margin-bottom: .8rem; }
.inv-doc-biz-name { font-size: 1.9rem; font-weight: 800; color: #003d93; margin-bottom: .3rem; }
.inv-doc-biz-meta, .inv-doc-cust-meta { font-size: 1.2rem; color: #555; white-space: pre-line; }
.inv-doc-title-block { text-align: right; }
.inv-doc-title { font-size: 2.6rem; font-weight: 800; letter-spacing: .04em; color: #003d93; text-transform: uppercase; }
.inv-doc-meta-row { display: flex; justify-content: flex-end; gap: .8rem; font-size: 1.2rem; color: #555; }
.inv-doc-meta-row b { color: #1a1d24; }
.inv-doc-status {
    display: inline-block; font-size: 1.1rem; font-weight: 700; padding: .4rem 1.1rem; border-radius: 99px;
    background: #f2f4f8; color: #6b7280; margin-top: .6rem;
}

.inv-doc-parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 2rem; margin: 2.2rem 0; }
.inv-doc-party h4 { font-size: 1.1rem; text-transform: uppercase; letter-spacing: .06em; color: #6b7280; margin-bottom: .5rem; }
.inv-doc-party-name { font-weight: 700; font-size: 1.4rem; }

.inv-doc-table { width: 100%; border-collapse: collapse; margin: 1.6rem 0; font-size: 1.25rem; }
.inv-doc-table th {
    text-align: left; background: #f2f4f8; color: #444; font-size: 1.05rem; text-transform: uppercase;
    letter-spacing: .04em; padding: 1rem .8rem; border-bottom: 2px solid #e3e7ee;
}
.inv-doc-table td { padding: 1rem .8rem; border-bottom: 1px solid #e3e7ee; vertical-align: top; }
.inv-doc-table .num { text-align: right; white-space: nowrap; }
.inv-doc-item-desc { color: #666; font-size: 1.15rem; margin-top: .2rem; }

.inv-doc-totals { margin-left: auto; width: 100%; max-width: 30rem; margin-top: 1.6rem; }
.inv-doc-totals .inv-doc-total-row {
    display: flex; flex-wrap: nowrap; align-items: baseline; justify-content: space-between;
    gap: 1.2rem; padding: .55rem 0; font-size: 1.25rem; color: #444;
}
.inv-doc-totals .inv-doc-total-row.grand { border-top: 2px solid #003d93; margin-top: .6rem; padding-top: 1.1rem; font-size: 1.6rem; font-weight: 800; color: #14181f; }

.inv-doc-section { margin-top: 2rem; }
.inv-doc-section h4 { font-size: 1.1rem; text-transform: uppercase; letter-spacing: .06em; color: #6b7280; margin-bottom: .5rem; }
.inv-doc-section p { white-space: pre-line; font-size: 1.2rem; color: #444; }

.inv-doc-footer { margin-top: 3rem; padding-top: 1.6rem; border-top: 1px solid #e3e7ee; text-align: center; color: #6b7280; font-size: 1.15rem; }

/* ===== Toast ===== */
.inv-toast {
    position: fixed; left: 50%; bottom: 2.4rem; transform: translate(-50%, 2rem);
    background: #14181f; color: #fff; font-size: 1.3rem; font-weight: 600;
    padding: 1.2rem 2rem; border-radius: 1rem; box-shadow: var(--inv-shadow-lg);
    opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease; z-index: 200;
}
.inv-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== About (matches the site-wide prose width/type scale) ===== */
.inv-about {
    max-width: 95rem; margin: 3rem auto; padding: 0 1.5rem; text-align: center;
}
.inv-about h3 { font-size: 3rem; font-weight: 600; line-height: 1.4; color: #003e93; }
.inv-about p { font-size: 1.5rem; line-height: 1.5; letter-spacing: 1.2px; word-spacing: 2.2px; }

/* ===== FAQ accordion (matches the styling used on every other tool page) ===== */
.faq-headline { font-size: 4rem; font-weight: bold; text-align: center; }
.faqbutton { background-color: var(--inv-card-bg) !important; color: var(--inv-text) !important; }
.faqanswer { font-size: 1.8rem; line-height: 1.4; color: var(--inv-muted); letter-spacing: 0.6px; }
.accordion-header button { font-size: 2.1rem; margin-top: 0; }

/* ===== Related tools ===== */
.inv-related { width: 100%; max-width: 100%; margin: 4rem auto 0; padding: 0 1.6rem 2rem; box-sizing: border-box; }
@media (min-width: 576px)  { .inv-related { max-width: 54rem; } }
@media (min-width: 768px)  { .inv-related { max-width: 72rem; } }
@media (min-width: 992px)  { .inv-related { max-width: 96rem; } }
@media (min-width: 1200px) { .inv-related { max-width: 114rem; } }
@media (min-width: 1400px) { .inv-related { max-width: 132rem; } }
.inv-related h2 { font-size: 2.4rem; font-weight: 800; color: var(--inv-primary); margin-bottom: 1.8rem; }
.inv-related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 1.6rem; }
.inv-related-card {
    display: block; background: #fff; border: 1px solid var(--inv-border); border-radius: var(--inv-radius);
    padding: 2rem; text-decoration: none; color: inherit; box-shadow: var(--inv-shadow); transition: transform .15s ease, box-shadow .15s ease;
}
.inv-related-card:hover { transform: translateY(-3px); box-shadow: var(--inv-shadow-lg); }
.inv-related-card h3 { font-size: 1.6rem; color: var(--inv-primary); margin-bottom: .5rem; }
.inv-related-card p { font-size: 1.25rem; color: var(--inv-muted); margin: 0; }

/* ===== Print ===== */
@media print {
    body > header, body > footer, .header, footer, .navbar,
    .inv-hide-print, .tool-heading, .inv-container {
        display: none !important;
    }
    @page { size: A4; margin: 1.4cm; }
    body, .inv-app { background: #fff !important; padding: 0 !important; }

    /* Force the preview modal to print even if the user never opened it
       (e.g. hit browser Ctrl/Cmd+P directly). */
    .inv-modal-backdrop {
        display: block !important; position: static !important; background: none !important;
        padding: 0 !important; overflow: visible !important;
    }
    .inv-modal {
        box-shadow: none !important; padding: 0 !important; max-width: none !important; width: 100% !important;
    }
    .inv-preview-surface {
        box-shadow: none !important; border: none !important; padding: 0 !important; max-height: none !important; overflow: visible !important;
    }
    .inv-doc-table { page-break-inside: auto; }
    .inv-doc-table tr { page-break-inside: avoid; }
}

/* ===== Responsive ===== */
@media (max-width: 700px) {
    .inv-card { padding: 1.8rem; }
}
