@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@300..700&display=swap');

/* Variables pour un Design Moderne & Épuré (White Space) */
:root {
    --primary-color: #126EAD; /* Bleu plus profond */
    --secondary-color: #126EAC; /* Vert : Résultats positifs (CV) */
    --background-color: #f4f7f9; /* Fond Gris très clair (moderne) */
    --card-background: #ffffff; 
    --text-color: #2c3e50; /* Texte anthracite pour un excellent contraste */
    --total-color: #e74c3c; /* Rouge alerte : Coût Total / Malus */
    --alert-color: #e74c3c; 
    --shadow-light: 0 4px 15px rgba(0, 0, 0, 0.08); /* Ombre améliorée */
    --border-radius: 12px; /* Coins plus arrondis */
    --font-header: 'Fredoka', sans-serif;
    --font-body: 'Roboto', sans-serif; /* Police simple et lisible (simulation) */
}

/* --- Rénitialisation et Base (Mobile First) --- */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary-color);
    transition: color 0.2s;
    text-decoration: none;
}

a:hover {
    color: #004080;
    text-decoration: underline;
}

/* --- Header --- */

.header {
    background: var(--primary-color);
    color: #ffffff;
    padding: 30px 15px;
    text-align: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.header h1 {
    font-family: var(--font-header);
    font-size: 2em;
    margin-bottom: 5px;
    font-weight: 700;
}
.header p {
    font-size: 1em;
}

/* --- Conteneur Principal --- */

.container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 15px;
    display: flex; 
    flex-direction: column;
    gap: 30px;
}

/* --- Cartes (Design Moderne) --- */

.card {
    background-color: var(--card-background);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    border: 1px solid #e0e0e0;
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
}

.card h2 {
    font-family: var(--font-header);
    color: var(--text-color);
    font-size: 1.6em;
    margin-bottom: 25px;
    border-bottom: 3px solid var(--primary-color); /* Ligne de séparation colorée */
    padding-bottom: 12px;
    font-weight: 500;
}

/* --- Formulaire et Entrées --- */

.input-group {
    margin-bottom: 25px;
}

.input-group label {
    font-weight: 600;
    font-size: 0.95em;
    margin-bottom: 10px;
    color: var(--text-color);
    display: block;
}

.input-group input,
.input-group select {
    padding: 14px;
    border: 1px solid #cccccc;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s, box-shadow 0.3s;
    background-color: #ffffff;
    width: 100%;
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.2);
    outline: none;
}

.small-text {
    font-size: 0.85em;
    color: #7f8c8d;
    margin-top: 5px;
}

/* NOUVEAU & CORRIGÉ: Sélecteur d'unité (Toggle Switch Design) */
.input-power-group {
    display: flex;
    flex-direction: column;
}

.unit-selector {
    display: flex;
    margin-bottom: 10px;
    /* Suppression des bordures externes pour un look plus clean */
    background-color: #ecf0f1; /* Fond gris clair pour l'ensemble */
    border-radius: 8px;
    overflow: hidden;
}

.unit-selector button {
    flex-grow: 1;
    padding: 12px 0;
    border: none;
    background-color: transparent;
    color: var(--text-color);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, box-shadow 0.3s;
    font-size: 1em;
    /* Séparation visuelle entre les boutons si nécessaire */
    border-right: 1px solid #bdc3c7; 
}

.unit-selector button:last-child {
    border-right: none;
}

.unit-selector button.active {
    background-color: var(--primary-color); /* Couleur primaire pour l'actif */
    color: white;
    font-weight: 700;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1); /* Ombre interne subtile */
    border-right: none;
    border-left: none;
}

.unit-selector button:hover:not(.active) {
    background-color: #dbe4e9; /* Léger changement de couleur au survol */
}

.input-power-group input#puissance_value {
    margin-top: 10px; 
    width: 100%;
}

/* Bouton - Mobile */
.flat-button {
    padding: 18px 20px;
    font-size: 1.2em;
    background-color: var(--total-color); /* Rouge pour attirer l'attention sur l'action */
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(231, 76, 60, 0.3);
    transition: background-color 0.2s, box-shadow 0.2s;
    width: 100%;
    border: none;
    color: white;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.flat-button:hover {
    background-color: #c0392b; 
    box-shadow: 0 6px 10px rgba(231, 76, 60, 0.4);
}

/* --- Section Résultats (Mobile) --- */

.result-card {
    background-color: #f9fbfc; /* Fond pour la carte de résultat */
    order: -1;
}

.result-card h2 {
    color: var(--text-color);
    border-bottom: 3px solid var(--secondary-color);
}

.result-label {
    font-size: 0.95em;
    font-weight: 500;
    color: #7f8c8d;
    margin-bottom: 5px;
}

.big-number {
    font-family: var(--font-header);
    font-size: 3em; 
    font-weight: 600;
    color: var(--secondary-color);
    line-height: 1.1;
}

/* Couleur Malus/Total */
.malus-result {
    color: var(--total-color);
    font-size: 3em; 
}

.total-result .big-number {
    color: var(--total-color);
    font-size: 3.5em; 
}

.separator {
    border: none;
    border-top: 1px solid #bdc3c7; /* Ligne plus propre */
    margin: 20px 0;
}

.small-note {
    font-size: 0.8em;
    color: #95a5a6;
    margin-top: 10px;
}

/* --- Section Info (SEO/Contenu) --- */

.info-section {
    order: 1;
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 30px;
}

.info-title {
    font-family: var(--font-header);
    color: var(--primary-color);
    margin: 25px 0 15px;
    font-size: 1.8em;
    border-bottom: 1px solid #ccc;
    padding-bottom: 8px;
    font-weight: 700;
    line-height: 1.2em;
}

.info-subtitle {
    font-family: var(--font-header);
    color: var(--text-color);
    margin: 15px 0 8px;
    font-size: 1.3em;
    font-weight: 600;
}

.info-list {
    margin-left: 25px;
    list-style-type: '👉'; 
    padding-left: 10px;
}

.info-list li {
    margin-bottom: 8px;
}

/* Affichage de la formule */
.formula-block {
    text-align: center;
    margin: 30px 0;
}

.formula-text {
    font-family: 'Consolas', monospace;
    font-size: 1.3em;
    font-weight: 700;
    margin: 15px auto;
    padding: 20px;
    background: #e9f0f9;
    border-radius: 10px;
    border-left: 5px solid var(--primary-color);
    max-width: 650px;
    color: #495057;
    line-height: 1.5;
    overflow-x: auto;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
}

.note-box {
    background-color: #fffacd;
    color: #856404;
    padding: 15px;
    border: 1px solid #ffeeba;
    border-radius: 8px;
    margin-top: 15px;
    font-size: 0.9em;
}

/* --- Footer --- */

.footer {
    text-align: center;
    padding: 25px 15px;
    margin-top: 30px;
    border-top: 1px solid #e9ecef;
    color: #95a5a6;
    font-size: 0.85em;
}


/* ======================================= */
/* --- TABLETTE ET DESKTOP (Media Queries) --- */
/* ======================================= */

@media (min-width: 1024px) {
    
    .container {
        margin: 50px auto;
        padding: 0 30px;
        display: grid; 
        grid-template-columns: 1fr 1fr;
        gap: 40px;
    }

    .calculator-card {
        order: 0; 
        padding: 40px;
    }

    .result-card {
        order: 0; 
        padding: 40px;
    }
    
    .info-section {
        grid-column: 1 / -1; 
        padding: 40px;
    }
    
    .big-number, .malus-result {
        font-size: 3.5em;
    }
    
    .total-result .big-number {
        font-size: 4em; 
    }
}