/* =====================================================
   ORGANIGRAMME — Styles principaux
   ===================================================== */

/* ---- Navbar ---- */
.navbar-logo {
    max-height: 34px;
    max-width: 160px;
    object-fit: contain;
    display: block;
}
.navbar-logo-app {
    max-height: 30px;
    max-width: 160px;
    object-fit: contain;
    display: block;
}

.org-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    color: #fff;
    font-size: .82rem;
    font-weight: 600;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Sidebar admin ---- */
.sidebar {
    min-height: calc(100vh - 56px);
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
}

.admin-sidebar .nav-link {
    color: #495057;
    border-radius: 6px;
    padding: .45rem 1rem;
    margin: .1rem .4rem;
    transition: background .15s, color .15s;
    font-size: .88rem;
}

/* (styles déplacés et modernisés dans le bloc Admin UI en bas de fichier) */

/* ---- Dashboard stats ---- */
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.bg-primary-soft { background: #e7f0ff; }
.bg-info-soft    { background: #e7f8ff; }
.bg-success-soft { background: #e6f9f0; }
.bg-warning-soft { background: #fff8e1; }

/* ---- Point couleur ---- */
.dept-dot {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 50%; margin-right: 4px; vertical-align: middle; flex-shrink: 0;
}

/* ---- Lien fonctionnel flèche admin ---- */
.functional-arrow { font-size: 1.4rem; color: #fd7e14; }

/* =====================================================
   VISIONNEUSE ORGANIGRAMME
   ===================================================== */
#orgChart {
    width: 100%;
    height: calc(100vh - 185px);
    min-height: 480px;
    display: block;
    background: #f5f7fa;
    border-radius: 0 0 .375rem .375rem;
    cursor: grab;
}
#orgChart:active { cursor: grabbing; }

.chart-spinner,
.chart-empty {
    position: absolute; inset: 0; z-index: 10;
    background: #f5f7fa;
    border-radius: 0 0 .375rem .375rem;
}

/* ---- Nœuds D3 ---- */
.node-card { cursor: pointer; }
.node-card rect.card-bg { rx: 8; ry: 8; }
.node-card:hover rect.card-bg { stroke: var(--primary) !important; stroke-width: 2 !important; }

.emp-name  { font: 700 12px/1 system-ui, sans-serif; fill: #212529; }
.emp-poste { font: 400 10px/1 system-ui, sans-serif; fill: #495057; }
.emp-dept  { font: 400  9px/1 system-ui, sans-serif; fill: #adb5bd; }

/* ---- Liens D3 ---- */
.link-hierarchical {
    fill: none; stroke: #4a5568; stroke-width: 1.5;
    marker-end: url(#arrow-hier);
}
.link-functional {
    fill: none; stroke: #fd7e14; stroke-width: 2.5;
    stroke-dasharray: 7 4; marker-end: url(#arrow-func); opacity: .9;
}
.link-label {
    font: 600 11px system-ui, sans-serif;
    fill: #e85d04;
    pointer-events: all;
    cursor: grab;
    paint-order: stroke;
    stroke: #ffffff;
    stroke-width: 4px;
    stroke-linejoin: round;
}
.link-label:active { cursor: grabbing; }
.link-functional-hit { fill: none; stroke: transparent; stroke-width: 14; cursor: ns-resize; }
.link-hierarchical-hit { fill: none; stroke: transparent; stroke-width: 14; cursor: move; }

/* ---- Légende ---- */
.legend-item {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: .78rem; color: #6c757d;
}
.legend-line { display: inline-block; width: 26px; height: 2px; border-radius: 2px; }
.legend-line.solid  { background: #4a5568; }
.legend-line.dashed { background: transparent; border-top: 2px dashed #fd7e14; }

/* ---- Tooltip ---- */
.emp-tooltip {
    position: fixed; z-index: 1000;
    background: #fff; border: 1px solid #dee2e6; border-radius: 8px;
    padding: 10px 14px; pointer-events: none; max-width: 260px;
    font-size: .83rem; line-height: 1.45;
}
.tt-name  { font-weight: 700; font-size: .93rem; margin-bottom: 2px; }
.tt-poste { color: #495057; margin-bottom: 5px; }
.tt-dept  { color: #6c757d; font-size: .78rem; }
.tt-email { color: #0d6efd; font-size: .78rem; }
.tt-tel   { color: #6c757d; font-size: .78rem; }

/* =====================================================
   EXTERNE / CODIR / COMEX
   ===================================================== */

/* Carte externe : bordure tiretée teal en survol */
.node-card.externe rect.card-bg {
    stroke-dasharray: 6 3;
}
.node-card.externe:hover rect.card-bg {
    stroke: #0dcaf0 !important;
}

/* Badges inline sur les cartes D3 */
.badge-codir {
    font: 700 8px/1 system-ui, sans-serif;
    fill: #fff;
}
.badge-comex {
    font: 700 8px/1 system-ui, sans-serif;
    fill: #fff;
}

/* Badges dans le tooltip */
.tt-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 700;
    margin-right: 3px;
    vertical-align: middle;
}
.tt-badge-codir { background: #ffc107; color: #212529; }
.tt-badge-comex { background: #dc3545; color: #fff; }
.tt-badge-externe { background: #0dcaf0; color: #000; }

/* =====================================================
   VUE SYNTHÈSE
   ===================================================== */
#synthesePanel {
    padding: 1.5rem;
    overflow-y: auto;
    height: calc(100vh - 185px);
    min-height: 480px;
    background: #f8f9fa;
    border-radius: 0 0 .375rem .375rem;
}

#synthesePanel .synthese-card {
    border-left: 4px solid var(--dept-color, #6c757d);
    transition: transform .15s, box-shadow .15s;
}
#synthesePanel .synthese-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
}

#synthesePanel .synthese-head {
    font-weight: 700;
    font-size: .95rem;
    color: var(--dept-color, #6c757d);
}

#synthesePanel .synthese-count {
    font-size: 1.6rem;
    font-weight: 800;
    color: #212529;
    line-height: 1;
}

#synthesePanel .synthese-count-label {
    font-size: .75rem;
    color: #6c757d;
}

/* =====================================================
   ORGANIGRAMME — LAYOUTS SPÉCIAUX
   ===================================================== */

/* Layout divisionnelle — rectangle en-tête de colonne */
.div-header {
    font: 700 11px/1 system-ui, sans-serif;
    fill: #fff;
}
.div-header-bg {
    rx: 6; ry: 6;
    opacity: .95;
}

/* Layout matricielle — cellules de fond */
.mat-col-bg {
    rx: 6; ry: 6;
    opacity: .06;
}
.mat-col-header {
    font: 700 11px/1 system-ui, sans-serif;
    fill: #fff;
}
.mat-col-header-bg {
    rx: 4; ry: 4;
    opacity: .85;
}
.mat-row-label {
    font: 400 9px/1 system-ui, sans-serif;
    fill: #6c757d;
}
.mat-grid-line {
    stroke: #dee2e6;
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

/* Layout fonctionnelle — bande de fond colorée par direction */
.func-band {
    opacity: .08;
    rx: 8; ry: 8;
}
.func-band-label {
    font: 700 10px/1 system-ui, sans-serif;
    opacity: .55;
}

/* =====================================================
   PARAMÈTRES — Aperçu carte
   ===================================================== */
.card-preview {
    font-family: system-ui, sans-serif;
    box-shadow: 0 2px 6px rgba(0,0,0,.1);
}

/* =====================================================
   ADMIN UI — Cohérence graphique "Floating Pill"
   ===================================================== */

/* 1. Sidebar */
nav.sidebar {
    background-color: #f4f6fc !important;
}
nav.sidebar > .pt-3 {
    border-bottom-color: rgba(0,0,0,0.08) !important;
}
.admin-sidebar .nav-link {
    border-radius: 8px;
    margin: 2px 6px;
    padding: 7px 10px;
    font-size: .85rem;
    transition: background 0.13s, color 0.13s, box-shadow 0.13s;
}
.admin-sidebar .nav-link:hover {
    background: rgba(0,0,0,0.05);
    color: var(--primary);
}
.admin-sidebar .nav-link.active {
    background: #ffffff;
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

/* 2. Cards */
.card {
    border-radius: 12px !important;
    border: 1px solid rgba(0,0,0,0.06) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
}
.card-header {
    background: #f8f9fc;
    border-bottom: 1px solid rgba(0,0,0,0.07);
    border-radius: 12px 12px 0 0 !important;
    color: #4a5568;
    font-size: .9rem;
}
.card-footer {
    border-top: 1px solid rgba(0,0,0,0.06);
    border-radius: 0 0 12px 12px !important;
}

/* 3. Boutons */
.btn {
    border-radius: 8px;
    transition: background 0.13s, color 0.13s, box-shadow 0.13s, border-color 0.13s, transform 0.1s;
    font-size: .85rem;
}
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
    --bs-btn-active-bg: var(--primary-dark);
    --bs-btn-active-border-color: var(--primary-dark);
    --bs-btn-focus-shadow-rgb: var(--primary-rgb);
    --bs-btn-color: var(--btn-text-color, #fff);
    --bs-btn-hover-color: var(--btn-text-color, #fff);
    --bs-btn-active-color: var(--btn-text-color, #fff);
    background: var(--primary);
    border-color: var(--primary);
    color: var(--btn-text-color, #fff);
}
.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: var(--btn-text-color, #fff);
    box-shadow: 0 3px 10px rgba(var(--primary-rgb), 0.3);
    transform: translateY(-1px);
}
.btn-primary:focus-visible,
.btn-primary:focus,
.btn-primary.active,
.btn-primary:active {
    background: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
    color: var(--btn-text-color, #fff) !important;
    box-shadow: 0 0 0 0.25rem rgba(var(--primary-rgb), 0.35) !important;
}
.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
    --bs-btn-hover-color: var(--btn-text-color, #fff);
    --bs-btn-active-bg: var(--primary);
    --bs-btn-active-border-color: var(--primary);
    --bs-btn-active-color: var(--btn-text-color, #fff);
    --bs-btn-focus-shadow-rgb: var(--primary-rgb);
}
.btn-outline-secondary:hover {
    background: #f0f2f8;
    color: #2d3748;
    border-color: #bcc3cf;
}
.btn-danger {
    background: #fff1f0;
    color: #c53030;
    border-color: #fca5a5;
}
.btn-danger:hover {
    background: #fee2e2;
    color: #9b1c1c;
    border-color: #f87171;
}
.btn-outline-danger:hover {
    background: #fff1f0;
    border-color: #fca5a5;
}

/* 4. Formulaires */
.form-control,
.form-select {
    border-radius: 8px;
    border-color: #dde1e7;
    font-size: .875rem;
}
.form-control:focus,
.form-select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.input-group-text {
    background: rgba(0,0,0,0.04);
    border-color: #dde1e7;
    font-size: .875rem;
}
.form-label {
    font-size: .85rem;
    font-weight: 500;
    color: #4a5568;
}

/* 5. Tables */
.table thead.table-light th,
.table > thead > tr > th {
    background: #f0f2f8 !important;
    color: #6c757d;
    font-size: .73rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
.table-hover > tbody > tr:hover > * {
    background-color: #f5f7ff;
}

/* 6. Badges */
.badge {
    border-radius: 6px;
    font-size: .72rem;
}

/* 7. Alertes */
.alert {
    border-radius: 10px;
    border: none;
    border-left: 3px solid transparent;
}
.alert-success {
    background: #f0fdf4;
    color: #166534;
    border-left-color: #4ade80;
}
.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-left-color: #f87171;
}
.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-left-color: #fbbf24;
}
.alert-info {
    background: #eff6ff;
    color: var(--primary-dark);
    border-left-color: #60a5fa;
}

/* 8. Modales */
.modal-content {
    border-radius: 14px;
    border: none;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-header {
    background: #f8f9fc;
    border-bottom: 1px solid rgba(0,0,0,0.07);
    border-radius: 14px 14px 0 0;
}
.modal-footer {
    background: #f8f9fc;
    border-top: 1px solid rgba(0,0,0,0.07);
    border-radius: 0 0 14px 14px;
}
.modal-title {
    font-size: 1rem;
    font-weight: 600;
}

/* 9. Cartes KPI dashboard */
.stat-icon {
    border-radius: 14px;
    transition: transform 0.15s;
}
.card.border-0:hover .stat-icon {
    transform: scale(1.08);
}
.card.border-0.h-100 {
    transition: transform 0.15s, box-shadow 0.15s;
}
.card.border-0.h-100:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1) !important;
}

/* 10. Fond de page */
body {
    background: #f4f6fc;
}

/* 11. Dropdowns globaux */
.dropdown-menu {
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.07);
    box-shadow: 0 8px 24px rgba(0,0,0,0.10);
    padding: 6px;
}
.dropdown-item {
    border-radius: 7px;
    font-size: .85rem;
    padding: 6px 10px;
}
.dropdown-item:hover,
.dropdown-item:focus {
    background: #f0f2f8;
    color: #2d3748;
}

/* 12. Tables dans les cards — overflow pour coins arrondis */
.card > .table-responsive,
.card > .card-body > .table-responsive {
    overflow: hidden;
    border-radius: 0 0 11px 11px;
}

/* 13. Checkboxes & radios */
.form-check-input {
    border-color: #dde1e7;
    border-radius: 5px;
}
.form-check-input:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* 14. Switches */
.form-switch .form-check-input {
    border-radius: 20px;
    background-color: #dde1e7;
    border-color: #dde1e7;
}
.form-switch .form-check-input:focus {
    background-color: #dde1e7;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-switch .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* 15. Nav-tabs (Import/Export) — style pill flottant */
.nav-tabs {
    border-bottom: 1px solid rgba(0,0,0,0.07);
    gap: 4px;
}
.nav-tabs .nav-link {
    border: none;
    border-radius: 8px;
    color: #4a5568;
    font-size: .85rem;
    padding: 6px 14px;
    transition: background 0.13s, color 0.13s;
    background: transparent;
    margin-bottom: 0;
}
.nav-tabs .nav-link:hover {
    background: rgba(0,0,0,0.05);
    color: var(--primary);
    border: none;
}
.nav-tabs .nav-link.active,
.nav-tabs .nav-link.active:focus,
.nav-tabs .nav-link.active:hover {
    background: #ffffff;
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    border: none;
}

/* 16. Nav-pills */
.nav-pills .nav-link.active {
    background-color: var(--primary);
}

/* 17. Navbar gradient — controlled via btn_gradient setting (injected in <style> by layout.php) */

/* 18. Groupe view inactive button */
.btn-groupe-inactive,
.btn-groupe-inactive:hover,
.btn-groupe-inactive:focus,
.btn-groupe-inactive:active {
    background: rgba(0, 0, 0, 0.06) !important;
    color: #6c757d !important;
    border-color: transparent !important;
    box-shadow: none !important;
}
.btn-groupe-inactive:hover {
    background: rgba(0, 0, 0, 0.10) !important;
}
