/**
 * Chatbot Widget CSS - GoldMMO Theme
 * Couleurs : Orange #ff6b35, Cyan #4ecdc4, Gold #d5b400
 */

.chatbot-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* TOGGLE BUTTON */
.chatbot-toggle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b35 0%, #e55a2b 100%);
    border: 3px solid #fff;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(255, 107, 53, 0.4), 0 0 0 4px rgba(255, 107, 53, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: .4s cubic-bezier(.4, 0, .2, 1);
    position: relative;
    overflow: visible;
    animation: 3s ease-in-out infinite floatBounce;
}

.chatbot-toggle .glyphicon {
    font-size: 28px;
    color: #fff;
}

/* Support Lucide icons */
.chatbot-toggle i,
.chatbot-toggle svg {
    width: 28px;
    height: 28px;
    color: #fff;
    stroke: #fff;
}

@keyframes floatBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-6px) scale(1.02); }
}

.chatbot-toggle:hover {
    animation: none;
    transform: scale(1.1);
    background: linear-gradient(135deg, #e55a2b 0%, #ff6b35 100%);
    box-shadow: 0 12px 40px rgba(255, 107, 53, 0.5), 0 0 0 4px rgba(255, 107, 53, 0.3);
}

.chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #d5b400 0%, #b8860b 100%);
    color: #000;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(213, 180, 0, 0.5);
    border: 2px solid #fff;
}

/* CONTAINER */
.chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 550px;
    background: #1a2332;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 107, 53, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
}

.chatbot-container.active {
    display: flex;
    animation: .3s cubic-bezier(.34, 1.56, .64, 1) slideUpScale;
}

@keyframes slideUpScale {
    from { opacity: 0; transform: translateY(20px) scale(.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.chatbot-container.resizing {
    transition: none !important;
    user-select: none;
}

/* HEADER */
.chatbot-header {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    background: linear-gradient(135deg, #ff6b35 0%, #e55a2b 100%);
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1;
}

.chatbot-avatar {
    width: 42px;
    height: 42px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #ff6b35;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chatbot-header-text h3 {
    margin: 0;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
}

.chatbot-header-text span {
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ecdc4;
    border-radius: 50%;
    display: inline-block;
    animation: 2s infinite statusBlink;
}

@keyframes statusBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: .2s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* MESSAGES AREA */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    background: #0f1623;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #ff6b35;
    border-radius: 3px;
}

/* MESSAGE */
.message {
    display: flex;
    gap: .6rem;
    animation: .3s ease-out messageSlideIn;
}

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

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

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, #ff6b35 0%, #e55a2b 100%);
    color: #fff;
}

.message.client .message-avatar {
    background: linear-gradient(135deg, #d5b400 0%, #b8860b 100%);
    color: #fff;
}

.message-content {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 14px;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message.client .message-content {
    background: linear-gradient(135deg, #ff6b35 0%, #e55a2b 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.bot .message-content {
    background: #1a2332;
    color: #e8eef4;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom-left-radius: 4px;
}

.message-text {
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 14px;
}

.message-text a {
    color: #4ecdc4;
    text-decoration: underline;
    font-weight: 500;
}

.message-text a:hover {
    color: #3dbdb5;
}

.message.client .message-text a {
    color: #fff;
}

.message-time {
    font-size: 10px;
    color: #8b9bb1;
    margin-top: 5px;
}

.message.client .message-time {
    color: rgba(255, 255, 255, 0.8);
}

/* TYPING INDICATOR */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .25rem;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #1a2332;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #ff6b35;
    border-radius: 50%;
    animation: 1.4s infinite typingBounce;
}

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

@keyframes typingBounce {
    0%, 100%, 60% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* INPUT AREA */
.chatbot-input {
    padding: 1rem;
    background: #1a2332;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: #0f1623;
    border-radius: 50px;
    padding: 5px 5px 5px 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: .2s;
}

.input-wrapper:focus-within {
    border-color: #ff6b35;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
}

#chatbot-message {
    flex: 1;
    background: transparent;
    border: none;
    color: #e8eef4;
    font-size: 14px;
    outline: 0;
    padding: 8px 0;
}

#chatbot-message::placeholder {
    color: #8b9bb1;
}

.chatbot-send {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b35 0%, #e55a2b 100%);
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: .2s;
}

.chatbot-send .glyphicon {
    font-size: 16px;
    color: #fff;
}

/* Support Lucide icons */
.chatbot-send i,
.chatbot-send svg {
    width: 18px;
    height: 18px;
    color: #fff;
    stroke: #fff;
}

.chatbot-close i,
.chatbot-close svg {
    width: 16px;
    height: 16px;
    color: #fff;
    stroke: #fff;
}

#chatbot-mic i,
#chatbot-mic svg {
    width: 18px;
    height: 18px;
}

#chatbot-mic.recording .mic-icon { display: none; }
#chatbot-mic.recording .stop-icon { display: block !important; }

.chatbot-send:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}

.chatbot-send:active:not(:disabled) {
    transform: scale(.95);
}

.chatbot-send:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* WELCOME MESSAGE */
.welcome-message {
    text-align: center;
    padding: 1.5rem 1rem;
    color: #b8c5d1;
    font-size: 14px;
    line-height: 1.6;
}

.welcome-message h4 {
    color: #ff6b35;
    margin-bottom: .5rem;
    font-size: 17px;
    font-weight: 600;
}

.welcome-message hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: .75rem 0;
}

