/* Mistral Chatbot - Frontend Styles */

:root {
    --mistral-primary-color: #C19B7B;
    --mistral-primary-dark: #A87F5E;
    --mistral-primary-light: #D4B596;
    --mistral-accent-color: #8B6F47;
    --mistral-text-color: #2c2420;
    --mistral-text-light: #6b5d52;
    --mistral-bg-color: #ffffff;
    --mistral-bg-secondary: #faf8f6;
    --mistral-border-color: #e8dfd7;
    --mistral-shadow: 0 10px 30px rgba(193, 155, 123, 0.15);
    --mistral-shadow-hover: 0 15px 40px rgba(193, 155, 123, 0.25);
}

/* Widget Container */
#mistral-chatbot-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#mistral-chatbot-widget.mistral-chatbot-bottom-right {
    bottom: 20px;
    right: 20px;
}

#mistral-chatbot-widget.mistral-chatbot-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Chat Button */
.mistral-chat-button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--mistral-primary-color) 0%, var(--mistral-accent-color) 100%);
    border: none;
    cursor: pointer;
    box-shadow: var(--mistral-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.mistral-chat-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mistral-chat-button:hover {
    background: linear-gradient(135deg, var(--mistral-primary-dark) 0%, var(--mistral-accent-color) 100%);
    transform: scale(1.1);
    box-shadow: var(--mistral-shadow-hover);
}

.mistral-chat-button:hover::before {
    opacity: 1;
}

.mistral-chat-button svg {
    width: 28px;
    height: 28px;
    color: white;
}

.mistral-chat-icon,
.mistral-close-icon {
    position: absolute;
    transition: all 0.3s ease;
}

.mistral-close-icon {
    opacity: 0;
    transform: rotate(90deg);
}

.mistral-chat-button.active .mistral-chat-icon {
    opacity: 0;
    transform: rotate(-90deg);
}

.mistral-chat-button.active .mistral-close-icon {
    opacity: 1;
    transform: rotate(0deg);
}

/* Bulle d'invitation */
.mistral-chat-invitation {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: linear-gradient(135deg, var(--mistral-primary-color) 0%, var(--mistral-accent-color) 100%);
    color: white;
    padding: 14px 20px;
    border-radius: 20px;
    box-shadow: var(--mistral-shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 220px;
    animation: mistral-invitation-slideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards,
               mistral-invitation-fadeOut 0.5s cubic-bezier(0.4, 0, 0.2, 1) 8s forwards;
    opacity: 0;
    transform: translateX(20px);
    white-space: nowrap;
}

.mistral-chat-invitation::before {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 24px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--mistral-accent-color);
}

.mistral-chat-invitation.dismissed {
    display: none;
}

.mistral-invitation-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
}

.mistral-invitation-text {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.mistral-invitation-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mistral-invitation-close:hover {
    color: white;
    transform: scale(1.1);
}

.mistral-invitation-close svg {
    width: 14px;
    height: 14px;
}

/* Animations pour la bulle */
@keyframes mistral-invitation-slideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes mistral-invitation-fadeOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* Position pour bottom-left */
.mistral-chatbot-bottom-left .mistral-chat-invitation {
    right: auto;
    left: 0;
    animation: mistral-invitation-slideInLeft 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards,
               mistral-invitation-fadeOutLeft 0.5s cubic-bezier(0.4, 0, 0.2, 1) 8s forwards;
}

.mistral-chatbot-bottom-left .mistral-chat-invitation::before {
    right: auto;
    left: 24px;
}

@keyframes mistral-invitation-slideInLeft {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes mistral-invitation-fadeOutLeft {
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .mistral-chat-invitation {
        min-width: 180px;
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .mistral-invitation-text {
        font-size: 13px;
    }
}

/* Notification Badge */
.mistral-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    font-size: 12px;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4);
    animation: mistralPulseNotification 2s infinite;
}

@keyframes mistralPulseNotification {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 2px 12px rgba(220, 38, 38, 0.6);
    }
}

