/* ============================================
   ONGLET CONTRÔLE & INDICATEURS - DESIGN MODERNE
   ============================================ */

.controle-content {
    padding: 24px !important;
    background: linear-gradient(135deg, #F8FAFB 0%, #FFFFFF 100%) !important;
    min-height: 600px !important;
}

/* ============================================
   SECTION KPI CARDS
   ============================================ */

.kpi-section {
    margin-bottom: 32px !important;
}

.kpi-cards {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    gap: 20px !important;
    margin-bottom: 24px !important;
}

.kpi-card {
    background: linear-gradient(135deg, #FFFFFF 0%, #F8FAFB 100%) !important;
    border-radius: 16px !important;
    padding: 24px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    overflow: hidden !important;
    border: 2px solid transparent !important;
}

.kpi-card::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 5px !important;
    background: linear-gradient(90deg, var(--kpi-color, #0078D4), var(--kpi-color-light, #40A6FF)) !important;
    transition: height 0.3s ease !important;
}

.kpi-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
    border-color: var(--kpi-color, #0078D4) !important;
}

.kpi-card:hover::before {
    height: 6px !important;
}

.kpi-card-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 16px !important;
}

.kpi-card-title {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #605E5C !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.kpi-card-title i {
    font-size: 18px !important;
    color: var(--kpi-color, #0078D4) !important;
}

.kpi-card-value {
    font-size: 42px !important;
    font-weight: 800 !important;
    color: #323130 !important;
    margin: 12px 0 !important;
    line-height: 1 !important;
    background: linear-gradient(135deg, var(--kpi-color, #0078D4), var(--kpi-color-light, #40A6FF)) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}

.kpi-card-subtitle {
    font-size: 12px !important;
    color: #605E5C !important;
    margin-top: 8px !important;
    line-height: 1.6 !important;
}

.kpi-card-details {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    margin-top: 16px !important;
    padding-top: 16px !important;
    border-top: 1px solid #E1E4E8 !important;
}

.kpi-detail-item {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 13px !important;
}

.kpi-detail-label {
    color: #605E5C !important;
    font-weight: 500 !important;
}

.kpi-detail-value {
    color: #323130 !important;
    font-weight: 700 !important;
}

.kpi-ecart {
    padding: 4px 10px !important;
    border-radius: 12px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
}

.kpi-ecart.positive {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%) !important;
    color: #FFFFFF !important;
}

.kpi-ecart.negative {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%) !important;
    color: #FFFFFF !important;
}

.kpi-ecart.zero {
    background: #F3F2F1 !important;
    color: #605E5C !important;
}

/* Couleurs spécifiques par type de KPI */
.kpi-card.conforme {
    --kpi-color: #10B981 !important;
    --kpi-color-light: #34D399 !important;
}

.kpi-card.nonconforme {
    --kpi-color: #EF4444 !important;
    --kpi-color-light: #F87171 !important;
}

.kpi-card.rebut {
    --kpi-color: #6B7280 !important;
    --kpi-color-light: #9CA3AF !important;
}

.kpi-card.disponibilite {
    --kpi-color: #3B82F6 !important;
    --kpi-color-light: #60A5FA !important;
}

/* ============================================
   SECTION CHART
   ============================================ */

.chart-section {
    margin-bottom: 32px !important;
}

.chart-container {
    background: #FFFFFF !important;
    border-radius: 16px !important;
    padding: 24px !important;
    padding-bottom: 40px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
    border: 1px solid #E1E4E8 !important;
    min-height: 450px !important;
}

.chart-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 20px !important;
    padding-bottom: 16px !important;
    border-bottom: 2px solid #F3F2F1 !important;
}

.chart-header h4 {
    margin: 0 !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    color: #323130 !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

.chart-header h4::before {
    content: '' !important;
    width: 4px !important;
    height: 24px !important;
    background: linear-gradient(135deg, #0078D4 0%, #40A6FF 100%) !important;
    border-radius: 2px !important;
}

.chart-container canvas {
    max-height: 450px !important;
    min-height: 350px !important;
    height: 400px !important;
    width: 100% !important;
}

/* ============================================
   SECTION GRID (TABLEAU)
   ============================================ */

.grid-section {
    margin-bottom: 24px !important;
}

.grid-container {
    background: #FFFFFF !important;
    border-radius: 16px !important;
    padding: 24px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
    border: 1px solid #E1E4E8 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
}

/* Container pour le tableau de contrôle avec scroll */
.controle-table-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    margin-top: 16px !important;
    position: relative !important;
}

.data-grid-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    position: relative !important;
}

.grid-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 20px !important;
    padding-bottom: 16px !important;
    border-bottom: 2px solid #F3F2F1 !important;
}

.grid-header h4 {
    margin: 0 !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    color: #323130 !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

.grid-header h4::before {
    content: '' !important;
    width: 4px !important;
    height: 24px !important;
    background: linear-gradient(135deg, #0078D4 0%, #40A6FF 100%) !important;
    border-radius: 2px !important;
}

/* Tableau de contrôle */
.controle-grid {
    width: 100% !important;
    min-width: 1200px !important;
    border-collapse: collapse !important;
    font-size: 13px !important;
    table-layout: fixed !important;
}

.controle-grid th,
.controle-grid td {
    box-sizing: border-box !important;
    margin: 0 !important;
}

.controle-grid thead {
    background: linear-gradient(135deg, #F8FAFB 0%, #F3F2F1 100%) !important;
}

.controle-grid th {
    padding: 14px 12px !important;
    text-align: left !important;
    font-weight: 700 !important;
    color: #323130 !important;
    font-size: 12px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    border: 1px solid #E1E4E8 !important;
    border-top: none !important;
    white-space: nowrap !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background: linear-gradient(135deg, #F8FAFB 0%, #F3F2F1 100%) !important;
    vertical-align: middle !important;
}

.controle-grid th:first-child {
    border-left: none !important;
}

.controle-grid th:last-child {
    border-right: none !important;
}

/* Largeurs fixes pour les autres colonnes - doivent correspondre exactement entre th et td */
.controle-grid th:nth-child(2),
.controle-grid th:nth-child(3),
.controle-grid th:nth-child(4),
.controle-grid th:nth-child(5),
.controle-grid th:nth-child(6),
.controle-grid th:nth-child(7),
.controle-grid th:nth-child(8),
.controle-grid th:nth-child(9),
.controle-grid th:nth-child(10),
.controle-grid th:nth-child(11),
.controle-grid th:nth-child(12),
.controle-grid th:nth-child(13),
.controle-grid td:nth-child(2),
.controle-grid td:nth-child(3),
.controle-grid td:nth-child(4),
.controle-grid td:nth-child(5),
.controle-grid td:nth-child(6),
.controle-grid td:nth-child(7),
.controle-grid td:nth-child(8),
.controle-grid td:nth-child(9),
.controle-grid td:nth-child(10),
.controle-grid td:nth-child(11),
.controle-grid td:nth-child(12),
.controle-grid td:nth-child(13) {
    width: calc((100% - 150px) / 12) !important;
    min-width: 100px !important;
    max-width: calc((100% - 150px) / 12) !important;
}

/* Aligner les en-têtes des colonnes numériques à droite */
.controle-grid th:nth-child(2),
.controle-grid th:nth-child(3),
.controle-grid th:nth-child(5),
.controle-grid th:nth-child(6),
.controle-grid th:nth-child(8),
.controle-grid th:nth-child(9),
.controle-grid th:nth-child(11),
.controle-grid th:nth-child(12) {
    text-align: right !important;
}

/* Centrer les en-têtes des colonnes d'écart */
.controle-grid th:nth-child(4),
.controle-grid th:nth-child(7),
.controle-grid th:nth-child(10),
.controle-grid th:nth-child(13) {
    text-align: center !important;
}

.controle-grid th:first-child {
    background: linear-gradient(135deg, #0078D4 0%, #40A6FF 100%) !important;
    color: #FFFFFF !important;
    position: sticky !important;
    left: 0 !important;
    z-index: 20 !important;
    width: 150px !important;
    min-width: 150px !important;
    max-width: 150px !important;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1) !important;
}

.controle-grid tbody tr {
    transition: background-color 0.2s ease !important;
}

.controle-grid tbody tr:hover {
    background-color: #F8FAFB !important;
}

.controle-grid tbody tr:last-child td {
    border-bottom: none !important;
}

.controle-grid td {
    padding: 14px 12px !important;
    color: #323130 !important;
    font-weight: 500 !important;
    vertical-align: middle !important;
    text-align: left !important;
    border: 1px solid #E1E4E8 !important;
    border-top: none !important;
}

.controle-grid td:first-child {
    border-left: none !important;
    font-weight: 700 !important;
    color: #0078D4 !important;
    text-align: left !important;
    position: sticky !important;
    left: 0 !important;
    z-index: 15 !important;
    background-color: #FFFFFF !important;
    width: 150px !important;
    min-width: 150px !important;
    max-width: 150px !important;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1) !important;
}

.controle-grid td:last-child {
    border-right: none !important;
}

.controle-grid tbody tr:hover td:first-child {
    background-color: #F8FAFB !important;
}

/* Colonnes numériques alignées à droite pour correspondre aux en-têtes */
.controle-grid td:nth-child(2),
.controle-grid td:nth-child(3),
.controle-grid td:nth-child(5),
.controle-grid td:nth-child(6),
.controle-grid td:nth-child(8),
.controle-grid td:nth-child(9),
.controle-grid td:nth-child(11),
.controle-grid td:nth-child(12) {
    text-align: right !important;
    font-family: 'Inter', 'Roboto Mono', monospace !important;
}

/* Colonnes d'écart (4, 7, 10, 13) centrées pour correspondre aux en-têtes */
.controle-grid td:nth-child(4),
.controle-grid td:nth-child(7),
.controle-grid td:nth-child(10),
.controle-grid td:nth-child(13) {
    text-align: center !important;
}

/* Style pour les écarts */
.controle-grid td.ecart-positive,
.controle-grid td.ecart-negative,
.controle-grid td.ecart-zero {
    font-weight: 700 !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    display: table-cell !important;
    text-align: center !important;
    vertical-align: middle !important;
}

/* Styles d'écart */
.controle-grid td.ecart-positive {
    background: linear-gradient(135deg, #D1FAE5 0%, #A7F3D0 100%) !important;
    color: #065F46 !important;
}

.controle-grid td.ecart-negative {
    background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%) !important;
    color: #991B1B !important;
}

.controle-grid td.ecart-zero {
    background: #F3F2F1 !important;
    color: #605E5C !important;
}

/* ============================================
   ÉTAT VIDE
   ============================================ */

.controle-content:empty::before {
    content: '📊 Chargement des indicateurs...' !important;
    display: block !important;
    text-align: center !important;
    padding: 40px !important;
    color: #605E5C !important;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .kpi-cards {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .controle-grid {
        font-size: 12px !important;
    }
    
    .controle-grid th,
    .controle-grid td {
        padding: 10px 8px !important;
    }
}

@media (max-width: 768px) {
    .controle-content {
        padding: 16px !important;
    }
    
    .kpi-cards {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .chart-container,
    .grid-container {
        padding: 16px !important;
    }
    
    .controle-grid {
        font-size: 11px !important;
        display: block !important;
        overflow-x: auto !important;
    }
    
    .kpi-card-value {
        font-size: 36px !important;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes kpiCardSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kpi-card {
    animation: kpiCardSlideIn 0.4s ease-out forwards !important;
}

.kpi-card:nth-child(1) {
    animation-delay: 0.1s !important;
}

.kpi-card:nth-child(2) {
    animation-delay: 0.2s !important;
}

.kpi-card:nth-child(3) {
    animation-delay: 0.3s !important;
}

.kpi-card:nth-child(4) {
    animation-delay: 0.4s !important;
}

/* ============================================
   SCROLLBAR PERSONNALISÉE
   ============================================ */

.data-grid-container::-webkit-scrollbar {
    height: 8px !important;
}

.data-grid-container::-webkit-scrollbar-track {
    background: #F3F2F1 !important;
    border-radius: 4px !important;
}

.data-grid-container::-webkit-scrollbar-thumb {
    background: #C8C6C4 !important;
    border-radius: 4px !important;
}

.data-grid-container::-webkit-scrollbar-thumb:hover {
    background: #A19F9D !important;
}


