/**
 * Invoicing Pro — shared UI primitives
 * Load after style.css so theme bridge overrides template red/orange defaults.
 */

@import url('einvoicingpro-badges.css?v=a0398420');
@import url('einvoicingpro-buttons.css?v=992f0b2c');
@import url('einvoicingpro-skeleton.css?v=bd47a60b');
@import url('einvoicingpro-numeric.css?v=569ca0f7');

/* ── Theme bridge (no orange / template red) ───────────────────────────── */

:root,
[data-bs-theme='light'],
html[data-color='blue'],
body[data-color='blue'] {
    --crms-primary: var(--einvoicingpro-color-brand);
    --crms-secondary: #64748b;
    --crms-success: var(--einvoicingpro-color-success);
    --crms-danger: var(--einvoicingpro-color-danger);
    --crms-warning: var(--einvoicingpro-color-warning);
    --crms-info: var(--einvoicingpro-color-info);
    --crms-primary-bg-subtle: var(--einvoicingpro-chip-brand-bg);
    --crms-success-bg-subtle: var(--einvoicingpro-chip-success-bg);
    --crms-danger-bg-subtle: var(--einvoicingpro-chip-danger-bg);
    --crms-warning-bg-subtle: var(--einvoicingpro-chip-warning-bg);
    --crms-info-bg-subtle: var(--einvoicingpro-chip-info-bg);
    --crms-secondary-bg-subtle: var(--einvoicingpro-chip-neutral-bg);
    --crms-link-color: var(--einvoicingpro-color-text-primary);
    --crms-link-hover-color: var(--einvoicingpro-color-brand-hover);
    --crms-link-hover-color-rgb: var(--einvoicingpro-color-brand-rgb);
    --crms-body-font-family: var(--einvoicingpro-font-family);
    --crms-heading-color: var(--einvoicingpro-color-text-primary);
    --crms-body-color: var(--einvoicingpro-color-text-secondary);
    --crms-border-color: var(--einvoicingpro-color-border);
}

:root[data-color='blue'],
html[data-color='blue'],
body[data-color='blue'] {
    --crms-primary: var(--einvoicingpro-color-brand);
    --crms-link-hover-color: var(--einvoicingpro-color-brand-hover);
    --crms-link-hover-color-rgb: var(--einvoicingpro-color-brand-rgb);
}

.btn-primary {
    --crms-btn-bg: var(--einvoicingpro-color-brand);
    --crms-btn-border-color: var(--einvoicingpro-color-brand);
    --crms-btn-hover-bg: var(--einvoicingpro-color-brand-hover);
    --crms-btn-hover-border-color: var(--einvoicingpro-color-brand-hover);
    --crms-btn-active-bg: var(--einvoicingpro-color-brand-hover);
    --crms-btn-active-border-color: var(--einvoicingpro-color-brand-hover);
    --crms-btn-focus-shadow-rgb: var(--einvoicingpro-color-brand-rgb);
}

.btn-outline-primary {
    --crms-btn-color: var(--einvoicingpro-color-brand);
    --crms-btn-border-color: var(--einvoicingpro-color-brand);
    --crms-btn-hover-bg: var(--einvoicingpro-color-brand);
    --crms-btn-hover-border-color: var(--einvoicingpro-color-brand);
    --crms-btn-hover-color: #fff;
}

/* Secondary buttons — neutral slate, never template orange */
.btn-secondary {
    --crms-btn-color: var(--einvoicingpro-color-text-primary);
    --crms-btn-bg: var(--einvoicingpro-color-border);
    --crms-btn-border-color: var(--einvoicingpro-color-border-strong);
    --crms-btn-hover-color: var(--einvoicingpro-color-text-primary);
    --crms-btn-hover-bg: #cbd5e1;
    --crms-btn-hover-border-color: #cbd5e1;
    --crms-btn-active-color: var(--einvoicingpro-color-text-primary);
    --crms-btn-active-bg: #cbd5e1;
    --crms-btn-active-border-color: #cbd5e1;
    --crms-btn-focus-shadow-rgb: var(--einvoicingpro-color-brand-rgb);
    --crms-btn-disabled-color: var(--einvoicingpro-color-text-muted);
    --crms-btn-disabled-bg: var(--einvoicingpro-color-border);
    --crms-btn-disabled-border-color: var(--einvoicingpro-color-border);
}

