/* ============================================================
   components.css — refonte design 2026
   Composants unifiés du design system. Chargé APRÈS custom.css :
   redéfinit les composants legacy (.block-with-title, .helpbox,
   modales) vers le style cible. Les alias .gr-* sont les noms
   canoniques adoptés au fil de la migration des pages.
   Dépend de : tokens.css.
   ============================================================ */

/* ------------------------------------------------------------
   1. Carte unifiée — .gr-card (alias legacy : .block-with-title)
   Fin du glassmorphism : surface nette, bord discret, ombre douce.
   ------------------------------------------------------------ */
.gr-card,
.block-with-title {
    background: var(--gr-surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid var(--gr-border);
    border-radius: var(--gr-radius);
    padding: 24px;
    box-shadow: var(--gr-shadow);
}

/* Titre de carte : aligné à gauche, sobre, barre d'accent couleur de section */
.gr-card .gr-card-title,
.block-with-title .block-title {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--gr-ink);
    font-size: 1rem;
    font-weight: 600;
    text-align: left;
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 1.25rem;
    padding: 0 0 0 .85rem;
    position: relative;
}
.gr-card .gr-card-title::before,
.block-with-title .block-title::before {
    content: "";
    display: block;
    position: absolute;
    left: 0;
    top: .1em;
    bottom: .1em;
    width: 4px;
    border-radius: 4px;
    background: var(--section-color, var(--gr-primary));
}
.block-with-title .block-title.no-margin { margin-bottom: 0; }

.gr-card .gr-card-intro,
.block-with-title .block-intro {
    font-style: normal;
    color: var(--gr-muted);
    font-size: .85rem;
    text-align: left;
    margin: -0.9rem 0 1.25rem 0.85rem;
}

/* ------------------------------------------------------------
   2. Popins d'aide (.helpbox, ouvertes via Fancybox)
   Avant : pavé de texte brut. Après : mise en page lisible.
   ------------------------------------------------------------ */
.helpbox {
    display: none;
    max-width: 640px !important;
    background: var(--gr-surface);
    border-radius: var(--gr-radius);
    padding: 1.75rem 2rem !important;
    color: var(--gr-text);
    font-size: .92rem;
    line-height: 1.65;
}
.helpbox .title {
    color: var(--gr-ink);
    font-family: var(--gr-font);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 1rem;
    padding: 0 0 .75rem .85rem;
    border-bottom: 1px solid var(--gr-border);
    position: relative;
}
.helpbox .title::before {
    content: "";
    position: absolute;
    left: 0;
    top: .1em;
    height: 1.2em;
    width: 4px;
    border-radius: 4px;
    background: var(--section-color, var(--gr-primary));
}
.helpbox p { margin: 0 0 .85rem; }
.helpbox p:last-child { margin-bottom: 0; }
.helpbox ul, .helpbox ol { margin: 0 0 .85rem; padding-left: 1.25rem; }
.helpbox li { margin-bottom: .35rem; }
.helpbox li::marker { color: var(--section-color, var(--gr-primary)); }
.helpbox strong, .helpbox b { color: var(--gr-ink); font-weight: 600; }
.helpbox h1, .helpbox h2, .helpbox h3, .helpbox h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gr-ink);
    margin: 1.1rem 0 .5rem;
}
.helpbox img { max-width: 100%; border-radius: var(--gr-radius-sm); margin: .5rem 0 1rem; }
.helpbox table { width: 100%; font-size: .85rem; border-collapse: collapse; margin: .5rem 0 1rem; }
.helpbox table th, .helpbox table td { padding: .45rem .6rem; border: 1px solid var(--gr-border); text-align: left; }
.helpbox table th { background: var(--gr-bg-subtle); font-weight: 600; }

/* ------------------------------------------------------------
   3. Modales Bootstrap — mise en page unifiée
   ------------------------------------------------------------ */
