/**
 * Directory — Annuaire clients / fournisseurs / contacts
 * public/css/pages/directory.css
 */

/* =========================================================================
   PAGE INDEX — Cartes statistiques
   ========================================================================= */

.stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 0.5rem;
}

/* =========================================================================
   PAGE SHOW — Grille info
   ========================================================================= */

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem 1.5rem;
}

.info-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem 1.5rem;
}

@media (max-width: 768px) {
    .info-grid,
    .info-grid-3 {
        grid-template-columns: 1fr;
    }
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.info-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
}

.info-value {
    font-size: 0.9rem;
    color: #212529;
}

/* =========================================================================
   PAGE SHOW — Titres de sections dans onglets
   ========================================================================= */

.section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6c757d;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

/* =========================================================================
   PAGE SHOW — Champs éditables inline
   ========================================================================= */

.field-editable {
    border: 1px solid transparent;
    background: transparent;
    transition: border-color 0.15s, background-color 0.15s;
    border-radius: 0.25rem;
    padding: 0.15rem 0.35rem;
    width: 100%;
}

.field-editable:hover,
.field-editable:focus {
    border-color: #dee2e6;
    background-color: #fff;
    outline: none;
}

/* =========================================================================
   PAGE SHOW — Modal création / édition (rôles)
   ========================================================================= */

.role-check-card {
    border: 2px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
    user-select: none;
}

.role-check-card:hover {
    border-color: #adb5bd;
    background: #f8f9fa;
}

.role-check-card.checked-customer {
    border-color: #0d6efd;
    background: #e7f1ff;
}

.role-check-card.checked-supplier {
    border-color: #198754;
    background: #e6f4ee;
}

.role-check-card.checked-contact {
    border-color: #ffc107;
    background: #fff8e1;
}

.role-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.role-label {
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0.25rem;
    color: #495057;
}

/* =========================================================================
   PAGE SHOW — Onglet Communications (timeline)
   ========================================================================= */

.activity-timeline {
    position: relative;
    padding-left: 1.5rem;
}

.activity-timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #dee2e6;
}

