/* ==========================================================================
   Page "Mon compte"
   ========================================================================== */

.compte-page {
    max-width: 720px;
}

/* --- Loading state --- */

.compte-loading {
    text-align: center;
    font-family: 'Nunito', sans-serif;
    color: var(--brun-cuir);
    padding: 2rem 0;
}

/* --- Conteneur principal --- */

.compte-form {
    background: var(--beige);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    color: var(--brun-nuit);
    margin-bottom: 0.5rem;
}

.form-group input[type='text'],
.form-group input[type='email'] {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    border: 1px solid var(--brun-cuir);
    border-radius: 6px;
    background: #fff;
    color: var(--brun-nuit);
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.form-group input[type='text']:focus,
.form-group input[type='email']:focus {
    outline: none;
    border-color: var(--or);
    box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.15);
}

/* --- Pseudo : label collé au-dessus du champ --- */

.form-group--inline {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.form-group--inline label {
    margin-bottom: 0;
    white-space: nowrap;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input[type='text'] {
    padding-right: 6.5rem; /* laisse la place à l'indicateur sans redimensionner le champ */
}

.save-indicator {
    position: absolute;
    top: 50%;
    right: 0.85rem;
    transform: translateY(-50%);
    font-family: 'Nunito', sans-serif;
    font-size: 0.78rem;
    color: var(--brun-cuir);
    white-space: nowrap;
    pointer-events: none;
}

#username-error {
    margin-top: 0.4rem;
}

/* --- Toggle switch --- */

.form-group--toggle {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.toggle-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
}

.toggle-context-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    color: var(--brun-nuit);
    font-size: 0.95rem;
}

.toggle-row .toggle-label {
    display: flex;
    gap: 8px;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0 !important;
}

.toggle-label input[type='checkbox'] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    background: var(--brun-cuir);
    border-radius: 999px;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.toggle-switch::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.toggle-label input[type='checkbox']:checked + .toggle-switch {
    background: #2e7d32; /* même vert que les interrupteurs de la page Collection */
}

.toggle-label input[type='checkbox']:checked + .toggle-switch::before {
    transform: translateX(18px);
}

.toggle-label input[type='checkbox']:focus-visible + .toggle-switch {
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.3);
}

.toggle-status {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 24px; /* même hauteur que .toggle-switch pour un centrage vertical fiable */
    color: var(--brun-cuir);
    cursor: pointer;
    transition: color 0.2s ease;
}

.form-hint {
    font-family: 'Nunito', sans-serif;
    font-size: 0.82rem;
    color: var(--brun-cuir);
    margin: 0;
}

/* --- Copier le lien de partage (à côté du statut) --- */

.copier-lien {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    font-family: 'Nunito', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--or-terne);
    background: none;
    border: 1px solid rgba(201, 154, 60, 0.5);
    border-radius: 999px;
    cursor: pointer;
    transition:
        background 0.2s ease,
        color 0.2s ease;
}

.copier-lien:hover,
.copier-lien.is-copied {
    color: #fff;
    background: var(--or);
}

.copier-lien[hidden] {
    display: none;
}

