/* Global custom styles. Per-subdomain styles live in templates' own asset entrypoints. */

body {
    min-height: 100vh;
}

/* Required-field marker.
 * Symfony's bootstrap_5_layout form theme adds the "required" class on the <label> of any
 * field whose constraint resolves to required (default true unless 'required' => false on
 * the field). Project rule: every required field shows a red asterisk after its label.
 * Single source of truth — no per-template tweak needed. */
label.required::after,
.form-label.required::after,
legend.required::after {
    content: " *";
    color: #dc3545;
    font-weight: 700;
}

/* …but not on the per-option labels of an expanded choice (radios / checkboxes).
 * The asterisk belongs on the field label only, not on every "Secondes / Répétitions / …"
 * choice. Bootstrap 5 form theme tags those with .form-check-label. */
.form-check-label.required::after,
.form-check label.required::after {
    content: none;
}

/* Input readonly piloté par un controller Stimulus de liaison (ex.
 * ascent-descent-link). Visuel "verrouillé" qui se distingue d'un input
 * vide normal sans utiliser :disabled (qui empêcherait la soumission de
 * la valeur côté form Symfony). */
input.field-locked {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
}
input.field-locked:focus {
    box-shadow: none;
    border-color: #e5e7eb;
}

/* === Combobox — sélecteur filtrant (wrap d'un <select> natif) ========
 * Composant PARTAGÉ : utilisé dans tous les modules via le controller
 * Stimulus `combobox`. Le CSS vit ici (global) et non dans un CSS de
 * module — sinon le combobox apparaît non stylé (liste à puces brute)
 * sur les pages d'un autre module. Couleurs neutres via les variables
 * Bootstrap (dark mode géré automatiquement). */