/* Chat Window */
.mistral-chat-window {
    position: absolute;
    bottom: 80px;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--mistral-bg-color);
    border-radius: 20px;
    box-shadow: var(--mistral-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: mistralSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--mistral-border-color);
}

.mistral-chatbot-bottom-right .mistral-chat-window {
    right: 0;
}

.mistral-chatbot-bottom-left .mistral-chat-window {
    left: 0;
}

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

/* Chat Header */
.mistral-chat-header {
    background: linear-gradient(135deg, var(--mistral-primary-color) 0%, var(--mistral-accent-color) 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.mistral-chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse"><path d="M 20 0 L 0 0 0 20" fill="none" stroke="rgba(255,255,255,0.05)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.5;
}

.mistral-chat-header-content {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    position: relative;
    z-index: 1;
}

.mistral-chat-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.mistral-chat-avatar svg {
    width: 24px;
    height: 24px;
}

.mistral-chat-header-text h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.mistral-chat-status {
    font-size: 13px;
    opacity: 0.95;
    display: flex;
    align-items: center;
    gap: 6px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.mistral-status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
    animation: mistralPulse 2s infinite;
}

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

.mistral-chat-minimize {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
}

.mistral-chat-minimize:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.mistral-chat-minimize svg {
    width: 20px;
    height: 20px;
}

/* Clear History Button */
.mistral-clear-history {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
    margin-right: 4px;
}

.mistral-clear-history:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.mistral-clear-history svg {
    width: 18px;
    height: 18px;
}

/* Notification */
.mistral-notification {
    padding: 12px 20px;
    margin: 12px;
    background: linear-gradient(135deg, rgba(193, 155, 123, 0.1) 0%, rgba(139, 111, 71, 0.1) 100%);
    border: 1px solid var(--mistral-border-color);
    border-radius: 12px;
    color: var(--mistral-text-color);
    font-size: 14px;
    text-align: center;
    animation: mistralSlideIn 0.3s ease;
}

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


/* Messages Container */
.mistral-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--mistral-bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.mistral-chat-messages::-webkit-scrollbar {
    width: 8px;
}

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

.mistral-chat-messages::-webkit-scrollbar-thumb {
    background: var(--mistral-primary-light);
    border-radius: 4px;
    border: 2px solid var(--mistral-bg-secondary);
}

.mistral-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--mistral-primary-color);
}

/* Message */
.mistral-message {
    display: flex;
    gap: 10px;
    animation: mistralFadeIn 0.3s ease;
}

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

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

.mistral-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mistral-message-bot .mistral-message-avatar {
    background: var(--mistral-primary-color);
    color: white;
}

.mistral-message-user .mistral-message-avatar {
    background: #6b7280;
    color: white;
}

.mistral-message-avatar svg {
    width: 20px;
    height: 20px;
}

.mistral-message-content {
    flex: 1;
    max-width: 75%;
}

.mistral-message-bubble {
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.mistral-message-bubble:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.mistral-message-bot .mistral-message-bubble {
    background: white;
    color: var(--mistral-text-color);
    border: 1px solid var(--mistral-border-color);
    border-top-left-radius: 4px;
}

.mistral-message-user .mistral-message-bubble {
    background: linear-gradient(135deg, var(--mistral-primary-color) 0%, var(--mistral-accent-color) 100%);
    color: white;
    border-top-right-radius: 4px;
}

/* Typing Indicator */
.mistral-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.mistral-typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: mistralTyping 1.4s infinite;
}

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

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

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

/* Input Area */
.mistral-chat-input-wrapper {
    border-top: 1px solid var(--mistral-border-color);
    background: white;
    padding: 18px 20px;
}

.mistral-chat-input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#mistral-chat-input {
    flex: 1;
    border: 2px solid var(--mistral-border-color);
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    transition: all 0.2s ease;
    background: var(--mistral-bg-secondary);
    color: var(--mistral-text-color);
}

#mistral-chat-input:focus {
    outline: none;
    border-color: var(--mistral-primary-color);
    background: white;
    box-shadow: 0 0 0 4px rgba(193, 155, 123, 0.1);
}