.btn-copy {
    padding: 0.5rem 1rem;
    font-family: 'Nunito', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: var(--or);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

.btn-copy:hover {
    opacity: 0.85;
}

.btn-copy:disabled {
    background: var(--brun-cuir);
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Messages --- */

.form-error {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    color: #8f2a1f;
    background: #fbe9e5;
    border: 1px solid rgba(163, 77, 39, 0.35);
    border-left: 4px solid var(--rouille);
    border-radius: 6px;
    padding: 0.6rem 0.85rem;
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
    animation: compte-erreur-secousse 0.35s ease;
}

.form-error::before {
    content: '!';
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 50%;
    background: var(--rouille);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
}

.form-error[hidden] {
    display: none;
}

/* Champ en erreur (adresse e-mail refusée) */
.compte-email.has-error input[type='email'] {
    border-color: var(--rouille);
    box-shadow: 0 0 0 3px rgba(163, 77, 39, 0.15);
}

@keyframes compte-erreur-secousse {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-4px);
    }
    75% {
        transform: translateX(4px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .form-error {
        animation: none;
    }
}

/* Succès : vert, construit comme .form-error pour trancher sur le fond beige */
.form-success {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    color: #1b5e20;
    background: #e8f5e9;
    border: 1px solid rgba(46, 125, 50, 0.35);
    border-left: 4px solid #2e7d32;
    border-radius: 6px;
    padding: 0.6rem 0.85rem;
    margin-top: 1rem;
    margin-bottom: 0;
    animation: compte-success-pulse 0.4s ease;
}

.form-success::before {
    content: '✓';
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 50%;
    background: #2e7d32;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
}

.form-success[hidden] {
    display: none;
}

@keyframes compte-success-pulse {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Adresse e-mail --- */

.compte-email {
    margin-top: 0.75rem;
}

.compte-newsletter {
    margin-bottom: 1rem;
}

/* Label, champ et bouton sur la même ligne (le bouton passe dessous sur un écran étroit) */
.compte-email-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.6rem;
    margin-bottom: 0.4rem;
}

.compte-email-row label {
    margin-bottom: 0;
    white-space: nowrap;
}

.compte-email-row input[type='email'] {
    flex: 1 1 12rem;
    width: auto;
    min-width: 0;
}

/* Nouvelle adresse en attente de confirmation */
/* Nouvelle adresse en attente : encadré blanc, bordure dorée, pour se détacher du fond beige */
.compte-email-attente {
    position: relative;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--brun-cuir);
    background: #fff;
    border: 1px solid rgba(201, 154, 60, 0.6);
    border-left: 4px solid var(--or);
    border-radius: 6px;
    padding: 0.7rem 0.9rem 0.7rem 2.6rem;
    margin-bottom: 0.6rem;
    box-shadow: 0 1px 4px rgba(61, 38, 23, 0.08);
}

.compte-email-attente::before {
    content: '';
    position: absolute;
    top: 0.75rem;
    left: 0.85rem;
    width: 1.1rem;
    height: 1.1rem;
    /* enveloppe */
    background: var(--or);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='m3 7 9 6 9-6'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='m3 7 9 6 9-6'/%3E%3C/svg%3E") center / contain no-repeat;
}

.compte-email-attente strong {
    color: var(--brun-cuir);
    font-weight: 800;
}

/* « Annuler le changement » : bouton secondaire */
#email-annuler {
    color: var(--brun-cuir);
    background: transparent;
    border: 1px solid var(--brun-cuir);
}

.compte-email-attente[hidden] {
    display: none;
}

.compte-email-attente p {
    margin: 0 0 0.5rem;
    overflow-wrap: anywhere;
}

.compte-email-attente-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

#email-info {
    margin-top: 0.2rem;
    margin-bottom: 0.5rem;
}


/* --- Moyens de connexion --- */

.compte-connexions {
    margin-top: 1.5rem;
    border-top: 2px solid var(--or);
    padding-top: 1rem;
}

.compte-connexions[hidden] {
    display: none;
}

.compte-connexions h2 {
    font-size: 1.3rem;
    margin-bottom: 0.4rem;
}

