:root {
    --primaire: #4361ee;
    --secondaire: #3a0ca3;
    --clair: #f8f9fa;
    --sombre: #212529;
    --succes: #4cc9f0;
    --gris: #6c757d;
    --gris-clair: #e9ecef;
    --arrondi: 8px;
    --ombre: 0 3px 10px rgba(0, 0, 0, 0.08);
    --transition: all 0.2s ease;
    --taille-etiquette: 0.95rem;
    
    /* Nouvelles variables pour l'espacement */
    --espace-xs: 4px;
    --espace-sm: 8px;
    --espace-md: 12px;
    --espace-lg: 16px;
    --espace-xl: 20px;
    
    /* Variables de hauteur */
    --hauteur-entree: 40px;
    --hauteur-bouton: 40px;
    --hauteur-resultat-min: 80px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html, body {
    height: 100%;
    overflow: hidden; /* Supprime les scrollbars globales */
}

body {
    background: linear-gradient(135deg, #f5f7ff 0%, #eef1ff 100%);
    color: var(--sombre);
    line-height: 1.4;
    padding: var(--espace-md);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.conteneur {
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--espace-md);
}

/* HEADER */
header {
    text-align: center;
    padding: var(--espace-lg);
    background: linear-gradient(135deg, var(--primaire), var(--secondaire));
    color: white;
    border-radius: var(--arrondi);
    box-shadow: var(--ombre);
    flex-shrink: 0;
}

h1 {
    font-size: 1.4rem;
    margin-bottom: var(--espace-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--espace-sm);
}

h1 i {
    color: var(--succes);
}

.sous-titre {
    font-size: 0.85rem;
    opacity: 0.9;
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.3;
}

/* CONTENU PRINCIPAL */
.contenu-principal {
    display: flex;
    flex: 1;
    overflow: hidden; /* Empêche le débordement vertical */
    gap: var(--espace-lg);
    min-height: 0;
}

.section-convertisseur {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.carte-convertisseur {
    background: white;
    border-radius: var(--arrondi);
    box-shadow: var(--ombre);
    padding: var(--espace-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: var(--espace-lg);
}

.section-entree {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--espace-lg);
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .section-entree {
        grid-template-columns: 1fr;
        gap: var(--espace-md);
    }
}

.groupe-entree {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: var(--espace-xs);
}

label, .titre-resultats, h2 {
    font-weight: 700;
    color: var(--secondaire);
    font-size: var(--taille-etiquette);
    display: flex;
    align-items: center;
    gap: var(--espace-xs);
    white-space: nowrap;
}

.conteneur-entree {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: var(--espace-xs);
}

.entree-unite {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: var(--hauteur-entree);
}

input[type="text"], input[type="number"] {
    padding: 0 var(--espace-xl) 0 var(--espace-md);
    border: 2px solid var(--gris-clair);
    border-radius: var(--arrondi);
    font-size: 0.95rem;
    width: 100%;
    height: 100%;
    transition: var(--transition);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

input[type="text"]:focus, input[type="number"]:focus {
    outline: none;
    border-color: var(--primaire);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.affichage-unite {
    position: absolute;
    right: var(--espace-md);
    font-weight: 600;
    color: var(--gris);
    font-size: 0.9rem;
    pointer-events: none;
    background: white;
    padding: 2px 0;
}

.exemple-entree {
    font-size: 0.7rem;
    color: var(--gris);
    text-align: left;
    line-height: 1.2;
    min-height: 16px;
}

.exemple-entree code {
    background-color: var(--gris-clair);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.65rem;
    margin: 0 2px;
}

.conteneur-entree-dms {
    display: none;
    height: var(--hauteur-entree);
}

.entree-dms {
    padding: 0 var(--espace-md);
    border: 2px solid var(--gris-clair);
    border-radius: var(--arrondi);
    font-size: 0.95rem;
    width: 100%;
    height: 100%;
    transition: var(--transition);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.entree-dms:focus {
    outline: none;
    border-color: var(--primaire);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.conteneur-selection {
    position: relative;
    width: 100%;
    height: var(--hauteur-entree);
    min-width: 170px;
}

select {
    width: 100%;
    height: 100%;
    padding: 0 35px 0 12px;
    border: 2px solid var(--gris-clair);
    border-radius: var(--arrondi);
    font-size: 0.95rem;
    background-color: white;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    color: var(--sombre);
    font-weight: 500;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    align-items: center;
    /*line-height: 1;*/
}

select:focus {
    outline: none;
    border-color: var(--primaire);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.fleche-selection {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--gris);
    pointer-events: none;
    transition: var(--transition);
}

select:focus + .fleche-selection {
    border-top-color: var(--primaire);
}

/* BOUTONS */
.boutons {
    display: flex;
    gap: var(--espace-md);
    flex-shrink: 0;
}

button {
    padding: 0 var(--espace-md);
    border: none;
    border-radius: var(--arrondi);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--espace-xs);
    flex: 1;
    height: var(--hauteur-bouton);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.bouton-convertir {
    background-color: var(--primaire);
    color: white;
}

.bouton-convertir:hover {
    background-color: var(--secondaire);
}

.bouton-reinitialiser {
    background-color: var(--gris-clair);
    color: var(--sombre);
}

.bouton-reinitialiser:hover {
    background-color: #d1d9e6;
}

/* SECTION RESULTATS */
.section-resultats {
    background-color: var(--clair);
    border-radius: var(--arrondi);
    padding: var(--espace-md);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: var(--hauteur-resultat-min);
}

.titre-resultats {
    font-weight: 700;
    margin-bottom: var(--espace-md);
    flex-shrink: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.grille-resultats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--espace-md);
    flex: 1;
    min-height: 0;
}

@media (max-width: 1200px) {
    .grille-resultats {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .grille-resultats {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
        gap: var(--espace-sm);
    }
}

.element-resultat {
    background: white;
    padding: var(--espace-md);
    border-radius: calc(var(--arrondi) - 2px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    text-align: center;
    min-height: var(--hauteur-resultat-min);
}

.entete-resultat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--espace-xs);
    margin-bottom: var(--espace-sm);
    flex-wrap: wrap;
    min-height: 28px;
}

.unite-resultat {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primaire);
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.etiquette-resultat {
    font-size: 0.75rem;
    color: var(--gris);
    font-weight: 600;
    background-color: var(--gris-clair);
    padding: 2px 6px;
    border-radius: 10px;
    white-space: nowrap;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.conteneur-valeur-resultat {
    width: 100%;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.valeur-resultat, .valeur-dms-simple {
    font-size: 1rem;
    font-weight: 700;
    color: var(--sombre);
    text-align: center;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    line-height: 1.2;
    padding: 3px 2px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.valeur-dms-simple {
    font-size: 0.95rem;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.symbole-pi {
    font-style: italic;
    font-weight: bold;
    color: var(--primaire);
}

.valeur-longue {
    font-size: 0.9rem;
}

/* Section Relations et Syntaxes - alignées verticalement */
.section-relations-syntaxes {
    display: flex;
    flex-direction: column;
    gap: var(--espace-lg);
    flex: 1;
    min-height: 0;
}

.relations-container, .syntaxes-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.explication1, .explication2 {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin: 0;
}

.explication1 h3, .explication2 h3 {
    font-size: 1rem;
    margin: 0 0 var(--espace-xs) 0;
    color: var(--sombre);
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.explication1 p, .explication2 p {
    margin-bottom: var(--espace-xs);
}

.surlignement {
    background-color: rgba(76, 201, 240, 0.2);
    padding: 2px 5px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 0.8rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.exemple-pi {
    background-color: rgba(67, 97, 238, 0.1);
    padding: var(--espace-md);
    border-radius: 6px;
    margin-top: 0;
    border-left: 3px solid var(--primaire);
    font-size: 0.85rem;
    flex: 1;
    max-height: 100%;
}

.exemple-pi code {
    background-color: var(--gris-clair);
    padding: 2px 5px;
    border-radius: 3px;
    font-family: monospace;
    display: inline-block;
    margin: 2px 0;
    font-size: 0.8rem;
}

.liste-syntaxe-pi {
    margin-top: var(--espace-sm);
    padding-left: 18px;
    font-size: 0.85rem;
}

.liste-syntaxe-pi li {
    margin-bottom: var(--espace-xs);
    line-height: 1.3;
}

/* SECTION INFO - Amélioration de la table */
.section-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.carte-info {
    background: white;
    border-radius: var(--arrondi);
    box-shadow: var(--ombre);
    padding: var(--espace-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: var(--espace-lg);
}

.contenu-info {
    flex: 1;
    overflow: auto;
    min-height: 0;
    padding-right: 5px;
}

h2 {
    margin-bottom: 0;
    flex-shrink: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* AMÉLIORATIONS DE LA TABLE */
.table-angle {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
    table-layout: fixed; /* Distribution égale des colonnes */
    min-width: 500px; /* Largeur minimale pour éviter l'écrasement */
}

.table-angle th,
.table-angle td {
    padding: var(--espace-md) var(--espace-sm);
    border-bottom: 1px solid var(--gris-clair);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.85rem;
    text-align: left;
    vertical-align: top;
    word-wrap: break-word; /* Permet le retour à la ligne */
    overflow-wrap: break-word; /* Alternative pour certains navigateurs */
    white-space: normal; /* Permet le retour à la ligne */
}

.table-angle th {
    background-color: var(--primaire);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-angle tr:nth-child(even) {
    background-color: var(--clair);
}

.table-angle tr:hover {
    background-color: rgba(67, 97, 238, 0.05);
}

/* Ajustement des largeurs de colonnes pour une meilleure lisibilité */
.table-angle th:nth-child(1),
.table-angle td:nth-child(1) {
    width: 25%; /* Unité */
}

.table-angle th:nth-child(2),
.table-angle td:nth-child(2) {
    width: 15%; /* Symbole */
}

.table-angle th:nth-child(3),
.table-angle td:nth-child(3) {
    width: 40%; /* Description */
}

.table-angle th:nth-child(4),
.table-angle td:nth-child(4) {
    width: 20%; /* Exemple */
}

/* Conteneur pour la table avec défilement horizontal seulement si nécessaire */
.conteneur-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: calc(var(--arrondi) - 2px);
    border: 1px solid var(--gris-clair);
    margin-top: var(--espace-xs);
}

/* Style pour le défilement horizontal */
.conteneur-table::-webkit-scrollbar {
    height: 6px;
}

.conteneur-table::-webkit-scrollbar-track {
    background: var(--gris-clair);
    border-radius: 3px;
}

.conteneur-table::-webkit-scrollbar-thumb {
    background: var(--primaire);
    border-radius: 3px;
}

.conteneur-table::-webkit-scrollbar-thumb:hover {
    background: var(--secondaire);
}

/* Mise en évidence des cellules importantes */
.table-angle td strong {
    color: var(--secondaire);
}

/* Icônes pour les exemples dans la table */
.table-angle td:last-child {
    font-family: monospace;
    font-size: 0.8rem;
    background-color: rgba(248, 249, 250, 0.5);
}

/* FOOTER */
footer {
    text-align: center;
    padding: var(--espace-sm);
    color: var(--gris);
    font-size: 0.8rem;
    border-top: 1px solid var(--gris-clair);
    flex-shrink: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.liens-footer {
    display: flex;
    justify-content: center;
    gap: var(--espace-md);
    margin-top: var(--espace-xs);
    flex-wrap: wrap;
}

.liens-footer a {
    color: var(--primaire);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.8rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.liens-footer a:hover {
    color: var(--secondaire);
    text-decoration: underline;
}

/* SCROLLBAR */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: var(--gris-clair);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: var(--primaire);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondaire);
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .boutons {
        flex-direction: column;
    }
    
    button {
        width: 100%;
    }
    
    .valeur-resultat, .valeur-dms-simple {
        font-size: 0.95rem;
    }
    
    .entete-resultat {
        flex-direction: column;
        gap: 3px;
    }
    
    .conteneur-selection {
        min-width: 140px;
    }
    
    select {
        font-size: 0.9rem;
        padding: 0 30px 0 10px;
    }
    
    .fleche-selection {
        right: 10px;
    }
    
    .valeur-dms-simple {
        font-size: 0.9rem;
    }
    
    .exemple-pi {
        padding: var(--espace-sm);
    }
    
    /* Responsive pour la table */
    .table-angle {
        min-width: 400px; /* Réduction de la largeur minimale */
        font-size: 0.8rem;
    }
    
    .table-angle th,
    .table-angle td {
        padding: var(--espace-sm) var(--espace-xs);
    }
    
    /* Ajustement des largeurs sur mobile */
    .table-angle th:nth-child(1),
    .table-angle td:nth-child(1) {
        width: 22%;
    }
    
    .table-angle th:nth-child(2),
    .table-angle td:nth-child(2) {
        width: 13%;
    }
    
    .table-angle th:nth-child(3),
    .table-angle td:nth-child(3) {
        width: 45%;
    }
    
    .table-angle th:nth-child(4),
    .table-angle td:nth-child(4) {
        width: 20%;
    }
    
    :root {
        --taille-etiquette: 0.9rem;
        --hauteur-entree: 38px;
        --hauteur-bouton: 38px;
    }
}

@media (max-width: 480px) {
    .table-angle {
        min-width: 300px;
        font-size: 0.75rem;
    }
    
    .table-angle th,
    .table-angle td {
        padding: var(--espace-xs);
    }
    
    .table-angle th:nth-child(1),
    .table-angle td:nth-child(1) {
        width: 20%;
    }
    
    .table-angle th:nth-child(2),
    .table-angle td:nth-child(2) {
        width: 12%;
    }
    
    .table-angle th:nth-child(3),
    .table-angle td:nth-child(3) {
        width: 48%;
    }
    
    .table-angle th:nth-child(4),
    .table-angle td:nth-child(4) {
        width: 20%;
    }
}

@media (max-height: 700px) {
    header {
        padding: var(--espace-md);
    }
    
    h1 {
        font-size: 1.2rem;
    }
    
    .carte-convertisseur, .carte-info {
        padding: var(--espace-md);
    }
    
    .section-resultats {
        min-height: 160px;
    }
    
    .element-resultat {
        padding: var(--espace-sm);
        min-height: 60px;
    }
    
    .valeur-resultat, .valeur-dms-simple {
        font-size: 0.95rem;
    }
    
    footer {
        padding: var(--espace-xs);
    }
    
    :root {
        --hauteur-entree: 38px;
        --hauteur-bouton: 38px;
        --hauteur-resultat-min: 60px;
    }
}

@media (min-width: 1400px) {
    .conteneur {
        max-width: 1400px;
    }
    
    .conteneur-selection {
        min-width: 200px;
    }
    
    select {
        font-size: 1rem;
        padding: 0 40px 0 15px;
    }
    
    .fleche-selection {
        right: 15px;
        border-left: 6px solid transparent;
        border-right: 6px solid transparent;
        border-top: 6px solid var(--gris);
    }
    
    .valeur-resultat, .valeur-dms-simple {
        font-size: 1.1rem;
    }
    
    .element-resultat {
        min-height: 80px;
    }
    
    :root {
        --taille-etiquette: 1rem;
        --hauteur-resultat-min: 80px;
    }
    
    .table-angle th,
    .table-angle td {
        min-width: 150px;
        max-width: 250px;
    }
}

/* Ajustements pour aligner les sections Relations et Syntaxes */
@media (max-width: 768px) {
    .section-relations-syntaxes {
        gap: var(--espace-md);
    }
}