.btn-light {
    --crms-btn-color: var(--einvoicingpro-color-text-primary);
    --crms-btn-bg: var(--einvoicingpro-color-surface);
    --crms-btn-border-color: var(--einvoicingpro-color-border);
    --crms-btn-hover-color: var(--einvoicingpro-color-text-primary);
    --crms-btn-hover-bg: var(--einvoicingpro-color-border);
    --crms-btn-hover-border-color: var(--einvoicingpro-color-border-strong);
}

a:hover,
.link-primary:hover {
    color: var(--einvoicingpro-color-brand-hover);
}

.form-check-input:checked {
    background-color: var(--einvoicingpro-color-brand);
    border-color: var(--einvoicingpro-color-brand);
}

.form-check-input:focus {
    border-color: var(--einvoicingpro-color-brand);
    box-shadow: 0 0 0 0.2rem var(--einvoicingpro-color-brand-subtle);
}

body {
    font-family: var(--einvoicingpro-font-family);
    font-size: var(--einvoicingpro-text-body-size);
    font-weight: var(--einvoicingpro-text-body-weight);
    line-height: var(--einvoicingpro-line-height-body);
    color: var(--einvoicingpro-color-text-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Focus */
:focus-visible {
    outline: 2px solid var(--einvoicingpro-color-brand);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Card */
.einvoicingpro-card {
    background: var(--einvoicingpro-color-surface-raised);
    border: 1px solid var(--einvoicingpro-color-border);
    border-radius: var(--einvoicingpro-radius-md);
    box-shadow: var(--einvoicingpro-shadow-sm);
}

/* Form field */
.einvoicingpro-form-field {
    margin-bottom: var(--einvoicingpro-space-4);
}

.einvoicingpro-form-field .form-label {
    font-size: var(--einvoicingpro-text-label-size);
    font-weight: var(--einvoicingpro-text-label-weight);
    color: var(--einvoicingpro-color-text-primary);
    margin-bottom: var(--einvoicingpro-space-2);
}

.einvoicingpro-form-field .form-control {
    min-height: 2.5rem;
    border-color: var(--einvoicingpro-color-border);
    border-radius: var(--einvoicingpro-radius-sm);
    font-size: var(--einvoicingpro-text-body-size);
    color: var(--einvoicingpro-color-text-primary);
    transition:
        border-color var(--einvoicingpro-duration-fast) var(--einvoicingpro-ease),
        box-shadow var(--einvoicingpro-duration-fast) var(--einvoicingpro-ease);
}

.einvoicingpro-form-field .form-control:focus {
    border-color: var(--einvoicingpro-color-brand);
    box-shadow: 0 0 0 3px var(--einvoicingpro-color-brand-subtle);
}

.einvoicingpro-form-field .form-control::placeholder {
    color: var(--einvoicingpro-color-text-muted);
}

/* Alerts */
.einvoicingpro-alert {
    display: flex;
    align-items: center;
    gap: var(--einvoicingpro-space-3);
    padding: var(--einvoicingpro-space-3) var(--einvoicingpro-space-4);
    border-radius: var(--einvoicingpro-radius-sm);
    font-size: var(--einvoicingpro-text-body-size);
    font-weight: 500;
    line-height: var(--einvoicingpro-line-height-body);
    width: 100%;
    box-sizing: border-box;
}

.einvoicingpro-alert[hidden] {
    display: none !important;
}

.einvoicingpro-alert .ti {
    flex-shrink: 0;
    font-size: 1.125rem;
    line-height: 1;
}

.einvoicingpro-alert--danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.28);
    color: #991b1b;
}

.einvoicingpro-alert--info {
    background: var(--einvoicingpro-color-brand-subtle);
    border: 1px solid rgba(47, 128, 237, 0.2);
    color: var(--einvoicingpro-color-brand-hover);
}

/* Button loading */
.einvoicingpro-btn--loading {
    position: relative;
    pointer-events: none;
    opacity: 0.85;
}

/* Page header — see einvoicingpro-pages.css for full implementation */

/* Terms modal — dialog-aligned chrome (login + app) */
.einvoicingpro-terms-modal .modal-content {
    border: none;
    border-radius: var(--einvoicingpro-radius-lg);
    box-shadow: var(--einvoicingpro-shadow-lg);
    overflow: hidden;
}

.einvoicingpro-terms-modal.show .modal-backdrop,
.modal-backdrop.show {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.terms-modal-body {
    line-height: 1.6;
    color: var(--einvoicingpro-color-text-secondary);
}

.terms-date-info {
    margin-bottom: var(--einvoicingpro-space-4);
}

.terms-disclaimer {
    margin-top: var(--einvoicingpro-space-5);
}

.terms-section-heading {
    margin-top: var(--einvoicingpro-space-6);
    margin-bottom: var(--einvoicingpro-space-3);
    font-weight: 600;
    color: var(--einvoicingpro-color-text-primary);
}

.terms-list {
    list-style-type: disc;
    padding-left: var(--einvoicingpro-space-6);
    margin-top: var(--einvoicingpro-space-2);
}

.terms-contact-list {
    list-style: none;
    padding-left: 0;
    margin-top: var(--einvoicingpro-space-2);
}

.terms-main-heading {
    text-align: center;
    font-size: var(--einvoicingpro-text-title-size);
    font-weight: 700;
    margin-top: var(--einvoicingpro-space-3);
    margin-bottom: var(--einvoicingpro-space-5);
    color: var(--einvoicingpro-color-text-primary);
}

.terms-section-divider {
    margin-top: var(--einvoicingpro-space-7);
    margin-bottom: var(--einvoicingpro-space-6);
    border: none;
    border-top: 2px solid var(--einvoicingpro-color-border);
}

.terms-contact-section {
    background: linear-gradient(135deg, var(--einvoicingpro-color-surface) 0%, var(--einvoicingpro-color-surface-raised) 100%);
    border-radius: var(--einvoicingpro-radius-lg);
    padding: var(--einvoicingpro-space-6) var(--einvoicingpro-space-6);
    margin-top: var(--einvoicingpro-space-5);
    border: 1px solid var(--einvoicingpro-color-border);
}

.terms-contact-logo {
    max-height: 60px;
    margin-bottom: var(--einvoicingpro-space-5);
}

.terms-contact-title {
    font-size: 0.95rem;
    color: var(--einvoicingpro-color-text-secondary);
    margin-bottom: var(--einvoicingpro-space-5);
    font-weight: 700;
}

.terms-contact-address {
    text-align: center;
    color: var(--einvoicingpro-color-text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: var(--einvoicingpro-space-5);
}

.terms-contact-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--einvoicingpro-space-4);
}

.terms-contact-info-item {
    display: flex;
    align-items: center;
    gap: var(--einvoicingpro-space-2);
    color: var(--einvoicingpro-color-text-secondary);
    font-size: 0.9rem;
}

.terms-contact-info-item i {
    color: var(--einvoicingpro-color-brand);
    font-size: 1rem;
}

.terms-contact-info-item a {
    color: var(--einvoicingpro-color-text-secondary);
    text-decoration: none;
    transition: color var(--einvoicingpro-duration-fast) var(--einvoicingpro-ease);
}

.terms-contact-info-item a:hover {
    color: var(--einvoicingpro-color-brand);
    text-decoration: underline;
}

.terms-contact-separator {
    width: 1px;
    height: 20px;
    background: var(--einvoicingpro-color-border);
    margin: 0 var(--einvoicingpro-space-2);
}

/* ==========================================================================
   Inline "add" button — sits beside a field and matches its height exactly.

   .btn-icon hard-codes height/width: 38px, which cannot line up with a form
   control whose height comes from its own padding (inside .page-wrapper
   .content, min-height is explicitly unset). Stretching to the flex row and
   taking a square aspect ratio makes the button exactly as tall as the field
   it sits next to, at any font size or density.

   Requires the flex parent to use align-items: stretch (the default).
   ========================================================================== */

.einvoicingpro-inline-add-btn.btn-icon {
    height: auto;
    align-self: stretch;
    /* Explicit width, and no aspect-ratio: aspect-ratio would derive the height from the
       width and beat align-self: stretch, leaving the button taller than the field. */
    width: 2.375rem;
    min-width: 2.375rem;
    flex: 0 0 auto;
}

/* Field + button share one wrapping flex line, so the button is a SIBLING of the control
   and stretches only to it. markInvalid injects .invalid-feedback next to the control
   (seller-create-invoice.js markInvalid); giving it full width drops it onto a second line,
   where it can no longer stretch the button. If the button sat outside this wrapper it would
   stretch to control + message instead. */
.einvoicingpro-inline-field-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.5rem;
}

