/* ===================================
   BASE GLOBALE & RESET
   =================================== */
html {
    box-sizing: border-box;
    scroll-behavior: smooth;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: inherit;
}

/* Les images ne débordent jamais de leur conteneur */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===================================
   BODY & LAYOUT GLOBAL
   =================================== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ===================================
   LOGIN
   =================================== */

.login-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 40px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

/* ✅ Logo centré dans la carte de connexion */
.login-container img {
    margin: 0 auto 20px;   /* centre horizontalement + marge en bas */
    max-width: 200px;      /* ajuste si tu veux plus grand/petit */
    height: auto;
}

.login-container h1 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 32px;
}

.login-form input,
.login-form select {
    width: 100%;
    padding: 15px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}

.login-form input:focus,
.login-form select:focus {
    border-color: #667eea;
}

.login-form button {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.login-form button:hover {
    transform: translateY(-2px);
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
}

/* ===================================
   CONTAINER CHAT
   =================================== */

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 1000px;
    height: 90vh;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.container.active {
    display: flex;
}

/* ===================================
   HEADER
   =================================== */

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left h1 {
    font-size: 24px;
}

.header-left p {
    font-size: 13px;
    opacity: 0.9;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* ✅ AVATAR CORRIGÉ - Plus grand et sans déformation */
.user-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    border: 3px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.user-avatar:hover {
    transform: scale(1.08);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.logout-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* ===================================
   CHAT
   =================================== */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f5;
}

.message {
    margin-bottom: 15px;
    display: flex;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 75%;
    padding: 12px 18px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: #f1f3f4;
    color: #202124;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 5px;
}

.file-attachment {
    background: rgba(255,255,255,0.2);
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

/* ===================================
   QUIZ
   =================================== */

.quiz-container {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-top: 10px;
}

.quiz-question {
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
}

.quiz-option {
    background: white;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.quiz-option:hover {
    border-color: #667eea;
    transform: translateX(5px);
}

.quiz-option.correct {
    background: #d4edda;
    border-color: #28a745;
}

.quiz-option.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
}

.quiz-option.disabled {
    opacity: 0.7;
    cursor: default;
}

/* ===================================
   MINDMAP
   =================================== */

.mindmap-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-top: 10px;
    overflow-x: auto;
}

.mindmap-node {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    margin: 10px;
    display: inline-block;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.mindmap-branch {
    background: #e3f2fd;
    color: #1976d2;
    padding: 10px 20px;
    border-radius: 8px;
    margin: 8px 20px;
    display: block;
    border-left: 4px solid #1976d2;
}

.mindmap-leaf {
    background: #f3e5f5;
    color: #7b1fa2;
    padding: 8px 15px;
    border-radius: 6px;
    margin: 5px 40px;
    display: block;
    font-size: 14px;
    border-left: 3px solid #7b1fa2;
}

/* ===================================
   INPUTS / FOOTER CHAT
   =================================== */

.input-area {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.input-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.file-upload-btn {
    background: #f0f0f0;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    transition: background 0.3s;
}

.file-upload-btn:hover {
    background: #e0e0e0;
}

.input-area input[type="text"] {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.3s;
}

.input-area input[type="text"]:focus {
    border-color: #667eea;
}

.send-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: translateY(-2px);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.action-btn {
    background: white;
    border: 2px solid #667eea;
    color: #667eea;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

.action-btn:hover {
    background: #667eea;
    color: white;
}

.file-preview {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    margin-top: 10px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-preview button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
}

/* ===================================
   TYPING INDICATOR
   =================================== */

.typing-indicator {
    display: none;
    padding: 12px 18px;
    background: white;
    border-radius: 18px;
    width: fit-content;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.typing-indicator.active {
    display: block;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* ===================================
   WELCOME MESSAGE
   =================================== */

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.welcome-message h2 {
    color: #667eea;
    margin-bottom: 15px;
}

input[type="file"] {
    display: none;
}

/* ===================================
   AVATAR FORMULAIRE INSCRIPTION
   =================================== */

.avatar-field {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-top: 15px;
    margin-bottom: 15px;
}

.avatar-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: #555;
}

.avatar-button {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.avatar-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.avatar-filename {
    font-size: 0.85rem;
    color: #7f8c8d;
    font-style: italic;
}

#signupAvatar {
    display: none;
}

/* ✅ Prévisualisation de l'avatar lors de l'inscription */
.avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin: 10px 0;
    border: 3px solid #667eea;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ===================================
   RESPONSIVE
   =================================== */

/* Tablettes / petits laptops */
@media (max-width: 900px) {
    body {
        display: block;
        padding: 16px;
        justify-content: flex-start;
        align-items: flex-start;
    }

    .login-container {
        margin: 20px auto;
        padding: 30px 24px;
        border-radius: 16px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    }

    .container {
        max-width: 100%;
        width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .header {
        padding: 14px 16px;
    }

    .header-left h1 {
        font-size: 20px;
    }

    .header-left p {
        font-size: 12px;
    }

    .user-avatar {
        width: 60px;
        height: 60px;
    }

    .chat-messages {
        padding: 12px 10px;
    }

    .message-content {
        max-width: 85%;
        font-size: 14px;
    }

    .input-area {
        padding: 10px 12px;
    }

    .input-area input[type="text"] {
        padding: 10px 14px;
        font-size: 14px;
    }

    .send-btn {
        padding: 10px 22px;
        font-size: 14px;
    }
}

/* Smartphones */
@media (max-width: 600px) {
    body {
        padding: 0;
    }

    .login-container {
        margin: 0;
        max-width: 100%;
        min-height: 100vh;
        border-radius: 0;
        box-shadow: none;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 24px 16px;
    }

    .header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .header-left h1 {
        font-size: 18px;
    }

    .user-info {
        gap: 10px;
    }

    .logout-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .action-buttons {
        gap: 6px;
    }

    .action-btn {
        font-size: 12px;
        padding: 6px 12px;
    }

    .mindmap-node,
    .mindmap-branch,
    .mindmap-leaf {
        margin-left: 0;
        margin-right: 0;
    }
}
/* =============================
   STYLES QUIZ AMÉLIORÉS
   ============================= */

.quiz-container {
    max-width: 100%;
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    margin-bottom: 15px;
}

.quiz-container h3 {
    margin-top: 0;
    color: #667eea;
    font-size: 1.4rem;
    margin-bottom: 20px;
    text-align: center;
}

.quiz-question {
    background: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.quiz-question p {
    margin: 0 0 12px 0;
    font-size: 1rem;
    line-height: 1.5;
    font-weight: 600;
    color: #333;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-option {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.quiz-option:hover:not(:disabled) {
    background: #e8eaf6;
    border-color: #667eea;
    transform: translateX(4px);
}

.quiz-option:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.quiz-option.correct {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
    font-weight: 600;
}

.quiz-option.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.quiz-feedback {
    margin-top: 12px;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
}

.quiz-feedback.correct {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.quiz-feedback.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* =============================
   STYLES CARTES MENTALES AMÉLIORÉS
   ============================= */

.mindmap-container {
    max-width: 100%;
    padding: 20px;
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    border-radius: 12px;
    margin-bottom: 15px;
}

.mindmap-container h3 {
    margin-top: 0;
    color: #d63031;
    font-size: 1.4rem;
    margin-bottom: 20px;
    text-align: center;
}

.mindmap-center {
    background: white;
    border: 3px solid #d63031;
    border-radius: 50%;
    padding: 20px;
    text-align: center;
    font-weight: bold;
    font-size: 1.2rem;
    margin: 0 auto 30px;
    max-width: 250px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.mindmap-branches {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.mindmap-branch {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #d63031;
}

.mindmap-branch h4 {
    margin: 0 0 12px 0;
    color: #d63031;
    font-size: 1.1rem;
}

.mindmap-branch ul {
    margin: 0;
    padding-left: 20px;
    list-style: disc;
}

.mindmap-branch li {
    margin-bottom: 6px;
    line-height: 1.5;
    color: #2d3436;
}

/* =============================
   MESSAGES UTILISATEUR/ASSISTANT
   ============================= */

.user-message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 18px;
    border-radius: 18px;
    margin-bottom: 10px;
    max-width: 70%;
    margin-left: auto;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.assistant-message {
    background: #f1f3f4;
    color: #202124;
    padding: 12px 18px;
    border-radius: 18px;
    margin-bottom: 10px;
    max-width: 70%;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* =============================
   RESPONSIVE
   ============================= */

@media (max-width: 768px) {
    .mindmap-branches {
        grid-template-columns: 1fr;
    }
    
    .quiz-option {
        font-size: 0.9rem;
        padding: 10px 12px;
    }
    
    .mindmap-center {
        font-size: 1rem;
        padding: 15px;
    }
    
    .user-message,
    .assistant-message {
        max-width: 85%;
    }
}