/* ERROR MESSAGE */
.error-message {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: #e74c3c;
    padding: 10px;
    border-radius: 10px;
    margin: .5rem;
    font-size: 13px;
    text-align: center;
}

/* RESIZE HANDLE */
.chatbot-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 10px;
    cursor: ns-resize;
    z-index: 20;
}

.chatbot-resize-handle::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 3px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 10px;
    transition: .2s;
}

.chatbot-resize-handle:hover::before {
    background: rgba(255, 255, 255, 0.7);
}

/* MIC BUTTON */
#chatbot-mic {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    flex-shrink: 0;
    background: #2a3a4d;
    color: #b8c5d1;
    cursor: pointer;
    transition: .2s;
    padding: 0;
    position: relative;
    overflow: hidden;
}

#chatbot-mic .glyphicon {
    font-size: 16px;
    line-height: 1;
}

/* Support Lucide icons pour mic */
#chatbot-mic i,
#chatbot-mic svg {
    width: 18px;
    height: 18px;
}

#chatbot-mic.recording .mic-icon { display: none !important; }
#chatbot-mic.recording .stop-icon { display: block !important; }

#chatbot-mic:hover {
    background: #3a4a5d;
    color: #ff6b35;
}

#chatbot-mic.recording {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
    animation: 1.5s ease-in-out infinite pulse-recording;
    border: none;
}

#chatbot-mic.recording:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
}

@keyframes pulse-recording {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.6); }
    50% { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); }
}

#chatbot-mic.recording::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    animation: 1s ease-out infinite wave-pulse;
}

@keyframes wave-pulse {
    0% { transform: translate(-50%, -50%) scale(.8); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.4); opacity: 0; }
}

#chatbot-mic:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* VOICE BUTTON IN MESSAGE */
.message-voice-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    margin-left: .4rem;
    vertical-align: middle;
    background: #2a3a4d;
    color: #b8c5d1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: .2s;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.message-voice-btn .glyphicon {
    font-size: 11px;
}

.message-voice-btn:hover {
    background: #ff6b35;
    color: #fff;
    border-color: #ff6b35;
}

.message-voice-btn:active {
    transform: scale(.95);
}

.message-voice-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.message-voice-btn.speaking,
.message-voice-btn.speaking:hover {
    background: linear-gradient(135deg, #ff6b35 0%, #e55a2b 100%);
    color: #fff;
    border-color: transparent;
    animation: 1.5s ease-in-out infinite pulse-speaking;
}

@keyframes pulse-speaking {
    0%, 100% { opacity: 1; }
    50% { opacity: .7; }
}

.message-voice-btn.speaking::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, currentColor 25%, transparent 50%, currentColor 75%, transparent 100%);
    background-size: 200% 100%;
    animation: .8s linear infinite sound-bars;
}

