/* --- VARIABLES & IDENTITÉ VISUELLE --- */
:root {
    --bg-dark: #0f0f1a;
    --primary: #50518b;
    --secondary: #282a6b;
    --creative: #50518b;
    --pro: #00a38d;
    --accent: #00d4ff;
    --text-light: #e0e0e0;
    --glass: rgba(255, 255, 255, 0.03);
    --card-bg: rgba(255, 255, 255, 0.05);
    --border-glass: rgba(255, 255, 255, 0.05);
}

/* --- POLICE MONTSERRAT --- */
@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 200 600;
    src: url('/public/montserrat-v31-latin.woff2') format('woff2');
    font-display: swap;
}

/* --- CONTRAINTE DE STRUCTURE ABSOLUE (FIX CLAVIER) --- */
html, body, #root {
    height: 100vh !important;
    height: 100svh !important;
    max-height: 100svh !important;
    width: 100vw !important;
    overflow: hidden !important;
    position: fixed; /* Indispensable pour empêcher la page de glisser sous le clavier */
    background-color: var(--bg-dark) !important;
    margin: 0;
    padding: 0;
    font-family: 'Montserrat', sans-serif !important;
    color: var(--text-light) !important;
}

/* Fond Blueprint */
#root::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    opacity: 0.3;
    pointer-events: none;
}

/* --- LAYOUT DYNAMIQUE DU CHAT --- */
.MuiContainer-root {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    max-height: 100% !important;
    max-width: 100% !important;
    padding: 0 20px !important;
    box-sizing: border-box !important;
}

/* Zone de défilement des messages uniquement */
#chat-list {
    flex-grow: 1 !important;
    flex-shrink: 1 !important;
    overflow-y: auto !important;
    padding-top: 20px !important;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

/* --- MESSAGES & BULLES --- */
.message {
    background: var(--card-bg) !important;
    backdrop-filter: blur(5px) !important;
    border: 1px solid var(--border-glass) !important;
    border-radius: 12px !important;
    margin-bottom: 1.5rem !important;
    padding: 1rem !important;
}

.message[data-author="Thomas Forest"] { border-left: 4px solid var(--pro) !important; }
.message[data-author="User"] { border-right: 4px solid var(--accent) !important; }

/* --- BARRE DE SAISIE (VERROUILLÉE) --- */
#chat-input-container {
    background: var(--glass) !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid var(--border-glass) !important;
    border-radius: 24px !important;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.1) !important;
    margin-bottom: 20px !important;
    margin-top: 10px !important;
    flex-shrink: 0 !important; /* Empêche l'input de s'écraser */
    position: relative !important;
    z-index: 10;
}

textarea {
    color: var(--text-light) !important;
    font-family: 'Montserrat', sans-serif !important;
    font-size: 16px !important; /* Fix crucial : évite le zoom auto de l'iPhone qui décale tout */
}

/* --- NETTOYAGE UI CIBLÉ --- */

/* 1. Masque le bouton de copie des messages */
button[aria-label="Copy"], 
button[aria-label="copy"] {
    display: none !important;
}

/* 2. Masque le bouton flottant "Ouvrir la barre latérale" */
#open-sidebar-button,
[aria-label="Ouvrir la barre latérale"],
[aria-label="Open sidebar"] {
    display: none !important;
}

/* 3. Masque le tiroir d'historique (Drawer) et son conteneur */
.chat-history-drawer,
.MuiDrawer-root,
.MuiDrawer-docked {
    display: none !important;
    width: 0 !important;
}

/* 4. Supprime les éléments de branding/header restants */
#header, 
.watermark, 
#sidebar-trigger {
    display: none !important;
}
/* On évite de masquer .MuiButtonBase-root car c'est la classe parente de trop d'éléments vitaux */

/* --- OPTIMISATION MOBILE --- */
@media (max-width: 768px) {
    body, #root {
        min-height: -webkit-fill-available;
    }

    .MuiContainer-root {
        padding: 0 10px !important;
    }

    #chat-input-container {
        /* Utilisation des safe areas pour les iPhones récents */
        margin-bottom: calc(env(safe-area-inset-bottom, 0px) + 15px) !important;
        width: 100% !important;
    }

    .message {
        padding: 0.8rem !important;
        margin-bottom: 1rem !important;
    }
}