/*
 * Thème du CRM — habille Filament aux couleurs du site vitrine.
 *
 * Source des tokens : .claude/skills/aitana-design/SKILL.md. Palette stricte,
 * DM Sans, filets fins plutôt qu'ombres, angles droits, rouge en accent.
 *
 * Ce fichier n'est PAS compilé par Vite : il est servi tel quel par
 * FilamentAsset, après le CSS de Filament. Ses règles, hors `@layer`, l'emportent
 * donc sur celles de Filament.
 */

:root {
    --crm-noir: #212121;
    --crm-gris-clair: #f2f2f2;
    --crm-gris-427: #d2d3d4;
    --crm-gris-cool: #7d7f82;
    --crm-rouge: #ba0001;
    --crm-label-tracking: 0.16em;
    --crm-touch: 2.75rem; /* cible tactile minimale */
}

/* ── Base ─────────────────────────────────────────────────────────── */

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body,
.fi-body,
.fi-layout {
    background-color: var(--crm-gris-clair);
    color: var(--crm-noir);
}

::selection {
    background: var(--crm-rouge);
    color: var(--crm-gris-clair);
}

:focus-visible {
    outline: 2px solid var(--crm-rouge);
    outline-offset: 2px;
}

/* Jamais de scroll horizontal de la page : seuls le tableau et le Kanban défilent. */
html,
body {
    overflow-x: hidden;
}

/* ── Bandeau du haut (navigation) ─────────────────────────────────── */

.fi-topbar {
    background: var(--crm-gris-clair);
    border-bottom: 1px solid var(--crm-gris-427);
    box-shadow: none;
    --tw-ring-shadow: 0 0 #0000;
}

.fi-topbar nav {
    background: transparent;
    box-shadow: none;
}

.fi-topbar-item-btn {
    border-radius: 0;
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: var(--crm-label-tracking);
}

.fi-topbar-item.fi-active .fi-topbar-item-btn {
    color: var(--crm-rouge);
    background: transparent;
}

.fi-logo {
    height: 1.75rem;
}

/* Écran de connexion : le logo prend la place que le site lui donne. */
.fi-simple-layout .fi-logo {
    height: 2.75rem !important;
}

.fi-simple-layout {
    background: var(--crm-gris-clair);
}

.fi-simple-main {
    border-radius: 0;
    box-shadow: none;
    background: #fff;
    border: 1px solid var(--crm-gris-427);
    --tw-ring-shadow: 0 0 #0000;
}

/* ── Titres de page ───────────────────────────────────────────────── */