.connexions-liste {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.connexion {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.5rem 0.9rem;
    background: #fff;
    border: 1px solid rgba(61, 38, 23, 0.2);
    border-radius: 8px;
    font-family: 'Nunito', sans-serif;
}

.connexion--associee {
    border-color: rgba(212, 160, 23, 0.6);
}

.connexion-infos {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.connexion-etat {
    font-size: 0.82rem;
    color: var(--brun-cuir);
    overflow-wrap: anywhere;
}

.connexion-associer {
    text-decoration: none;
}

.connexion-associer[hidden],
.connexion .coordonnees-supprimer[hidden] {
    display: none;
}

/* --- Modale de retour d'association / fusion de comptes --- */

.compte-modale {
    max-width: 600px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    text-align: left;
    font-family: 'Nunito', sans-serif;
    color: var(--brun-nuit);
    border-top: 6px solid var(--or);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    animation: compte-success-pulse 0.25s ease;
}

.compte-modale--succes {
    border-top-color: #4f7a3a;
}

.compte-modale--erreur {
    border-top-color: var(--rouille);
}

.compte-modale-icone {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 0.75rem;
    border-radius: 50%;
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
    background: var(--or);
}

.compte-modale--succes .compte-modale-icone {
    background: #4f7a3a;
}

.compte-modale--erreur .compte-modale-icone {
    background: var(--rouille);
}

.compte-modale-titre {
    text-align: center;
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.compte-modale p {
    font-size: 0.95rem;
    line-height: 1.5;
}

.compte-modale-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
}

.compte-modale-actions .btn-copy {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
}

.fusion-apercu {
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
    background: var(--beige-clair);
    border: 1px solid var(--beige-fonce);
    border-radius: 8px;
    font-size: 0.9rem;
}

.fusion-apercu[hidden] {
    display: none;
}

.fusion-apercu p {
    margin: 0;
}

.fusion-apercu-detail {
    color: var(--brun-cuir-clair);
}

.fusion-effets {
    padding-left: 1.2rem;
    margin-bottom: 0;
    font-size: 0.9rem;
}

.fusion-effets li {
    margin-bottom: 0.35rem;
}

.compte-modale [data-fusion-confirmer][hidden] {
    display: none;
}

@media (max-width: 480px) {
    .compte-modale {
        padding: 24px 18px;
    }

    .compte-modale-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }
}

/* --- Coordonnées de livraison --- */

.compte-coordonnees {
    margin-top: 1.5rem;
    border-top: 2px solid var(--or);
    padding-top: 1rem;
}

.compte-coordonnees[hidden] {
    display: none;
}

.compte-coordonnees h2 {
    font-size: 1.3rem;
    margin-bottom: 0.4rem;
}

.coordonnees-champs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
    margin: 0.75rem 0;
}

.coordonnees-champ {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.9rem;
    font-weight: 700;
}

.coordonnees-champ--large {
    grid-column: 1 / -1;
}

.coordonnees-champ input,
.coordonnees-champ select {
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--brun-cuir);
    border-radius: 6px;
    background: #fff;
    color: var(--brun-nuit);
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    font-weight: 400;
}

.coordonnees-champ input:focus,
.coordonnees-champ select:focus {
    outline: none;
    border-color: var(--or);
    box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.15);
}

.coordonnees-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.coordonnees-supprimer {
    border: none;
    background: none;
    color: #b03a2e;
    font-family: 'Nunito', sans-serif;
    font-size: 0.85rem;
    text-decoration: underline;
    cursor: pointer;
}

.coordonnees-supprimer[hidden] {
    display: none;
}

@media (max-width: 560px) {
    .coordonnees-champs {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* --- Suppression du compte --- */

.compte-suppression {
    margin-top: 2.5rem;
    border-top: 1px solid rgba(176, 58, 46, 0.35);
    padding-top: 1rem;
}

.compte-suppression h2 {
    font-size: 1.1rem;
    margin-bottom: 0.4rem;
    color: #b03a2e;
}

.compte-suppression-bouton {
    padding: 0.55rem 1.1rem;
    border: 1px solid #b03a2e;
    border-radius: 6px;
    background: #fff;
    color: #b03a2e;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}

.compte-suppression-bouton:hover:not(:disabled) {
    background: #b03a2e;
    color: #fff;
}

.compte-suppression-bouton:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.compte-modale [data-suppression-confirmer] {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
}

.compte-suppression-saisie {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 1rem;
    font-size: 0.95rem;
}

.compte-suppression-saisie input {
    max-width: 16rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--brun-cuir);
    border-radius: 6px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    letter-spacing: 0.05em;
}

.compte-suppression-saisie input:focus {
    outline: none;
    border-color: #b03a2e;
    box-shadow: 0 0 0 3px rgba(176, 58, 46, 0.15);
}

.compte-modale [hidden] {
    display: none !important;
}

/* --- Responsive --- */

@media (max-width: 480px) {
    .compte-page {
        margin: 1.5rem auto;
    }

    .compte-form {
        padding: 1rem;
    }
}