/* flex-basis 0, not auto: these controls are width:100%, so an auto basis fills the line and
   pushes the button onto a second line of its own — where it can no longer match the field. */
.einvoicingpro-inline-field-row > .form-control,
.einvoicingpro-inline-field-row > .customer-display-area {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
}

/* Messages belong under the field, not in the row beside the "+".
   Anything appended to this wrapper becomes a flex item, so it lines up next to the button
   unless it is told to take the full width and wrap. #fbrErrorMessage is added here at
   runtime by showFBRErrorMessage and is not an .invalid-feedback, so it needs naming. */
.einvoicingpro-inline-field-row > .invalid-feedback,
.einvoicingpro-inline-field-row > #fbrErrorMessage {
    width: 100%;
    flex: 0 0 100%;
    order: 99;
    margin-top: 0.25rem;
}

/* The clear (x) used to be appended to this row, where .end-0 pinned it over the "+" and
   .top-50 centred it on the row rather than the field — so it slid to the bottom as soon
   as the row wrapped a message onto a second line. It is now anchored inside
   #customerDisplayArea instead, which is both the right edge and the vertical centre we
   actually want, so no offset is needed here. Kept as a guard for anything else absolutely
   positioned into this row. */
.einvoicingpro-inline-field-row > .btn-link.position-absolute {
    right: 2.875rem !important;
}

