/* ============================================
   STYLES KPI MODERNES - INTERFACE CRM
   ============================================ */

/* Contrôles et filtres KPI */
.kpi-controls {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.kpi-header-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.kpi-select {
    padding: 0.625rem 2.5rem 0.625rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155;
    background: white url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23334155' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e") no-repeat right 0.75rem center/12px 10px;
    cursor: pointer;
    transition: all 0.2s;
    appearance: none;
}

.kpi-select:hover {
    border-color: #cbd5e1;
}

.kpi-select:focus {
    outline: none;
    border-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

/* Grille des cartes KPI */
.kpi-overview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Carte KPI moderne */
.kpi-card-modern {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.kpi-card-modern::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #16a34a 0%, #22c55e 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.kpi-card-modern.clickable {
    cursor: pointer;
}

.kpi-card-modern.clickable:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.kpi-card-modern.clickable:hover::before {
    opacity: 1;
}

/* En-tête de carte KPI */
.kpi-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.kpi-value-large {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.1;
}

/* Icône KPI moderne */
.kpi-icon-modern {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Pied de carte KPI */
.kpi-card-footer {
    margin-top: 0.75rem;
}

/* Barre de progression KPI */
.kpi-progress-bar {
    height: 5px;
    background: #f1f5f9;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    position: relative;
}

.kpi-progress-bar.warning {
    background: #fef3c7;
}

.kpi-progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.kpi-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Métadonnées KPI */
.kpi-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    flex-wrap: wrap;
}

.kpi-count {
    color: #64748b;
    font-weight: 500;
}

.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
    padding: 0.2rem 0.4rem;
    border-radius: 5px;
}

.kpi-trend.positive {
    color: #16a34a;
    background: #ecfdf5;
}

.kpi-trend.negative {
    color: #dc2626;
    background: #fef2f2;
}

.kpi-trend.neutral {
    color: #64748b;
    background: #f1f5f9;
}

.kpi-vs {
    color: #94a3b8;
    font-weight: 500;
}

/* Sparkline (mini graphique) */
.kpi-sparkline {
    height: 40px;
    margin-top: 1rem;
    position: relative;
}

/* Jauge circulaire */
.kpi-gauge-container {
    width: 56px;
    height: 56px;
    position: relative;
}

/* Graphique donut */
.kpi-donut-chart {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: conic-gradient(
        #16a34a 0deg 268.2deg,
        #e2e8f0 268.2deg 360deg
    );
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-left: auto;
}

.kpi-donut-chart::before {
    content: '';
    width: 56px;
    height: 56px;
    background: white;
    border-radius: 50%;
    position: absolute;
}

/* Étoiles de notation */
.kpi-stars {
    display: flex;
    gap: 0.25rem;
    font-size: 1.25rem;
    color: #f59e0b;
    margin-left: auto;
}

/* Breakdown NPS */
.kpi-nps-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.nps-segment {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #64748b;
}

.nps-bar {
    height: 6px;
    border-radius: 3px;
}

.nps-bar.promoters {
    background: #16a34a;
}

.nps-bar.neutrals {
    background: #f59e0b;
}

.nps-bar.detractors {
    background: #dc2626;
}

/* Barres d'engagement */
.kpi-engagement-bars {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.engagement-item {
    display: grid;
    grid-template-columns: 60px 1fr 50px;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.engagement-item span:first-child {
    color: #64748b;
    font-weight: 600;
}

.engagement-item span:last-child {
    text-align: right;
    color: #1e293b;
    font-weight: 600;
}

.engagement-bar {
    height: 6px;
    background: #f1f5f9;
    border-radius: 3px;
    overflow: hidden;
}

.engagement-bar div {
    height: 100%;
    background: #ea580c;
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* Breakdown par canal */
.kpi-channel-breakdown {
    display: flex;
    gap: 0.75rem;
    justify-content: space-around;
    margin-left: auto;
}

.channel-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.channel-item i {
    font-size: 1.25rem;
    color: #64748b;
}

.channel-item span {
    font-size: 0.75rem;
    font-weight: 600;
    color: #1e293b;
}

/* Section graphiques */
.kpi-charts-section {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-chart-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.kpi-chart-card.large {
    grid-column: span 3;
}

.chart-header {
    margin-bottom: 1.5rem;
}

.chart-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.25rem 0;
}

.chart-subtitle {
    font-size: 0.875rem;
    color: #64748b;
    margin: 0;
}

.chart-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.chart-toggle {
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-toggle:hover {
    border-color: #cbd5e1;
    color: #334155;
}

.chart-toggle.active {
    background: #16a34a;
    border-color: #16a34a;
    color: white;
}

/* Section insights */
.kpi-insights-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 1.5rem 0;
}

.section-title i {
    color: #f59e0b;
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.insight-card {
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid;
    background: #f8fafc;
}

.insight-card.success {
    border-color: #16a34a;
}

.insight-card.warning {
    border-color: #f59e0b;
}

.insight-card.danger {
    border-color: #dc2626;
}

.insight-card.info {
    border-color: #2563eb;
}

.insight-title {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.insight-message {
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.5;
}

.insight-action {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: white;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #16a34a;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.insight-action:hover {
    background: #ecfdf5;
}

/* Modal détail KPI */
.kpi-detail-modal {
    max-width: 900px;
}

.insight-detail-modal {
    max-width: 800px;
}

.kpi-detail-content,
.insight-detail-content {
    padding: 1.5rem;
}

.kpi-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #f1f5f9;
}

.kpi-detail-main-value {
    font-size: 3rem;
    font-weight: 700;
    color: #1e293b;
}

.kpi-detail-trend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    margin-top: 0.5rem;
}

.kpi-detail-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-detail-stat {
    text-align: center;
}

.kpi-detail-stat-label {
    font-size: 0.8125rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.kpi-detail-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

.kpi-detail-chart {
    height: 300px;
    margin-bottom: 2rem;
}

.kpi-detail-breakdown {
    background: #f8fafc;
    border-radius: 8px;
    padding: 1.5rem;
}

.kpi-detail-breakdown h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 1rem 0;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e2e8f0;
}

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

.breakdown-label {
    font-weight: 500;
    color: #334155;
}

.breakdown-value {
    font-weight: 600;
    color: #1e293b;
}

/* Styles pour insights détaillés */
.insight-detail-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.insight-detail-type {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.insight-detail-type.success {
    background: #ecfdf5;
    color: #16a34a;
}

.insight-detail-type.warning {
    background: #fef3c7;
    color: #d97706;
}

.insight-detail-type.info {
    background: #eff6ff;
    color: #2563eb;
}

.insight-detail-description {
    font-size: 1rem;
    color: #334155;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.insight-detail-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

.insight-metric-box {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.insight-metric-label {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.insight-metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

.insight-metric-change {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.action-plan {
    margin-top: 2rem;
}

.action-plan-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-step {
    background: white;
    border-left: 4px solid #16a34a;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    border-radius: 0 8px 8px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.action-step.priority-high {
    border-left-color: #dc2626;
}

.action-step.priority-medium {
    border-left-color: #f59e0b;
}

.action-step.priority-low {
    border-left-color: #2563eb;
}

.action-step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.action-step-title {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9375rem;
}

.action-step-priority {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.action-step-priority.high {
    background: #fef2f2;
    color: #dc2626;
}

.action-step-priority.medium {
    background: #fef3c7;
    color: #d97706;
}

.action-step-priority.low {
    background: #eff6ff;
    color: #2563eb;
}

.action-step-description {
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.action-step-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.8125rem;
    color: #94a3b8;
}

.action-step-meta i {
    margin-right: 0.25rem;
}

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

.recommendation-card {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.recommendation-title {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.recommendation-title i {
    color: #16a34a;
}

.recommendation-text {
    font-size: 0.8125rem;
    color: #64748b;
    line-height: 1.5;
}

.timeline-section {
    margin-top: 2rem;
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 8px;
}

.timeline-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1rem;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    position: relative;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 28px;
    bottom: -12px;
    width: 2px;
    background: #e2e8f0;
}

.timeline-item:last-child::before {
    display: none;
}

.timeline-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 3px solid #16a34a;
    flex-shrink: 0;
    margin-top: 2px;
}

.timeline-dot.current {
    background: #16a34a;
}

.timeline-content {
    flex: 1;
}

.timeline-date {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.timeline-action {
    font-size: 0.875rem;
    color: #1e293b;
    font-weight: 600;
}

.timeline-description {
    font-size: 0.8125rem;
    color: #64748b;
    margin-top: 0.25rem;
}

/* Filtrage par catégorie */
.kpi-card-modern[data-category] {
    transition: opacity 0.3s, transform 0.3s;
}

.kpi-card-modern[data-category].hidden {
    display: none; /* Masquer complètement au lieu de opacity */
}

.timeline-description {
    font-size: 0.8125rem;
    color: #64748b;
    margin-top: 0.25rem;
}

/* Section Documentation KPI */
.kpi-documentation-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-top: 2rem;
}

.documentation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}

.documentation-content {
    margin-top: 1.5rem;
}

.documentation-content table {
    width: 100%;
    font-size: 0.875rem;
}

.documentation-content table code {
    background: #f1f5f9;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.8125rem;
    color: #475569;
    display: inline-block;
}

.documentation-content table td,
.documentation-content table th {
    padding: 0.75rem;
    vertical-align: middle;
}

.documentation-content table tbody tr:hover {
    background: #f8fafc;
}

/* Responsive */
@media (max-width: 1400px) {
    .kpi-charts-section {
        grid-template-columns: 1fr 1fr;
    }
    
    .kpi-chart-card.large {
        grid-column: span 2;
    }
}

@media (max-width: 1024px) {
    .kpi-overview-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .kpi-charts-section {
        grid-template-columns: 1fr;
    }
    
    .kpi-chart-card.large {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .kpi-header-section {
        flex-direction: column;
    }
    
    .kpi-overview-grid {
        grid-template-columns: 1fr;
    }
    
    .kpi-detail-stats {
        grid-template-columns: 1fr;
    }
}

/* Animation d'entrée */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kpi-card-modern {
    animation: fadeInUp 0.4s ease-out backwards;
}

.kpi-card-modern:nth-child(1) { animation-delay: 0.05s; }
.kpi-card-modern:nth-child(2) { animation-delay: 0.1s; }
.kpi-card-modern:nth-child(3) { animation-delay: 0.15s; }
.kpi-card-modern:nth-child(4) { animation-delay: 0.2s; }
.kpi-card-modern:nth-child(5) { animation-delay: 0.25s; }
.kpi-card-modern:nth-child(6) { animation-delay: 0.3s; }
.kpi-card-modern:nth-child(7) { animation-delay: 0.35s; }
.kpi-card-modern:nth-child(8) { animation-delay: 0.4s; }
.kpi-card-modern:nth-child(9) { animation-delay: 0.45s; }
.kpi-card-modern:nth-child(10) { animation-delay: 0.5s; }
.kpi-card-modern:nth-child(11) { animation-delay: 0.55s; }
.kpi-card-modern:nth-child(12) { animation-delay: 0.6s; }
.kpi-card-modern:nth-child(13) { animation-delay: 0.65s; }
.kpi-card-modern:nth-child(14) { animation-delay: 0.7s; }
.kpi-card-modern:nth-child(15) { animation-delay: 0.75s; }
.kpi-card-modern:nth-child(16) { animation-delay: 0.8s; }
