/* ========================================
   Enguerrand 1072 V2 - Design Chevalier Épique
   ======================================== */

:root {
    --gold: #FFD700;
    --gold-light: #FFF4CC;
    --gold-dark: #B8860B;
    --gold-glow: rgba(255, 215, 0, 0.15);
    --bronze: #CD7F32;
    --bg: #0A0A0F;
    --bg-elevated: #12121A;
    --bg-card: #1A1A26;
    --text: #E8E8F0;
    --text-light: #B0B0C0;
    --text-muted: #707080;
    --border: #2A2A38;
    --border-gold: #3A3420;
    --shadow: rgba(0, 0, 0, 0.6);
    --shadow-strong: rgba(0, 0, 0, 0.8);
    --shadow-gold: 0 0 30px rgba(255, 215, 0, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(180deg, #0A0A0F 0%, #0F0F14 100%);
    color: var(--text);
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    width: 100%;
}

.container {
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

/* ========================================
   HEADER V2 - Design Épique
   ======================================== */

.header-v2 {
    position: relative;
    padding: 0;
    background: var(--bg-elevated);
    border-bottom: 3px solid var(--gold-dark);
    overflow: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Bannière château médiéval */
.castle-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background:
        linear-gradient(180deg, rgba(184, 134, 11, 0.1) 0%, transparent 100%),
        repeating-linear-gradient(90deg,
            transparent 0px,
            transparent 50px,
            rgba(255, 215, 0, 0.03) 50px,
            rgba(255, 215, 0, 0.03) 100px
        );
    opacity: 0.5;
}

.castle-banner::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg,
        transparent 0%,
        transparent 35%,
        var(--gold-light) 48%,
        var(--gold) 50%,
        var(--gold-light) 52%,
        transparent 65%,
        transparent 100%
    );
    animation: slideHorizontal 6s linear infinite;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 10px rgba(255, 215, 0, 0.5);
    z-index: 10;
}

@keyframes shimmer {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

@keyframes slideHorizontal {
    0% {
        transform: translateX(-100%);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    50% {
        transform: translateX(100%);
        opacity: 1;
    }
    60% {
        opacity: 0;
    }
    100% {
        transform: translateX(-100%);
        opacity: 0;
    }
}

.header-content {
    position: relative;
    display: flex;
    align-items: center;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 30px;
    z-index: 1;
}

/* Avatar Hero avec effets */
.avatar-hero {
    position: relative;
    width: 100px;
    height: 100px;
    flex-shrink: 0;
}

.avatar-glow {
    position: absolute;
    inset: -20px;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.2) 0%, rgba(255, 215, 0, 0.1) 40%, transparent 70%);
    animation: pulse-glow 2.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pulse-glow {
    0%, 100% {
        transform: scale(0.95);
        opacity: 0.4;
    }
    50% {
        transform: scale(1.15);
        opacity: 0.7;
    }
}

.avatar-hero img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%;
    border: 5px solid var(--gold);
    box-shadow:
        0 0 0 3px var(--bg-elevated),
        0 0 0 6px var(--gold-dark),
        var(--shadow-gold);
    position: relative;
    z-index: 2;
}

.avatar-ring {
    position: absolute;
    inset: -8px;
    border: 2px solid var(--gold);
    border-radius: 50%;
    opacity: 0.3;
    /* animation: rotate-ring 10s linear infinite; */
}

@keyframes rotate-ring {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Texte du header */
.hero-title {
    font-family: 'Cinzel', 'Cormorant', serif;
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 50%, var(--bronze) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 10px rgba(255, 215, 0, 0.2);
}

.hero-subtitle {
    font-family: 'Cormorant', Georgia, serif;
    font-size: 0.95rem;
    color: var(--text-light);
    font-style: italic;
    margin-bottom: 6px;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.status-dot {
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, #10B981 0%, #059669 100%);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
    animation: pulse-status 2s ease-in-out infinite;
}

@keyframes pulse-status {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.9);
    }
}

.status-text {
    font-family: 'Cormorant', serif;
    font-weight: 500;
}

/* Logo container */
.logo-container {
    margin-left: auto;
    position: relative;
}

.header-logo {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid var(--gold-dark);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(255, 215, 0, 0.1);
    transition: all 0.3s ease;
    background: var(--bg-card);
}

.header-logo:hover {
    transform: scale(1.05) rotate(2deg);
    border-color: var(--gold);
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(255, 215, 0, 0.2);
}

/* ========================================
   MESSAGES - Style amélioré
   ======================================== */

.messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    background:
        radial-gradient(circle at 20% 50%, rgba(255, 215, 0, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(184, 134, 11, 0.02) 0%, transparent 50%);
}

.message {
    display: flex;
    gap: 12px;
    /* animation: messageSlide 0.4s ease-out; */
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--gold-dark);
    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.4),
        inset 0 0 0 1px rgba(255, 215, 0, 0.2);
    position: relative;
}