.bk-combobox { position: relative; }
.bk-combobox__input {
    width: 100%;
    cursor: text;
}
.bk-combobox__list {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: 1080; /* au-dessus du corps d'une modale Bootstrap */
    max-height: 18rem;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem 0;
    list-style: none;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.bk-combobox__group {
    padding: 0.35rem 0.75rem 0.3rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color, #6c757d);
    font-weight: 700;
    background: var(--bs-tertiary-bg, #f8f9fa);
    border-top: 1px solid var(--bs-border-color, #dee2e6);
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}
.bk-combobox__group:first-child { border-top: 0; }
.bk-combobox__item {
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--bs-body-color, #212529);
}
.bk-combobox__item:hover,
.bk-combobox__item.is-active {
    background: var(--bs-tertiary-bg, #f1f3f5);
    color: var(--bs-emphasis-color, #000);
}
/* Nœud parent non sélectionnable (arbre de comptes / catégories). */
.bk-combobox__parent {
    padding: 0.3rem 0.75rem 0.15rem 1rem;
    font-weight: 600;
    color: var(--bs-emphasis-color, #000);
    font-size: 0.85rem;
    cursor: default;
    user-select: none;
}
.bk-combobox__parent::before {
    content: '▾ ';
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.75rem;
    margin-right: 0.15rem;
}
/* Feuille enfant indentée sous son parent. */
.bk-combobox__item--child {
    padding-left: 2.25rem;
    position: relative;
}
.bk-combobox__item--child::before {
    content: '↳';
    position: absolute;
    left: 1.1rem;
    color: var(--bs-secondary-color, #6c757d);
}

/* Layout 2 colonnes pour les options qui exposent leurs soldes (.bk-combobox__bals) :
   nom du compte à gauche, paire « Bancaire / Réel » alignée à droite. Marche
   aussi sur les parents non sélectionnables (solde agrégé des enfants). Le
   `flex-wrap: nowrap` est explicite pour garantir que les 2 montants restent
   sur la même ligne que le nom même quand l'option est un sous-compte indenté
   ou que le nom est long (le nom tronque avec ellipsis). */
.bk-combobox__item:has(.bk-combobox__bals),
.bk-combobox__parent:has(.bk-combobox__bals) {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}
.bk-combobox__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Bloc de droite qui regroupe les 2 montants — séparateur visuel discret
   entre B et R via border-left sur le 2e item. flex-shrink: 0 pour que ce
   soit le nom (à gauche) qui rétrécisse en cas de manque de place, jamais
   les soldes (sinon ils wraperaient sur 2 lignes). */
.bk-combobox__bals {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    display: inline-flex;
    align-items: baseline;
    gap: 0.5rem;
    font-variant-numeric: tabular-nums;
}
.bk-combobox__bal {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    justify-content: flex-end;
}
.bk-combobox__bal + .bk-combobox__bal {
    padding-left: 0.5rem;
    border-left: 1px solid var(--bs-border-color, #dee2e6);
}
/* Badge gris discret « B » / « R » devant chaque montant pour distinguer
   d'un coup d'œil quel solde on regarde, sans dépendre d'un tooltip. */
.bk-combobox__bal-tag {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--bs-secondary-color, #6c757d);
    background: var(--bs-tertiary-bg, #f1f3f5);
    padding: 0.05rem 0.3rem;
    border-radius: 0.25rem;
    line-height: 1;
}
/* Couleurs par signe — appliquées au wrapper, héritées par le texte ;
   les tags restent gris pour ne pas saturer visuellement. */
.bk-combobox__bal--pos  { color: var(--bs-success, #198754); }
.bk-combobox__bal--neg  { color: var(--bs-danger, #dc3545); }
.bk-combobox__bal--zero { color: var(--bs-secondary-color, #6c757d); }

/* Preview du solde du compte sélectionné, posée sous le combobox.
   Reprend les mêmes briques (.bk-combobox__bal*) mais en plus grand
   et avec un fond subtil pour bien la détacher du champ form.
   `display: flex` (block-level) + `width: 100%` pour que la preview
   occupe toute la largeur du champ, et chaque solde prend exactement
   50% via `flex: 1 1 0`. Visuellement plus équilibré que la version
   inline-flex « ajustée au contenu ». */
.bk-balance-preview-slot:empty { display: none; }
.bk-balance-preview {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    width: 100%;
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
    border: 1px solid var(--bs-border-color, #dee2e6);
    font-variant-numeric: tabular-nums;
}
.bk-balance-preview .bk-combobox__bal {
    flex: 1 1 0;              /* 50/50 strict entre Bancaire et Réel */
    font-size: 0.95rem;       /* > 0.82rem du dropdown */
    justify-content: flex-start;
}
.bk-balance-preview .bk-combobox__bal + .bk-combobox__bal {
    padding-left: 0.9rem;
    margin-left: 0.5rem;
    border-left: 1px solid var(--bs-border-color, #dee2e6);
}
.bk-balance-preview .bk-combobox__bal-tag {
    font-size: 0.7rem;
}

/* ═══════════════════════════════════════════════════════════════════════
   Phone app shell (< 768 px): bottom tab bar + bottom sheets
   ═══════════════════════════════════════════════════════════════════════
   Shared by the module layouts that opt in with the body class
   `has-mobile-tabbar` (markup: _macros/mobile_tabbar.html.twig, sheets are
   Bootstrap `offcanvas-bottom.mz-sheet`). Each module only sets the --mz-*
   colour variables in its own stylesheet. Desktop never sees any of it. */
@media (max-width: 767.98px) {
    .has-mobile-tabbar { --mz-tabbar-h: 68px; }
    .has-mobile-tabbar > footer { display: none; }
    .has-mobile-tabbar #mainNav > .navbar-nav.me-auto { display: none; }
    .has-mobile-tabbar > main { padding-bottom: calc(var(--mz-tabbar-h) + 24px + env(safe-area-inset-bottom)); }

    .mz-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1035;
        height: calc(var(--mz-tabbar-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        align-items: center;
        background: var(--mz-tabbar-bg);
        border-top: 1px solid var(--mz-line);
    }
    .mz-tabbar__item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 52px;
        border: 0;
        background: transparent;
        color: var(--mz-muted);
        font: inherit;
        font-size: 11px;
        font-weight: 600;
        text-decoration: none;
    }
    .mz-tabbar__item .bi { font-size: 1.35rem; line-height: 1; }
    .mz-tabbar__item.is-active { color: var(--mz-accent); font-weight: 700; }
    /* Optional count on a tab (macro `badge`), pinned to the icon's corner. */
    .mz-tabbar__item { position: relative; }
    .mz-tabbar__badge {
        position: absolute;
        top: 4px;
        left: calc(50% + 6px);
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: 999px;
        background: var(--mz-accent);
        color: var(--mz-page-bg);
        font-size: 11px;
        font-weight: 800;
        line-height: 18px;
        text-align: center;
    }
    .mz-tabbar__add {
        justify-self: center;
        width: 58px;
        height: 58px;
        margin-top: -26px;
        border-radius: 50%;
        display: grid;
        place-items: center;
        background: var(--mz-add-bg);
        color: var(--mz-add-fg);
        font-size: 1.7rem;
        box-shadow: 0 6px 18px rgba(0, 0, 0, .35), 0 0 0 5px var(--mz-page-bg);
        text-decoration: none;
        border: 0; /* also rendered as a <button> when it opens a sheet */
        padding: 0;
    }
    .mz-tabbar__add:hover { color: var(--mz-add-fg); }
    .mz-tabbar__add.is-active { filter: brightness(1.12); }

    .mz-sheet.offcanvas-bottom {
        --bs-offcanvas-height: auto;
        --bs-offcanvas-bg: var(--mz-sheet-bg);
        --bs-offcanvas-color: var(--mz-sheet-fg);
        max-height: 82vh;
        border-radius: 22px 22px 0 0;
        border-top: 1px solid var(--mz-line) !important;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .mz-sheet .offcanvas-title { font-size: 1.1rem; font-weight: 800; }
    .mz-sheet .offcanvas-body { padding-top: 0; }
    .mz-sheet__group {
        margin: 14px 4px 6px;
        font-size: .75rem;
        font-weight: 700;
        letter-spacing: .06em;
        text-transform: uppercase;
        color: var(--mz-muted);
    }
    .mz-sheet__list {
        list-style: none;
        margin: 0;
        padding: 0;
        border-radius: 16px;
        overflow: hidden;
        border: 1px solid var(--mz-line);
    }
    .mz-sheet__list li + li { border-top: 1px solid var(--mz-line); }
    .mz-sheet__parent { padding: 10px 14px 4px; font-size: .8rem; font-weight: 700; color: var(--mz-muted); }
    .mz-sheet__link {
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: 50px;
        padding: 0 14px;
        color: var(--mz-sheet-fg);
        font-weight: 600;
        text-decoration: none;
    }
    .mz-sheet__link--child { padding-left: 26px; }
    .mz-sheet__link.is-active { color: var(--mz-accent); background: var(--mz-sheet-active-bg); }
    .mz-sheet__grid {
        list-style: none;
        margin: 4px 0 8px;
        padding: 0;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
    }
    .mz-sheet__tile {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 78px;
        padding: 8px 4px;
        border-radius: 16px;
        background: var(--mz-sheet-soft);
        border: 1px solid var(--mz-line);
        color: var(--mz-sheet-fg);
        font-size: 12px;
        font-weight: 600;
        text-align: center;
        text-decoration: none;
    }
    .mz-sheet__tile .bi { font-size: 1.4rem; color: var(--mz-accent); }
    .mz-sheet__tile.is-active { border-color: var(--mz-accent); }
}
