/* ==========================================================================
   Styles spécifiques pour la page /account/
   ========================================================================== */

/* Conteneur principal du formulaire */
.form-container {
    max-width: 520px; /* Largeur augmentée pour la vue desktop */
    margin: 3rem auto;
    padding: 2.5rem;
    background-color: var(--surface-bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    /* box-shadow: 0 8px 25px rgba(0,0,0,0.07); */ /* SUPPRIMÉ */
}

/* On s'assure que le H1 du formulaire est bien centré */
.form-container h1 {
    justify-content: center;
    font-size: 2.5rem;
    line-height: 1.2;
}

.form-container p {
    color: #6c757d;
    margin-bottom: 2.5rem;
    text-align: center;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: border-color 0.2s; /* MODIFIÉ : box-shadow retiré de la transition */
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    /* box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.2); */ /* SUPPRIMÉ */
}

.form-container .btn-base {
    width: 100%;
    margin-top: 1rem;
    padding-top: 14px;
    padding-bottom: 14px;
}

.form-switch-link, .form-links {
    margin-top: 2.5rem;
    text-align: center;
    font-size: 0.95rem;
}

.form-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
}

.form-links .separator {
    color: var(--border-color);
}

/* Style pour les sections du formulaire de profil */
.account-form-section {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 30px;
    /* box-shadow: 0 2px 4px rgba(0,0,0,0.05); */ /* SUPPRIMÉ */
}

.account-form-section h2 {
    margin-top: 0;
    margin-bottom: 8px;
    font-family: 'Patrick Hand', 'Arial', cursive;
    font-size: 1.8rem;
    color: #333;
}

.account-form-section p.section-intro {
    font-size: 0.95rem;
    color: #666;
    margin-top: 0;
    margin-bottom: 20px;
}

/* Espacement des boutons dans les sections */
.account-form-section .btn-base {
    margin-top: 10px;
}

/* Messages de succès spécifiques à une section */
.account-form-section .success-message {
    margin-bottom: 15px;
    padding: 12px 18px;
}

/* Message d'erreur global */
.form-container > .error-message {
    margin-bottom: 20px;
}

/* ==========================================================================
   Styles pour le Hub Compte (index.php)
   ========================================================================== */

.account-hub-container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1rem; /* Ajoute un padding sur mobile */
}

/* Le H1 et l'intro doivent être alignés à gauche sur le hub */
.account-hub-container h1 {
    text-align: left;
}

.account-hub-intro {
    font-size: 1.15rem;
    color: #6c757d;
    margin-bottom: 2.5rem;
    text-align: left; /* Aligne le texte d'intro à gauche */
}

/* La grille de navigation */
.account-hub-nav {
    display: grid;
    grid-template-columns: 1fr; /* 1 colonne par défaut (mobile) */
    gap: 1.5rem; /* Espace entre les blocs */
}

