/**
 * Refonte complète du design de la section Synthèse
 * Design moderne, aéré, avec meilleure hiérarchie visuelle
 */

/* ============================== */
/* Conteneur principal            */
/* ============================== */
.synthesis-section {
    max-width: 1600px;
    margin: 0 auto;
}

.synthesis-section header {
    background: linear-gradient(135deg, var(--color-primary), #6366f1);
    color: white;
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-lg);
}

.synthesis-section header h1 {
    color: white;
    font-size: 1.3rem;
    margin-bottom: var(--spacing-xs);
}

.synthesis-section header p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
}

/* ============================== */
/* Sélecteur de mois              */
/* ============================== */
.synthesis-controls {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    box-shadow: var(--shadow-sm);
}

.synthesis-controls label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.synthesis-controls select {
    flex: 0 0 200px;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: all var(--transition-base);
}

.synthesis-controls select:hover {
    border-color: var(--color-primary);
}

.synthesis-controls select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* ============================== */
/* Blocs principaux               */
/* ============================== */
.synth-block {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: box-shadow var(--transition-base);
}

.synth-block:hover {
    box-shadow: var(--shadow-lg);
}

/* Header des blocs */
.synth-block-header {
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 0;
    position: relative;
    overflow: hidden;
}

.synth-block-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit;
    opacity: 0.95;
}

.synth-block-header h2 {
    position: relative;
    z-index: 1;
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Gradients des headers - Charte élégante */
.synth-header-rentability {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.synth-header-cost {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
}

.synth-header-usage {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.synth-header-perf {
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
}

/* ============================== */
/* Sous-blocs (sections)          */
/* ============================== */
.synth-subblock {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color-light);
}

.synth-subblock:last-child {
    border-bottom: none;
}

.synth-subtitle {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--spacing-sm) 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.synth-subtitle::before {
    content: '';
    width: 4px;
    height: 1.2em;
    background: var(--color-primary);
    border-radius: 2px;
}

/* Sous-blocs héros (mise en avant) */
.synth-subblock-hero {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-bottom: 2px solid var(--border-color);
}

.synth-subblock-hero .synth-subtitle {
    font-size: 1.3rem;
    color: var(--text-primary);
}

/* ============================== */
/* Cellules de données            */
/* ============================== */
.synth-row {
    display: flex;
    gap: var(--spacing-xs);
    flex-wrap: wrap;
}

.synth-row:not(:last-child) {
    margin-bottom: var(--spacing-xs);
}

.synth-cell {
    flex: 1;
    min-width: 160px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

/* Row label styling for table-like layout */
.synth-row-label {
    flex: 0 0 auto;
    min-width: 140px;
    max-width: 140px;
    background: var(--bg-secondary);
    font-weight: 600;
    justify-content: center;
}

.synth-row-label .synth-label {
    font-weight: 600;
    color: var(--text-primary);
}

.synth-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--color-primary);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.synth-cell:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.synth-cell:hover::before {
    opacity: 1;
}

.synth-cell-wide {
    min-width: 100%;
}

.synth-cell-highlight {
    background: linear-gradient(135deg, #ede9fe, #ddd6fe);
    border-color: #c4b5fd;
}

.synth-cell-highlight:hover {
    border-color: #a78bfa;
}

.synth-cell-hero {
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    border: 2px solid var(--border-color);
    padding: var(--spacing-md);
}

.synth-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.synth-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.synth-value-num {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--color-primary);
}

/* ============================== */
/* Delta (variations) - Contexte  */
/* ============================== */

/* Par défaut: COST sections (baisse = vert, hausse = rouge) */
.synth-delta {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px var(--spacing-xs);
    border-radius: var(--radius-sm);
    margin-left: var(--spacing-xs);
    vertical-align: middle;
}

.synth-delta-up {
    background: #fee2e2;
    color: #991b1b;
}

.synth-delta-down {
    background: #dcfce7;
    color: #166534;
}

.synth-delta-neutral {
    background: var(--color-gray-100);
    color: var(--text-secondary);
}

/* Inversion pour USAGE/PERFORMANCE (hausse = vert, baisse = rouge) */
[data-higher-better="true"] .synth-delta-up {
    background: #dcfce7;
    color: #166534;
}

[data-higher-better="true"] .synth-delta-down {
    background: #fee2e2;
    color: #991b1b;
}

/* Conteneur pour valeur + delta sur la même ligne */
.synth-right {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: flex-start;
    gap: var(--spacing-xs);
    flex-wrap: nowrap;
    white-space: nowrap;
}

.synth-value-num {
    display: inline-block;
}

.synth-cell .synth-right {
    display: flex !important;
    flex-direction: row !important;
}

/* ============================== */
/* Grid des comptes AWS - 4x2     */
/* ============================== */
.synth-account-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xs);
}

