/* =============================================================
   THEOLOGIA REFORMATA — STYLES DU MAGISTER IOHANNES
   Compagnon pédagogique : bouton flottant + page dédiée
   ============================================================= */

/* --- 1. BOUTON FLOTTANT --- */
.magister-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--encre);
    color: var(--velin);
    border: 3px solid var(--or);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--ombre-forte);
    transition: all var(--transition);
    font-family: var(--serif-titre);
    padding: 0;
}

.magister-fab::before {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--or) 0%, var(--or-pale) 50%, var(--or) 100%);
    z-index: -1;
    opacity: 0;
    transition: opacity var(--transition);
}

.magister-fab:hover {
    transform: scale(1.08);
    border-color: var(--or-pale);
}

.magister-fab:hover::before {
    opacity: 1;
}

.magister-fab .glyphe {
    font-size: 28px;
    color: var(--or);
    line-height: 1;
    font-weight: 600;
}

.magister-fab .badge-actif {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: var(--sapin);
    border: 2px solid var(--velin);
    border-radius: 50%;
}

.magister-fab .pulse {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid var(--or);
    opacity: 0;
    animation: pulse-magister 2.5s ease-out infinite;
    pointer-events: none;
}

@keyframes pulse-magister {
    0% { transform: scale(0.95); opacity: 0.6; }
    70% { transform: scale(1.15); opacity: 0; }
    100% { transform: scale(0.95); opacity: 0; }
}

