/* ============================================
   L'Oracle — Chatbot ProVoyance
   Theme mystique immersif
   ============================================ */

/* --- Variables --- */
:root {
    --oracle-bg: #0a0a14;
    --oracle-surface: #12121f;
    --oracle-surface-2: #1a1a2e;
    --oracle-border: #2a2a44;
    --oracle-gold: #c9a84c;
    --oracle-gold-light: #e8d48b;
    --oracle-gold-dim: rgba(201, 168, 76, 0.15);
    --oracle-purple: #7b5ea7;
    --oracle-purple-light: #a78bca;
    --oracle-purple-dim: rgba(123, 94, 167, 0.15);
    --oracle-blue: #4a6fa5;
    --oracle-text: #e0dce8;
    --oracle-text-dim: #8a8699;
    --oracle-user-bg: #1e2a4a;
    --oracle-assistant-bg: #1a1530;
    --oracle-radius: 16px;
    --oracle-radius-sm: 10px;
    --oracle-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --oracle-glow: 0 0 20px rgba(201, 168, 76, 0.2);
    --oracle-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
body {
    background: var(--oracle-bg) !important;
    min-height: 100vh;
}

/* --- Fond etoile --- */
.oracle-stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.oracle-star {
    position: absolute;
    border-radius: 50%;
    background: white;
    animation: oracle-twinkle var(--duration, 3s) ease-in-out infinite;
    animation-delay: var(--delay, 0s);
    opacity: 0;
}

@keyframes oracle-twinkle {
    0%, 100% { opacity: 0; transform: scale(0.5); }
    50% { opacity: var(--max-opacity, 0.7); transform: scale(1); }
}

/* Etoile filante */
.oracle-shooting-star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    animation: oracle-shoot 2s linear forwards;
    opacity: 0;
}

.oracle-shooting-star::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 1px;
    background: linear-gradient(to left, white, transparent);
    transform-origin: right;
}

@keyframes oracle-shoot {
    0% { opacity: 0; transform: translate(0, 0) rotate(-45deg); }
    10% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; transform: translate(-300px, 300px) rotate(-45deg); }
}

/* --- Container principal --- */
.oracle-container {
    position: relative;
    z-index: 1;
    max-width: 760px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 76px); /* 76px = navbar */
}

/* --- Header --- */
.oracle-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 0 16px;
    border-bottom: 1px solid var(--oracle-border);
    flex-shrink: 0;
}

.oracle-avatar {
    position: relative;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
}

.oracle-avatar-glow {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--oracle-gold-dim), transparent 70%);
    animation: oracle-pulse-glow 3s ease-in-out infinite;
}

@keyframes oracle-pulse-glow {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.15); }
}

.oracle-avatar-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--oracle-surface-2), var(--oracle-purple-dim));
    border-radius: 50%;
    font-size: 20px;
    color: var(--oracle-gold);
    z-index: 1;
}

.oracle-avatar-ring {
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 2px solid var(--oracle-gold);
    opacity: 0.5;
    animation: oracle-ring-rotate 8s linear infinite;
    border-top-color: transparent;
    border-right-color: transparent;
}

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

.oracle-header-text {
    flex: 1;
    min-width: 0;
}

.oracle-title {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--oracle-gold);
    margin: 0;
    letter-spacing: 0.05em;
}

.oracle-subtitle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--oracle-text-dim);
    margin: 2px 0 0;
}

.oracle-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #50c878;
    display: inline-block;
    animation: oracle-status-pulse 2s ease-in-out infinite;
}

@keyframes oracle-status-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; box-shadow: 0 0 6px #50c878; }
}

.oracle-tools {
    display: flex;
    gap: 10px;
}

.oracle-tool {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--oracle-surface-2);
    border: 1px solid var(--oracle-border);
    color: var(--oracle-text-dim);
    font-size: 0.8rem;
    transition: var(--oracle-transition);
    cursor: default;
}

.oracle-tool:hover {
    color: var(--oracle-gold);
    border-color: var(--oracle-gold-dim);
    background: var(--oracle-gold-dim);
}

.oracle-tool.active {
    color: var(--oracle-gold);
    border-color: var(--oracle-gold);
    box-shadow: 0 0 10px var(--oracle-gold-dim);
}

/* --- Zone de messages --- */
.oracle-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--oracle-border) transparent;
}

.oracle-messages::-webkit-scrollbar {
    width: 5px;
}

.oracle-messages::-webkit-scrollbar-track {
    background: transparent;
}

.oracle-messages::-webkit-scrollbar-thumb {
    background: var(--oracle-border);
    border-radius: 10px;
}

/* --- Ecran d'accueil --- */
.oracle-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    animation: oracle-fade-in 1s ease-out;
}

@keyframes oracle-fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Boule de cristal */
.oracle-crystal {
    position: relative;
    margin-bottom: 30px;
}

.oracle-crystal-ball {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%,
        rgba(168, 130, 255, 0.3),
        rgba(74, 50, 120, 0.6) 50%,
        rgba(20, 15, 40, 0.9) 100%
    );
    border: 2px solid rgba(201, 168, 76, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    animation: oracle-crystal-float 4s ease-in-out infinite;
}

