/*
 * ATTIMO — Les choix (lot Laboratoire scolaire du 21/10, point 3) : UN fichier.
 *
 * Jamais de bouton rond ni de case à cocher du navigateur dans Attimo :
 *   - oui / non : l'interrupteur (.toggle), précédé de son champ miroir ;
 *   - un choix parmi plusieurs : les cartes de choix (.choice-cards / .choice-card) ;
 *   - une sélection multiple dans une liste, un accord à donner : la case
 *     dessinée par Attimo (.attimo-check).
 *
 * Chargé par public/css/attimo.css (back-office, Studio, connexion) et, seul,
 * par les pages des clients qui ne chargent pas le socle. Les couleurs ont
 * leur valeur de repli : la feuille vit aussi sans les variables du socle.
 */

/* ================================
   INTERRUPTEUR (oui / non)
   ================================ */
.toggle {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-border, #E2E8F0);
    transition: var(--transition-fast, all 0.15s ease);
    border-radius: var(--radius-pill, 999px);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: var(--transition-fast, all 0.15s ease);
    border-radius: var(--radius-full, 50%);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.08));
}

.toggle input:checked + .toggle-slider {
    background-color: var(--color-primary, #6B9ECE);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.toggle input:focus-visible + .toggle-slider {
    outline: 2px solid var(--color-primary, #6B9ECE);
    outline-offset: 2px;
}

/* Interrupteur bloqué : grisé par le socle, comme un bouton désactivé (§7.4) */
.toggle input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Toggle avec label */
.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toggle-label {
    font-size: 14px;
    color: var(--color-text, #4A5568);
}

/* Un interrupteur suivi de sa phrase, sur une ligne. */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.toggle-row > span:not(.toggle) {
    min-width: 0;
}

/* ================================
   CARTES DE CHOIX (un choix parmi plusieurs)
   ================================ */
.choice-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 12px;
}

.choice-card {
    position: relative;
    display: block;
    min-width: 0;
    margin: 0;
    cursor: pointer;
}

.choice-card > input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    pointer-events: none;
}

.choice-card-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid var(--color-border, #E2E8F0);
    border-radius: var(--radius-sm, 8px);
    background: #fff;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.choice-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text, #4A5568);
}

.choice-card-title svg {
    flex-shrink: 0;
}

.choice-card-text {
    font-size: 13px;
    line-height: 1.45;
    color: var(--color-text-light, #718096);
}

.choice-card:hover .choice-card-body {
    border-color: var(--color-primary, #6B9ECE);
}

.choice-card > input:checked + .choice-card-body {
    border-color: var(--color-primary, #6B9ECE);
    background: rgba(107, 158, 206, 0.1);
}

.choice-card > input:checked + .choice-card-body .choice-card-title {
    color: var(--color-primary, #6B9ECE);
}

.choice-card > input:focus-visible + .choice-card-body {
    outline: 2px solid var(--color-primary, #6B9ECE);
    outline-offset: 2px;
}

.choice-card > input:disabled + .choice-card-body {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Une rangée de petites cartes (filtres, formats, choix courts). */
.choice-cards.is-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.choice-cards.is-compact .choice-card-body {
    padding: 7px 12px;
}

.choice-cards.is-compact .choice-card-title {
    font-weight: 600;
    font-size: 13px;
}

/* Une carte déjà dessinée par son module (moyen de paiement, livraison…) :
   seul le rond du navigateur disparaît, la carte dit le choix. */
.choice-hidden-input {
    position: absolute !important;
    opacity: 0 !important;
    width: 1px !important;
    height: 1px !important;
    margin: 0 !important;
    pointer-events: none;
}

:has(> .choice-hidden-input) {
    position: relative;
}

:has(> .choice-hidden-input:focus-visible) {
    outline: 2px solid var(--color-primary, #6B9ECE);
    outline-offset: 2px;
}

/* ================================
   CASE DESSINÉE PAR ATTIMO (sélection multiple, accord)
   ================================ */
.attimo-check {
    -webkit-appearance: none;
    appearance: none;
    display: inline-block;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin: 0;
    vertical-align: middle;
    border: 1.5px solid #CBD5E0;
    border-radius: 5px;
    background-color: #fff;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 12px 12px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.attimo-check:hover {
    border-color: var(--color-primary, #6B9ECE);
}

.attimo-check:checked {
    border-color: var(--color-primary, #6B9ECE);
    background-color: var(--color-primary, #6B9ECE);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}

.attimo-check:indeterminate {
    border-color: var(--color-primary, #6B9ECE);
    background-color: var(--color-primary, #6B9ECE);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E");
}

.attimo-check:focus-visible {
    outline: 2px solid var(--color-primary, #6B9ECE);
    outline-offset: 2px;
}

.attimo-check:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
