/* ================= RESET ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
}

/* ================= VARIABLES ================= */
:root {
    --bg-main: #0f0b1e;
    --bg-card: #1a1433;
    --bg-header: #0a061a;
    --violet-main: #8b5cf6;
    --violet-hover: #7c3aed;
    --text-main: #eae7ff;
    --text-muted: #b7b2d9;
    --border-soft: rgba(139, 92, 246, 0.25);
}

/* ================= BODY ================= */
body {
    min-height: 100vh;
    background: radial-gradient(circle at top, #241b46, var(--bg-main));
    display: flex;
    flex-direction: column;
    color: var(--text-main);
}

/* ================= HEADERS ================= */
header {
    background-color: var(--bg-header);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

/* Accueil */
.home-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 3.5rem 2rem;
}

.home-header img {
    width: 120px;
}

.home-header h1 {
    font-size: 2.6rem;
}

/* Pages classiques */
.page-header {
    text-align: center;
    padding: 2rem;
}

.page-header img {
    width: 80px;
    margin-bottom: 0.5rem;
}

.page-header h1 {
    font-size: 1.8rem;
}

/* ================= MAIN ================= */
main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

/* ================= CARTES ================= */
main > div,
main > form {
    background-color: var(--bg-card);
    padding: 2.2rem;
    border-radius: 14px;
    width: 100%;
    max-width: 420px;
    box-shadow:
            0 0 0 1px var(--border-soft),
            0 10px 30px rgba(0, 0, 0, 0.7);
    text-align: center;
}

/* ================= TEXTE ================= */
main p {
    margin-bottom: 1.6rem;
    line-height: 1.6;
    color: var(--text-muted);
}

/* ================= FORMULAIRES ================= */
form {
    text-align: left;
}

label {
    display: block;
    margin-top: 1.2rem;
    margin-bottom: 0.4rem;
    font-weight: bold;
}

input {
    width: 100%;
    padding: 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border-soft);
    background-color: #0f0b1e;
    color: var(--text-main);
}

input:focus {
    outline: none;
    border-color: var(--violet-main);
    box-shadow: 0 0 0 1px var(--violet-main);
}

/* ================= BOUTONS ================= */
button {
    width: 100%;
    padding: 0.75rem;
    margin-top: 1.2rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--violet-main), var(--violet-hover));
    color: #ffffff;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
}

/* Bouton retour */
.back-button {
    background: transparent;
    border: 1px solid var(--border-soft);
}

.back-button:hover {
    background-color: rgba(139, 92, 246, 0.15);
    box-shadow: none;
}

/* Liens */
.button-link {
    text-decoration: none;
}

/* ================= FOOTER ================= */
footer {
    background-color: var(--bg-header);
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ================================================= */
/* ================= CONVERSATIONS ================= */
/* ================================================= */

/* Layout pleine largeur + bouton bas */
.conversation-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 220px); /* header + footer */
}

/* Liste scrollable pleine largeur */
.conversation-list {
    flex: 1;
    width: 100%;
    background-color: var(--bg-card);
    overflow-y: auto;
    box-shadow: 0 0 0 1px var(--border-soft);
}

/* Item conversation */
.conversation-item {
    display: block;
    width: 100%;
    padding: 1rem;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-main);
    text-decoration: none;
}

.conversation-item:hover {
    background-color: rgba(139, 92, 246, 0.15);
}

.conversation-item strong {
    display: block;
}

.conversation-item span {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Bouton nouvelle conversation (bas de page) */
.new-conversation-container {
    padding: 1.5rem 0;
    display: flex;
    justify-content: center;
    background-color: var(--bg-main);
}

.new-conversation-button {
    width: 50%;
    min-width: 220px;
    max-width: 500px;
}

/* ================================================= */
/* ====================== CHAT ===================== */
/* ================================================= */

.chat-header {
    background-color: var(--bg-header);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-back {
    color: var(--violet-main);
    font-size: 1.5rem;
    text-decoration: none;
}

.chat-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin: auto;
    width: 100%;
    height: calc(100vh - 220px); /* header + footer */
}

.chat-list {
    flex: 1;
    width: 100%;
    background-color: var(--bg-card);
    overflow-y: auto;
    box-shadow: 0 0 0 1px var(--border-soft);
}


.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Messages */
.message {
    max-width: 70%;
    padding: 0.7rem 1rem;
    border-radius: 14px;
    font-size: 0.95rem;
}

.message.received {
    align-self: flex-start;
    background-color: #2a2352;
}

.message.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--violet-main), var(--violet-hover));
}

