/* --- Styles Généraux --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    display: flex;
    flex-direction: column; /* <--- IMPERATIF : Empile les éléments verticalement */
    align-items: center;    /* <--- IMPERATIF : Centre les éléments horizontalement */
    justify-content: center;
    padding: 20px;
    margin: 0;
    min-height: 100vh; /* Optionnel : Centre le tout verticalement sur l'écran */
}

.container {
    width: 100%;
    max-width: 1100px;
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

h1 {
    text-align: center;
    color: #003366;
    margin-bottom: 30px;
    font-size: 1.6em;
}

h2 {
    color: #333;
    border-left: 5px solid #003366;
    padding-left: 10px;
    margin-top: 30px;
}

/* --- Barre d'actions (Boutons Icones) --- */
.action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 10px;
}

.btn-icon {
    padding: 8px 15px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.3s;
}

.btn-icon:hover { background-color: #5a6268; }
.btn-share { background-color: #17a2b8; }
.btn-share:hover { background-color: #138496; }

/* --- Formulaire --- */
.input-table {
    display: table;
    width: 100%;
    border-spacing: 0 10px;
}

.input-row {
    display: flex;
    margin-bottom: 10px;
    align-items: center;
}

.cell { padding: 10px; }

.header {
    background-color: #e9ecef;
    font-weight: 600;
    width: 40%;
    border: 1px solid #ddd;
    border-right: none;
    border-radius: 5px 0 0 5px;
    display: flex;
    align-items: center;
}

.input-field {
    width: 60%;
    border: 1px solid #ddd;
    border-radius: 0 5px 5px 0;
    padding: 0;
}

input[type="text"], input[type="date"], select {
    width: 100%;
    padding: 12px;
    border: none;
    font-size: 1em;
    box-sizing: border-box;
    outline: none;
    background: transparent;
}

#calculerBtn {
    width: 100%;
    padding: 15px;
    background-color: #0056b3;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.3s;
}

#calculerBtn:hover { background-color: #004494; }

/* --- Tableau de Résultats --- */
.table-scroll-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin-top: 15px;
}

.output-table {
    width: 100%;
    min-width: 850px;
    border-collapse: collapse;
}

.output-row th, .output-row td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: right;
    font-size: 0.95em;
}

.output-label {
    text-align: left !important;
    background-color: #f8f9fa;
    font-weight: bold;
    width: 20%;
    position: sticky;
    left: 0;
    z-index: 10;
}

/* Couleurs des Scénarios */
.header-value {
    text-align: center !important;
    color: white;
    font-weight: bold;
    vertical-align: top;
}
.scenario-1 { background-color: #27ae60; } 
.scenario-2 { background-color: #2980b9; } 
.scenario-3 { background-color: #8e44ad; } 
.scenario-4 { background-color: #34495e; } 

.total-row td {
    background-color: #fff3cd;
    color: #856404;
    font-weight: 900;
    font-size: 1.1em;
    border-top: 2px solid #333;
}

/* --- MOBILE --- */
@media (max-width: 700px) {
    .input-row { flex-direction: column; }
    .header, .input-field { width: 100%; border-radius: 5px; }
    .header { margin-bottom: 5px; border: 1px solid #ddd; }
}

/* --- IMPRESSION (PDF A4) --- */
@media print {
    body {
        background-color: white;
        padding: 0;
        margin: 0;
        font-size: 12pt;
    }
    .container {
        box-shadow: none;
        max-width: 100%;
        padding: 0;
        margin: 0;
    }
    /* Cacher les boutons lors de l'impression */
    .no-print { display: none !important; }

    /* Ajustements pour que ça rentre sur A4 */
    h1 { font-size: 1.4em; margin-bottom: 10px; color: black; }
    h2 { font-size: 1.2em; border-left: 3px solid #000; margin-top: 15px; }

    .input-table { margin-bottom: 10px; }
    
    /* Force l'affichage du tableau complet sans ascenseur */
    .table-scroll-container {
        overflow: visible;
        border: none;
    }
    .output-table {
        min-width: 100%;
        width: 100%;
        font-size: 0.8em; /* Réduit un peu la police du tableau pour tout faire rentrer */
    }
    
    /* Assure que les couleurs de fond s'impriment */
    .header-value, .scenario-1, .scenario-2, .scenario-3, .scenario-4, .total-row td {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    /* Évite de couper un tableau au milieu d'une page */
    table, tr, td, th { page-break-inside: avoid; }
}