.activity-item {
    position: relative;
    padding: 0.75rem 0 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item::before {
    content: '';
    position: absolute;
    left: -1.25rem;
    top: 1.1rem;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: #adb5bd;
    border: 2px solid #fff;
}

.activity-date {
    font-size: 0.72rem;
    color: #adb5bd;
    white-space: nowrap;
}

.communication-item {
    background: #f8f9fa;
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-left: 3px solid #dee2e6;
}

.communication-item.type-email {
    border-left-color: #0d6efd;
}

.communication-item.type-phone {
    border-left-color: #198754;
}

.communication-item.type-visit {
    border-left-color: #fd7e14;
}

/* =========================================================================
   PAGE SHOW — Badges statut paiement
   ========================================================================= */

.payment-status-badge {
    font-size: 0.7rem;
    padding: 0.2em 0.5em;
    border-radius: 0.25rem;
    font-weight: 600;
}

/* =========================================================================
   RESPONSIVE — petits écrans
   ========================================================================= */

@media (max-width: 576px) {
    .role-check-card {
        padding: 0.5rem 0.75rem;
    }

    .role-icon {
        font-size: 1.2rem;
    }
}

/* =========================================================================
   V157 — INDEX : Stat cards cliquables
   ========================================================================= */

.dir-stat-card {
    background: #fff;
    border: 2px solid #dee2e6;
    border-radius: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.25rem;
    user-select: none;
}

.dir-stat-card:hover {
    border-color: #adb5bd;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.dir-stat-card.active {
    border-color: #0d6efd;
    background: #f0f6ff;
    box-shadow: 0 2px 8px rgba(13,110,253,.15);
}

.dir-stat-all.active { border-color: #0d6efd; background: #f0f6ff; }
.dir-stat-customer.active { border-color: #0dcaf0; background: #e8f8fd; }
.dir-stat-supplier.active { border-color: #198754; background: #e8f4ee; }
.dir-stat-contact.active  { border-color: #ffc107; background: #fff8e1; }

.dir-stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: rgba(108,117,125,.08);
    font-size: 1rem;
    color: #6c757d;
}

.dir-stat-count {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.dir-stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6c757d;
}

/* =========================================================================
   V157 — INDEX : Barre toggle colonnes
   ========================================================================= */

.dir-col-legend {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.dir-col-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.dir-col-badge.dir-col-inline {
    background: #cfe2ff;
    color: #0a369d;
    border-color: #9ec5fe;
}

.dir-col-badge.dir-col-inline.dir-col-hidden {
    background: #eef3ff;
    color: #6589c9;
    border-color: #c5d3f5;
}

.dir-col-badge.dir-col-inline.dir-col-visible {
    background: #cfe2ff;
    color: #0a369d;
    border-color: #9ec5fe;
}

/* Toggle switch statut & exclusif : rouge (inactif) / vert (actif) */
.dir-status-switch .form-check-input,
.dir-exclusive-switch .form-check-input {
    background-color: #dc3545;
    border-color: #dc3545;
}
.dir-status-switch .form-check-input:checked,
.dir-exclusive-switch .form-check-input:checked {
    background-color: #198754;
    border-color: #198754;
}
.dir-status-switch .form-check-input:focus,
.dir-exclusive-switch .form-check-input:focus {
    box-shadow: 0 0 0 .25rem rgba(25, 135, 84, .25);
}
.dir-status-switch .form-check-input:disabled,
.dir-exclusive-switch .form-check-input:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* Toggle switch newsletter : gris (non abonné) / violet (abonné) */
.dir-newsletter-switch .form-check-input {
    background-color: #adb5bd;
    border-color: #adb5bd;
}
.dir-newsletter-switch .form-check-input:checked {
    background-color: #6f42c1;
    border-color: #6f42c1;
}
.dir-newsletter-switch .form-check-input:focus {
    box-shadow: 0 0 0 .25rem rgba(111, 66, 193, .25);
}
.dir-newsletter-switch .form-check-input:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.dir-col-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 2rem;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .12s;
    border: 1px solid transparent;
    user-select: none;
}

.dir-col-badge.dir-col-locked {
    cursor: default;
    opacity: .7;
}

.dir-col-badge.dir-col-visible {
    background: #d1e7dd;
    color: #0f5132;
    border-color: #a3cfbb;
}

.dir-col-badge.dir-col-hidden {
    background: #f8f9fa;
    color: #6c757d;
    border-color: #dee2e6;
}

.dir-col-badge.dir-col-hidden.dir-col-sensitive {
    background: #fff3cd;
    color: #664d03;
    border-color: #ffe69c;
}

.dir-col-badge:not(.dir-col-locked):hover {
    filter: brightness(.92);
}

/* Drag & drop colonnes */
.dir-col-badge[draggable="true"] {
    cursor: grab;
}
.dir-col-badge[draggable="true"]:active {
    cursor: grabbing;
}
.dir-col-badge.dragging {
    opacity: .35;
    cursor: grabbing;
}
.dir-col-badge.drag-over-left {
    box-shadow: -3px 0 0 0 #0d6efd;
    border-left-color: #0d6efd;
    margin-left: 2px;
}
.dir-col-badge.drag-over-right {
    box-shadow: 3px 0 0 0 #0d6efd;
    border-right-color: #0d6efd;
    margin-right: 2px;
}

/* =========================================================================
   V157 — SHOW : Sidebar info
   ========================================================================= */

.dir-show-header {
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 1rem;
}

.dir-code {
    font-size: .75rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: .25rem;
    padding: .1rem .4rem;
    color: #495057;
}

.dir-info-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.dir-info-row {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
}

.dir-info-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6c757d;
}

.dir-info-value {
    font-size: 0.85rem;
    color: #212529;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* =========================================================================
   V157 — SHOW : Chaîne BE resolution
   ========================================================================= */

.dir-be-chain {
    font-size: 0.82rem;
}

.dir-be-node {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: .5rem;
    padding: .5rem .75rem;
    min-width: 100px;
}

.dir-be-node.dir-be-empty {
    opacity: .5;
}

.dir-be-node.dir-be-override {
    border-color: #0d6efd;
    background: #e7f1ff;
}

.dir-be-node.dir-be-resolved {
    border-color: #198754;
    background: #e8f4ee;
}

.dir-be-level {
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: .15rem;
}

.dir-be-value {
    font-size: .82rem;
}

/* État inactif (btn-outline-dark) */
#roleFilters button[data-professional="true"],
#roleFilters button[data-professional="false"] {
    --bs-btn-color: #343a40;
    --bs-btn-border-color: #343a40;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #343a40;
    --bs-btn-hover-border-color: #343a40;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #495057;
    --bs-btn-active-border-color: #495057;
    --bs-btn-disabled-color: #343a40;
    color: #343a40;
    border-color: #343a40;
    background-color: transparent;
}

/* État actif (btn-secondary active) */
#roleFilters button[data-professional="true"].active,
#roleFilters button[data-professional="false"].active {
    color: #fff;
    background-color: #495057;
    border-color: #495057;
}

/* =========================================================================
   V160p — Boutons TYPE (Pro/Part) : classe custom dir-btn-pro
   Découplé de Bootstrap : contrôle total des couleurs, aucun conflit.
   ========================================================================= */

/* Bouton inactif (outline sombre) */
.dir-btn-pro {
    color: #343a40 !important;
    background-color: transparent !important;
    border-color: #343a40 !important;
}

.dir-btn-pro:hover:not(:disabled) {
    color: #fff !important;
    background-color: #343a40 !important;
    border-color: #343a40 !important;
}

/* Bouton actif */
.dir-btn-pro.active {
    color: #fff !important;
    background-color: #495057 !important;
    border-color: #495057 !important;
}

/* Badge dans bouton inactif */
.dir-btn-pro .badge {
    background-color: #6c757d !important;
    color: #fff !important;
}

/* Badge dans bouton actif : blanc avec texte sombre */
.dir-btn-pro.active .badge {
    background-color: #fff !important;
    color: #343a40 !important;
}

/* =========================================================================
   V160t — Lignes inactives grisées
   ========================================================================= */
#directoryTable tbody tr.row-inactive td {
    opacity: 0.55;
    font-style: italic;
}
#directoryTable tbody tr.row-inactive td a.dir-name-link {
    color: #6c757d !important;
}