.modal-content {
    border: none;
    border-radius: var(--gr-radius);
    box-shadow: var(--gr-shadow-lg);
}
.modal-header {
    border-bottom: 1px solid var(--gr-border);
    padding: 1.1rem 1.5rem;
}
.modal-title {
    color: var(--gr-ink);
    font-size: 1.05rem;
    font-weight: 600;
    text-align: left;
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 0;
}
.modal-body {
    padding: 1.5rem;
    font-size: .92rem;
    line-height: 1.6;
    color: var(--gr-text);
}
.modal-body p { margin-bottom: .85rem; }
.modal-body p:last-child { margin-bottom: 0; }
.modal-footer {
    border-top: 1px solid var(--gr-border);
    padding: 1rem 1.5rem;
}

/* ------------------------------------------------------------
   4. KPI — .gr-kpi
   ------------------------------------------------------------ */
.gr-kpi { display: flex; flex-direction: column; gap: .15rem; }
.gr-kpi .gr-kpi-label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gr-muted);
}
.gr-kpi .gr-kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gr-ink);
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
.gr-kpi .gr-kpi-delta { font-size: .8rem; font-weight: 600; }
.gr-kpi .gr-kpi-delta.up { color: var(--gr-up); }
.gr-kpi .gr-kpi-delta.down { color: var(--gr-down); }
.gr-kpi .gr-kpi-delta.neutral { color: var(--gr-muted); }

/* ------------------------------------------------------------
   5. Badges — .gr-badge (remplace les badges PNG)
   ------------------------------------------------------------ */
.gr-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .6rem;
    border-radius: 2rem;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}
.gr-badge.success { background: var(--gr-up-soft); color: color-mix(in srgb, var(--gr-up) 80%, black); }
.gr-badge.danger { background: var(--gr-down-soft); color: color-mix(in srgb, var(--gr-down) 80%, black); }
.gr-badge.warning { background: var(--gr-warning-soft); color: color-mix(in srgb, var(--gr-warning) 70%, black); }
.gr-badge.info { background: var(--gr-info-soft); color: color-mix(in srgb, var(--gr-info) 75%, black); }
.gr-badge.neutral { background: var(--gr-bg-subtle); color: var(--gr-muted); }

/* ------------------------------------------------------------
   6. Tableaux — .gr-table (socle ; Simple-DataTables par famille)
   ------------------------------------------------------------ */
.gr-table { width: 100%; font-size: .875rem; border-collapse: collapse; }
.gr-table thead th {
    background: var(--gr-bg-subtle);
    color: var(--gr-muted);
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .65rem .85rem;
    border-bottom: 1px solid var(--gr-border);
    text-align: left;
    white-space: nowrap;
}
.gr-table tbody td {
    padding: .65rem .85rem;
    border-bottom: 1px solid var(--gr-border);
    color: var(--gr-text);
    vertical-align: middle;
}
.gr-table tbody tr:hover { background: color-mix(in srgb, var(--gr-bg-subtle) 60%, transparent); }
.gr-table tbody tr:last-child td { border-bottom: none; }

/* ------------------------------------------------------------
   6bis. Tableaux Bootstrap & DataTables — harmonisation globale
   (pages admin, piliers, listings)
   ------------------------------------------------------------ */
.table > thead > tr > th {
    background: var(--gr-bg-subtle);
    color: var(--gr-muted);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--gr-border);
}
.table-bordered, .table-bordered > :not(caption) > * > * { border-color: var(--gr-border); }
.table > tbody > tr > td { color: var(--gr-text); }

/* Contrôles DataTables (recherche, longueur, info, pagination) */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--gr-border-strong);
    border-radius: var(--gr-radius-sm);
    padding: .3rem .6rem;
    font-size: .85rem;
    background: var(--gr-surface);
    color: var(--gr-text);
}
.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: var(--gr-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gr-primary) 15%, transparent);
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label { color: var(--gr-muted); font-size: .82rem; }

/* Pagination (DataTables + Bootstrap) */
.page-link { color: var(--gr-primary); }
.page-link:hover { color: var(--gr-primary-dark); }
.page-item.active .page-link {
    background-color: var(--gr-primary);
    border-color: var(--gr-primary);
    color: #fff;
}

/* ------------------------------------------------------------
   7. Boutons — .btn-gr
   ------------------------------------------------------------ */
