/* ==========================================================================
   Stackly — Ancien vocabulaire global
   Ce qui reste de la feuille d'avant la refonte : les elements nus (titres,
   tableaux, champs), les classes .btn / .card / .form-* / .alert / .badge
   encore posees par des gabarits non repris, et les styles partages des
   listes « Live Components » (.lc-*).

   Elle ne decrit PLUS le chassis : barre laterale, zone de contenu et menu
   mobile vivent dans shell.css, seul proprietaire. Les regles de chassis qui
   se battaient ici avec lui a coups de `!important` ont ete retirees, comme
   les classes que plus aucun gabarit ni script n'emploie (grille .col-md-*,
   utilitaires .mt-* / .d-flex, cartes .stat-card, .model-card, barres
   .module-nav, liste .lc-event-*...).

   Tout est ecrit contre tokens.css. Charge avant shell.css et components.css.
   ========================================================================== */

/* ---------- Alias de l'ancienne charte ------------------------------------
   Une quarantaine de feuilles de module lisent encore ces noms. Ils pointent
   desormais vers les jetons. Poses sur `body` et non sur `:root` : --primary
   suit l'accent de l'outil, et une variable calculee sur :root resterait figee
   sur la teinte par defaut.
   ------------------------------------------------------------------------ */
:root,
body {
    --primary:       var(--accent-solid);
    --primary-50:    var(--accent-tint-2);
    --primary-hover: var(--accent-ink);
    --secondary:     var(--accent-ink);

    --gray-50:  var(--surface-muted);
    --gray-100: var(--surface-sunken);
    --gray-200: var(--border);
    --gray-300: var(--border-strong);
    --gray-400: var(--ink-faint);
    --gray-500: var(--ink-muted);
    --gray-600: var(--ink-muted);
    --gray-700: var(--ink-secondary);
    --gray-900: var(--ink);
    --white:    var(--surface);

    --text-primary:   var(--ink);
    --text-secondary: var(--ink-muted);
    --border-color:   var(--border);
    --bg-base:        var(--surface);
    --bg-subtle:      var(--surface-muted);

    --radius-sm:  var(--radius-chip);
    --radius-md:  var(--radius-field);
    --radius-lg:  var(--radius-card);
    --radius-xlg: var(--radius-button);

    --shadow-sm: var(--shadow-1);
    --shadow:    var(--shadow-1);
    --shadow-md: var(--shadow-2);
    --shadow-lg: var(--shadow-3);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ---------- Titres ---------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
    margin-bottom: 0.65rem;
    color: var(--ink);
    font-weight: var(--weight-semibold);
    line-height: 1.25;
}

h1 { font-size: var(--text-title-1); }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
h5 { font-size: 14px; }

.lead {
    color: var(--ink-secondary);
    font-size: var(--text-body-lg);
    font-weight: var(--weight-regular);
}

/* ---------- Conteneurs ------------------------------------------------------ */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-6);
}

main {
    min-height: calc(100vh - 140px);
    padding: 1.75rem 0;
}

/*  Grille heritee. Les classes .row / .col-md-* ne sont plus posees nulle
    part, mais le selecteur d'attribut attrape encore quatre classes de module
    dont le nom contient « col- » (.mg-col--right, .sk-col-grid...) et leur
    donne leur marge interieure. Conserve tel quel pour ne pas les decaler. */
[class*="col-"] {
    padding: 0 1rem;
}

@media (max-width: 768px) {
    [class*="col-"] { width: 100%; }
}

/* ---------- Boutons herites --------------------------------------------------
   Les ecrans repris utilisent .ui-btn (components.css). Celui-ci en reprend
   l'allure pour que les deux familles ne jurent pas sur un meme ecran.
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--control-md);
    padding: 0 var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius-button);
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: var(--weight-medium);
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease),
                border-color var(--duration-fast) var(--ease),
                color var(--duration-fast) var(--ease);
}

.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-solid);
    color: var(--ink-on-dark);
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(0.92);
    color: var(--ink-on-dark);
}

.btn-outline {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--ink);
}

.btn-outline:hover:not(:disabled) {
    background: var(--surface-sunken);
    color: var(--ink);
}

.btn-danger {
    background: var(--surface);
    border-color: var(--danger);
    color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-tint);
    color: var(--danger);
}

.btn-sm {
    min-height: var(--control-sm);
    padding: 0 var(--space-3);
    font-size: var(--text-sm);
}

.btn-lg {
    min-height: var(--control-lg);
    padding: 0 var(--space-6);
    font-size: 15px;
}

/* ---------- Cartes heritees ------------------------------------------------- */

.card {
    overflow: hidden;
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
}

/* ---------- Champs herites -------------------------------------------------- */

.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    margin-bottom: 6px;
    color: var(--ink-secondary);
    font-size: 14px;
    font-weight: var(--weight-medium);
}

