/* Comptheures — styles spécifiques à la calculette */

/* ---------- Bloc principal ---------- */
.bloc-calculette {
    width: 100%;
}

@media (min-width: 768px) {
    .bloc-calculette {
        max-width: 380px;
    }
}

/* ---------- Aide (details/summary) ---------- */
details {
    margin-bottom: 1.2rem;
}

details summary {
    cursor: pointer;
    color: var(--couleur-accent-2);
    font-size: 0.9rem;
    font-weight: 600;
    user-select: none;
}

details pre {
    border: 1px solid var(--couleur-bordure);
    border-radius: var(--rayon);
    background: var(--couleur-fond-doux);
    padding: 1rem;
    margin-top: 0.6rem;
    font-family: inherit;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--couleur-texte);
    width: 100%;
    height: 220px;
    overflow: auto;
    white-space: pre-wrap;
    scrollbar-width: thin;
    scrollbar-color: var(--couleur-accent-2) transparent;
}

details pre::-webkit-scrollbar {
    width: 8px;
}

details pre::-webkit-scrollbar-thumb {
    background: var(--couleur-accent-2);
    border-radius: 4px;
}

/* ---------- Formulaire ---------- */
form.calculette {
    background: var(--couleur-fond-doux);
    border: 1px solid var(--couleur-bordure);
    border-radius: var(--rayon);
    padding: 1.3rem;
    width: 100%;
}

form.calculette label {
    display: block;
    font-size: 0.82rem;
    color: var(--couleur-texte-clair);
    margin-bottom: 0.3rem;
}

.champ-historique {
    margin-bottom: 0.9rem;
}

.champ-saisie {
    margin-bottom: 0.9rem;
}

form.calculette textarea,
form.calculette input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--couleur-bordure);
    border-radius: var(--rayon);
    font-family: inherit;
    font-size: 0.92rem;
    background: var(--couleur-fond);
    color: var(--couleur-texte);
}

form.calculette textarea {
    resize: vertical;
    font-family: "Courier New", monospace;
    font-size: 0.82rem;
    min-height: 110px;
}

form.calculette textarea:focus,
form.calculette input[type="text"]:focus {
    outline: none;
    border-color: var(--couleur-accent);
}

/* ---------- Ligne d'actions ---------- */
.ligne-actions {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
}

/* ---------- Select personnalisé ---------- */
.groupe-format {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.05rem;
    position: relative;
}

.groupe-format > label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--couleur-texte-clair);
    white-space: nowrap;
}

.select-perso {
    position: relative;
    display: inline-block;
    margin: 0;
    line-height: normal;
}

.select-perso summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--couleur-fond);
    border: 1px solid var(--couleur-bordure);
    border-radius: var(--rayon);
    padding: 0.45rem 0.85rem;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--couleur-texte);
    transition: border-color 0.15s ease;
    width: 190px;
}

.select-perso summary::marker {
    display: none;
}

.select-perso summary::-webkit-details-marker { display: none; }

.select-perso summary::after {
    content: "";
    width: 10px;
    height: 7px;
    margin-left: auto;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%234c7c6b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    transition: transform 0.15s ease;
}

.select-perso[open] summary::after { transform: rotate(180deg); }
.select-perso:hover summary { border-color: var(--couleur-accent); }
.select-perso[open] summary { border-color: var(--couleur-accent); }

/* Valeur affichée */
.valeur-affichee::before { content: ""; }

.select-perso:has(input[value="h_float"]:checked) .valeur-affichee::before { content: "1.50"; }
.select-perso:has(input[value="mini_misc"]:checked) .valeur-affichee::before { content: "1h30"; }
.select-perso:has(input[value="misc"]:checked) .valeur-affichee::before { content: "1h30m00(s)"; }
.select-perso:has(input[value="misc_max"]:checked) .valeur-affichee::before { content: "1h30m00s,000ms"; }
.select-perso:has(input[value="misc_max_point"]:checked) .valeur-affichee::before { content: "1h30m00s.000ms"; }
.select-perso:has(input[value="mini"]:checked) .valeur-affichee::before { content: "1:30"; }
.select-perso:has(input[value="std"]:checked) .valeur-affichee::before { content: "1:30:00"; }
.select-perso:has(input[value="std_max"]:checked) .valeur-affichee::before { content: "1:30:00,000"; }
.select-perso:has(input[value="std_max_point"]:checked) .valeur-affichee::before { content: "1:30:00.000"; }

/* ---------- Panneau d'options ---------- */
.liste-options {
    position: absolute;
    top: calc(100% + 0.3rem);
    left: 0;
    min-width: 220px;
    max-height: 260px;
    overflow-y: auto;
    background: var(--couleur-fond);
    border: 1px solid var(--couleur-bordure);
    border-radius: var(--rayon);
    box-shadow: 0 6px 16px rgba(46, 42, 38, 0.12);
    z-index: 20;
    padding: 0.4rem 0;
}

.titre-groupe {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--couleur-accent);
    padding: 0.35rem 0.85rem 0.15rem;
}

.option {
    position: relative;
    display: block;
    cursor: pointer;
}

.option input {
    position: absolute;
    opacity: 0;
    inset: 0;
    margin: 0;
    cursor: pointer;
}

.option span {
    display: block;
    padding: 0.2rem 0.85rem;
    font-size: 0.78rem;
    color: var(--couleur-texte);
}

.option:hover span {
    background: var(--couleur-accent-clair);
}

.option input:checked + span {
    background: var(--couleur-accent-2);
    color: #ffffff;
    font-weight: 600;
}

/* ---------- Boutons ---------- */
.boutons-calcul {
    display: flex;
    gap: 0.5rem;
}

.boutons-calcul button {
    border: none;
    border-radius: var(--rayon);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem 0.9rem;
}

.bouton-raz {
    background: var(--couleur-fond);
    color: var(--couleur-texte-clair);
    border: 1px solid var(--couleur-bordure) !important;
}

.bouton-calculer {
    background: var(--couleur-accent-2);
    color: #ffffff;
    min-width: 2.6rem;
}

.boutons-calcul button:hover {
    opacity: 0.85;
}

.btn-retour {
    background: none;
    border: none;
    color: var(--couleur-accent-2);
    cursor: pointer;
    padding: 0;
    font-size: 0.95rem;
    text-decoration: underline;
    font-family: inherit;
}

.btn-retour:hover {
    color: var(--couleur-accent);
}

/* ---------- Responsive spécifique ---------- */
@media (max-width: 640px) {
    .ligne-actions {
        justify-content: flex-start;
    }
}