.btn-gr {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    background: var(--gr-primary);
    color: #fff;
    border: 1px solid var(--gr-primary);
    border-radius: var(--gr-radius-sm);
    padding: .5rem 1.1rem;
    font-size: .875rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s ease;
}
.btn-gr:hover { background: var(--gr-primary-dark); border-color: var(--gr-primary-dark); color: #fff; }
.btn-gr-outline {
    background: transparent;
    color: var(--gr-primary);
}
.btn-gr-outline:hover { background: var(--gr-primary-soft); color: var(--gr-primary-dark); }

/* ------------------------------------------------------------
   8. États vides — .gr-empty
   ------------------------------------------------------------ */
.gr-empty {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--gr-muted);
}
.gr-empty i { font-size: 2rem; color: var(--gr-faint); margin-bottom: .75rem; display: block; }
.gr-empty .gr-empty-title { font-weight: 600; color: var(--gr-text); margin-bottom: .35rem; }
.gr-empty p { font-size: .875rem; margin: 0 auto .9rem; max-width: 420px; }

/* ------------------------------------------------------------
   8a. Indicateur de tâches prioritaires (topbar)
   Coche verte = RAS · triangle orange = important · rouge = critique
   ------------------------------------------------------------ */
.task-bell i { font-size: 1.25rem; }
.task-bell.is-ok i { color: var(--gr-up); }
.task-bell.is-important i { color: var(--gr-warning); }
.task-bell.is-critical i { color: var(--gr-down); }
/* Le compteur est ancré sur l'icône (pas sur le lien, qui fait toute la hauteur de la topbar) */
.task-bell .task-bell-wrap { position: relative; display: inline-flex; }
.task-bell .task-bell-counter {
    position: absolute;
    top: -.6rem;
    right: -.75rem;
    background: var(--gr-warning);
    color: #fff;
    border-radius: 2rem;
    font-size: .72rem;
    font-weight: 700;
    min-width: 1.25rem;
    height: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 .28rem;
    line-height: 1;
    border: 2px solid var(--gr-surface);
}
.task-bell.is-critical .task-bell-counter { background: var(--gr-down); }

.task-bell-menu {
    width: 22.5rem !important;
    padding: 0;
    border: 1px solid var(--gr-border);
    border-radius: var(--gr-radius);
    overflow: hidden;
}
.task-bell-head {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    padding: .85rem 1.1rem;
    background: var(--gr-bg-subtle);
    border-bottom: 1px solid var(--gr-border);
}
.task-bell-head-title {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gr-muted);
}
.task-bell-head-domain { font-size: .9rem; font-weight: 600; color: var(--gr-ink); }

.task-bell-items { max-height: 20rem; overflow-y: auto; }
.task-bell-item {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .7rem 1.1rem;
    text-decoration: none;
    border-bottom: 1px solid var(--gr-border);
}
.task-bell-item:hover { background: color-mix(in srgb, var(--gr-bg-subtle) 60%, transparent); }
.task-bell-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: .8rem;
}
.task-bell-icon.important { background: var(--gr-warning-soft); color: color-mix(in srgb, var(--gr-warning) 70%, black); }
.task-bell-icon.critical { background: var(--gr-down-soft); color: var(--gr-down); }
.task-bell-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.task-bell-meta { font-size: .72rem; color: var(--gr-muted); }
.task-bell-priority.important { color: color-mix(in srgb, var(--gr-warning) 70%, black); font-weight: 600; }
.task-bell-priority.critical { color: var(--gr-down); font-weight: 700; }
.task-bell-item-title { font-size: .84rem; font-weight: 600; color: var(--gr-ink); line-height: 1.35; }

.task-bell-empty { text-align: center; padding: 1.75rem 1.25rem; color: var(--gr-muted); }
.task-bell-empty i { font-size: 1.9rem; color: var(--gr-up); margin-bottom: .5rem; display: block; }
.task-bell-empty p { margin: 0; font-size: .85rem; }

.task-bell-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .7rem 1.1rem;
    background: var(--gr-bg-subtle);
    border-top: 1px solid var(--gr-border);
}
.task-bell-see-all {
    font-size: .82rem;
    font-weight: 600;
    color: var(--gr-primary);
    text-decoration: none;
}
.task-bell-see-all:hover { color: var(--gr-primary-dark); }
.task-bell-hide {
    font-size: .78rem;
    color: var(--gr-faint);
    text-decoration: none;
}
.task-bell-hide:hover { color: var(--gr-muted); }