/* --- 2. FENÊTRE DE CHAT FLOTTANTE --- */
.magister-chat {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 998;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 560px;
    max-height: calc(100vh - 140px);
    background: var(--velin-clair);
    border: 1px solid var(--bordure);
    border-radius: 4px;
    box-shadow: var(--ombre-forte);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: chat-apparition 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.magister-chat[data-ouvert="true"] {
    display: flex;
}

@keyframes chat-apparition {
    from { opacity: 0; transform: scale(0.92) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.magister-chat-entete {
    background: var(--encre);
    color: var(--velin);
    padding: var(--espace-4);
    display: flex;
    align-items: center;
    gap: var(--espace-3);
    border-bottom: 2px solid var(--or);
}

.magister-portrait-mini {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5a4a35 0%, #2c2417 100%);
    border: 2px solid var(--or);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--serif-titre);
    font-size: 22px;
    color: var(--or-pale);
    flex-shrink: 0;
    font-weight: 600;
    overflow: hidden;
}

.magister-chat-titre {
    flex: 1;
    line-height: 1.3;
}

.magister-chat-titre .nom {
    font-family: var(--serif-titre);
    font-size: var(--texte-md);
    font-weight: 600;
    color: var(--velin);
}

.magister-chat-titre .statut {
    font-family: var(--sans-ui);
    font-size: 11px;
    color: var(--or-pale);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.magister-chat-titre .statut::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    background: var(--sapin-clair);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--sapin-clair);
}

.magister-chat-fermer {
    background: none;
    border: none;
    color: var(--velin);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 2px;
    line-height: 1;
    transition: background var(--transition);
}

.magister-chat-fermer:hover {
    background: rgba(245, 241, 232, 0.12);
}

.magister-chat-corps {
    flex: 1;
    overflow-y: auto;
    padding: var(--espace-4);
    background: var(--velin-clair);
    display: flex;
    flex-direction: column;
    gap: var(--espace-3);
    scroll-behavior: smooth;
}

.magister-chat-corps::-webkit-scrollbar { width: 6px; }
.magister-chat-corps::-webkit-scrollbar-thumb {
    background: var(--bordure);
    border-radius: 3px;
}

/* --- 3. BULLES DE DIALOGUE --- */
.bulle {
    max-width: 88%;
    padding: var(--espace-3) var(--espace-4);
    border-radius: 4px;
    line-height: 1.55;
    font-size: var(--texte-sm);
    animation: bulle-apparition 0.22s ease;
}

@keyframes bulle-apparition {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.bulle p { margin: 0 0 var(--espace-2) 0; max-width: none; }
.bulle p:last-child { margin-bottom: 0; }

.bulle-magister {
    align-self: flex-start;
    background: var(--velin);
    border: 1px solid var(--bordure);
    border-bottom-left-radius: 0;
    color: var(--encre-doux);
    font-family: var(--serif-texte);
    position: relative;
}

.bulle-magister::before {
    content: "";
    position: absolute;
    left: -8px;
    bottom: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 10px 10px;
    border-color: transparent transparent var(--velin) transparent;
}

.bulle-utilisateur {
    align-self: flex-end;
    background: var(--encre);
    color: var(--velin);
    border-bottom-right-radius: 0;
    font-family: var(--serif-texte);
}

.bulle-systeme {
    align-self: center;
    background: rgba(176, 141, 87, 0.1);
    border: 1px dashed var(--or);
    color: var(--encre-doux);
    font-style: italic;
    font-size: var(--texte-xs);
    text-align: center;
    max-width: 92%;
    font-family: var(--sans-ui);
    letter-spacing: 0.04em;
}

.bulle em, .bulle strong { color: inherit; }
.bulle-magister :is([lang="grc"], [lang="he"], [lang="syc"], [lang="la"]) {
    color: var(--sanguine);
    font-weight: 500;
}

/* Indicateur de frappe */
.bulle-frappe {
    align-self: flex-start;
    background: var(--velin);
    border: 1px solid var(--bordure);
    border-bottom-left-radius: 0;
    padding: var(--espace-3) var(--espace-4);
    display: flex;
    gap: 4px;
}

.bulle-frappe span {
    width: 6px;
    height: 6px;
    background: var(--gris-clair);
    border-radius: 50%;
    animation: frappe-pulse 1.4s infinite ease-in-out;
}
.bulle-frappe span:nth-child(2) { animation-delay: 0.2s; }
.bulle-frappe span:nth-child(3) { animation-delay: 0.4s; }

@keyframes frappe-pulse {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* --- 4. CHIPS DE SUGGESTIONS --- */
.suggestions-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: var(--espace-2) var(--espace-4);
    background: var(--velin-clair);
    border-top: 1px solid var(--bordure);
}

.chip {
    background: var(--velin);
    border: 1px solid var(--bordure);
    color: var(--encre-doux);
    padding: 6px 12px;
    border-radius: 14px;
    font-family: var(--sans-ui);
    font-size: 11px;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.04em;
    font-weight: 500;
}

.chip:hover {
    background: var(--encre);
    color: var(--velin);
    border-color: var(--encre);
}

.chip-primaire {
    background: rgba(139, 44, 44, 0.08);
    color: var(--sanguine);
    border-color: rgba(139, 44, 44, 0.2);
}

/* --- 5. ZONE DE SAISIE --- */
.magister-saisie {
    border-top: 1px solid var(--bordure);
    padding: var(--espace-3);
    background: var(--velin);
    display: flex;
    gap: var(--espace-2);
    align-items: flex-end;
}

.magister-saisie textarea {
    flex: 1;
    border: 1px solid var(--bordure);
    border-radius: 3px;
    padding: var(--espace-2) var(--espace-3);
    font-family: var(--serif-texte);
    font-size: var(--texte-sm);
    line-height: 1.4;
    background: var(--velin-clair);
    color: var(--encre);
    resize: none;
    min-height: 38px;
    max-height: 120px;
    outline: none;
    transition: border-color var(--transition);
}

.magister-saisie textarea:focus {
    border-color: var(--or);
    box-shadow: 0 0 0 2px rgba(176, 141, 87, 0.15);
}

.magister-saisie button[type="submit"] {
    background: var(--encre);
    color: var(--velin);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 3px;
    cursor: pointer;
    transition: background var(--transition);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.magister-saisie button[type="submit"]:hover:not(:disabled) {
    background: var(--sanguine);
}

.magister-saisie button[type="submit"]:disabled {
    opacity: 0.5;
    cursor: default;
}

/* --- 6. PAGE DÉDIÉE — PORTRAIT GRAND FORMAT --- */
.magister-page-entete {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: var(--espace-8);
    align-items: center;
    margin-bottom: var(--espace-12);
    padding-bottom: var(--espace-8);
    border-bottom: 2px solid var(--or);
}

@media (max-width: 700px) {
    .magister-page-entete {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

.magister-portrait {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #6b5535 0%, #3d2f1e 50%, #1a1006 100%);
    border: 4px solid var(--or);
    box-shadow:
        0 0 0 1px rgba(176, 141, 87, 0.3),
        var(--ombre-forte);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    margin: 0 auto;
}

/* Portrait stylisé d'un vieux professeur — composé en CSS pur */
.magister-portrait::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        /* Cadre intérieur */
        radial-gradient(ellipse at 50% 78%, transparent 30%, rgba(0,0,0,0.4) 75%),
        /* Visage - teinte chair */
        radial-gradient(ellipse at 50% 42%, #d4a574 0%, #c89a68 18%, #a07f4f 25%, transparent 35%),
        /* Cheveux blancs - couronne */
        radial-gradient(ellipse at 30% 22%, #e8e2d0 0%, #c8c1a8 8%, transparent 16%),
        radial-gradient(ellipse at 70% 22%, #e8e2d0 0%, #c8c1a8 8%, transparent 16%),
        radial-gradient(ellipse at 50% 18%, #d8d0b8 0%, transparent 12%),
        /* Barbe blanche */
        radial-gradient(ellipse at 50% 62%, #e8e2d0 0%, #c8c1a8 12%, transparent 22%);
}

.magister-portrait::after {
    content: "";
    position: absolute;
    /* Lunettes rondes - cerclage doré */
    width: 60%;
    height: 18%;
    top: 38%;
    left: 20%;
    background:
        radial-gradient(circle at 25% 50%, transparent 26%, rgba(176, 141, 87, 0.85) 27%, rgba(176, 141, 87, 0.85) 30%, transparent 31%),
        radial-gradient(circle at 75% 50%, transparent 26%, rgba(176, 141, 87, 0.85) 27%, rgba(176, 141, 87, 0.85) 30%, transparent 31%);
    background-size: 50% 100%, 50% 100%;
    background-repeat: no-repeat;
    background-position: 0% 50%, 100% 50%;
}

.magister-portrait-initiale {
    position: absolute;
    bottom: -8px;
    right: -8px;
    width: 56px;
    height: 56px;
    background: var(--velin);
    border: 3px solid var(--encre);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--serif-titre);
    font-size: 28px;
    color: var(--encre);
    font-weight: 600;
    z-index: 2;
    font-style: italic;
}

.magister-page-titre h1 {
    font-size: var(--texte-3xl);
    margin-bottom: var(--espace-2);
    line-height: 1.1;
}

.magister-page-titre h1 em {
    color: var(--sanguine);
}

.magister-page-titre .sous-titre {
    font-family: var(--serif-titre);
    font-style: italic;
    font-size: var(--texte-lg);
    color: var(--gris);
    margin-bottom: var(--espace-3);
    max-width: 60ch;
    line-height: 1.45;
}

.magister-page-titre .meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--espace-3);
    font-family: var(--sans-ui);
    font-size: var(--texte-xs);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--gris);
    font-weight: 600;
}

.magister-page-titre .meta span {
    padding: 4px 10px;
    background: rgba(176, 141, 87, 0.1);
    border: 1px solid rgba(176, 141, 87, 0.25);
    color: var(--encre-doux);
    border-radius: 2px;
}

/* --- 7. CHAT EN PAGE PLEINE --- */
.magister-chat-pleine {
    background: var(--velin-clair);
    border: 1px solid var(--bordure);
    border-radius: 4px;
    box-shadow: var(--ombre-medium);
    display: flex;
    flex-direction: column;
    height: 600px;
    margin: var(--espace-8) 0;
    overflow: hidden;
}

.magister-chat-pleine .magister-chat-corps {
    padding: var(--espace-6);
}

.magister-chat-pleine .bulle {
    max-width: 70%;
    font-size: var(--texte-base);
}

/* --- 8. CARTES DE LEÇONS --- */
.lecon-grille {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--espace-4);
    margin: var(--espace-6) 0;
}

.lecon-carte {
    background: var(--velin-clair);
    border: 1px solid var(--bordure);
    border-radius: 3px;
    padding: var(--espace-6);
    transition: all var(--transition);
    cursor: pointer;
    text-align: left;
    width: 100%;
    font-family: inherit;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.lecon-carte::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--or);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform var(--transition);
}

.lecon-carte:hover {
    box-shadow: var(--ombre-medium);
    transform: translateY(-2px);
    border-color: var(--or);
}

.lecon-carte:hover::after {
    transform: scaleY(1);
}

.lecon-carte .niveau {
    font-family: var(--sans-ui);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--sanguine);
    font-weight: 700;
    margin-bottom: var(--espace-2);
    display: block;
}

.lecon-carte h4 {
    font-family: var(--serif-titre);
    font-size: var(--texte-md);
    font-weight: 600;
    color: var(--encre);
    margin-bottom: var(--espace-2);
    line-height: 1.3;
}

.lecon-carte p {
    font-size: var(--texte-sm);
    color: var(--gris);
    line-height: 1.55;
    margin: 0;
}

.lecon-carte .duree {
    margin-top: var(--espace-3);
    font-family: var(--sans-ui);
    font-size: 11px;
    color: var(--gris-clair);
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.lecon-carte .duree::before {
    content: "⧗";
    color: var(--or);
}

/* --- 9. RESPONSIVE FAB & CHAT --- */
@media (max-width: 600px) {
    .magister-fab {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .magister-chat {
        bottom: 80px;
        right: 16px;
        left: 16px;
        width: auto;
        height: 70vh;
    }
}

/* --- 10. AVERTISSEMENT API CLAUDE --- */
.api-config {
    background: rgba(176, 141, 87, 0.08);
    border-left: 3px solid var(--or);
    padding: var(--espace-4) var(--espace-6);
    margin: var(--espace-6) 0;
    border-radius: 0 3px 3px 0;
}

.api-config .marque {
    font-family: var(--sans-ui);
    font-size: var(--texte-xs);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--or);
    font-weight: 700;
    display: block;
    margin-bottom: var(--espace-3);
}

.api-config input[type="password"] {
    width: 100%;
    padding: var(--espace-2) var(--espace-3);
    border: 1px solid var(--bordure);
    background: var(--velin);
    color: var(--encre);
    font-family: 'SF Mono', Consolas, monospace;
    font-size: var(--texte-sm);
    margin: var(--espace-2) 0;
    border-radius: 2px;
}

.api-config input[type="password"]:focus {
    outline: none;
    border-color: var(--or);
}

.api-config .actions {
    display: flex;
    gap: var(--espace-2);
    margin-top: var(--espace-3);
}

.api-config .badge-statut {
    display: inline-block;
    font-family: var(--sans-ui);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
    margin-left: var(--espace-2);
}

.badge-statut.connecte {
    background: var(--sapin);
    color: var(--velin);
}

.badge-statut.deconnecte {
    background: var(--gris-clair);
    color: var(--encre);
}