.message-avatar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 25%;
}

.message.user .message-avatar {
    display: none;
}

.message-content {
    max-width: 650px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Bulles de message */
.message-bubble {
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message-bubble p {
    margin: 0;
    line-height: 1.4;
    font-size: 0.95rem;
}

/* Message ancien français */
.message.bot .message-bubble.old-french {
    font-family: 'Cormorant', Georgia, serif;
    font-size: 1rem;
    font-weight: 500;
    background:
        linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(184, 134, 11, 0.1) 100%),
        var(--bg-card);
    border: 2px solid var(--gold-dark);
    color: var(--gold-light);
    box-shadow:
        inset 0 1px 0 rgba(255, 215, 0, 0.2),
        0 4px 12px rgba(255, 215, 0, 0.1);
    letter-spacing: 0.3px;
}

/* Symbole croix désactivé
.message.bot .message-bubble.old-french::before {
    content: '✠';
    position: absolute;
    top: -8px;
    right: 20px;
    font-size: 16px;
    color: var(--gold);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
*/

/* Message utilisateur */
.message.user .message-bubble {
    background: linear-gradient(135deg, #2A2A38 0%, #1C1C28 100%);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Toggle de traduction amélioré */
.translation-toggle {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.05) 0%, transparent 100%);
    border: 2px dashed var(--border-gold);
    padding: 12px 16px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.translation-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.1), transparent);
    transition: left 0.5s ease;
}

.translation-toggle:hover::before {
    left: 100%;
}

.translation-toggle:hover {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.12) 0%, rgba(184, 134, 11, 0.05) 100%);
    border-color: var(--gold);
    border-style: solid;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.15);
}

.toggle-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-style: italic;
    font-family: 'Cormorant', serif;
    font-weight: 600;
}

.translation-content {
    display: none;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-gold);
    color: var(--text-light);
    font-size: 1rem;
    font-family: 'Cormorant', Georgia, serif;
    /* animation: fadeInDown 0.4s ease; */
}

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

.translation-toggle.active .toggle-text {
    color: var(--gold-light);
    font-weight: 600;
}

.translation-toggle.active .translation-content {
    display: block;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-left: 8px;
    font-style: italic;
}

/* ========================================
   INPUT AREA V2
   ======================================== */

.input-area {
    padding: 20px 30px 24px;
    border-top: 3px solid var(--gold-dark);
    background: var(--bg-elevated);
    position: relative;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
}

.input-area::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg,
        transparent 0%,
        transparent 40%,
        var(--gold-light) 50%,
        var(--gold) 52%,
        var(--gold-light) 54%,
        transparent 60%,
        transparent 100%
    );
    animation: slideHorizontal 7s linear infinite 0.5s;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

@keyframes scan {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 1;
    }
}

/* Indicateur de frappe amélioré */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    color: var(--text-light);
    font-size: 0.95rem;
    font-family: 'Cormorant', serif;
    font-style: italic;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.typing-indicator.active {
    display: flex;
    /* animation: fadeIn 0.3s ease; */
}