/* The customer suggestions hang from the bottom of the field. The field and its "+" share
   this flex row, and an absolutely positioned box with no top of its own is drawn at the top
   of a flex row — right over the name being typed. */
.einvoicingpro-inline-field-row > .search-results-panel {
    top: 100%;
    left: 0;
}

/* Focus ring for the customer picker.
   It is a div.form-control wrapping a bare, border-less input, so neither element can ever
   match .form-control:focus — it was the only control on the invoice header with no focus
   treatment at all, which is what made it look wrong beside every other field.
   :focus-within moves the standard brand ring onto the wrapper when the input takes focus.
   Defined here rather than in einvoicingpro-pages.css because that file is not linked by
   seller-create-invoice.html. */
.page-wrapper .content .customer-display-area.form-control:focus-within,
.customer-display-area.form-control:focus-within {
    border-color: var(--einvoicingpro-color-brand);
    box-shadow: 0 0 0 3px var(--einvoicingpro-color-brand-subtle);
}

/* Standard import report (assets/js/import-utility.js).
   Rendered inside the page alert, so it inherits the alert colour. Each list is capped at 25 entries in JS;
   the height cap here only keeps a long error message from pushing the table off screen. */
.import-report__section {
    margin-bottom: var(--einvoicingpro-space-2);
}

.import-report__heading {
    font-weight: 600;
    margin-bottom: var(--einvoicingpro-space-1);
}

.import-report__list {
    max-height: 14rem;
    overflow-y: auto;
    margin: 0;
    padding-left: var(--einvoicingpro-space-5);
    font-size: 0.8125rem;
    line-height: 1.5;
}

