/* --- VARIABLES --- */
:root {
    --primary-gold: #ffcc00;
    --accent-red: #a00;
    --bg-dark: #0a0a0b;
    --leather: #161618;
    --text-color: #e0e0e0;
}

/* --- BASE & LAYOUT --- */
* { box-sizing: border-box; } /* Crucial pour les calculs de largeur */

body {
    background-color: var(--bg-dark);
    background-image: url('https://www.transparenttextures.com/patterns/dark-leather.png');
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
    margin: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Empêche le scroll de toute la page */
}

/* --- CONTENEUR PRINCIPAL (Fixe) --- */
.chat-container {
    width: 95vw;
    max-width: 450px;
    height: 95vh;
    background: var(--leather);
    border-radius: 30px;
    display: flex;
    flex-direction: column; /* Sandwich vertical */
    box-shadow: 0 30px 60px rgba(0,0,0,0.9);
    border: 1px solid rgba(255,255,255,0.05);
    overflow: hidden;
    position: relative;
}

/* --- HEADER FIXE --- */
.main-header {
    flex-shrink: 0; /* Ne s'écrase jamais */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #000;
    border-bottom: 2px solid var(--accent-red);
    z-index: 10;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-titles { display: flex; flex-direction: column; }
.title { color: var(--primary-gold); font-weight: bold; letter-spacing: 2px; font-size: 1rem; }
.typing-text { font-size: 0.65rem; color: var(--primary-gold); height: 12px; opacity: 0.7; }
.header-right { display: flex; align-items: center; gap: 15px; }
.head-btn { background: none; border: none; color: var(--primary-gold); cursor: pointer; display: flex; transition: transform 0.2s; }
.head-btn svg { width: 22px; height: 22px; }

/* --- BARRE D'ORDRE --- */
.pinned-order-bar {
    flex-shrink: 0;
    background: linear-gradient(to bottom, #1a1a1a, #0d0d0d);
    border-bottom: 1px solid var(--primary-gold);
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* --- ZONE MESSAGES (Défilement interne) --- */
#messages {
    flex: 1; /* Prend TOUT l'espace restant */
    overflow-y: auto; /* Autorise le scroll ici seulement */
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: transparent;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

/* --- BULLES DE MESSAGE --- */
.msg {
    padding: 12px 18px;
    border-radius: 20px;
    max-width: 85%;
    font-size: 0.95rem;
    position: relative;
    word-wrap: break-word;
}

.me { background: var(--primary-gold); color: black; align-self: flex-end; border-bottom-right-radius: 4px; }
.other { background: #2a2a2d; color: white; align-self: flex-start; border-bottom-left-radius: 4px; border-left: 3px solid var(--accent-red); }

/* --- GESTION DES IMAGES DANS LE TCHAT --- */
.msg-image {
    padding: 6px !important;
    width: fit-content;
    max-width: 85%;
}

.msg img.chat-img {
    max-width: 100%;
    max-height: 300px; /* Empêche l'image de boucher tout l'écran */
    height: auto;
    display: block;
    border-radius: 12px;
    cursor: pointer;
}

/* --- ZONE INPUT FIXE (Bas de l'écran) --- */
.input-area {
    flex-shrink: 0; /* Reste toujours visible en bas */
    padding: 15px;
    background: #000;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #222;
}

#messageInput {
    flex: 1;
    background: #111;
    border: 1px solid #333;
    padding: 12px 15px;
    border-radius: 20px;
    color: white;
    outline: none;
}

#sendBtn {
    background: var(--accent-red);
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    flex-shrink: 0;
}

/* --- MODALES & OVERLAYS --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.modal-content {
    background: var(--leather);
    border: 1px solid var(--primary-gold);
    padding: 25px;
    border-radius: 20px;
    text-align: center;
    width: 85%;
    max-width: 350px;
}

/* --- MENU CONTEXTUEL (Supprimer/Modifier) --- */
.context-menu {
    position: fixed;
    background: #1a1a1a;
    border: 1px solid var(--primary-gold);
    border-radius: 8px;
    padding: 5px 0;
    min-width: 150px;
    z-index: 2000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
}

.menu-item {
    padding: 10px 20px;
    color: white;
    cursor: pointer;
    font-size: 14px;
}

.menu-item:hover { background: #333; }
.menu-item.delete { color: #ff4444; }
.menu-item.edit { color: var(--primary-gold); }

/* --- ZOOM IMAGE --- */
.zoom-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    cursor: zoom-out;
}
.zoom-overlay img { max-width: 95%; max-height: 95%; border-radius: 10px; }

/* Style de la réaction */
.reaction {
    position: absolute;
    bottom: -10px;
    right: 5px;
    background: #1a1a1a;
    border: 1px solid var(--primary-gold);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    z-index: 5;
    animation: popReaction 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.status-text {
    font-size: 0.7rem;
    color: #888;
    margin-top: 2px;
}
.status-text.online {
    color: #4caf50;
    font-weight: bold;
}

@keyframes popReaction {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}
.reaction {
    position: absolute;
    bottom: -10px;
    right: 10px;
    background: #1a1a1a;
    border: 1px solid var(--primary-gold);
    border-radius: 50%;
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    z-index: 10;
}