.form-control,
.form-select {
    width: 100%;
    min-height: var(--field-height);
    padding: 0 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-field);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    transition: border-color var(--duration-fast) var(--ease),
                box-shadow var(--duration-fast) var(--ease);
}

textarea.form-control {
    min-height: 100px;
    padding: 11px 13px;
    resize: vertical;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring-field);
}

.form-control:disabled {
    background: var(--surface-sunken);
    cursor: not-allowed;
}

/* ---------- Encarts herites ------------------------------------------------- */

.alert {
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink-secondary);
    font-size: 14px;
}

/* ---------- Tableaux --------------------------------------------------------
   En-tetes en casse normale, 13 px, gris lisible. Pas de bandes zebrees.
   -------------------------------------------------------------------------- */

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

th {
    padding: 10px var(--space-3);
    border-bottom: 1px solid var(--border);
    color: var(--ink-muted);
    font-size: var(--text-label);
    font-weight: var(--weight-medium);
    text-align: left;
    white-space: nowrap;
}

td {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--ink);
    font-size: 14px;
}

tbody tr:hover {
    background: var(--surface-muted);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------- Pastilles heritees ----------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 9px;
    border-radius: var(--radius-pill);
    background: var(--surface-sunken);
    color: var(--ink-secondary);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    white-space: nowrap;
}

/* ---------- Utilitaires encore employes ------------------------------------- */

.text-center { text-align: center; }
.text-right  { text-align: right; }

/* ---------- Pied de page public ------------------------------------------- */

footer {
    margin-top: auto;
    padding: 0.2rem 0;
    background: var(--surface);
}

.footer-text {
    text-align: center;
}

/* ---------- Apparition ----------------------------------------------------- */

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* ==========================================================================
   Adaptations
   ========================================================================== */

@media (max-width: 991.98px) {
    /*  LE PIEGE. Cette regle impose 800 px a tout tableau qui ne s'est pas
        explicitement exclu. Tout tableau destine a se replier en cartes doit
        figurer ici (voir tests/Unit/Css/TableauxMobilesTest.php). Celui qui
        n'y figure pas defile lateralement dans son conteneur, ce qui reste un
        choix valable pour un tableau dense.  */
    table:not(.table-mobile-cards):not(.stats-table):not(.ui-table--stack) {
        min-width: 800px;
    }
}

/*  Tableau herite replie en cartes sur telephone. Les deux definitions
    (ici et dans l'ancienne shell-legacy.css) sont reunies. */
@media (max-width: 767.98px) {
    .table-mobile-cards {
        display: block;
        width: 100%;
        min-width: 0;
        table-layout: auto;
    }

    .table-mobile-cards thead { display: none; }

    .table-mobile-cards tbody,
    .table-mobile-cards tr {
        display: block;
        width: 100%;
    }

    .table-mobile-cards tr {
        margin-bottom: var(--space-3);
        padding: var(--space-3) var(--space-4);
        border: 1px solid var(--border);
        border-radius: var(--radius-card);
        background: var(--surface);
        box-shadow: var(--shadow-1);
    }

    .table-mobile-cards td {
        display: block;
        padding: 6px 0;
        border: none;
        border-bottom: 1px solid var(--border-subtle);
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .table-mobile-cards td:last-child { border-bottom: none; }

    .table-mobile-cards td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 2px;
        color: var(--ink-muted);
        font-size: var(--text-xs);
        font-weight: var(--weight-medium);
    }

    /* Le texte « Page 2 sur 5 » cede la place aux seules fleches. */
    .pagination-text { display: none; }
}

@media (max-width: 575.98px) {
    .container { padding: var(--space-4); }
    .card { padding: var(--space-4); }
}

@media print {
    .btn { display: none; }
}

/* Mouvement reduit : aucune animation ni transition ne s'impose. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Live Components — styles partages
   Listes clients, documents, paiements. Alignees sur le vocabulaire de
   components.css : carte blanche, en-tetes en casse normale, pastilles.
   ========================================================================== */

/* --- Barre de filtres --- */
.lc-filters {
    margin-bottom: var(--space-5);
    padding: var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
}

.lc-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.lc-label {
    display: block;
    margin-bottom: 6px;
    color: var(--ink-secondary);
    font-size: 14px;
    font-weight: var(--weight-medium);
}

.lc-input,
.lc-select {
    width: 100%;
    min-height: var(--field-height);
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-field);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
}

.lc-input:focus,
.lc-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring-field);
}

.lc-filter-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.lc-btn-reset {
    min-height: var(--control-md);
    padding: 0 var(--space-4);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease);
}

.lc-btn-reset:hover { background: var(--surface-sunken); }

.lc-count {
    color: var(--ink-muted);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.lc-count-primary {
    color: var(--ink);
    font-size: 14px;
    font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums;
}

/* --- Tableau --- */
.lc-table-container {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
}

.lc-table-scroll {
    overflow-x: auto;
}

.lc-table {
    width: 100%;
    border-collapse: collapse;
}

.lc-table th {
    height: 40px;
    padding: 0 var(--space-4);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink-muted);
    font-size: var(--text-label);
    font-weight: var(--weight-medium);
    text-align: left;
    white-space: nowrap;
}