@keyframes sound-bars {
    0% { background-position: 0 0; }
    100% { background-position: 200% 0; }
}

/* TOOLTIPS */
#chatbot-mic[title]::after,
.message-voice-btn[title]::before {
    content: attr(title);
    position: absolute;
    left: 50%;
    background: #1a2332;
    color: #fff;
    white-space: nowrap;
    pointer-events: none;
    transition: .2s;
    z-index: 1000;
    border-radius: 4px;
    font-size: 11px;
    padding: 4px 8px;
    opacity: 0;
    transform: translateX(-50%) scale(0);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#chatbot-mic[title]::after {
    bottom: calc(100% + 6px);
}

.message-voice-btn[title]::before {
    bottom: calc(100% + 5px);
}

#chatbot-mic:hover::after,
.message-voice-btn:hover::before {
    transform: translateX(-50%) scale(1);
    opacity: 1;
}

.message-voice-btn.speaking::before {
    display: none;
}

/* RECORDING INDICATOR */
.recording-indicator {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
    position: absolute;
    top: -40px;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: fit-content;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
    animation: .2s slideDown;
}

#chatbot-mic.recording ~ .recording-indicator {
    display: flex;
}

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

.recording-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    animation: 1s infinite blink;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: .3; }
}

#chatbot-mic:disabled:hover,
.message-voice-btn:disabled:hover {
    transform: none;
    background: #2a3a4d;
    color: #8b9bb1;
}

#chatbot-mic:focus-visible,
.message-voice-btn:focus-visible {
    outline: #ff6b35 solid 2px;
    outline-offset: 2px;
}

/* TAKEOVER NOTICE */
.takeover-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    margin: 8px 0;
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.2) 0%, rgba(78, 205, 196, 0.1) 100%);
    border: 1px solid rgba(78, 205, 196, 0.3);
    border-radius: 20px;
    color: #4ecdc4;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    animation: .3s ease-out noticeSlideIn;
}

.takeover-notice .glyphicon {
    font-size: 14px;
}

@keyframes noticeSlideIn {
    from { opacity: 0; transform: translateY(-10px) scale(.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ADMIN MESSAGE */
.message.admin-message .message-avatar {
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    color: #fff;
    position: relative;
}

.message.admin-message .message-content {
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.2) 0%, rgba(78, 205, 196, 0.1) 100%);
    border: 1px solid rgba(78, 205, 196, 0.3);
    border-bottom-left-radius: 4px;
}

.message.admin-message .message-text {
    color: #e8eef4;
}

.message.admin-message .message-time {
    color: #4ecdc4;
}

.admin-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #4ecdc4;
    margin-bottom: 4px;
    letter-spacing: .5px;
}

.message.admin-message {
    animation: .4s cubic-bezier(.34, 1.56, .64, 1) adminMessageIn;
}

@keyframes adminMessageIn {
    from { opacity: 0; transform: translateX(-20px) scale(.9); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

.message.admin-message .message-avatar::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background: #4ecdc4;
    border: 2px solid #1a2332;
    border-radius: 50%;
}

/* RESPONSIVE */
@media (max-width: 480px) {
    .chatbot-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        height: 100% !important;
        max-width: none;
        border-radius: 0;
        z-index: 9999;
    }
    
    .chatbot-toggle {
        width: 60px;
        height: 60px;
    }
    
    .chatbot-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .chatbot-resize-handle {
        display: none;
    }
    
    #chatbot-mic {
        width: 36px;
        height: 36px;
    }
    
    #chatbot-mic .glyphicon {
        font-size: 14px;
    }
    
    .message-voice-btn {
        width: 24px;
        height: 24px;
    }
    
    .message-voice-btn .glyphicon {
        font-size: 10px;
    }
}