/* Les "boutons" de navigation */
.account-hub-block {
    display: block;
    background-color: var(--surface-bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem 2rem;
    text-decoration: none; /* Supprime le soulignement du lien */
    /* box-shadow: 0 4px 10px rgba(0,0,0,0.04); */ /* SUPPRIMÉ */
    transition: transform 0.2s ease, border-color 0.2s ease; /* MODIFIÉ */
}

.account-hub-block:hover {
    transform: translateY(-4px);
    /* box-shadow: 0 8px 20px rgba(0,0,0,0.08); */ /* SUPPRIMÉ */
    border-color: var(--primary-color); /* Utilise la couleur principale au survol */
}

/* Contenu des blocs */
.account-hub-block .hub-icon {
    display: block;
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.account-hub-block .hub-title {
    display: block;
    font-family: 'Patrick Hand', 'Arial', cursive;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.account-hub-block .hub-desc {
    display: block;
    font-size: 0.95rem;
    color: #6c757d;
    line-height: 1.5;
}

/* --- Responsive pour le Hub --- */
@media (min-width: 768px) {
    /* Passe à 3 colonnes sur tablette et plus */
    .account-hub-nav {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================================================
   Styles pour les pages listes (Contacts, Suivi)
   ========================================================================== */

/* Conteneur principal pour contacts.php et tracking.php */
.account-list-container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Cible le H1 de la page (ex: "Mon Carnet d'adresses") */
.account-list-container > h1 {
    text-align: left; /* Aligne le H1 à gauche sur desktop */
}

/* Cible le paragraphe d'introduction (le premier <p> après H1) */
.account-list-container > h1 + p {
    font-size: 1.15rem;
    color: #6c757d;
    margin-bottom: 2.5rem;
    text-align: left;
}

/* --- Zone de contrôles (Bouton + Tri) --- */
.account-list-controls {
    display: flex;
    flex-direction: column; /* Mobile first: empilé */
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.account-list-controls .action-button {
    width: 100%;
    max-width: 350px; /* Limite la largeur du bouton sur mobile */
}

.sort-options {
    font-size: 0.95rem;
    color: #6c757d;
}

.sort-options .separator {
    margin: 0 0.5rem;
    color: var(--border-color);
}

.sort-options a {
    font-weight: 600;
    color: var(--text-color);
    text-decoration: underline;
    text-decoration-style: dashed;
    text-underline-offset: 3px;
}

.sort-options a:hover {
    text-decoration-style: solid;
}

/* Style pour le lien de tri actif */
.sort-options a.active {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 700;
}

/* --- Message "Aucun contact" --- */
/* Cible un <p> qui suit directement le bloc de contrôles */
.account-list-controls + p {
    font-size: 1.1rem;
    color: #6c757d;
    text-align: center;
    padding: 2.5rem 2rem;
    background-color: var(--surface-bg-color);
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
    margin-top: 0;
}


/* --- Grille de Cartes Contact --- */
.contact-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.contact-card {
    background-color: var(--surface-bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s ease;
}

.contact-card:hover {
    border-color: var(--primary-color);
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-grow: 1; /* Pousse les actions en bas */
    margin-bottom: 1rem;
}

.contact-name {
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--text-color);
}

.contact-email {
    color: #6c757d;
    font-size: 0.95rem;
    word-break: break-all;
}

.contact-birthdate {
    font-size: 0.95rem;
    color: var(--primary-color);
    font-weight: 600;
    margin-top: 0.25rem;
}

.contact-actions {
    display: flex;
    gap: 1.25rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.contact-actions a {
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}
.contact-actions a:hover {
    text-decoration: underline;
}

.contact-actions .action-edit {
    color: var(--primary-color);
}

.contact-actions .action-delete {
    color: #c62828; /* Rouge d'erreur */
}


/* --- Responsive pour les contrôles de liste --- */
@media (min-width: 768px) {
    .account-list-controls {
        flex-direction: row; /* Aligne bouton et tri sur la même ligne */
        justify-content: space-between;
    }

    .account-list-controls .action-button {
        width: auto; /* Revient à la taille auto */
        max-width: none;
    }
}

/* --- Style pour le formulaire d'ajout/modif de contact --- */
/* Il utilise .form-container, mais on ajoute un espacement */
.account-list-container .form-container {
     margin-top: 1rem;
}

/* Conteneur pour les boutons "Enregistrer" / "Annuler" */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}
.form-actions .btn-base {
    width: auto;
    flex-grow: 1;
    margin-top: 0;
}
.secondary-button {
    background-color: #f8f9fa;
    border-color: #dee2e6;
}
.secondary-button:hover {
    background-color: #e9ecef;
    color: var(--text-color);
}

/* Bouton de suppression (confirmation) */
.danger-button {
    background-color: #ffebee;
    color: #c62828;
    border-color: #ffcdd2;
}
.danger-button:hover {
    background-color: #c62828;
    color: #ffffff;
    border-color: #c62828;
}

/* Boîte de confirmation de suppression */
.confirmation-box.delete-confirm p {
    text-align: center;
    font-size: 1.1rem;
    color: var(--text-color);
}
.confirmation-box.delete-confirm .form-actions {
    justify-content: center;
}
.confirmation-box.delete-confirm .form-actions .btn-base {
    flex-grow: 0; /* Empêche les boutons de s'étirer */
    padding-left: 2rem;
    padding-right: 2rem;
}

/* --- Style pour les champs requis (*) --- */
.form-group label .required {
    color: #c62828;
    font-weight: 600;
    margin-left: 4px;
}

/* Style pour le lien de déconnexion sur la page hub */
.account-hub-logout {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e9ecef; /* Ligne de séparation légère */
}

.account-hub-logout a {
    color: #dc3545; /* Couleur rouge pour la déconnexion */
    text-decoration: none;
    font-weight: 600;
}

.account-hub-logout a:hover {
    text-decoration: underline;
}

.account-hub-logout a .logout-icon {
    margin-right: 0.4em; /* Espace entre l'icône et le texte */
    display: inline-block; /* Pour assurer un bon alignement vertical */
}

/* ==========================================================================
   Styles pour le NOUVEAU Suivi des envois (tracking.php)
   ========================================================================== */

/* Retire l'arrière-plan gris de la liste */
.tracking-list-container {
    background-color: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

/* Le conteneur de la carte (fond blanc, ombre) */
.tracking-card {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 3px 6px rgba(0,0,0,0.05);
    overflow: hidden;
}

/* Le résumé (partie toujours visible) */
.tracking-card-summary {
    display: flex;
    flex-direction: column; /* Empilé sur mobile */
    gap: 1rem;
    padding: 1rem;
}

/* Wrapper pour la vignette et les infos */
.tracking-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* La vignette cliquable */
.tracking-card-thumb-wrapper {
    width: 70px; /* Taille réduite */
    height: 70px;
    object-fit: cover;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background-color: #eee;
    display: block; /* Pour que le lien <a> prenne la taille */
    position: relative; /* Pour l'icône "Revoir" */
    border: 1px solid #eee;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tracking-card-thumb-wrapper img,
.tracking-card-thumb-wrapper source {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Effet au survol de la vignette */
.tracking-card-thumb-wrapper:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* --- Infos principales (type, date, statut) --- */
.tracking-card-info {
    flex-grow: 1;
    min-width: 0; /* Correction flexbox pour l'ellipsis */
}

.tracking-card-info span {
    display: block;
    font-size: 0.9rem;
    color: #6c757d;
    line-height: 1.5;
}

.tracking-card-info .tracking-card-type {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
}

/* Style pour le destinataire unique (s'il est affiché) */
.tracking-card-info .tracking-card-recipient {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Coupe les emails trop longs */
}

/* Statut principal (Lu, non lu, etc.) */
.tracking-card-status {
    font-weight: 600;
}
.tracking-card-status.status-lu {
    color: #28a745; /* Vert */
}
.tracking-card-status.status-envoye {
    color: #007bff; /* Bleu */
}
.tracking-card-status.status-attente {
    color: #fd7e14; /* Orange */
}
.tracking-card-status.status-erreur {
    color: #dc3545; /* Rouge */
}


/* --- Zone d'actions (boutons) --- */
.tracking-card-actions {
    display: flex;
    flex-wrap: wrap; /* Permet aux boutons de passer à la ligne sur mobile */
    gap: 0.75rem;
    align-items: center;
    padding-top: 0.5rem; /* Espace si les boutons passent à la ligne */
}

/* Boutons "Revoir", "Partager", "Modifier" */
.tracking-card-actions .btn-base {
    padding: 0.5rem 1rem; /* Boutons plus petits */
    font-size: 0.9rem;
    /* Les boutons s'adapteront à leur contenu */
}

/* Lien pour afficher/masquer les détails */
.tracking-card-toggle {
    background: none;
    border: none;
    padding: 0.5rem 0;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    margin-top: 0.5rem;
}
.tracking-card-toggle:hover {
    text-decoration: underline;
}

/* --- Zone de détails (accordéon) --- */
.tracking-card-details {
    background-color: #fdfdfd; /* Fond très légèrement gris */
    padding: 1rem 1.5rem;
    border-top: 1px solid #f0f0f0;
    display: none; /* Caché par défaut */
}

.tracking-card-details strong {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 1rem;
    color: #333;
}

.tracking-card-details ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.tracking-card-details li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    font-size: 0.9rem;
    border-bottom: 1px dashed #eee;
}
.tracking-card-details li:last-child {
    border-bottom: none;
}

.tracking-card-details li strong {
    margin-bottom: 0; /* Annule la marge pour le <strong> de l'email */
}

/* Statut pour les points de couleur */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.status-lu { background-color: #28a745; }
.status-dot.status-envoye { background-color: #007bff; }
.status-dot.status-attente { background-color: #fd7e14; }
.status-dot.status-erreur { background-color: #dc3545; }


/* --- Responsive --- */
@media (min-width: 600px) {
    .tracking-card-summary {
        flex-direction: row; /* Côte à côte sur écran plus large */
        justify-content: space-between;
        align-items: center;
    }
    
    .tracking-card-header {
        flex-grow: 1; /* Le header prend la place */
    }

    .tracking-card-actions {
        flex-shrink: 0; /* Les boutons ne se compriment pas */
        flex-wrap: nowrap; /* Les boutons restent sur une ligne */
        padding-top: 0; /* Annule l'espacement mobile */
    }
}


/* --- Styles pour les NOUVEAUX filtres de suivi --- */
.tracking-filter-nav {
    display: flex;
    flex-wrap: wrap; /* Passe à la ligne sur mobile */
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}
.tracking-filter-nav a {
    text-decoration: none;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    border-radius: 20px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}
.tracking-filter-nav a:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
}
.tracking-filter-nav a.active {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

/* --- Ajustement Icone (au-dessus du titre) --- */
.tracking-card-info .icon {
    display: block;
    font-size: 1.5rem;
    line-height: 1;
    margin-bottom: 0.3rem;
    color: #888;
}
.tracking-card-info .tracking-card-type {
    font-size: 1.05rem; /* Titre légèrement plus petit */
}

/* --- Ajustement Boutons (police, hauteur, alignement) --- */
.tracking-card-actions .btn-base {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-family: 'Nunito Sans', sans-serif; /* Force la police "normale" */
    font-weight: 600;
    line-height: 1.5; /* Alignement vertical du texte */
    min-height: 38px; /* Hauteur minimale fixe */
    box-sizing: border-box; /* Assure que padding/border sont inclus */
    text-decoration: none; /* Enlève le soulignement des <a> */
}


/* --- NOUVEAU : Bloc d'information migration --- */
.migration-notice {
    background-color: #e7f5fe; /* Bleu clair (similaire à carte-confirmation.php) */
    border: 1px solid #a5d8f3;
    border-radius: 8px;
    padding: 1.5rem 2rem;
    margin-bottom: 2.5rem;
    text-align: center;
}
.migration-notice h2 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: #0c5460;
    font-size: 1.3rem;
    font-weight: 600;
    font-family: 'Nunito Sans', sans-serif;
}
.migration-notice p {
    font-size: 1rem;
    color: #0c5460;
    margin-top: 0;
    margin-bottom: 1.5rem;
    text-align: center; /* Surcharge le text-align: left de la page */
}
.migration-notice .btn-base {
    /* Bouton avec style principal */
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    font-weight: 600;
    font-family: 'Nunito Sans', sans-serif;
}
.migration-notice .btn-base:hover {
    background-color: #333;
    border-color: #333;
    color: #ffffff;
}

/* --- Styles pour les filtres de suivi --- */
.tracking-filter-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}
.tracking-filter-nav a {
    text-decoration: none;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    border-radius: 20px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}
.tracking-filter-nav a:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
}
.tracking-filter-nav a.active {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

/* --- CORRECTION CSS : Position de l'icône --- */
.tracking-card-info {
    display: flex; /* Active Flexbox */
    flex-direction: column; /* Empile les enfants verticalement */
    align-items: flex-start; /* Aligne à gauche */
    flex-grow: 1;
    min-width: 0;
}



/* --- CORRECTION CSS : Style des boutons d'action --- */
.tracking-card-actions .btn-base {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-family: 'Nunito Sans', sans-serif; /* Force la police "normale" */
    font-weight: 600;
    line-height: 1.5; /* Alignement vertical du texte */
    min-height: 38px; /* Hauteur minimale fixe */
    box-sizing: border-box; /* Assure que padding/border sont inclus */
    text-decoration: none; /* Enlève le soulignement des <a> */
    
    /* Assure le style secondaire pour tous */
    background-color: #f8f9fa;
    color: var(--text-color);
    border-color: #dee2e6;
}
.tracking-card-actions .btn-base:hover {
    background-color: #e9ecef;
    color: var(--text-color);
    border-color: #dee2e6;
}

/* S'assure que les boutons "Modifier" (qui sont <a ... class="action-button">)
   sont bien stylés comme des boutons secondaires. */
.tracking-card-actions a.action-button {
    background-color: #f8f9fa;
    color: var(--text-color);
    border-color: #dee2e6;
}
.tracking-card-actions a.action-button:hover {
    background-color: #e9ecef;
    color: var(--text-color);
    border-color: #dee2e6;
}

/* --- CORRECTION CSS : Position de l'icône AU-DESSUS --- */

/* Wrapper pour icône + vignette */
.tracking-card-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem; /* Espace entre icône et vignette */
    width: 70px; /* Largeur fixe pour l'alignement */
    flex-shrink: 0;
}

/* L'icône elle-même */
.tracking-card-visual .icon {
    font-size: 1.5rem;
    line-height: 1;
    color: #888;
}

/* On cache l'ancien mauvais positionnement au cas où */
.tracking-card-info .icon {
    display: none;
}