/**
 * APRAPFEA — Styles de l'Organigramme Fonctionnel Interactif
 * Conforme aux couleurs et à l'identité visuelle de l'APRAPFEA
 */

.aprapfea-organigramme-wrapper {
    position: relative;
    margin: 30px 0 60px 0;
}

/* En-tête de section */
.aprapfea-org-header {
    text-align: center;
    margin-bottom: 25px;
}

.aprapfea-org-header .org-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: rgba(201, 151, 56, 0.12);
    border: 1px solid rgba(201, 151, 56, 0.35);
    border-radius: 50px;
    font-size: 13px;
    font-weight: 700;
    color: #0D3823;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.aprapfea-org-header .org-title {
    font-size: 32px;
    font-weight: 800;
    color: #0D3823;
    margin-bottom: 8px;
}

.aprapfea-org-header .org-subtitle {
    font-size: 16px;
    color: #555;
    max-width: 750px;
    margin: 0 auto;
    line-height: 1.5;
}

/* Légende du schéma */
.aprapfea-org-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 18px;
    padding: 10px 18px;
    background: #FAF8F5;
    border: 1px solid #EADBCE;
    border-radius: 8px;
    font-size: 13px;
    color: #4A5568;
}

.aprapfea-org-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.aprapfea-org-legend .legend-line-solid {
    width: 28px;
    height: 3px;
    background: #334E68;
    border-radius: 2px;
}

.aprapfea-org-legend .legend-line-dashed {
    width: 28px;
    height: 0;
    border-top: 3px dashed #E6A700;
}

/* Cadre du Viewport Interactif */
.aprapfea-org-viewport {
    position: relative;
    width: 100%;
    height: 600px;
    background: #FFFFFF;
    border: 2px solid #E2E8F0;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(13, 56, 35, 0.06), 0 1px 3px rgba(0,0,0,0.04);
    overflow: hidden;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.aprapfea-org-viewport.is-dragging {
    cursor: grabbing;
}

.aprapfea-org-viewport.is-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999;
    border-radius: 0;
    border: none;
}

/* Grille de fond subtile façon plan technique */
.aprapfea-org-viewport::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(#CBD5E1 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.45;
    pointer-events: none;
}