.lc-table td {
    height: var(--row-height);
    padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--ink);
    font-size: 14px;
    vertical-align: middle;
}

.lc-table tbody tr:last-child td { border-bottom: none; }

.lc-table th.text-right,
.lc-table td.text-right {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.lc-table th.text-center,
.lc-table td.text-center {
    text-align: center;
}

.lc-table td.fw-bold,
.lc-table td.fw-semibold {
    color: var(--ink);
    font-weight: var(--weight-semibold);
}

.lc-table td.text-dark {
    color: var(--ink);
}

.lc-table tbody tr {
    transition: background var(--duration-fast) var(--ease);
}

.lc-table tbody tr:hover {
    background: var(--surface-muted);
}

/* --- Pastilles ---
   Une pastille ne passe jamais a la ligne et ne deborde jamais. */
.lc-badge {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 9px;
    border-radius: var(--radius-pill);
    background: var(--surface-sunken);
    color: var(--ink-secondary);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    white-space: nowrap;
}

/* Type de fiche */
.lc-badge--type-client   { background: var(--success-tint); color: var(--success-ink); }
.lc-badge--type-prospect { background: var(--info-tint);    color: var(--info-ink); }

/* Etape commerciale */
.lc-badge--statut-lead,
.lc-badge--statut-qualifie     { background: var(--surface-sunken); color: var(--ink-secondary); }
.lc-badge--statut-gagne        { background: var(--success-tint);   color: var(--success-ink); }
.lc-badge--statut-perdu        { background: var(--danger-tint);    color: var(--danger-ink); }
.lc-badge--statut-negociation  { background: var(--warning-tint);   color: var(--warning-ink); }

/* Type de document : la teinte de l'outil Documents, en plusieurs nuances. */
.lc-badge--doc-facture     { background: var(--success-tint);   color: var(--success-ink); }
.lc-badge--doc-devis       { background: var(--info-tint);      color: var(--info-ink); }
.lc-badge--doc-commande    { background: var(--warning-tint);   color: var(--warning-ink); }
.lc-badge--doc-bon-travail { background: var(--mod-documents-tint); color: var(--mod-documents-ink); }
.lc-badge--doc-avoir       { background: var(--danger-tint);    color: var(--danger-ink); }

/* Mode et etat de paiement */
.lc-badge--method        { background: var(--surface-sunken); color: var(--ink-secondary); }
.lc-badge--pay-received  { background: var(--success-tint);   color: var(--success-ink); }
.lc-badge--pay-pending   { background: var(--warning-tint);   color: var(--warning-ink); }
.lc-badge--pay-cancelled { background: var(--danger-tint);    color: var(--danger-ink); }

/* --- Etat vide --- */
.lc-empty {
    padding: var(--space-12) var(--space-6);
    color: var(--ink-muted);
    text-align: center;
}

.lc-empty-icon {
    display: block;
    margin-bottom: var(--space-3);
    color: var(--ink-faint);
    font-size: 32px;
}

.lc-empty p {
    margin: 0;
    color: var(--ink);
    font-size: 16px;
    font-weight: var(--weight-medium);
}

.lc-empty p + p {
    margin-top: var(--space-2);
    color: var(--ink-muted);
    font-size: 14px;
    font-weight: var(--weight-regular);
}

/* --- Actions de ligne --- */
.lc-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}

.lc-btn-edit,
.lc-btn-delete {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: var(--control-sm);
    padding: 0 var(--space-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: var(--weight-medium);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease);
}

.lc-btn-edit:hover {
    background: var(--surface-sunken);
    color: var(--ink);
}

.lc-btn-edit--sm {
    height: 32px;
    padding: 0 10px;
    font-size: var(--text-sm);
}

.lc-btn-delete {
    color: var(--danger);
}

.lc-btn-delete:hover {
    background: var(--danger-tint);
}

/* --- Pagination --- */
.lc-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border);
}

.lc-pagination--mt {
    margin-top: var(--space-6);
    padding: 0;
    border-top: none;
    gap: var(--space-4);
}

.lc-btn-page {
    min-height: var(--control-sm);
    padding: 0 var(--space-4);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: var(--weight-medium);
    cursor: pointer;
}

.lc-btn-page:hover:not(:disabled) {
    background: var(--surface-sunken);
}

.lc-btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lc-page-info {
    padding: 0 var(--space-3);
    color: var(--ink-secondary);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

/* --- Divers --- */
.lc-link {
    color: var(--accent-ink);
    text-decoration: none;
}

.lc-link:hover {
    text-decoration: underline;
}

.lc-muted {
    color: var(--ink-muted);
}

.lc-filter-end {
    display: flex;
    align-items: flex-end;
}

.lc-form-inline {
    display: inline;
}

.lc-filter-stats {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}