.typing-dots {
    display: flex;
    gap: 5px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    border-radius: 50%;
    animation: typingPulse 1.4s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

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

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

@keyframes typingPulse {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.3;
    }
    30% {
        transform: translateY(-10px) scale(1.2);
        opacity: 1;
    }
}

/* Formulaire d'input amélioré */
.input-form {
    display: flex;
    align-items: stretch;
    gap: 14px;
    background: linear-gradient(135deg, var(--bg) 0%, rgba(26, 26, 38, 0.8) 100%);
    border: 2px solid var(--border);
    border-radius: 20px;
    padding: 14px 14px 14px 20px;
    transition: all 0.3s ease;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.input-form::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(255, 215, 0, 0.05) 0%,
        transparent 50%
    );
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.input-form:focus-within {
    border-color: var(--gold);
    box-shadow:
        0 0 0 3px var(--gold-glow),
        var(--shadow-gold),
        inset 0 1px 0 rgba(255, 215, 0, 0.1);
    transform: translateY(-1px);
}

.input-form:focus-within::before {
    opacity: 1;
}

#input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1.05rem;
    font-family: 'Inter', sans-serif;
    resize: none;
    max-height: 140px;
    color: var(--text);
    padding: 4px 0;
    align-self: center;
    line-height: 1.5;
}

#input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* Bouton d'envoi épique */
#send-btn {
    width: 46px;
    height: 46px;
    border: 2px solid var(--gold-dark);
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: var(--bg);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow:
        0 2px 8px rgba(255, 215, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

#send-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

#send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow:
        0 6px 20px rgba(255, 215, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

#send-btn:hover:not(:disabled)::before {
    transform: translateX(100%);
}

#send-btn:active:not(:disabled) {
    transform: translateY(0) scale(1);
}

#send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

#send-btn svg {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* ========================================
   SCROLLBAR CUSTOM
   ======================================== */

.messages::-webkit-scrollbar {
    width: 12px;
}

.messages::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 6px;
}

.messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--border) 0%, var(--gold-dark) 50%, var(--border) 100%);
    border-radius: 6px;
    border: 2px solid var(--bg);
}

.messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--gold-dark) 0%, var(--gold) 50%, var(--gold-dark) 100%);
}

/* ========================================
   ANIMATIONS GLOBALES
   ======================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@media (max-width: 768px) {
    .header-content {
        padding: 24px 20px;
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
    }

    .avatar-hero {
        width: 120px;
        height: 120px;
    }

    .hero-title {
        font-size: 1.4rem;
    }

    .logo-container {
        display: none;
    }

    .messages {
        padding: 30px 15px;
        gap: 20px;
    }

    .message-content {
        max-width: 90%;
    }

    .message-avatar {
        width: 40px;
        height: 40px;
    }

    .input-area {
        padding: 20px 20px 28px;
    }
}

@media (min-width: 1600px) {
    .messages,
    .header-content,
    .input-form,
    .typing-indicator {
        max-width: 1600px;
    }
}


/* ========================================
   EFFETS SPÉCIAUX
   ======================================== */

/* Particules dorées flottantes - DÉSACTIVÉ pour résoudre le problème de scrollbar */
/*
@keyframes float-particle {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.4;
    }
    90% {
        opacity: 0.4;
    }
    100% {
        transform: translateY(-100vh) rotate(360deg);
        opacity: 0;
    }
}

.container::before {
    content: '⚜';
    position: fixed;
    color: var(--gold);
    font-size: 20px;
    opacity: 0.1;
    animation: float-particle 20s linear infinite;
    left: 10%;
    pointer-events: none;
}

.container::after {
    content: '✠';
    position: fixed;
    color: var(--gold-dark);
    font-size: 24px;
    opacity: 0.08;
    animation: float-particle 25s linear infinite 5s;
    left: 80%;
    pointer-events: none;
}
*/