/* 
 * Styles avancés pour l'entête de statistiques des boîtiers OTB
 * Widgets modernes avec graphiques intégrés
 */

/* Variables CSS pour la cohérence des couleurs */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-gradient: linear-gradient(135deg, #56ab2f, #a8e6cf);
    --warning-gradient: linear-gradient(135deg, #f093fb, #f5576c);
    --info-gradient: linear-gradient(135deg, #4facfe, #00f2fe);
    --danger-gradient: linear-gradient(135deg, #fa709a, #fee140);
    --dark-gradient: linear-gradient(135deg, #2c3e50, #3498db);
    
    --widget-shadow: 0 4px 16px rgba(0,0,0,0.06);
    --widget-shadow-hover: 0 10px 20px rgba(0,0,0,0.1);
    --border-radius: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --text-muted: #868e96;
    --border-light: #e9ecef;
}

/* Conteneur principal des statistiques */
.advanced-stats-header {
    background: white;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--widget-shadow);
    border: 1px solid #e9ecef;
    position: relative;
    overflow: hidden;
}

/* Effet de texture subtil */
.advanced-stats-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="%23667eea" opacity="0.02"/><circle cx="75" cy="75" r="1" fill="%23764ba2" opacity="0.01"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    pointer-events: none;
}

/* Titre principal */
.stats-header-title {
    color: #2c3e50;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    z-index: 1;
}

.stats-header-title i {
    font-size: 32px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: rotate 10s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Grille des widgets */
.stats-widgets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
    position: relative;
    z-index: 1;
}

/* Widget moderne de base */
.stat-widget-modern {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--widget-shadow);
    border: 1px solid #e9ecef;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-widget-modern::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(102, 126, 234, 0.02) 50%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-widget-modern:hover {
    transform: translateY(-5px);
    box-shadow: var(--widget-shadow-hover);
    border-color: #667eea;
}

.stat-widget-modern:hover::before {
    opacity: 1;
}

/* En-tête du widget */
.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

/* Icône du widget */
.widget-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: transform 0.3s ease;
}

.widget-icon:hover {
    transform: scale(1.1);
}

.widget-icon.primary { background: var(--primary-gradient); }
.widget-icon.success { background: var(--success-gradient); }
.widget-icon.warning { background: var(--warning-gradient); }
.widget-icon.info { background: var(--info-gradient); }
.widget-icon.danger { background: var(--danger-gradient); }
.widget-icon.dark { background: var(--dark-gradient); }

/* Valeurs principales */
.widget-main-value {
    font-size: 36px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 5px;
    transition: color 0.3s ease;
}

.widget-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Conteneur des graphiques */
.widget-chart-container {
    width: 80px;
    height: 80px;
    position: relative;
    margin: 0 auto;
}

.widget-chart-mini {
    width: 100%;
    height: 100%;
}

/* Barres de progression modernes */
.widget-progress {
    margin-top: 15px;
    position: relative;
}

.progress-modern {
    height: 6px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-modern {
    height: 100%;
    border-radius: 3px;
    transition: width 1s ease-in-out;
    position: relative;
}

.progress-bar-modern::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.widget-percentage {
    font-size: 12px;
    font-weight: 600;
    margin-top: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
}

/* Indicateurs de tendance */
.trend-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(248, 249, 250, 0.8);
}

.trend-up { 
    color: #27ae60; 
    background: rgba(39, 174, 96, 0.1);
}

.trend-down { 
    color: #e74c3c; 
    background: rgba(231, 76, 60, 0.1);
}

.trend-stable { 
    color: #f39c12; 
    background: rgba(243, 156, 18, 0.1);
}

/* Widget d'alerte avec animation */
.alert-widget {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
    color: #2c3e50;
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 8px 32px rgba(255, 154, 158, 0.3); }
    50% { box-shadow: 0 8px 32px rgba(255, 154, 158, 0.6); }
}

.alert-widget .widget-main-value,
.alert-widget .widget-label,
.alert-widget .widget-percentage {
    color: #2c3e50 !important;
    text-shadow: none;
}

/* Widget de résumé global */
.global-summary-widget {
    grid-column: 1 / -1;
    background: var(--primary-gradient);
    color: white;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.2);
    position: relative;
}

.summary-metric {
    text-align: center;
    padding: 20px;
    position: relative;
}

.summary-metric::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    bottom: 20%;
    width: 1px;
    background: rgba(255,255,255,0.2);
}

.summary-metric:last-child::after {
    display: none;
}

.summary-metric-value {
    font-size: 48px;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.summary-metric-label {
    font-size: 14px;
    opacity: 0.95;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.summary-metric-trend {
    font-size: 12px;
    margin-top: 5px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

/* Animations d'entrée */
.stat-widget-modern {
    animation: slideInUp 0.6s ease-out;
    animation-fill-mode: both;
}

.stat-widget-modern:nth-child(1) { animation-delay: 0.1s; }
.stat-widget-modern:nth-child(2) { animation-delay: 0.2s; }
.stat-widget-modern:nth-child(3) { animation-delay: 0.3s; }
.stat-widget-modern:nth-child(4) { animation-delay: 0.4s; }
.stat-widget-modern:nth-child(5) { animation-delay: 0.5s; }
.stat-widget-modern:nth-child(6) { animation-delay: 0.6s; }

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mode sombre */
@media (prefers-color-scheme: dark) {
    .stat-widget-modern {
        background: rgba(45, 55, 72, 0.95);
        color: white;
        border-color: #4a5568;
    }
    
    .widget-main-value {
        color: white;
    }
    
    .widget-label {
        color: #cbd5e0;
    }
    
    .widget-percentage {
        color: #a0aec0;
    }
    
    .advanced-stats-header {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .stats-header-title {
        color: white;
    }
}

/* Responsive */
@media (max-width: 1200px) {
    .stats-widgets-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .advanced-stats-header {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .stats-header-title {
        font-size: 24px;
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .stats-widgets-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .global-summary-widget {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .summary-metric-value {
        font-size: 20px;
    }
    
    .widget-main-value {
        font-size: 16px;
    }
    
    .widget-chart-container {
        width: 35px;
        height: 35px;
    }
}

@media (max-width: 480px) {
    .global-summary-widget {
        grid-template-columns: 1fr;
    }
    
    .summary-metric::after {
        display: none;
    }
}

/* Amélioration de l'accessibilité */
@media (prefers-reduced-motion: reduce) {
    .stat-widget-modern {
        animation: none;
    }
    
    .progress-bar-modern::after {
        animation: none;
    }
    
    .alert-widget {
        animation: none;
    }
    
    .stats-header-title i {
        animation: none;
    }
}

/* États de focus pour l'accessibilité */
.stat-widget-modern:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Amélioration des contrastes */
@media (prefers-contrast: high) {
    .stat-widget-modern {
        border: 2px solid #2c3e50;
    }
    
    .widget-label {
        color: #2c3e50;
        font-weight: 700;
    }
}