/* =========================================================================
   V160t — Lignes sélectionnées (actions groupées)
   ========================================================================= */
#directoryTable tbody tr.row-selected {
    background-color: #e8f0fe !important;
}
#directoryTable tbody tr.row-selected td {
    opacity: 1 !important; /* surpasser row-inactive si les deux classes coexistent */
}

/* Colonne checkbox : largeur fixe, centrage */
th.dt-select-col,
td.dt-select-col {
    width: 32px !important;
    min-width: 32px !important;
    text-align: center !important;
    padding: 0.25rem !important;
}

/* =========================================================================
   V160v — Select géo groupé (pays + continent)
   ========================================================================= */
/* L'option "Tout [Continent]" est légèrement stylée */
#filterGeo option.dir-geo-continent-opt {
    font-style: italic;
    color: #495057;
    padding-left: 4px;
}
/* Optgroup désactivé (count = 0) → texte grisé */
#filterGeo optgroup:disabled {
    color: #adb5bd;
}

/* =========================================================================
   V161a — Titres de section dans le modal formulaire (règle R77 contraste)
   ========================================================================= */
.form-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.35rem;
    margin-bottom: 0.75rem;
}

/* =========================================================================
   FIX Bootstrap tab-pane — les panes sont dans .p-3 (pas enfants directs
   de .tab-content), donc Bootstrap .tab-content > .tab-pane { display:none }
   ne s'applique pas. Ce correctif reproduit le comportement attendu.
   ========================================================================= */

.tab-content .p-3 > .tab-pane {
    display: none;
}
.tab-content .p-3 > .tab-pane.active {
    display: block;
}

/* bp734 — icone d'aide « i » dans les en-tetes de colonnes (definition de la donnee).
   Le libelle reste le texte du th : l'icone ne doit ni grossir la ligne ni gener le tri. */
.dir-col-help {
    font-size: .75rem;
    color: #6c757d;
    margin-left: .25rem;
    cursor: help;
    vertical-align: baseline;
}
.dir-col-help:hover { color: #0d6efd; }

/* bp737 — origine d'une generation de catalogue, sous la date (historique). */
.dir-gen-origin { font-size: .72rem; }

/* bp745 — graphique annuel CA/volume (fiche intranet ET fiche espace client). */
.dir-annual-chart-wrap { position: relative; height: 220px; }
.dir-chart-hint { font-size: .68rem; }
