/* ==========================================================================
   EMA — thin layer on top of the theme the ERP already uses.

   Everything structural comes from template/assets/css/style.css. This file
   only holds what the theme has no opinion about: the wordmark, the topline
   row, and the pages that run without a sidebar (landing, signup, sign-in).

   Rule for anything added here: if the theme already has a component for it,
   use the theme's. A second design system is what produced the three
   incompatible layouts in the legacy ERP.
   ========================================================================== */

/* --- Wordmark ----------------------------------------------------------- */

.ema-wordmark {
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    font-size: 1.05rem;
    color: var(--primary);
}

/* --- Language switch ---------------------------------------------------- */
/* The theme has no bilingual control; everything around it is its own. The
   page title and the topbar are `.page-header` and `.header`, not a layout
   invented here. */

.ema-lang .btn { font-size: .75rem; padding: .2rem .6rem; }

/* --- Pages with no sidebar ---------------------------------------------- */
/* Landing, signup and sign-in have no navigation to show yet, so the theme's
   sidebar offset has to be removed and the content centred instead. */

.page-wrapper.ema-no-sidebar { margin-left: 0; }

.page-wrapper.ema-no-sidebar .content {
    max-width: 52rem;
    margin-inline: auto;
}

/* Sign-in is narrower than a working screen: a single decision, no scanning. */
.ema-narrow { max-width: 26rem; margin-inline: auto; }

/* --- Module rows -------------------------------------------------------- */
/* Built from the theme's card, with one addition: a coloured left edge so
   which modules a customer actually runs reads at a glance, before any label
   is read. */

.ema-module { border-left: 3px solid transparent; }
.ema-module.is-on { border-left-color: var(--success); }
.ema-module.is-off { opacity: .6; }

/* --- Forfait cards ------------------------------------------------------ */
/* The opening screen. Each card is one trade and the whole card is the click
   target (stretched-link), so the hover has to move — a card that looks inert
   under the cursor reads as a heading, not as a choice. */

.ema-forfait { transition: border-color .12s ease, box-shadow .12s ease; }

.ema-forfait:hover,
.ema-forfait:focus-within {
    border-color: var(--bs-primary, #3b7ddd);
    box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .06);
}

/* The "I choose myself" door is a card like the others but must not compete
   with them: dashed, so it reads as an exit rather than a tenth trade. */
.ema-forfait-other { border-style: dashed; }

/* Suggested, deliberately NOT ticked. Dashed for the same reason the badge is
   not filled: the eye must not price it in. */
.ema-forfait-suggested {
    border: 1px dashed var(--bs-border-color, #dee2e6);
    font-weight: 400;
}

/* --- Data tables -------------------------------------------------------- */
/* Label-and-value tables: the fact on the right, what it is on the left.
   The theme pads a `td` by 12px/16px and centres it, but leaves a `th` at 4px
   aligned to the top — so every label sat high and left of its own value, on
   this screen and on each of the detail pages. Matching them is the whole
   fix. */

.ema-facts th {
    font-weight: 500;
    color: var(--gray-600);
    width: 16rem;
    padding: .75rem 1rem;
    vertical-align: middle;
}

/* Tax numbers, quantities and totals are read as columns of figures. */
.ema-facts td, .ema-mono { font-variant-numeric: tabular-nums; }

@media (max-width: 36rem) {
    .ema-facts th, .ema-facts td { display: block; width: auto; }
    .ema-facts th { border-bottom: 0; padding-bottom: 0; }
}

/* --- Signup address field ----------------------------------------------- */
/* The one place this product differs from a generic signup: the customer is
   claiming an address, so the host they are about to own is shown inline. */

.ema-host { display: flex; align-items: stretch; }

.ema-host input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    font-family: var(--bs-font-monospace, monospace);
}