@keyframes oracle-crystal-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.oracle-crystal-glow {
    position: absolute;
    inset: -20px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(201, 168, 76, 0.15), transparent 60%);
    animation: oracle-crystal-glow-pulse 3s ease-in-out infinite alternate;
}

@keyframes oracle-crystal-glow-pulse {
    from { opacity: 0.4; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1.1); }
}

.oracle-crystal-icon {
    font-size: 32px;
    color: var(--oracle-gold);
    opacity: 0.7;
    z-index: 1;
    animation: oracle-crystal-icon-glow 2s ease-in-out infinite alternate;
}

@keyframes oracle-crystal-icon-glow {
    from { text-shadow: 0 0 10px transparent; opacity: 0.5; }
    to { text-shadow: 0 0 20px var(--oracle-gold); opacity: 0.9; }
}

.oracle-crystal-base {
    width: 60px;
    height: 12px;
    background: linear-gradient(to bottom, var(--oracle-surface-2), var(--oracle-border));
    border-radius: 0 0 50% 50% / 0 0 100% 100%;
    margin: -4px auto 0;
}

.oracle-welcome-title {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: var(--oracle-gold);
    margin: 0 0 12px;
    letter-spacing: 0.04em;
}

.oracle-welcome-text {
    color: var(--oracle-text-dim);
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 400px;
    margin: 0 0 30px;
}

.oracle-start-btn {
    padding: 14px 36px;
    border: 1px solid var(--oracle-gold);
    border-radius: 50px;
    background: linear-gradient(135deg, var(--oracle-gold-dim), rgba(201, 168, 76, 0.05));
    color: var(--oracle-gold);
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: var(--oracle-transition);
    position: relative;
    overflow: hidden;
}

.oracle-start-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(201, 168, 76, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.oracle-start-btn:hover {
    background: linear-gradient(135deg, rgba(201, 168, 76, 0.25), rgba(201, 168, 76, 0.1));
    box-shadow: var(--oracle-glow);
    transform: translateY(-1px);
}

.oracle-start-btn:hover::before {
    transform: translateX(100%);
}

.oracle-start-btn:active {
    transform: translateY(0);
}

.oracle-start-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

/* --- Bulles de message --- */
.oracle-msg {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    animation: oracle-msg-in 0.4s ease-out;
    max-width: 88%;
}

@keyframes oracle-msg-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.oracle-msg.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.oracle-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
    margin-top: 4px;
}

.oracle-msg.assistant .oracle-msg-avatar {
    background: linear-gradient(135deg, var(--oracle-surface-2), var(--oracle-purple-dim));
    border: 1px solid var(--oracle-gold-dim);
    color: var(--oracle-gold);
}

.oracle-msg.user .oracle-msg-avatar {
    background: var(--oracle-user-bg);
    border: 1px solid var(--oracle-border);
    color: var(--oracle-blue);
}

.oracle-msg-bubble {
    padding: 14px 18px;
    border-radius: var(--oracle-radius);
    line-height: 1.65;
    font-size: 0.93rem;
    position: relative;
}

.oracle-msg.assistant .oracle-msg-bubble {
    background: var(--oracle-assistant-bg);
    border: 1px solid rgba(123, 94, 167, 0.15);
    color: var(--oracle-text);
    border-top-left-radius: 4px;
}

.oracle-msg.user .oracle-msg-bubble {
    background: var(--oracle-user-bg);
    border: 1px solid rgba(74, 111, 165, 0.2);
    color: var(--oracle-text);
    border-top-right-radius: 4px;
}

/* Markdown dans les messages Oracle */
.oracle-msg.assistant .oracle-msg-bubble em {
    color: var(--oracle-purple-light);
    font-style: italic;
}

.oracle-msg.assistant .oracle-msg-bubble strong {
    color: var(--oracle-gold-light);
    font-weight: 600;
}

.oracle-msg.assistant .oracle-msg-bubble p {
    margin: 0 0 10px;
}

.oracle-msg.assistant .oracle-msg-bubble p:last-child {
    margin-bottom: 0;
}

/* Curseur clignotant pendant le streaming */
.oracle-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--oracle-gold);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: oracle-cursor-blink 0.8s step-end infinite;
}

@keyframes oracle-cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Indicateur de frappe --- */
.oracle-typing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 0 16px;
    animation: oracle-fade-in 0.3s ease-out;
}

.oracle-typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--oracle-surface-2), var(--oracle-purple-dim));
    border: 1px solid var(--oracle-gold-dim);
    color: var(--oracle-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.oracle-typing-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--oracle-assistant-bg);
    border: 1px solid rgba(123, 94, 167, 0.15);
    border-radius: var(--oracle-radius-sm);
    border-top-left-radius: 4px;
}

.oracle-typing-text {
    font-size: 0.82rem;
    color: var(--oracle-text-dim);
    font-style: italic;
}

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

.oracle-typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--oracle-purple-light);
    animation: oracle-typing-bounce 1.4s ease-in-out infinite;
}

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

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