.import-report__list code {
    color: inherit;
    word-break: break-word;
}

.import-report__more,
.import-report__meta {
    opacity: 0.8;
    font-size: 0.8125rem;
}

.import-report__details {
    margin-bottom: var(--einvoicingpro-space-2);
    font-size: 0.8125rem;
}

.import-report__details > summary {
    cursor: pointer;
    font-weight: 600;
}

.import-report__details > .import-report__list {
    margin-top: var(--einvoicingpro-space-1);
}

.import-report__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--einvoicingpro-space-3);
    margin-top: var(--einvoicingpro-space-2);
}

.import-loader__spinner {
    width: 3rem;
    height: 3rem;
}

.import-guide__heading {
    margin-bottom: var(--einvoicingpro-space-2);
}

.import-guide__heading:not(:first-child) {
    margin-top: var(--einvoicingpro-space-4);
}

.import-guide__rules {
    margin-bottom: 0;
    padding-left: var(--einvoicingpro-space-5);
    color: var(--einvoicingpro-color-text-secondary);
}

.import-guide__rules > li + li {
    margin-top: var(--einvoicingpro-space-1);
}

/* The import guide, written for someone who has never imported a file: a short intro,
   numbered steps, each column with a plain "must fill / optional" label, then tips.
   Columns are a list, not a table, so they read as well on a phone as in the modal. */
.import-guide__intro {
    margin-bottom: var(--einvoicingpro-space-4);
    color: var(--einvoicingpro-color-text-primary);
}

.import-guide__steps {
    margin-bottom: 0;
    padding-left: var(--einvoicingpro-space-5);
}

.import-guide__steps > li + li {
    margin-top: var(--einvoicingpro-space-2);
}

.import-guide__group {
    margin: var(--einvoicingpro-space-3) 0 var(--einvoicingpro-space-2);
    font-weight: 600;
    color: var(--einvoicingpro-color-text-primary);
}

.import-guide__columns {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--einvoicingpro-color-border);
    border-radius: var(--einvoicingpro-radius-sm);
}

.import-guide__columns > li {
    padding: var(--einvoicingpro-space-2) var(--einvoicingpro-space-3);
}

.import-guide__columns > li + li {
    border-top: 1px solid var(--einvoicingpro-color-border);
}

.import-guide__column-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--einvoicingpro-space-2);
}

.import-guide__column-name {
    font-weight: 600;
    color: var(--einvoicingpro-color-text-primary);
    overflow-wrap: anywhere;
}

.import-guide__column-text {
    margin-top: var(--einvoicingpro-space-1);
    color: var(--einvoicingpro-color-text-secondary);
}

.import-guide__need {
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.import-guide__need--must {
    background: var(--bs-danger-bg-subtle);
    color: var(--bs-danger-text-emphasis);
}

.import-guide__need--if {
    background: var(--bs-warning-bg-subtle);
    color: var(--bs-warning-text-emphasis);
}

.import-guide__need--optional {
    background: var(--bs-secondary-bg-subtle);
    color: var(--bs-secondary-text-emphasis);
}

/* The theme takes list markers off every list; the guide needs its bullets and numbers. */
.import-guide__list {
    margin-bottom: 0;
    padding-left: var(--einvoicingpro-space-5);
    list-style: disc;
}

.import-guide__steps {
    list-style: decimal;
}

.import-guide__list > li,
.import-guide__steps > li {
    display: list-item;
}

/* Examples of what to type: a quiet chip, not Bootstrap's pink code colour, which reads as
   an error to someone who has never seen code. */
.import-guide code {
    padding: 0.0625rem 0.375rem;
    border-radius: var(--einvoicingpro-radius-sm);
    background: var(--bs-tertiary-bg);
    color: var(--einvoicingpro-color-text-primary);
    font-size: 0.875em;
    overflow-wrap: anywhere;
}

.import-guide__list > li + li {
    margin-top: var(--einvoicingpro-space-1);
}