#mistral-chat-input::placeholder {
    color: var(--mistral-text-light);
}

.mistral-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--mistral-primary-color) 0%, var(--mistral-accent-color) 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(193, 155, 123, 0.3);
}

.mistral-chat-send:hover {
    background: linear-gradient(135deg, var(--mistral-primary-dark) 0%, var(--mistral-accent-color) 100%);
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(193, 155, 123, 0.4);
}

.mistral-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.mistral-chat-send svg {
    width: 20px;
    height: 20px;
}

.mistral-chat-footer {
    margin-top: 10px;
    text-align: center;
}

.mistral-powered-by {
    font-size: 12px;
    color: var(--mistral-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.mistral-powered-by strong {
    color: var(--mistral-primary-color);
    font-weight: 600;
}

/* Error Message */
.mistral-error-message {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 14px;
    margin-top: 10px;
    border: 1px solid #fca5a5;
    box-shadow: 0 2px 8px rgba(153, 27, 27, 0.1);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .mistral-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        border-radius: 16px;
    }
    
    .mistral-chat-button {
        width: 60px;
        height: 60px;
    }
    
    .mistral-chat-button svg {
        width: 26px;
        height: 26px;
    }
    
    .mistral-chat-header {
        padding: 16px 20px;
    }
    
    .mistral-chat-messages {
        padding: 20px 16px;
    }
}

@media (max-width: 480px) {
    #mistral-chatbot-widget.mistral-chatbot-bottom-right,
    #mistral-chatbot-widget.mistral-chatbot-bottom-left {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .mistral-chat-window {
        width: 100%;
        bottom: 70px;
        border-radius: 16px 16px 0 0;
    }
    
    .mistral-chat-button {
        width: 56px;
        height: 56px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --mistral-text-color: #f5f5f4;
        --mistral-text-light: #a8a29e;
        --mistral-bg-color: #1c1917;
        --mistral-bg-secondary: #292524;
        --mistral-border-color: #44403c;
    }
    
    .mistral-chat-messages {
        background: var(--mistral-bg-color);
    }
    
    .mistral-message-bot .mistral-message-bubble {
        background: var(--mistral-bg-secondary);
        border-color: var(--mistral-border-color);
    }
    
    #mistral-chat-input {
        background: var(--mistral-bg-secondary);
        color: var(--mistral-text-color);
        border-color: var(--mistral-border-color);
    }
    
    #mistral-chat-input:focus {
        background: var(--mistral-bg-color);
    }
    
    .mistral-chat-input-wrapper {
        background: var(--mistral-bg-secondary);
        border-top-color: var(--mistral-border-color);
    }
}

/* Smooth animations for links in messages */
.mistral-message-bubble a {
    color: var(--mistral-primary-color);
    text-decoration: underline;
    transition: all 0.2s ease;
    font-weight: 500;
}

.mistral-message-bubble a:hover {
    color: var(--mistral-primary-dark);
    text-decoration: none;
}

.mistral-message-user .mistral-message-bubble a {
    color: white;
    text-decoration: underline;
    font-weight: 600;
}

.mistral-message-user .mistral-message-bubble a:hover {
    opacity: 0.9;
}

/* Code blocks in messages */
.mistral-message-bubble code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Monaco', 'Courier New', monospace;
}

.mistral-message-user .mistral-message-bubble code {
    background: rgba(255, 255, 255, 0.2);
}

/* Strong text in messages */
.mistral-message-bubble strong {
    font-weight: 600;
    color: var(--mistral-accent-color);
}

.mistral-message-user .mistral-message-bubble strong {
    color: white;
}

/* Loading animation enhancement */
@keyframes mistralShimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.mistral-message-bot.mistral-typing .mistral-message-bubble {
    background: linear-gradient(
        90deg,
        #ffffff 25%,
        var(--mistral-bg-secondary) 50%,
        #ffffff 75%
    );
    background-size: 1000px 100%;
    animation: mistralShimmer 2s infinite;
}