@media (max-width: 1400px) {
    .synth-account-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1000px) {
    .synth-account-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.synth-account-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-base);
}

.synth-account-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-primary);
}

.synth-account-card .synth-subtitle {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    padding: var(--spacing-xs) var(--spacing-sm);
    margin: 0;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
}

.synth-account-card .synth-subtitle::before {
    display: none;
}

.synth-account-card .synth-row {
    padding: var(--spacing-xs);
    margin: 0;
    display: flex;
    flex-direction: column; /* Empiler verticalement */
    gap: 2px;
}

.synth-account-card .synth-cell {
    flex: none;
    width: 100%;
    padding: 6px var(--spacing-sm);
    font-size: 0.8rem;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-xs);
}

.synth-account-card .synth-cell .synth-label {
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.synth-account-card .synth-cell .synth-value {
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    text-align: right;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--spacing-xs);
}

/* Variations horizontales */
.synth-account-card .synth-cell .synth-value .synth-delta {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
}

.synth-account-card .synth-value-num {
    flex-shrink: 0;
}

.synth-account-global-banner {
    background: linear-gradient(135deg, var(--color-primary), #6366f1);
    color: white;
    padding: var(--spacing-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.synth-account-global-banner .synth-label {
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.synth-account-global-banner .synth-value-num,
.synth-account-global-banner .synth-value {
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.synth-account-global-banner .synth-delta {
    font-size: 0.65rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 1px 6px;
    border-radius: 10px;
    white-space: nowrap;
}

/* ============================== */
/* Groupes de services            */
/* ============================== */
.synth-services-group {
    margin-top: var(--spacing-sm);
    padding-top: var(--spacing-sm);
    border-top: 2px dashed var(--border-color);
}

.synth-services-group .synth-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.synth-services-group .synth-subtitle::before {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Couleurs par service */
.synth-services-group[data-service="other"] .synth-subtitle::before {
    background: #8b5cf6;
}

.synth-services-group[data-service="github"] .synth-subtitle::before {
    background: #24292f;
}

.synth-services-group[data-service="circleci"] .synth-subtitle::before {
    background: #049b4a;
}

.synth-services-group[data-service="newrelic"] .synth-subtitle::before {
    background: #008c99;
}

/* ============================== */
/* Responsive                     */
/* ============================== */
@media (max-width: 1200px) {
    .synth-account-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .synthesis-section header {
        padding: var(--spacing-lg);
    }

    .synthesis-section header h1 {
        font-size: 1.5rem;
    }

    .synthesis-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .synthesis-controls select {
        flex: 1;
    }

    .synth-block-header h2 {
        font-size: 1.25rem;
    }

    .synth-row {
        flex-direction: column;
    }

    .synth-cell {
        min-width: auto;
    }

    .synth-account-grid {
        grid-template-columns: 1fr;
    }

    .synth-value {
        font-size: 1.5rem;
    }

    .synth-value-num {
        font-size: 1.75rem;
    }
}

/* ============================== */
/* Animations                     */
/* ============================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.synth-block {
    animation: fadeInUp 0.4s ease-out;
    animation-fill-mode: both;
}

.synth-block:nth-child(1) { animation-delay: 0.1s; }
.synth-block:nth-child(2) { animation-delay: 0.2s; }
.synth-block:nth-child(3) { animation-delay: 0.3s; }
.synth-block:nth-child(4) { animation-delay: 0.4s; }
.synth-block:nth-child(5) { animation-delay: 0.5s; }
.synth-block:nth-child(6) { animation-delay: 0.6s; }

/* ============================== */
/* States & Utilities             */
/* ============================== */
.synth-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    color: var(--text-tertiary);
    font-style: italic;
}

.synth-empty {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-tertiary);
}

.synth-error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    margin: var(--spacing-md) 0;
}

/* ============================== */
/* Total Global - Design sobre    */
/* ============================== */
.synth-total-global {
    background: var(--bg-primary);
    padding: var(--spacing-md) !important;
    border: 2px solid var(--color-primary);
}

.synth-total-global .synth-subtitle {
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: var(--spacing-sm);
}

.synth-total-global .synth-subtitle::before {
    background: var(--color-primary);
}

.synth-cell-total {
    background: linear-gradient(135deg, #f8fafc 0%, #e0f2fe 100%);
    color: var(--text-primary);
    border: 1px solid var(--color-primary) !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    padding: var(--spacing-md) !important;
    position: relative;
    overflow: hidden;
}

.synth-cell-total::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: var(--color-primary);
}

.synth-cell-total .synth-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.synth-cell-total .synth-value {
    color: var(--color-primary) !important;
    font-size: 1.8rem;
    font-weight: 800;
}