.ema-host .ema-host-suffix {
    display: flex;
    align-items: center;
    padding: 0 .75rem;
    border: 1px solid var(--bs-border-color);
    border-left: 0;
    border-top-right-radius: var(--bs-border-radius);
    border-bottom-right-radius: var(--bs-border-radius);
    background: var(--bs-secondary-bg, #f4f4f4);
    color: var(--gray-600);
    font-family: var(--bs-font-monospace, monospace);
    font-size: .85rem;
    white-space: nowrap;
}

/* --- Action principale d'une liste -------------------------------------- */
/* É-3 : le bouton du haut à droite échappe à l'œil. Celui du corps de page
   prend toute la largeur sur mobile — là où le pouce le cherche — et se réduit
   à son texte dès qu'il y a de la place, pour qu'une liste de cinquante lignes
   ne soit pas coiffée d'une bannière. Bootstrap n'a pas de `w-sm-auto`. */

@media (min-width: 576px) {
    .w-sm-auto { width: auto !important; }
}

/* --- Sidebar: the menu flows, it does not stretch ----------------------- */
/* The theme sets justify-content:space-between on .sidebar-menu, which
   glues the LAST section to the bottom of the screen — with a short trade
   menu (salon, CRM) the gap looks like a defect (Martin, 2026-08-04:
   « collé sur le bas de mon écran, on dirait un défaut »). Sections follow
   each other naturally instead. */
.sidebar .sidebar-menu,
.sidebars .sidebar-menu {
    justify-content: flex-start;
}

/* --- Every page breathes at the bottom -------------------------------- */
/* The content used to end flush against the viewport's bottom edge —
   « beaucoup trop collé sur le bas de mon écran » (Martin, 2026-08-04).
   One rule, every screen: room under the last card, the last button,
   the last row. */
.page-wrapper .content {
    padding-bottom: 64px;
}

/* --- The sidebar scrolls, UNDER the logo band --------------------------- */
/* The menu is taller than the screen and its fixed column did not scroll:
   « on voit Administration mais il n'y a rien en dessous » (Martin,
   2026-08-04) — the entries were rendered but unreachable. The theme
   expects a scroll plugin we do not ship; plain overflow does the job.

   Then the band itself (Martin, 2026-08-14 : « les éléments du side bar se
   glissent derrière le logo du client ») : the theme reserves EXACTLY 56px
   for the logo, but a two-line wordmark — EMBALLAGE CODERRE — is taller
   than that, and the band had no background, so the menu visibly slid
   through the letters. The column is now a real flex stack: the band is a
   solid block that takes the height IT needs (56px minimum, so one-line
   brands keep the exact old geometry), and the menu gets the rest. */
.sidebar {
    display: flex;
    flex-direction: column;
}
.sidebar .sidebar-logo {
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    min-height: 56px;
    background: var(--menu-bg, var(--light));
}
.sidebar .sidebar-inner {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow-y: auto;
    padding-bottom: 32px;
    scrollbar-width: thin;
}
/* The 56px the theme pushed the menu down by is now real space taken by
   the band — pushing again would double it. */
.sidebar .sidebar-menu {
    margin-top: 0;
}

/* --- Finger-first controls --------------------------------------------- */
/* « Ça doit aller vite, souvent sur un écran touch » (Martin, 2026-08-04) :
   the theme's office-sized cells punish fingers. One pass: every input,
   select and button reaches the 44px touch standard. The -sm variants
   (dense read tables, inline rows) keep their size on purpose. */
.content .form-control:not(.form-control-sm),
.content .form-select:not(.form-select-sm) {
    min-height: 44px;
    font-size: 1rem;
}
.content .btn:not(.btn-sm):not(.btn-close) {
    min-height: 44px;
    padding-top: .5rem;
    padding-bottom: .5rem;
    font-size: 1rem;
}
.content .form-check-input {
    width: 1.4em;
    height: 1.4em;
}

/* --- The board rail ----------------------------------------------------- */
/* More chairs than screen: the columns become a swipeable rail (arrows
   appear only when it overflows — Martin, 2026-08-04). */
.salon-rail { overflow-x: auto; scroll-behavior: smooth; padding-bottom: 6px; scrollbar-width: thin; }
.salon-colonne { flex: 0 0 20rem; min-width: 20rem; }

/* Les valeurs des fiches sont CENTRÉES (règle Martin, 2026-08-05 —
   « quand tu affiches des données, affiche-les centrées »). */
.ema-facts td { text-align: center; }

/* --- Le calendrier au-dessus de la modale ------------------------------ */
/* Martin, 2026-08-15 : « échéance n'a pas de calendrier » — flatpickr
   s'initialisait bien dans la modale, mais son calendrier (accroché au
   <body>) se dessinait DERRIÈRE la fenêtre Bootstrap (z-index 1055).
   Il passe devant, partout. */
.flatpickr-calendar {
    z-index: 2000 !important;
}

/* --- LE MENU SOUS 992 px (Martin, 2026-08-15 : « je vois pas la side bar »)
   Le thème réduit `.two-col-sidebar` à width:0 sous 992 px et cache sa
   colonne d'icônes : la navigation disparaît, et rien ne la rouvre. Le ☰ du
   topbar bascule `.ema-menu-ouvert` sur le wrapper ; la barre revient en
   panneau, un voile la referme. Rien de tout ceci n'existe au-dessus de
   992 px, où la barre tient sa place normale. ---------------------------- */
.ema-menu-toggle { display: none; }
.ema-menu-voile { display: none; }

@media (max-width: 991.98px) {
    .ema-menu-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        font-size: 1.25rem; line-height: 1; padding: .35rem .7rem;
        margin-right: .5rem; border-radius: .5rem;
    }

    .main-wrapper.ema-menu-ouvert .two-col-sidebar { width: auto; }

    .main-wrapper.ema-menu-ouvert .two-col-sidebar .sidebar {
        position: fixed; top: 0; left: 0; width: 276px; height: 100vh;
        overflow-y: auto; z-index: 1046;
        background: var(--menu-bg, #f7f8f9);
        box-shadow: 0 0 40px rgba(5, 19, 33, .25);
    }

    .main-wrapper.ema-menu-ouvert .ema-menu-voile {
        display: block; position: fixed; inset: 0; z-index: 1045;
        background: rgba(5, 19, 33, .45);
    }
}