/* Barre d'outils de zoom flottante */
.aprapfea-org-toolbar {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(13, 56, 35, 0.15);
    padding: 6px 10px;
    border-radius: 40px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.aprapfea-org-toolbar button {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 50%;
    color: #0D3823;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.aprapfea-org-toolbar button:hover {
    background: #0D3823;
    border-color: #0D3823;
    color: #FFFFFF;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(13, 56, 35, 0.25);
}

.aprapfea-org-toolbar .zoom-indicator {
    font-size: 13px;
    font-weight: 700;
    color: #0D3823;
    min-width: 48px;
    text-align: center;
    padding: 0 4px;
}

/* Indication interactive en bas */
.aprapfea-org-hint {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    background: rgba(13, 56, 35, 0.88);
    color: #FFFFFF;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: fadeHint 6s forwards;
}

@keyframes fadeHint {
    0%, 75% { opacity: 1; }
    100% { opacity: 0.35; }
}

/* Canevas transformable contenant le SVG */
.aprapfea-org-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    will-change: transform;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aprapfea-org-svg {
    display: block;
    overflow: visible;
}

/* Cartes / Boîtes de l'organigramme (HTML dans foreignObject) */
.org-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    padding: 6px 12px;
    box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.org-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.org-box-role {
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.3px;
    line-height: 1.25;
    margin: 0;
}

.org-box-sub {
    font-size: 10.5px;
    opacity: 0.9;
    font-style: italic;
    margin-top: 2px;
    line-height: 1.15;
}

.org-box-name {
    font-size: 12.5px;
    font-weight: 700;
    margin-top: 4px;
    padding-top: 3px;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* Thèmes des boîtes selon les niveaux et pôles */

/* Niveau 1 : Directeur */
.org-box-level-1 {
    background: linear-gradient(135deg, #1A4D2E 0%, #0D3823 100%);
    border: 2px solid #C99738;
    color: #FFFFFF;
}

.org-box-level-1 .org-box-role {
    font-size: 15px;
    color: #FEE7B3;
}

.org-box-level-1 .org-box-name {
    color: #FFFFFF;
    font-size: 14px;
}

/* Niveau 2 : Ligne des 5 directions */
.org-box-level-2 {
    background: #334E68;
    border: 1.5px solid #486581;
    color: #FFFFFF;
}

.org-box-level-2 .org-box-role {
    font-size: 13px;
    color: #FFFFFF;
}

.org-box-level-2 .org-box-name {
    color: #F7D070;
    font-size: 12px;
}

/* Niveau 3 : Unités opérationnelles et terrain */
.org-box-level-3 {
    background: #486581;
    border: 1px solid #627D98;
    color: #F0F4F8;
}

.org-box-level-3.terrain {
    background: #3E5A44;
    border-color: #557A5D;
}

.org-box-level-3 .org-box-role {
    font-size: 12px;
    color: #FFFFFF;
}

.org-box-level-3 .org-box-sub {
    color: #CBD5E1;
}

.org-box-level-3 .org-box-name {
    color: #FEE7B3;
    font-size: 11.5px;
}

/* Lignes de liaison SVG */
.org-link-solid {
    stroke: #334E68;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.org-link-dashed {
    stroke: #D69E2E;
    stroke-width: 2.5;
    stroke-dasharray: 6 5;
    fill: none;
    animation: flowDash 20s linear infinite;
}

@keyframes flowDash {
    to {
        stroke-dashoffset: -100;
    }
}

/* Sections 2 & 3 sous l'organigramme */
.aprapfea-poles-section {
    margin-top: 60px;
    padding: 40px;
    background: #FAF8F5;
    border: 1px solid #EADBCE;
    border-radius: 16px;
}

.aprapfea-poles-section h3.section-subtitle {
    font-size: 24px;
    font-weight: 800;
    color: #0D3823;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.aprapfea-poles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
}

.aprapfea-pole-card {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #E2E8F0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.aprapfea-pole-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(13, 56, 35, 0.08);
}

.aprapfea-pole-card .pole-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.aprapfea-pole-card .pole-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: rgba(13, 56, 35, 0.08);
    color: #0D3823;
}

.aprapfea-pole-card.gold .pole-icon {
    background: rgba(201, 151, 56, 0.12);
    color: #C99738;
}

.aprapfea-pole-card.green .pole-icon {
    background: rgba(46, 125, 50, 0.12);
    color: #2E7D32;
}

.aprapfea-pole-card .pole-title {
    font-size: 18px;
    font-weight: 800;
    color: #0D3823;
    margin: 0;
}

.aprapfea-pole-card .pole-body {
    font-size: 14.5px;
    color: #4A5568;
    line-height: 1.6;
}

/* Fiches de Poste */
.aprapfea-fiches-section {
    margin-top: 40px;
}

.aprapfea-fiches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 25px;
}

.aprapfea-fiche-card {
    background: #FFFFFF;
    border-radius: 14px;
    border: 1px solid #E2E8F0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
    overflow: hidden;
}

.aprapfea-fiche-header {
    background: #0D3823;
    color: #FFFFFF;
    padding: 18px 24px;
    border-bottom: 3px solid #C99738;
}

.aprapfea-fiche-header .fiche-tag {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #C99738;
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
}

.aprapfea-fiche-header h4 {
    color: #FFFFFF;
    font-size: 20px;
    font-weight: 800;
    margin: 0;
}

.aprapfea-fiche-body {
    padding: 24px;
}

.aprapfea-fiche-mission {
    background: #F8FAFC;
    border-left: 3px solid #0D3823;
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 20px;
}

.aprapfea-fiche-mission strong {
    color: #0D3823;
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    text-transform: uppercase;
}

.aprapfea-fiche-mission p {
    margin: 0;
    font-size: 14px;
    color: #334E68;
    line-height: 1.5;
}

.aprapfea-fiche-resp h5 {
    font-size: 14px;
    font-weight: 800;
    color: #0D3823;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.aprapfea-fiche-resp ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.aprapfea-fiche-resp li {
    position: relative;
    padding-left: 24px;
    margin-bottom: 12px;
    font-size: 14px;
    color: #4A5568;
    line-height: 1.5;
}

.aprapfea-fiche-resp li::before {
    content: "✓";
    position: absolute;
    left: 0;
    top: 0;
    color: #C99738;
    font-weight: 900;
}

/* Responsivité Mobile */
@media (max-width: 768px) {
    .aprapfea-org-viewport {
        height: 480px;
    }
    .aprapfea-org-header .org-title {
        font-size: 24px;
    }
    .aprapfea-poles-section {
        padding: 24px 16px;
    }
}
