/**
 * Brainsap Manager theme — professional light skin on top of Bootstrap 5.
 * Loaded LAST so it wins over bootstrap, bs3-compat and legacy style.css.
 */

/* ------------------------------------------------------------- density */
/* BS5 defaults to a 16px root — the whole app grew ~15% vs. the old BS3
   look. 14px root restores the familiar compact density; every rem-based
   size (buttons, inputs, spacing) scales with it. */
html { font-size: 14px; }

h1 { font-size: 2.2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.45rem; }
h4 { font-size: 1.15rem; }
h5 { font-size: 1rem; }
h6 { font-size: .85rem; }

/* -------------------------------------------------------------- canvas */
body {
    background: #eceef2;
    color: #1f2329;
    -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------- cards */
.panel, .card {
    border: 1px solid #d3d9e0;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .09);
    background: #fff;
}
.panel-heading {
    font-weight: 600;
    color: #344054;
    background: #f2f4f7;
    border-bottom: 1px solid #e1e5ea;
    border-radius: 8px 8px 0 0;
}
.well {
    background: #f2f4f7;
    border: 1px solid #d3d9e0;
    border-radius: 8px;
    padding: 14px;
}

/* -------------------------------------------------------------- tables */
.table { --bs-table-hover-bg: #eaf1fb; }
.table thead th {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #667085;
    background: #f2f4f7;
    border-bottom: 2px solid #d3d9e0;
    white-space: nowrap;
}
.table tbody td { vertical-align: middle; }
.table > tbody > tr:hover > td { background-color: #eaf1fb; }
/* keep severity rows readable on hover */
.table > tbody > tr.success:hover > td { background-color: #c4e3d3; }
.table > tbody > tr.danger:hover > td  { background-color: #f2c6cb; }
.table > tbody > tr.warning:hover > td { background-color: #f7ecc2; }

/* ------------------------------------------------------------- buttons */
/* Streamlined default: compact everywhere (the legacy views used oversized
   default buttons); .btn-lg stays available for deliberate big targets. */
.btn {
    --bs-btn-padding-y: .32rem;
    --bs-btn-padding-x: .7rem;
    --bs-btn-font-size: .93rem;
    border-radius: 6px;
    font-weight: 500;
    box-shadow: 0 1px 1px rgba(16, 24, 40, .04);
}
.btn-lg {
    --bs-btn-padding-y: .55rem;
    --bs-btn-padding-x: 1rem;
    --bs-btn-font-size: 1.1rem;
}
.streamlined-group { display: inline-flex; vertical-align: middle; }
.btn:active { box-shadow: none; }
.btn-default {
    --bs-btn-bg: #fff;
    --bs-btn-border-color: #d0d5dd;
    --bs-btn-color: #344054;
    --bs-btn-hover-bg: #f2f4f7;
    --bs-btn-hover-border-color: #c3c9d4;
    --bs-btn-hover-color: #1f2329;
}
.btn-xs, .btn-group-xs > .btn {
    padding: .2rem .45rem;
    font-size: .82rem;
    border-radius: 5px;
    box-shadow: none;
}
/* Row quick actions need a real click target — pure xs was too tiny. */
.order-quick-actions > .btn {
    padding: .45rem .7rem;
    font-size: 1.1rem;
    line-height: 1;
}

/* ---------------------------------------------------------------- tabs */
/* Modern underline tabs — clear active indicator, no boxy borders. */
.nav-tabs {
    border-bottom: 1px solid #d3d9e0;
    gap: 2px;
    flex-wrap: wrap;
}
.nav-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 6px 6px 0 0;
    color: #475467;
    padding: .5rem .85rem;
    margin-bottom: -1px;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 5px;
}
.nav-tabs .nav-link:hover { background: #f2f4f7; color: #1f2329; border-color: transparent; }
.nav-tabs .nav-link.active,
.nav-tabs li.active > a {
    border: 0;
    border-bottom: 2px solid #2563eb;
    color: #1d4ed8;
    font-weight: 600;
    background: transparent;
}

/* --------------------------------------------------------------- modal */
.modal-content {
    border: 0;
    border-radius: 10px;
    box-shadow: 0 24px 64px rgba(16, 24, 40, .28);
}
.modal-header {
    border-bottom: 1px solid #e1e5ea;
    padding: .8rem 1.1rem;
}
.modal-title { font-weight: 600; }
.modal-footer { border-top: 1px solid #e1e5ea; padding: .6rem 1.1rem; }
/* The order dialog carries a lot of content — give it room on desktop. */
@media (min-width: 1200px) {
    .modal-lg { --bs-modal-width: 1080px; }
}

/* --------------------------------------------------------------- forms */
.form-control, .form-select {
    border-color: #d0d5dd;
    border-radius: 6px;
}
.form-control:focus, .form-select:focus {
    border-color: #93b4f8;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
label { font-weight: 500; color: #344054; }

/* Searchable selects (bootstrap-select): the stock btn-light toggle sat
   grey-on-grey with an invisible border and a #999 placeholder. Make the
   toggle look like every other form control, in every state. */
.bootstrap-select > .btn.dropdown-toggle,
.bootstrap-select > .btn.dropdown-toggle:hover,
.bootstrap-select > .btn.dropdown-toggle:active,
.bootstrap-select > .btn.dropdown-toggle.show {
    background-color: #fff;
    border: 1px solid #d0d5dd;
    color: #212529;
}
.bootstrap-select > .btn.dropdown-toggle:focus,
.bootstrap-select > .btn.dropdown-toggle.show {
    border-color: #93b4f8;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
    outline: none !important;
}
.bootstrap-select > .btn.dropdown-toggle.bs-placeholder,
.bootstrap-select > .btn.dropdown-toggle.bs-placeholder:hover,
.bootstrap-select > .btn.dropdown-toggle.bs-placeholder:focus { color: #667085; }

/* Menu rows: readable selected/keyboard-highlight state in every variant
   bootstrap-select emits (.active, .selected, li.selected > a). */
.bootstrap-select .dropdown-menu .dropdown-item.active,
.bootstrap-select .dropdown-menu .dropdown-item.selected,
.bootstrap-select .dropdown-menu li.selected .dropdown-item {
    background-color: #2563eb;
    color: #fff;
}
.bootstrap-select .dropdown-menu .dropdown-item:hover:not(.active):not(.selected),
.bootstrap-select .dropdown-menu .dropdown-item:focus:not(.active):not(.selected) {
    background-color: #eef2f8;
    color: #101828;
}

/* -------------------------------------------------------------- navbar */
.navbar.bg-white { border-bottom: 1px solid #d3d9e0; }
.navbar .nav-link { font-size: .95rem; padding-top: .55rem; padding-bottom: .55rem; color: #344054; }
.navbar .nav-link:hover { color: #0d6efd; }
.dropdown-menu {
    border: 1px solid #d3d9e0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, .14);
    font-size: .93rem;
}
.dropdown-item { padding: .32rem 1rem; }

/* Dialog tab bars sat directly on the tab content — give them air. */
.modal .nav-tabs { margin-bottom: 14px; }

/* ------------------------------------------------- order dialog facelift */
/* The Order tab duplicated the modal title as a big h3 — hide it unless it
   carries a status color (canceled/return/lost), then render it as a slim
   alert strip. */
[id^="order-dialog-tab-order-"] > h3:not(.bg-danger):not(.bg-warning) { display: none; }
[id^="order-dialog-tab-order-"] > hr { display: none; }
/* Same for every other tab: the active tab already names the section, so the
   redundant first headline (Addresses, Invoice, Notes, …) and its divider go. */
.modal [id^="order-dialog-tab-"] > h3:first-child:not(.bg-danger):not(.bg-warning),
.modal [id^="order-dialog-vat-exempt-"] > h3:first-child { display: none; }
.modal [id^="order-dialog-tab-"] > h3:first-child + hr,
.modal [id^="order-dialog-tab-"] > hr:first-child { display: none; }
[id^="order-dialog-tab-order-"] > h3.bg-danger,
[id^="order-dialog-tab-order-"] > h3.bg-warning {
    font-size: 1rem;
    font-weight: 600;
    padding: 8px 12px !important;
    border-radius: 6px;
    margin: 0 0 12px;
}
/* readable status strips: white on red, dark on yellow */
[id^="order-dialog-tab-order-"] > h3.bg-danger { color: #fff !important; background-color: #dc3545 !important; }
[id^="order-dialog-tab-order-"] > h3.bg-warning { color: #664d03 !important; background-color: #ffe69c !important; }

/* BS5 renders its own dropdown caret (::after) — hide the legacy BS3 span so
   dropdown buttons don't show two carets. */
.dropdown-toggle .caret { display: none; }

/* Every table in the dialog gets the card treatment — incl. the top info
   tables and the eBay/SKU item lists. */
.modal [id^="order-dialog-tab-"] table.table {
    background: #fff;
    border: 1px solid #d3d9e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .09);
}
.modal [id^="order-dialog-tab-"] table.table > tbody > tr > td,
.modal [id^="order-dialog-tab-"] table.table > tr > td { padding: .45rem .75rem; }
.modal [id^="order-dialog-tab-"] .desc-cell { width: 220px; color: #667085; background: #f2f4f7; }

/* Section headings inside the dialog (eBay Items, SKU Items, Orders by
   Customer, Addresses, …) — consistent slim section titles. */
.modal [id^="order-dialog-tab-"] h3,
.modal [id^="order-dialog-tab-"] h4 {
    font-size: .95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #667085;
    margin: 14px 0 8px;
}

/* Canned-message selects sat grey-on-grey inside the reply form wrap. */
.reply-form select, .reply-form .bootstrap-select > .btn,
select.canned-response, select.order-compose-canned { background-color: #fff !important; }

/* --------------------------------------------------------------- misc */
.glyphicon { vertical-align: -1px; }
.badge { border-radius: 10px; font-weight: 600; }
kbd {
    background: #1f2329;
    border-radius: 4px;
    padding: 2px 6px;
}
::selection { background: rgba(37, 99, 235, .18); }

/* ------------------------------------------------------------ ship nav */
/* ZURÜCK/WEITER stay reachable while scrolling an order section (navbar is
   fixed-top ~56px, so stick right below it). */
.ship-nav-row {
    position: sticky;
    top: 58px;
    z-index: 900;
    background: #fff;
    padding: 6px 4px;
    margin-left: -4px;
    margin-right: -4px;
    border-bottom: 1px solid #e1e5ea;
    box-shadow: 0 2px 6px rgba(16, 24, 40, .05);
}

/* -------------------------------------------------------------- mobile */
/* Ship-page anchor jumps (Nachrichten ↓ / Nach oben) must not hide under
   the sticky navbar. */
[id^="order-top-"], [id^="order-messages-"] { scroll-margin-top: 64px; }

@media (max-width: 768px) {
    /* Denser base: smaller root font, tighter paddings — less scrolling. */
    html { font-size: 12.5px; }
    .container-fluid { padding-left: 6px; padding-right: 6px; }
    .panel { margin-bottom: 8px; }
    .panel-body { padding: 8px; }
    .well { padding: 6px; margin-bottom: 8px; }
    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.4rem; }
    h3 { font-size: 1.15rem; }
    h4 { font-size: 1rem; }
    .modal-body { padding: 8px; }
    .table > :not(caption) > * > * { padding: .28rem .35rem; }

    /* Compact controls: BS5 defaults are desktop-sized — shrink inputs,
       selects and buttons across the board. */
    .form-control, .form-select {
        padding: .28rem .5rem;
        font-size: .95rem;
        min-height: 0;
    }
    .form-group { margin-bottom: 6px; }
    label { margin-bottom: 1px; font-size: .9em; }
    .btn {
        --bs-btn-padding-y: .28rem;
        --bs-btn-padding-x: .55rem;
        --bs-btn-font-size: .9rem;
    }
    .bootstrap-select > .btn, .btn.dropdown-toggle {
        padding-top: .28rem;
        padding-bottom: .28rem;
        font-size: .9rem;
    }

    /* Ship pages: compact address data (label left, value right; slightly
       larger than the desktop 12px for readability), primary nav thumb-sized. */
    .address-data-table td { padding: 2px 6px !important; font-size: 13px; }
    .address-item .next-address-button,
    .address-item .go-back-address-button { padding: .45rem .8rem; font-size: .9rem; }
    .address-check-icons { font-size: 15px !important; margin-right: 6px !important; }
    .switch-address-lines-link { padding: .28rem .2rem; font-size: .85rem; height: 100%; }
    .address-item textarea.form-control { height: 72px !important; }
    .order-messages-jump { font-size: .85rem; padding: .25rem .5rem; }

    /* Message bubbles in embeds: tighter */
    .order-thread-block { margin-bottom: 10px; }

    /* Quick actions stay finger-friendly but not oversized on phones. */
    .order-quick-actions > .btn { padding: .35rem .55rem; font-size: 1rem; }
}

/* DataTables polish */
/* Layout rows (search bar line) flex on all widths so injected cells like the
   orders SELECT ALL sit on the SAME line as the Suchen box. */
div.dt-container .dt-layout-row { display: flex !important; align-items: center !important; flex-wrap: wrap; }
div.dt-container .dt-layout-row .dt-layout-end { margin-left: auto; }
div.dt-container div.dt-search input { border-radius: 6px; border-color: #d0d5dd; }
.dt-filter-row th { padding: .3rem .35rem !important; background: #fff; }
.dt-filter-row input { min-width: 70px; }
table.dataTable thead > tr > th.dt-orderable-asc:hover,
table.dataTable thead > tr > th.dt-orderable-desc:hover { background: #f2f4f7; }

/* --------------------------------------------------- sticky Tabellenköpfe */
/* EINE zentrale Regel für das ganze Panel — jede Liste behält ihren
 * Spaltenkopf im Blick.
 *
 * Warum nicht schlicht `thead th { position: sticky; top: 64px }`? Am
 * 06.09.2026 im Dev-Chrome gemessen: so bleibt gar nichts stehen, aus zwei
 * voneinander unabhängigen Gründen.
 *
 * 1. Spezifität. DataTables setzt `position:relative` auf jede sortierbare
 *    Spalte (table.dataTable thead>tr>th.dt-orderable-asc, Spezifität 0,2,4)
 *    und schlägt damit `.table > thead > tr > th` (0,1,4). Gemessen auf
 *    /cancels: getComputedStyle(th).position blieb `relative` — still und
 *    ohne Fehlermeldung.
 * 2. Scrollport. Jede Liste steckt in einem overflow-Vorfahren:
 *    `div.dt-container` (bs3-compat.css:256) bzw. `.table-responsive`
 *    (Bootstrap 5.3.3). `overflow-x:auto` zieht overflow-y laut Spec auf
 *    `auto` mit, also ist der Wrapper der nächste Scrollport — und weil er
 *    mit dem Inhalt mitwächst (gemessen /performance/purchase-prices:
 *    clientHeight == scrollHeight == 174363px), hat sticky dort null
 *    Klebeweg. Gemessen vorher, Seite 1500px gescrollt: Kopfoberkante auf
 *    -773px (purchase-prices), -1372px (/cancels), -780px
 *    (/performance/products) — längst aus dem Bild.
 *
 * Lösung: den senkrechten Scroll bewusst IN den Wrapper legen (max-height)
 * und sticky auf das <thead> setzen statt auf die <th>. Das umgeht die
 * DataTables-Spezifität komplett und trägt beide Kopfzeilen (Beschriftung +
 * die von js/tables.js:47 injizierte .dt-filter-row) ohne Offset-Rechnerei.
 * Nachher gemessen: Kopfoberkante == Kastenoberkante, Abweichung 0px.
 */
:root {
    /* Gemessen: #main-nav (fixed-top) ist 64,02px hoch. */
    --bsm-nav-h: 64px;
    /* Was neben dem Kasten Platz braucht: Panel-Überschrift (gemessen 37px)
       + DataTables-Suchzeile (gemessen 27px) + 24px Luft nach unten, damit
       der Kasten nie bündig am Fensterrand klebt und sichtbar bleibt, dass
       die Seite weitergeht. Die Summe geht genau auf: steht die Überschrift
       unter der Navbar, füllen 64 + 37 + 27 + Kasten + 24 exakt 100vh. */
    --bsm-table-reserve: 88px;
    --bsm-table-max-h: calc(100vh - var(--bsm-nav-h) - var(--bsm-table-reserve));
}

/* 1) DataTables: nicht der ganze dt-container scrollt, sondern nur seine
      Tabellenzeile — so bleibt die Suchleiste außerhalb der Scrollbox stehen
      (gemessen /cancels: Suchfeld blieb bei 94px, während innen 6000px
      gescrollt wurde). Überschreibt bs3-compat.css:256 allein über die
      Ladereihenfolge, theme.css ist das letzte Stylesheet. */
div.dt-container { overflow: visible; }
div.dt-container > .dt-layout-table {
    max-height: var(--bsm-table-max-h);
    overflow: auto;
    /* Die .row-Negativmargins (gemessen -10,5px) würden im Scrollport links
       abgeschnitten. Margin raus und das Gegenstück, das Zellpadding, gleich
       mit — zusammen ergibt das exakt denselben Tabellenrand wie vorher. */
    margin-left: 0;
    margin-right: 0;
}
div.dt-container > .dt-layout-table > .dt-layout-full { padding-left: 0; padding-right: 0; }

/* 2) Alles ohne DataTables: no-dt-Listen, Statistik-, VAT- und Report-Seiten
      sowie die Wrapper in performance/database, die dafür von style= auf
      class="table-responsive" umgestellt wurden. */
.table-responsive {
    max-height: var(--bsm-table-max-h);
    overflow: auto;
}

/* 3) Keine zwei Scrollboxen übereinander, wenn DataTables schon drinhängt —
      sonst stünden zwei senkrechte Rollbalken nebeneinander. */
.table-responsive:has(> div.dt-container) {
    max-height: none;
    overflow: visible;
}

/* 4) Der Kopf. Sticky sitzt auf dem <thead>, siehe Kommentar oben. */
.table > thead,
table.dataTable > thead {
    position: sticky;
    top: 0;
    z-index: 3;
}

/* Trennlinie unter dem Kopf: mit border-collapse:collapse (Reboot) gehört
   die Linie dem Tabellenraster und nicht der Zelle — sie bleibt beim
   Scrollen liegen, während die geklebte Zelle weiterwandert. Deshalb die
   border-bottom aus Zeile 55 hier abschalten und die Linie als inset-Schatten
   IN die Zelle malen; der scrollt mit. Nur die letzte Kopfzeile bekommt sie,
   sonst stünde zwischen Beschriftungs- und Filterzeile eine doppelte Linie. */
.table > thead > tr > th,
table.dataTable > thead > tr > th { border-bottom-width: 0; }
.table > thead > tr:last-child > th,
table.dataTable > thead > tr:last-child > th { box-shadow: inset 0 -2px 0 #d3d9e0; }

/* 5) Verschachtelte Detail-Tabellen kleben nicht: ihr Kopf würde sich an
      dieselbe Oberkante hängen wie der Kopf der äußeren Liste und ihn
      verdecken. Vorsorge — auf /csv_connect_products sind 50 der 51 Tabellen
      verschachtelt, keine davon hat einen thead. */
.table .table > thead { position: static; }

/* 6) Modale ausnehmen: `.modal` ist selbst overflow-y:auto (gemessen am
      Order-Dialog), der Kopf würde dort unter dem Modal-Kopf kleben. */
.modal .table-responsive,
.modal div.dt-container > .dt-layout-table { max-height: none; }
.modal .table > thead,
.modal table.dataTable > thead { position: static; }

/* 7) Druck: eine Scrollbox druckt nur ihren sichtbaren Ausschnitt — auf
      Papier gehört die ganze Tabelle hin. */
@media print {
    div.dt-container > .dt-layout-table,
    .table-responsive { max-height: none; overflow: visible; }
    .table > thead,
    table.dataTable > thead { position: static; }
}