/* Input chat */
.chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border-soft);
}

.chat-input input {
    flex: 1;
}

.chat-input button {
    width: auto;
    padding: 0 1.2rem;
}

/* ================================================= */
/* ================= BANDEAU USER ================= */
/* ================================================= */

.user-banner {
    background-color: var(--bg-header);
    padding: 0.8rem 1.2rem;
    border-bottom: 1px solid var(--border-soft);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    max-width: 900px;
    margin: auto;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--violet-main), var(--violet-hover));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.user-text {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: bold;
}

.user-status {
    font-size: 0.8rem;
    color: #4ade80;
}


/* ================================================= */
/* ====================== CHAT ===================== */
/* ================================================= */

.chat-header {
    background-color: var(--bg-header);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-back {
    color: var(--violet-main);
    font-size: 1.5rem;
    text-decoration: none;
}

/* ================================================= */
/* ================= LAYOUT CHAT =================== */
/* ================================================= */

/* main spécifique au chat */
.chat-page {
    justify-content: flex-start;
    align-items: stretch;
    padding: 0;
}

/* Annule le style "carte" global */
.chat-page > .chat-layout {
    max-width: none;
    background: none;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
}

/* Layout pleine largeur */
.chat-layout {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* ================================================= */
/* ==================== MESSAGES =================== */
/* ================================================= */

.chat-messages {
    flex: 1;
    width: 100%;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    overflow-y: auto;
}

/* Message commun */
.message {
    max-width: 65%;
}

/* Message reçu (gauche) */
.message.received {
    align-self: flex-start;
    margin-right: auto;
}

/* Message envoyé (droite) */
.message.sent {
    align-self: flex-end;
    margin-left: auto;
}

/* ================================================= */
/* =================== INPUT CHAT ================== */
/* ================================================= */

.chat-input {
    padding: 1rem;
    border-top: 1px solid var(--border-soft);
    display: flex;
    justify-content: center;
    gap: 0.8rem;
}

.chat-input input {
    width: 100%;
    max-width: 700px;
    padding: 0.8rem;
    border-radius: 10px;
    border: none;
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 1rem;
}

.chat-input button {
    padding: 0 1.6rem;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--violet-main), var(--violet-hover));
    color: white;
    border: none;
    cursor: pointer;
}

/* Conteneur de la ligne */
.conversation-row {
    display: flex;
    align-items: stretch; /* Pour que les deux zones fassent la même hauteur */
    border-bottom: 1px solid var(--border-soft);
    transition: background 0.2s ease;
}

.conversation-row:hover {
    background-color: rgba(139, 92, 246, 0.05);
}

/* On ajuste l'item existant pour qu'il ne prenne plus toute la largeur forcée */
.conversation-item {
    flex: 1; /* Prend tout l'espace disponible */
    border-bottom: none; /* On enlève la bordure car elle est sur le parent .conversation-row */
    padding: 1rem;
}

/* Style du bouton supprimer */
.delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    border-left: 1px solid var(--border-soft);
}

.delete-btn:hover {
    background-color: rgba(239, 68, 68, 0.2); /* Fond rouge léger */
    color: #ff4d4d; /* Icône rouge */
}

/* Le conteneur de la ligne doit forcer l'alignement horizontal */
.conversation-row {
    display: flex !important; /* On force le flex pour contrer d'éventuels héritages */
    flex-direction: row; /* Aligne les enfants horizontalement */
    align-items: center;
    width: 100%;
    /* Bordure visible en permanence */
    border-bottom: 1px solid var(--border-soft);
    background-color: transparent;
    text-align: left; /* Aligne le texte à gauche au lieu du centre */
}

/* On s'assure que le lien de discussion prend toute la place à gauche */
.conversation-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.2rem;
    text-decoration: none;
    color: var(--text-main);
}