.fi-header-heading,
.fi-simple-header-heading {
    font-weight: 300;
    font-size: clamp(1.75rem, 4.4vw, 2.75rem);
    line-height: 1.1;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.fi-simple-header-heading {
    font-size: clamp(1.5rem, 5vw, 1.875rem);
    text-align: center;
}

.fi-header-subheading,
.fi-section-header-description {
    color: var(--crm-gris-cool);
}

.fi-modal-heading {
    font-weight: 400;
}

/* ── Cadres : filets, angles droits, pas d'ombre ──────────────────── */

.fi-section,
.fi-ta-ctn,
.fi-wi-stats-overview-stat,
.fi-modal-window {
    border-radius: 0;
    box-shadow: none;
    --tw-shadow: 0 0 #0000;
    --tw-ring-shadow: 0 0 #0000;
    border: 1px solid var(--crm-gris-427);
    background: #fff;
}

.fi-tabs {
    overflow-x: auto;
    scrollbar-width: none;
}

.fi-tabs::-webkit-scrollbar {
    display: none;
}

.fi-input-wrp,
.fi-btn,
.fi-badge,
.fi-dropdown-list-item,
.fi-icon-btn {
    border-radius: 0;
}

.fi-input-wrp {
    box-shadow: none;
    --tw-ring-shadow: 0 0 #0000;
    border: 1px solid var(--crm-gris-427);
    background: #fff;
}

.fi-input-wrp:focus-within {
    border-color: var(--crm-noir);
    outline: 2px solid var(--crm-rouge);
    outline-offset: 2px;
}

.fi-input-wrp input:focus-visible,
.fi-input-wrp select:focus-visible,
.fi-input-wrp textarea:focus-visible {
    outline: none;
}

/* ── Étiquettes : MAJUSCULES espacées, comme sur le site ──────────── */

.fi-fo-field-label-content,
.fi-in-entry-label,
.fi-section-header-heading,
.fi-wi-stats-overview-stat-label {
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: var(--crm-label-tracking);
}

.fi-fo-field-label-content,
.fi-in-entry-label,
.fi-wi-stats-overview-stat-label {
    color: var(--crm-gris-cool);
}

.fi-tabs-item {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: var(--crm-label-tracking);
    white-space: nowrap;
    border-radius: 0;
    min-height: var(--crm-touch);
}

.fi-tabs-item.fi-active {
    box-shadow: inset 0 -2px 0 var(--crm-rouge);
    background: transparent;
}

/* ── Boutons ──────────────────────────────────────────────────────── */

.fi-btn {
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    box-shadow: none;
}

/* Bouton d'étape : le seul élément plein d'une ligne. Noir, rouge au survol. */
.fi-btn.fi-color-primary {
    background: var(--crm-noir);
    color: var(--crm-gris-clair);
    --tw-ring-shadow: 0 0 #0000;
}

.fi-btn.fi-color-primary:hover {
    background: var(--crm-rouge);
}

.fi-btn.fi-color-gray {
    background: #fff;
    border: 1px solid var(--crm-gris-427);
    color: var(--crm-noir);
    --tw-ring-shadow: 0 0 #0000;
}

.fi-btn.fi-color-gray:hover {
    border-color: var(--crm-noir);
}

/* ── Tableaux ─────────────────────────────────────────────────────── */

.fi-ta-ctn {
    overflow: hidden;
}

.fi-ta-header-cell {
    background: transparent;
    border-bottom: 1px solid var(--crm-noir);
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: var(--crm-label-tracking);
    color: var(--crm-gris-cool);
}

.fi-ta-row {
    transition: background-color 0.15s ease-out;
}

.fi-ta-row:hover {
    background: var(--crm-gris-clair);
}

.fi-ta-content {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Le nom passe à la ligne dans une largeur bornée (desktop) ; les colonnes
   sans contenu long gardent leur largeur naturelle. Sans ça, un texte long ne se coupe jamais
   et le tableau déborde, même sur grand écran. */
.crm-cell-name {
    min-width: 12rem;
}

.crm-cell-name,
.crm-cell-name * {
    white-space: normal;
    overflow-wrap: anywhere;
}

.crm-cell-name .fi-ta-text-description {
    color: var(--crm-noir);
    font-size: 1rem;
    line-height: 1.35;
    margin-top: 0.25rem;
}

/* Poste en clair, entreprise en dessous (cartes Kanban) : c'est ce qu'on scrute en premier. */
.crm-role {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.crm-role__company {
    color: var(--crm-gris-cool);
    font-size: 0.8125rem;
}

.crm-role__title {
    color: var(--crm-noir);
    font-weight: 400;
}

.crm-card .crm-role {
    margin-top: 0.25rem;
}

.crm-card .crm-role__title {
    font-size: 0.875rem;
}

/* Bouton LinkedIn : « in » blanc sur le bleu de la marque, pour repérer
   d'un coup d'œil le lien qui sort vers le profil. */
.fi-icon-btn.crm-linkedin {
    background: #0a66c2;
    color: #fff;
    border-radius: 0;
}

.fi-icon-btn.crm-linkedin:hover {
    background: #004182;
}

.crm-linkedin .crm-linkedin-logo {
    width: 1.125rem;
    height: 1.125rem;
    color: #fff;
}

.crm-advance {
    letter-spacing: 0.08em;
    text-align: center;
    line-height: 1.25;
}

/* Hors mobile, toute colonne autre que le nom prend exactement la largeur de
   son contenu. Sans ça, les boutons d'action (qui peuvent passer à la ligne,
   donc dont la largeur minimale est ridicule) sont comprimés par le tableau
   et débordent sur les cellules voisines. */
@media (min-width: 768px) {
    .fi-ta-table .fi-ta-cell:not(.crm-cell-name):not(.crm-cell-job):not(.crm-cell-company):not(.crm-cell-notes):not(.fi-ta-selection-cell) {
        width: 1%;
        white-space: nowrap;
    }

    /* Le poste et l'entreprise peuvent être longs : elle se replie dans une largeur bornée. */
    .crm-cell-name {
        width: 16rem;
        max-width: 16rem;
    }

    .crm-cell-company {
        width: 14rem;
        max-width: 14rem;
    }

    /* Le poste absorbe toute la place restante. */
    .crm-cell-job {
        width: 100%;
    }

    /* Le poste prime sur les notes : il garde au moins 18rem, les notes
       cèdent jusqu'à 12rem quand l'écran se resserre. */
    .crm-cell-job {
        min-width: 18rem;
    }

    .crm-cell-notes {
        width: 18rem;
        min-width: 12rem;
        max-width: 18rem;
    }

    .crm-cell-job,
    .crm-cell-company,
    .crm-cell-notes {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .fi-ta-table .fi-ta-cell .fi-ta-actions {
        flex-wrap: nowrap;
        justify-content: flex-end;
    }

    .crm-advance {
        white-space: nowrap;
    }
}

/* ── Badges de statut : filet + texte ─────────────────────────────── */

.fi-badge {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    --tw-ring-shadow: 0 0 #0000;
    border: 1px solid currentColor;
    background: transparent;
    white-space: nowrap;
}

/* ── Chiffres du tableau de bord ──────────────────────────────────── */

.fi-wi-stats-overview-stat-value {
    font-family: "DM Serif Display", ui-serif, Georgia, serif;
    font-weight: 400;
    font-size: clamp(2rem, 5vw, 2.75rem);
    letter-spacing: 0;
    line-height: 1.1;
}

.fi-wi-stats-overview-stat-description {
    color: var(--crm-gris-cool);
    font-size: 0.8125rem;
}

/* ── Notifications ────────────────────────────────────────────────── */

.fi-no-notification {
    border-radius: 0;
    box-shadow: none;
    border: 1px solid var(--crm-noir);
    background: #fff;
    --tw-ring-shadow: 0 0 #0000;
}

/* ── Kanban ───────────────────────────────────────────────────────── */

.crm-col {
    border-radius: 0;
    background: transparent;
    border: 1px solid var(--crm-gris-427);
    padding: 0.75rem;
}

.crm-col__header {
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: var(--crm-label-tracking);
    padding: 0 0 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--crm-noir);
}

.crm-col__count {
    background: transparent;
    border-radius: 0;
    color: var(--crm-gris-cool);
    padding: 0;
}

.crm-card {
    border-radius: 0;
    border: 1px solid var(--crm-gris-427);
    background: #fff;
    transition: border-color 0.15s ease-out;
}

.crm-card:hover {
    border-color: var(--crm-noir);
}

.crm-card__name {
    font-weight: 500;
}

.crm-card__meta,
.crm-card__age {
    color: var(--crm-gris-cool);
    opacity: 1;
}

.crm-card__age--stale {
    color: var(--crm-rouge);
    font-weight: 500;
}

.crm-card__advance {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--crm-rouge);
    min-height: var(--crm-touch);
    padding: 0 0.25rem;
}

.crm-kanban-more {
    min-height: var(--crm-touch);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.6875rem;
}

/* ── Mobile ───────────────────────────────────────────────────────── */

@media (max-width: 767px) {
    /* Champs à 16px minimum : en dessous, iOS zoome à la sélection. */
    input,
    select,
    textarea {
        font-size: 1rem !important;
    }

    .fi-btn,
    .fi-icon-btn,
    .fi-dropdown-list-item {
        min-height: var(--crm-touch);
    }

    .fi-icon-btn {
        min-width: var(--crm-touch);
    }

    /* Actions d'en-tête : sous le titre, larges, faciles à toucher. */
    .fi-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .fi-header-actions-ctn {
        flex-wrap: wrap;
    }

    .fi-header-actions-ctn .fi-btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    /* Tableau → liste de cartes. Chaque ligne est une grille :

         [AT]  Nom                       3 j
               Poste
               Entreprise
               │ aperçu des notes
               [STATUT]
         [ ÉTAPE SUIVANTE ────────── ]  ↗  ⋮

       Ce qu'on lit en premier (qui, quel poste) en haut, l'action en bas,
       sous le pouce. Plus aucun défilement latéral. */
    .fi-ta-table,
    .fi-ta-table tbody {
        display: block;
        width: 100%;
    }

    .fi-ta-table thead {
        display: none;
    }

    .fi-ta-table .fi-ta-row {
        display: grid;
        grid-template-columns: 2.5rem minmax(0, 1fr) auto;
        grid-template-areas:
            "avatar  name    since"
            "avatar  job     job"
            ".       company company"
            ".       notes   notes"
            ".       status  status"
            "actions actions actions";
        column-gap: 0.875rem;
        align-items: start;
        padding: 1rem;
        border-bottom: 1px solid var(--crm-gris-427);
    }

    /* `display: block` est voulu : il annule le masquage « grand écran
       seulement » de Filament (avatar, notes, ancienneté), que la carte
       affiche, elle, à sa place. */
    .fi-ta-table .fi-ta-cell {
        display: block;
        width: auto;
        min-width: 0;
        max-width: none;
        padding: 0;
        grid-column: 2 / -1;   /* colonnes ajoutées via le sélecteur : sous le reste */
    }

    .fi-ta-table .fi-ta-cell .fi-ta-col,
    .fi-ta-table .fi-ta-cell .fi-ta-text {
        padding: 0;
    }

    .fi-ta-table .fi-ta-cell-avatar {
        grid-area: avatar;
    }

    .fi-ta-table .crm-cell-name {
        grid-area: name;
        align-self: center;
    }

    .fi-ta-table .crm-cell-name .fi-ta-text-item {
        font-size: 1.0625rem;
    }

    .fi-ta-table .fi-ta-cell-status-since {
        grid-area: since;
        align-self: center;
        white-space: nowrap;
    }

    .fi-ta-table .crm-cell-job {
        grid-area: job;
        margin-top: 0.125rem;
    }

    .fi-ta-table .crm-cell-job .fi-ta-text-item {
        line-height: 1.35;
    }

    .fi-ta-table .crm-cell-company {
        grid-area: company;
        margin-top: 0.125rem;
    }

    .fi-ta-table .crm-cell-company .fi-ta-text-item {
        color: var(--crm-gris-cool);
        font-size: 0.875rem;
    }

    /* La note : un filet à gauche, comme une annotation en marge. */
    .fi-ta-table .crm-cell-notes {
        grid-area: notes;
        margin-top: 0.5rem;
        padding-left: 0.625rem;
        border-left: 1px solid var(--crm-gris-427);
    }

    .fi-ta-table .fi-ta-cell-status {
        grid-area: status;
        margin-top: 0.625rem;
    }

    /* Pas de case vide dans la carte quand l'info manque. */
    .fi-ta-table :is(.crm-cell-job, .crm-cell-company, .crm-cell-notes):not(:has(.fi-ta-text-item)) {
        display: none;
    }

    /* Les actions : le bouton d'étape prend la largeur, LinkedIn et le
       menu à droite, tous à portée de pouce. */
    .fi-ta-table .fi-ta-cell:last-child {
        grid-area: actions;
        margin-top: 0.875rem;
    }

    .fi-ta-table .fi-ta-cell:last-child .fi-ta-actions {
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 0.25rem;
    }

    .fi-ta-table .fi-ta-cell:last-child .crm-advance {
        flex: 1 1 auto;
        margin-right: 0.5rem;
    }

    .crm-advance {
        white-space: normal;
    }

    /* Fenêtres : plein écran, sans marge perdue. */
    .fi-modal-window {
        max-width: 100vw;
        width: 100vw;
        margin: 0;
    }

    /* Kanban : une colonne presque pleine largeur ; la suivante dépasse pour
       signaler qu'on peut glisser horizontalement. */
    .crm-kanban {
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .crm-col {
        flex: 0 0 82vw;
        min-width: 0;
        scroll-snap-align: center;
    }

    .crm-kanban-filters > * {
        min-width: 100%;
    }
}
