/* ==========================================================================
   MODULE PROSPECTION - MEDEF54
   ========================================================================== */

/* --------------------------------------------------------------------------
   Variables
   -------------------------------------------------------------------------- */
:root {
    --prospection-orange: #fd7e14;
    --prospection-purple: #6f42c1;
}

/* --------------------------------------------------------------------------
   KPI Cards
   -------------------------------------------------------------------------- */
.kpi-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card-clickable {
    cursor: pointer;
}

.kpi-card-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.kpi-icon {
    font-size: 2rem;
    opacity: 0.8;
}

.kpi-value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-title {
    font-size: 0.875rem;
    color: var(--bs-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --------------------------------------------------------------------------
   Pipeline Widget
   -------------------------------------------------------------------------- */
.pipeline-container {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    min-height: 180px;
    padding-top: 1rem;
}

.pipeline-container-lg {
    min-height: 260px;
    gap: 0.75rem;
    padding-top: 1.25rem;
}

.pipeline-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.pipeline-stage:hover {
    background-color: var(--bs-light);
}

.pipeline-count {
    margin-bottom: 0.5rem;
}

.pipeline-label {
    font-size: 0.75rem;
    color: var(--bs-secondary);
    text-align: center;
    margin-bottom: 0.5rem;
}

.pipeline-bar {
    width: 100%;
    height: 80px;
    background-color: var(--bs-gray-200);
    border-radius: 0.25rem;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

.pipeline-bar-lg {
    height: 140px;
}

.pipeline-label-lg {
    font-size: 0.875rem;
    font-weight: 500;
}

.pipeline-bar-fill {
    width: 100%;
    border-radius: 0.25rem;
    transition: height 0.3s ease-out;
}

.pipeline-arrow {
    display: flex;
    align-items: center;
    color: var(--bs-gray-400);
    font-size: 1.25rem;
}

@media (max-width: 768px) {
    .pipeline-container {
        flex-wrap: wrap;
    }
    .pipeline-stage {
        flex: 0 0 calc(33.333% - 0.5rem);
    }
    .pipeline-arrow {
        display: none;
    }
}

/* --------------------------------------------------------------------------
   Timeline d'interactions
   -------------------------------------------------------------------------- */
.timeline {
    position: relative;
    padding-left: 2.5rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.875rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--bs-primary), var(--bs-gray-300));
}

.timeline::after {
    content: '';
    position: absolute;
    left: calc(0.875rem - 2px);
    top: -3px;
    width: 6px;
    height: 14px;
    background-color: var(--bs-primary);
    border-radius: 3px 3px 0 0;
    z-index: 1;
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -2.5rem;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.timeline-content {
    background: var(--bs-gray-100);
    padding: 1rem;
    border-radius: 0.5rem;
    position: relative;
}

.timeline-content::before {
    content: '';
    position: absolute;
    left: -0.5rem;
    top: 0.75rem;
    border-width: 0.5rem;
    border-style: solid;
    border-color: transparent var(--bs-gray-100) transparent transparent;
}

.timeline-content:hover {
    background: var(--bs-gray-200);
}

.timeline-marker.bg-appel,
.tdi-marker.bg-appel            { background-color: #0d6efd; } /* bleu Bootstrap        */
.timeline-marker.bg-email,
.tdi-marker.bg-email            { background-color: #0dcaf0; } /* teal clair             */
.timeline-marker.bg-rdv,
.tdi-marker.bg-rdv              { background-color: #198754; } /* vert                   */
.timeline-marker.bg-evenement,
.tdi-marker.bg-evenement        { background-color: #6f42c1; } /* violet                 */
.timeline-marker.bg-courrier,
.tdi-marker.bg-courrier         { background-color: #6c757d; } /* gris                   */
.timeline-marker.bg-linkedin,
.tdi-marker.bg-linkedin         { background-color: #0077b5; } /* bleu LinkedIn          */
.timeline-marker.bg-changement-statut,
.tdi-marker.bg-changement-statut{ background-color: #fd7e14; } /* orange                 */
.timeline-marker.bg-campagne,
.tdi-marker.bg-campagne         { background-color: #d63384; } /* rose Brevo             */
.timeline-marker.bg-echange-email,
.tdi-marker.bg-echange-email    { background-color: #0078d4; } /* bleu Exchange          */

/* --------------------------------------------------------------------------
   Timeline duale centrée (ProspectDetail)
   -------------------------------------------------------------------------- */
.timeline-dual {
    position: relative;
}

.timeline-dual::before {
    content: '';
    position: absolute;
    left: calc(50% - 1px);
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--bs-primary), var(--bs-gray-300));
    z-index: 0;
}

.timeline-dual::after {
    content: '';
    position: absolute;
    left: calc(50% - 3px);
    top: -3px;
    width: 6px;
    height: 14px;
    background-color: var(--bs-primary);
    border-radius: 3px 3px 0 0;
    z-index: 2;
}

/* Chaque ligne = 3 colonnes : gauche | marqueur 44px | droite */
.tdi {
    display: grid;
    grid-template-columns: 1fr 44px 1fr;
    margin-bottom: 10px;
    position: relative;
}

.tdi-left  { padding-right: 10px; display: flex; justify-content: flex-end; align-items: flex-start; }
.tdi-right { padding-left: 10px;  display: flex; justify-content: flex-start; align-items: flex-start; }

.tdi-center {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 6px;
    z-index: 1;
}

.tdi-marker {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.tdi-content {
    background: var(--bs-gray-100);
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    max-width: 100%;
    transition: background 0.15s;
}

.tdi-content:hover { background: var(--bs-gray-200); }

/* Flèche pointant vers le marqueur */
.tdi-content-left {
    position: relative;
}
.tdi-content-left::after {
    content: '';
    position: absolute;
    right: -7px;
    top: 10px;
    border-width: 7px 0 7px 7px;
    border-style: solid;
    border-color: transparent transparent transparent var(--bs-gray-100);
}
.tdi-content-left:hover::after {
    border-left-color: var(--bs-gray-200);
}

.tdi-content-right {
    position: relative;
}
.tdi-content-right::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 10px;
    border-width: 7px 7px 7px 0;
    border-style: solid;
    border-color: transparent var(--bs-gray-100) transparent transparent;
}
.tdi-content-right:hover::before {
    border-right-color: var(--bs-gray-200);
}

@media (max-width: 768px) {
    /* Mobile : tout à gauche, marqueur à droite de chaque item */
    .timeline-dual::before { left: calc(2rem + 2px); }
    .tdi { grid-template-columns: 2rem 1fr; }
    .tdi-left,
    .tdi-right { grid-column: 2; padding-left: 10px; padding-right: 0; justify-content: flex-start; }
    .tdi-center { grid-column: 1; grid-row: 1; }
    .tdi-content-left::after,
    .tdi-content-right::before { display: none; }
}

/* --------------------------------------------------------------------------
   Statut Badges
   -------------------------------------------------------------------------- */
.badge.bg-orange {
    background-color: var(--prospection-orange) !important;
    color: white;
}

.badge.bg-purple {
    background-color: var(--prospection-purple) !important;
    color: white;
}

/* --------------------------------------------------------------------------
   Prospect Filters
   -------------------------------------------------------------------------- */
.prospect-filters {
    background-color: var(--bs-gray-100);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.prospect-filters .form-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--bs-secondary);
    margin-bottom: 0.25rem;
}

/* --------------------------------------------------------------------------
   Actions Board
   -------------------------------------------------------------------------- */
.action-card {
    border-left: 4px solid var(--bs-primary);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.action-card:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.action-card.action-retard {
    border-left-color: var(--bs-danger);
    background-color: rgba(var(--bs-danger-rgb), 0.05);
}

.action-card.action-today {
    border-left-color: var(--bs-warning);
}

.action-card .action-date {
    font-size: 0.75rem;
    font-weight: 600;
}

.action-card .action-date.text-danger {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* --------------------------------------------------------------------------
   Cible Preview
   -------------------------------------------------------------------------- */
.cible-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.cible-preview-stat {
    background: var(--bs-gray-100);
    padding: 1rem;
    border-radius: 0.5rem;
    text-align: center;
}

.cible-preview-stat .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--bs-primary);
}

.cible-preview-stat .label {
    font-size: 0.875rem;
    color: var(--bs-secondary);
}

/* --------------------------------------------------------------------------
   Contact Principal Card
   -------------------------------------------------------------------------- */
.contact-card .contact-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background-color: var(--bs-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.25rem;
}

/* --------------------------------------------------------------------------
   Tableaux de prospects
   -------------------------------------------------------------------------- */
.table-prospects tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

.table-prospects tbody tr:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.05);
}

.table-prospects .prospect-name {
    font-weight: 600;
}

.table-prospects .prospect-siren {
    font-family: var(--bs-font-monospace);
    font-size: 0.75rem;
    color: var(--bs-secondary);
}

.table-prospects tr.row-retard {
    background-color: rgba(var(--bs-warning-rgb), 0.1);
}

.table-prospects tr.row-retard:hover {
    background-color: rgba(var(--bs-warning-rgb), 0.2);
}

/* --------------------------------------------------------------------------
   Partenaires
   -------------------------------------------------------------------------- */
.partenariat-card {
    border-left: 4px solid var(--bs-info);
}

.partenariat-card.type-enseignement { border-left-color: var(--bs-success); }
.partenariat-card.type-institutionnel { border-left-color: var(--bs-primary); }
.partenariat-card.type-sponsor { border-left-color: var(--prospection-orange); }
.partenariat-card.type-prestataire { border-left-color: var(--bs-secondary); }
.partenariat-card.inactif { opacity: 0.6; }

/* --------------------------------------------------------------------------
   Cibles List
   -------------------------------------------------------------------------- */
.cible-progress {
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background-color: var(--bs-gray-200);
}

.cible-progress-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease-out;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
    .kpi-value {
        font-size: 1.75rem;
    }
    .timeline {
        padding-left: 2rem;
    }
    .timeline::before {
        left: 0.625rem;
    }
    .timeline::after {
        left: calc(0.625rem - 2px);
    }
    .timeline-marker {
        left: -2rem;
        width: 1.25rem;
        height: 1.25rem;
        font-size: 0.625rem;
    }
}

@media (max-width: 576px) {
    .pipeline-container {
        flex-direction: column;
        align-items: stretch;
    }
    .pipeline-stage {
        flex-direction: row;
        justify-content: space-between;
    }
    .pipeline-bar {
        width: 100px;
        height: 1.5rem;
        flex-direction: row;
        align-items: stretch;
    }
    .pipeline-bar-fill {
        height: 100%;
    }
}

/* --------------------------------------------------------------------------
   Dark Mode
   -------------------------------------------------------------------------- */
[data-bs-theme="dark"] .timeline-content {
    background: var(--neutral-layer-2);
    color: var(--neutral-foreground-rest);
}
[data-bs-theme="dark"] .timeline-content::before {
    border-right-color: var(--neutral-layer-2);
}
[data-bs-theme="dark"] .timeline-content:hover {
    background: rgba(255,255,255,0.08);
}

[data-bs-theme="dark"] .tdi-content {
    background: var(--neutral-layer-2);
    color: var(--neutral-foreground-rest);
}
[data-bs-theme="dark"] .tdi-content:hover {
    background: rgba(255,255,255,0.08);
}
[data-bs-theme="dark"] .tdi-content-left::after {
    border-left-color: var(--neutral-layer-2);
}
[data-bs-theme="dark"] .tdi-content-left:hover::after {
    border-left-color: rgba(255,255,255,0.08);
}
[data-bs-theme="dark"] .tdi-content-right::before {
    border-right-color: var(--neutral-layer-2);
}
[data-bs-theme="dark"] .tdi-content-right:hover::before {
    border-right-color: rgba(255,255,255,0.08);
}

[data-bs-theme="dark"] .timeline-dual::before {
    background: linear-gradient(to bottom, var(--bs-primary), var(--neutral-stroke-rest));
}
[data-bs-theme="dark"] .timeline::before {
    background: linear-gradient(to bottom, var(--bs-primary), var(--neutral-stroke-rest));
}

[data-bs-theme="dark"] .prospect-filters {
    background-color: var(--neutral-layer-2);
}
[data-bs-theme="dark"] .cible-preview-stat {
    background: var(--neutral-layer-2);
}
[data-bs-theme="dark"] .pipeline-bar {
    background-color: var(--neutral-layer-2);
}
[data-bs-theme="dark"] .cible-progress {
    background-color: var(--neutral-layer-2);
}

/* --------------------------------------------------------------------------
   Print styles
   -------------------------------------------------------------------------- */
@media print {
    .pipeline-container,
    .kpi-card-clickable,
    .action-card {
        break-inside: avoid;
    }
    .btn, .nav-tabs, .pagination {
        display: none !important;
    }
    .timeline-content {
        background: white;
        border: 1px solid var(--bs-gray-300);
    }
}
