/* ==================================================================
   SAGE ADAPTER - this app's few additions to the house style
   ------------------------------------------------------------------
   Loaded after ui.css and desktop.css (which are unchanged copies of
   roadtrakcloud's). Keep it small: put only this app's own styles here.
   ================================================================== */


/* ==================================================================
   INVOICES PAGE
   Amber (paused, warnings) is Bootstrap's own warning colour, which
   follows light and dark mode; the house palette has no amber.
   ================================================================== */

/* ---- Top bar: TESTING / Pretend Sage badges, serial ---- */
.mode-badges { display: flex; flex-wrap: wrap; gap: .35rem; min-width: 0; }
.mode-badge { font-size: .78rem; }
.desk-serial { color: var(--app-muted); font-size: .85rem; font-weight: 600; white-space: nowrap; }
@media (max-width: 767.98px) {
    .desk-serial { display: none; }
}

/* ---- Top bar: the Sage connection (live Sage only) ---- */
.sage-connection { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.sage-name {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    max-width: 18rem;
    overflow: hidden;
    color: var(--app-accent-text);
    font-weight: 700;
    font-size: .9rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.sage-disconnect, .sage-connect { margin: 0; }
.run-alert .sage-connect { display: inline-block; margin-left: .5rem; }
.sage-connection .btn-setup { padding: .35rem .8rem; }

/* ---- Choose a Sage business ---- */
.business-form { max-width: 40rem; }
.business-form fieldset { margin: 0 0 1rem; }
.business-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---- Invoice rows: click opens the side panel ---- */
.invoice-table tbody tr[data-inv] { cursor: pointer; }
.invoice-table tbody td { transition: opacity .4s ease; }

/* Row states during a run */
.data-table tbody tr.row-sending td { background: rgb(var(--app-primary-rgb) / .08); }
.data-table tbody tr.row-failed td:first-child { box-shadow: inset 4px 0 0 var(--app-alert); }
.data-table tbody tr.row-skipped td { color: var(--app-muted); }
.data-table tbody tr.row-paused td:first-child { box-shadow: inset 4px 0 0 var(--bs-warning-text-emphasis); }
.data-table tbody tr.row-exported td { opacity: 0; }

/* The reason a row failed, as a full-width line under it */
.data-table tbody tr.row-message td {
    padding-top: .35rem;
    padding-left: 3.4rem;
    color: var(--app-alert);
    background: rgb(var(--app-alert-rgb) / .06);
    font-weight: 600;
    white-space: pre-line;
    box-shadow: inset 4px 0 0 var(--app-alert);
}
.invoice-table tbody tr.row-failed td { border-bottom-color: transparent; }

.status-sent    { color: var(--app-accent-text); font-weight: 700; }
.status-failed  { color: var(--app-alert); font-weight: 700; }
.status-skipped { color: var(--app-muted); font-weight: 700; }
.status-paused  { color: var(--bs-warning-text-emphasis); font-weight: 700; }

/* ---- Successful exports ---- */
.success-list { margin-top: 1.5rem; }
.success-title { margin: 0 0 .6rem; font-size: 1.1rem; font-weight: 700; }
.data-table td small.success-warning { color: var(--bs-warning-text-emphasis); font-weight: 600; }

/* ---- Bottom dock: the question panel above the selection bar ---- */
.run-dock {
    position: sticky;
    bottom: 1rem;
    z-index: 1020;
    margin-top: 1rem;
}
.run-dock .bulk-bar { position: static; margin-top: 0; }
.run-dock .run-alert { margin-bottom: .6rem; box-shadow: 0 14px 34px rgba(0, 0, 0, .18); }
.selection-bar .run-status { font-size: .9rem; opacity: .85; }

.run-prompt {
    max-height: 60vh;
    overflow-y: auto;
    margin-bottom: .6rem;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--app-line);
    border-left: 5px solid var(--app-primary);
    border-radius: 16px;
    background: var(--app-surface);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .18);
}
.run-prompt-title { margin: 0 0 .35rem; font-size: 1.1rem; font-weight: 800; }
.run-prompt-text { margin: 0 0 .85rem; color: var(--app-muted); }
.run-prompt .detail-list { max-width: 36rem; }
.run-prompt .detail-list dd { text-align: left; }
.run-prompt .table-wrap { max-width: 40rem; border: 1px solid var(--app-line); border-radius: 12px; margin-bottom: .85rem; }
.run-prompt-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