/* Force le texte à ne pas être centré */
.conversation-item strong,
.conversation-item span {
    text-align: left;
    display: block;
    width: 100%;
}

/* Le bouton de suppression à droite */
.delete-btn {
    padding: 0 1.5rem;
    font-size: 1.2rem;
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.2s, background 0.2s;
    height: 100%; /* Pour que la zone cliquable fasse toute la hauteur */
    display: flex;
    align-items: center;
}

.delete-btn:hover {
    opacity: 1;
    background-color: rgba(239, 68, 68, 0.1);
    color: #ff4d4d;
}

/* 1. On libère la largeur pour la liste des conversations */
.conversation-layout {
    max-width: 900px !important; /* On s'aligne sur la largeur de ton chat */
    margin: 0 auto;
}

/* 2. Le conteneur de ligne */
.conversation-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    width: 100%;
    min-height: 70px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-soft) !important; /* Bordure visible */
    transition: background 0.2s;
}

.conversation-row:hover {
    background-color: rgba(139, 92, 246, 0.1);
}

/* 3. La zone de texte (prend tout l'espace sauf le bouton) */
.conversation-item {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center;
    padding: 1rem 1.5rem !important;
    text-decoration: none !important;
    text-align: left !important; /* Force l'alignement à gauche */
}

.conv-user {
    color: var(--violet-main);
    font-size: 1.1rem;
    margin-bottom: 4px;
    text-align: left !important;
}

.conv-msg {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: left !important;
}

/* 4. Le bouton de suppression (enfin discret !) */
.delete-link {
    text-decoration: none !important;
    padding: 0 20px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    height: 100%;
    border-left: 1px solid var(--border-soft);
}

.delete-icon {
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: transform 0.2s, color 0.2s;
    /* On s'assure qu'il n'hérite d'aucun style de bouton */
    background: none !important;
    border: none !important;
    width: auto !important;
}

.delete-link:hover .delete-icon {
    color: #ff4d4d;
    transform: scale(1.2);
}


/* ================================================= */
/* ================= PAGE PROFIL =================== */
/* ================================================= */

/* On force le profil à être bien au centre */
.profile-card {
    background-color: var(--bg-card);
    padding: 2.5rem;
    border-radius: 18px;
    width: 100%;
    max-width: 500px; /* Un peu plus large que tes formulaires standards */
    box-shadow: 0 0 0 1px var(--border-soft), 0 15px 40px rgba(0, 0, 0, 0.8);
    margin: 2rem auto;
}

.profile-card h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--violet-main);
    text-align: center;
    border-bottom: 2px solid var(--border-soft);
    padding-bottom: 1rem;
}

/* Groupement des champs */
.form-group {
    margin-bottom: 1.8rem;
}

/* Style des labels informatifs */
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-main);
}

/* Affichage de la donnée actuelle (le label secondaire) */
.form-group label:nth-of-type(2) {
    font-weight: normal;
    font-style: italic;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(139, 92, 246, 0.05);
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 0.8rem;
    border-left: 2px solid var(--violet-main);
}

/* Séparateur horizontal */
hr {
    border: 0;
    height: 1px;
    background: var(--border-soft);
    margin: 2.5rem 0;
}

/* Bouton spécifique Suppression */
.btn-delete {
    background: transparent !important;
    border: 1px solid #ff4d4d !important;
    color: #ff4d4d !important;
    box-shadow: none !important;
    font-weight: bold;
    margin-top: 0.5rem;
}

.btn-delete:hover {
    background: rgba(255, 77, 77, 0.1) !important;
    transform: scale(0.98);
}

/* Lien retour */
.profile-card a {
    color: var(--violet-main);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.profile-card a:hover {
    color: var(--violet-hover);
    text-decoration: underline;
}

select {
    width: 100%;
    padding: 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border-soft);
    background-color: #0f0b1e;
    color: var(--text-main);
    cursor: pointer;
    appearance: none; /* Enlève le style par défaut du navigateur */
}

select:focus {
    outline: none;
    border-color: var(--violet-main);
    box-shadow: 0 0 0 1px var(--violet-main);
}