/* ------------------------------------------------------------
   8bis. Réseaux sociaux — harmonisation des pages FB/IG/LinkedIn/TikTok
   (remplace les styles inline dupliqués ; les pages ne gardent que
   leurs accents d'identité réseau : rose IG, bleu LinkedIn…)
   ------------------------------------------------------------ */
.kpi-card {
    border-left: 4px solid var(--sec-social);
    border-radius: var(--gr-radius);
    transition: transform .2s ease;
}
.kpi-card:hover { transform: translateY(-2px); }
.kpi-card.primary { border-left-color: var(--sec-social); }
.kpi-card.success { border-left-color: var(--gr-success); }
.kpi-card.info { border-left-color: var(--gr-info); }
.kpi-card.warning { border-left-color: var(--gr-warning); }
.kpi-card.danger { border-left-color: var(--gr-danger); }
.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gr-ink);
    font-variant-numeric: tabular-nums;
}
.kpi-label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gr-muted);
}
.chart-container { height: 280px; position: relative; }
@media (max-width: 767.98px) { .chart-container { height: 220px; } }

.post-thumbnail { width: 60px; height: 60px; object-fit: cover; border-radius: var(--gr-radius-sm); }
.post-placeholder {
    width: 80px;
    height: 80px;
    border-radius: var(--gr-radius-sm);
    background: var(--gr-bg-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gr-faint);
}
.table-posts td { vertical-align: middle; font-size: .85rem; }
.table-posts .post-content { max-width: 350px; }

/* BS5 a supprimé .thead-light : restyle des en-têtes de tableaux */
.thead-light th, .table-posts thead th {
    background: var(--gr-bg-subtle);
    color: var(--gr-muted);
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--gr-border);
    white-space: nowrap;
}
.pagination .page-link { font-size: .85rem; padding: .35rem .65rem; }

/* Onglets custom (FB/IG/Ads) */
.nav-tabs-custom { border-bottom: 2px solid var(--gr-border); }
.nav-tabs-custom .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--gr-muted);
    font-weight: 600;
    padding: .75rem 1.5rem;
    margin-bottom: -2px;
}
.nav-tabs-custom .nav-link:hover { border-color: transparent; color: var(--gr-primary); }
.nav-tabs-custom .nav-link.active {
    color: var(--gr-primary);
    border-bottom-color: var(--gr-primary);
    background: transparent;
}
.nav-tabs-custom .nav-link.fb-tab.active { color: #4267B2; border-bottom-color: #4267B2; }
.nav-tabs-custom .nav-link.advertising-tab.active { color: var(--gr-success); border-bottom-color: var(--gr-success); }
.nav-tabs-custom .nav-link.ig-tab.active { color: #E1306C; border-bottom-color: #E1306C; }
.tab-content { padding-top: 1.5rem; }

/* Statuts de campagnes */
.campaign-status {
    display: inline-block;
    padding: .25rem .5rem;
    border-radius: var(--gr-radius-sm);
    font-size: .75rem;
    font-weight: 600;
}
.campaign-status.active { background: var(--gr-up-soft); color: color-mix(in srgb, var(--gr-up) 75%, black); }
.campaign-status.paused { background: var(--gr-warning-soft); color: color-mix(in srgb, var(--gr-warning) 65%, black); }
.campaign-status.completed { background: var(--gr-bg-subtle); color: var(--gr-muted); }

.demo-card { background: var(--gr-bg-subtle); border-radius: var(--gr-radius); }

/* ------------------------------------------------------------
   9. Conteneurs de graphes — hauteurs standard
   ------------------------------------------------------------ */
.gr-chart { position: relative; height: 300px; width: 100%; }
.gr-chart.sm { height: 220px; }
.gr-chart.lg { height: 380px; }
@media (max-width: 767.98px) {
    .gr-chart { height: 240px; }
    .gr-chart.lg { height: 280px; }
}