/* Already-in-Sage comparison: differences stand out */
.compare-table tbody th { color: var(--app-muted); font-weight: 600; white-space: nowrap; }
.data-table.compare-table tbody tr.is-different th,
.data-table.compare-table tbody tr.is-different td {
    background: rgb(var(--app-alert-rgb) / .08);
    color: var(--app-alert);
    font-weight: 700;
}

/* ---- Side panel: wide enough for the lines table ---- */
.invoice-panel.side-panel { width: min(900px, 96vw) !important; }
.panel-existing { border-left: 5px solid var(--bs-warning-text-emphasis); }
.panel-lines .table-wrap { border: 1px solid var(--app-line); border-radius: 12px; }
.panel-lines .data-table { font-size: .88rem; }
.multi-line > span { display: block; }

/* ---- Logo (landscape 2:1, so the house square sizes don't apply) ---- */
.desk-brand img { width: auto; height: 36px; }
.brand-inner .brand-logo { height: auto; }


/* ==================================================================
   ADMIN PAGES (switches, Export log, Admin log)
   ================================================================== */

/* The tabs sit under the top bar, lined up with the page content */
.is-desktop .admin-tabs {
    max-width: var(--desk-content-max);
    margin: 0 auto;
    padding: 1.25rem 1.25rem 0;
}
.is-desktop .admin-tabs .desk-tabs { margin-bottom: 0; }
.is-desktop .app-content.admin-page { padding-top: 1.25rem; }
@media (min-width: 992px) {
    .is-desktop .admin-tabs { padding: 1.5rem 2rem 0; }
}

/* ---- Settings ---- */
.admin-settings { max-width: 46rem; }
.admin-switch { margin: 0 0 1rem; }
.admin-switch .form-check-input { width: 2.6em; height: 1.4em; margin-top: .05em; }
.admin-switch .form-check-label { padding-left: .5rem; padding-top: .1rem; }
.admin-choice { margin: 0 0 1rem; }
.admin-choice legend { margin-bottom: .35rem; font-size: 1rem; }
.admin-choice .form-check { margin-left: .25rem; }
.admin-note { color: var(--app-muted); font-size: .9rem; }
.admin-settings .admin-note { margin: 0 0 1rem; }

/* ---- Export log: expand a row to see its trail ---- */
.export-log-table .trail-toggle { width: 2.6rem; padding-right: 0; }
.btn-trail {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--app-accent-text);
}
.btn-trail:hover { background: var(--app-field); }
.export-log-table .log-message { min-width: 16rem; }

.data-table tbody tr.trail-row td { padding: 0; background: var(--app-page); }
.data-table tbody tr.trail-row:hover td { background: var(--app-page); }
.trail { padding: .9rem 1rem .9rem 3.4rem; }
.trail-step { margin-bottom: 1rem; }
.trail-step:last-child { margin-bottom: 0; }
.trail-step h3 { margin: 0 0 .4rem; font-size: .95rem; font-weight: 800; }
.trail-step h4 { margin: .5rem 0 .25rem; font-size: .8rem; font-weight: 700; color: var(--app-muted); }
.trail-call { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.trail-pre {
    max-height: 24rem;
    margin: 0;
    padding: .6rem .75rem;
    overflow: auto;
    border: 1px solid var(--app-line);
    border-radius: 10px;
    background: var(--app-surface);
    font-size: .8rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