@keyframes oracle-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* --- Zone de saisie --- */
.oracle-input-area {
    padding: 12px 0 8px;
    border-top: 1px solid var(--oracle-border);
    flex-shrink: 0;
    animation: oracle-fade-in 0.5s ease-out;
}

.oracle-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--oracle-surface);
    border: 1px solid var(--oracle-border);
    border-radius: var(--oracle-radius);
    padding: 8px 8px 8px 16px;
    transition: var(--oracle-transition);
}

.oracle-input-wrapper:focus-within {
    border-color: var(--oracle-purple);
    box-shadow: 0 0 16px rgba(123, 94, 167, 0.15);
}

.oracle-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--oracle-text);
    font-family: 'Lato', sans-serif;
    font-size: 0.93rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 120px;
    padding: 6px 0;
}

.oracle-input::placeholder {
    color: var(--oracle-text-dim);
    opacity: 0.6;
}

.oracle-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--oracle-purple), var(--oracle-purple-light));
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--oracle-transition);
    flex-shrink: 0;
}

.oracle-send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: var(--oracle-border);
}

.oracle-send-btn:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 0 12px rgba(123, 94, 167, 0.4);
}

.oracle-input-hint {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--oracle-text-dim);
    opacity: 0.5;
    padding: 4px 8px 0;
}

.oracle-hint-separator {
    opacity: 0.3;
}

/* --- Actions --- */
.oracle-actions {
    display: flex;
    justify-content: center;
    padding: 4px 0 12px;
    flex-shrink: 0;
}

.oracle-action-btn {
    padding: 8px 20px;
    border: 1px solid var(--oracle-border);
    border-radius: 20px;
    background: transparent;
    color: var(--oracle-text-dim);
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--oracle-transition);
}

.oracle-action-btn:hover {
    border-color: var(--oracle-gold-dim);
    color: var(--oracle-gold);
    background: var(--oracle-gold-dim);
}

/* --- Disclaimer --- */
.oracle-disclaimer {
    position: relative;
    z-index: 1;
    max-width: 760px;
    margin: 0 auto;
    padding: 8px 20px 20px;
}

.oracle-disclaimer p {
    font-size: 0.72rem;
    color: var(--oracle-text-dim);
    opacity: 0.5;
    text-align: center;
    margin: 0;
    line-height: 1.5;
}

/* --- Message de limite atteinte --- */
.oracle-limit-msg {
    text-align: center;
    padding: 20px;
    animation: oracle-fade-in 0.5s ease-out;
}

.oracle-limit-msg p {
    color: var(--oracle-text-dim);
    font-size: 0.9rem;
    margin: 0 0 14px;
}

.oracle-limit-msg .oracle-start-btn {
    font-size: 0.85rem;
    padding: 10px 24px;
}

/* --- Boutons de choix interactifs --- */
.oracle-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(201, 168, 76, 0.1);
    animation: oracle-fade-in 0.4s ease-out;
}

.oracle-choice-btn {
    padding: 9px 18px;
    border: 1px solid var(--oracle-gold);
    border-radius: 22px;
    background: rgba(201, 168, 76, 0.08);
    color: var(--oracle-gold);
    font-family: 'Lato', sans-serif;
    font-size: 0.84rem;
    cursor: pointer;
    transition: var(--oracle-transition);
    white-space: nowrap;
}

.oracle-choice-btn:hover:not(:disabled) {
    background: rgba(201, 168, 76, 0.2);
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.15);
    transform: translateY(-1px);
}

.oracle-choice-btn:active:not(:disabled) {
    transform: translateY(0);
}

.oracle-choice-btn.selected {
    background: var(--oracle-gold);
    color: var(--oracle-bg);
    font-weight: 600;
    border-color: var(--oracle-gold);
}

.oracle-choice-btn.disabled:not(.selected) {
    opacity: 0.3;
    cursor: default;
    border-color: var(--oracle-border);
    color: var(--oracle-text-dim);
    background: transparent;
}

/* --- Footer override --- */
footer {
    display: none !important;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .oracle-container {
        height: calc(100vh - 60px);
        padding: 0 10px;
    }

    .oracle-header {
        padding: 14px 0 12px;
    }

    .oracle-tools {
        display: none;
    }

    .oracle-title {
        font-size: 1.1rem;
    }

    .oracle-msg {
        max-width: 94%;
    }

    .oracle-msg-bubble {
        padding: 12px 14px;
        font-size: 0.9rem;
    }

    .oracle-msg-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.65rem;
    }

    .oracle-welcome-title {
        font-size: 1.2rem;
    }

    .oracle-crystal-ball {
        width: 80px;
        height: 80px;
    }

    .oracle-crystal-icon {
        font-size: 26px;
    }
}

@media (max-width: 480px) {
    .oracle-msg-avatar {
        display: none;
    }

    .oracle-typing-avatar {
        display: none;
    }

    .oracle-msg {
        max-width: 98%;
    }

    .oracle-msg.assistant .oracle-msg-bubble {
        border-top-left-radius: var(--oracle-radius);
    }

    .oracle-msg.user .oracle-msg-bubble {
        border-top-right-radius: var(--oracle-radius);
    }
}
