/* ========================================
   THE LOFT LOUNGE - CHATBOT PREMIUM CSS
   Design luxueux avec animations fluides
   ======================================== */

/* ─── VARIABLES ─────────────────────────────────────────────── */
.loft-chatbot {
    --cb-sage: #8B9A7A;
    --cb-sage-light: #A8B89D;
    --cb-sage-dark: #6E7D5F;
    --cb-gold: #D4AF37;
    --cb-gold-light: #E8C968;
    --cb-pink: #E5A8C8;
    --cb-white: #FFFFFF;
    --cb-marble: #F5F5F0;
    --cb-gray: #8B8B8B;
    --cb-gray-dark: #4A4A4A;
    --cb-radius: 24px;
    --cb-shadow: 0 25px 80px rgba(0, 0, 0, 0.2), 0 10px 30px rgba(0, 0, 0, 0.12);
    --cb-transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);

    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ─── FLOATING TOGGLE BUTTON ────────────────────────────────── */
.chatbot-toggle {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--cb-sage) 0%, var(--cb-sage-dark) 50%, var(--cb-gold) 100%);
    color: var(--cb-white);
    cursor: pointer;
    position: relative;
    z-index: 100002;
    box-shadow:
        0 8px 32px rgba(139, 154, 122, 0.45),
        0 4px 12px rgba(0, 0, 0, 0.15),
        inset 0 2px 0 rgba(255, 255, 255, 0.2);
    transition: var(--cb-transition);
    outline: none;
    overflow: visible;
}

.chatbot-toggle:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow:
        0 12px 40px rgba(139, 154, 122, 0.55),
        0 6px 18px rgba(0, 0, 0, 0.2),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

.chatbot-toggle-inner i {
    font-size: 1.6rem;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: absolute;
}

.chatbot-icon-open {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.chatbot-icon-close {
    opacity: 0;
    transform: scale(0.3) rotate(-180deg);
}

.chatbot-active .chatbot-icon-open {
    opacity: 0;
    transform: scale(0.3) rotate(180deg);
}

.chatbot-active .chatbot-icon-close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Pulse Animation */
.chatbot-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--cb-sage);
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
    animation: chatbotPulse 2.5s ease-out infinite;
    pointer-events: none;
}

.chatbot-pulse-2 {
    animation-delay: 1.25s;
}

.chatbot-active .chatbot-pulse {
    animation: none;
    opacity: 0;
}

@keyframes chatbotPulse {
    0% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(2.2);
    }
}

/* Greeting tooltip */
.chatbot-greeting::after {
    content: '💬 Besoin d\'aide ?';
    position: absolute;
    right: 80px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--cb-white);
    color: var(--cb-gray-dark);
    padding: 10px 20px;
    border-radius: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
    border: 2px solid var(--cb-sage-light);
    animation: greetingSlideIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    pointer-events: none;
}

@keyframes greetingSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

/* ─── CHAT WINDOW ───────────────────────────────────────────── */
.chatbot-window {
    position: absolute;
    bottom: 86px;
    right: 0;
    width: 420px;
    max-height: 650px;
    height: 650px;
    background: var(--cb-white);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.6) translateY(30px);
    transform-origin: bottom right;
    transition:
        opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        visibility 0.4s;
    border: 2px solid rgba(139, 154, 122, 0.15);
}

.chatbot-window.chatbot-open {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

/* ─── HEADER ────────────────────────────────────────────────── */
.chatbot-header {
    background: linear-gradient(135deg, var(--cb-sage) 0%, var(--cb-sage-dark) 40%, #5a6d4d 100%);
    padding: 20px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.chatbot-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(212, 175, 55, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(229, 168, 200, 0.1) 0%, transparent 40%);
    pointer-events: none;
}

.chatbot-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--cb-gold), var(--cb-pink), var(--cb-gold));
    background-size: 200% 100%;
    animation: headerShimmer 4s linear infinite;
}

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

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

.chatbot-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-gold), var(--cb-gold-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--cb-white);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
    position: relative;
    flex-shrink: 0;
}

.chatbot-status-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    background: #4ADE80;
    border-radius: 50%;
    border: 2.5px solid var(--cb-sage);
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
    50% { box-shadow: 0 0 0 4px rgba(74, 222, 128, 0); }
}

.chatbot-header-info h3 {
    color: var(--cb-white);
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin: 0;
    line-height: 1.2;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.chatbot-status {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.78rem;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.chatbot-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--cb-white);
    width: 36px;
    height: 36px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: var(--cb-transition);
    position: relative;
    z-index: 1;
    backdrop-filter: blur(5px);
}

.chatbot-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* ─── MESSAGES AREA ─────────────────────────────────────────── */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background:
        linear-gradient(to bottom, var(--cb-marble) 0%, var(--cb-white) 100%);
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(139, 154, 122, 0.3);
    border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 154, 122, 0.5);
}

/* ─── MESSAGE BUBBLES ───────────────────────────────────────── */
.chatbot-msg {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    opacity: 0;
    transform: translateY(15px);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    max-width: 90%;
}

.chatbot-msg.msg-visible {
    opacity: 1;
    transform: translateY(0);
}

.bot-msg {
    align-self: flex-start;
}

.user-msg {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-sage), var(--cb-sage-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--cb-white);
    flex-shrink: 0;
    box-shadow: 0 3px 8px rgba(139, 154, 122, 0.3);
}

.msg-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-msg .msg-content {
    align-items: flex-end;
}

.msg-bubble {
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 0.92rem;
    line-height: 1.65;
    word-wrap: break-word;
    position: relative;
}

.bot-bubble {
    background: var(--cb-white);
    color: var(--cb-gray-dark);
    border: 1.5px solid rgba(139, 154, 122, 0.15);
    border-radius: 20px 20px 20px 6px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.06);
}

.bot-bubble strong {
    color: var(--cb-sage-dark);
    font-weight: 700;
}

.bot-bubble em {
    color: var(--cb-gray);
    font-style: italic;
}

.bot-bubble a {
    color: var(--cb-gold);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1.5px solid rgba(212, 175, 55, 0.3);
    transition: var(--cb-transition);
}

.bot-bubble a:hover {
    color: var(--cb-sage);
    border-bottom-color: var(--cb-sage);
}

.user-bubble {
    background: linear-gradient(135deg, var(--cb-sage) 0%, var(--cb-sage-dark) 100%);
    color: var(--cb-white);
    border-radius: 20px 20px 6px 20px;
    box-shadow: 0 4px 15px rgba(139, 154, 122, 0.35);
}

.msg-time {
    font-size: 0.7rem;
    color: var(--cb-gray);
    padding: 0 6px;
    opacity: 0.7;
}

/* ─── TYPING INDICATOR ─────────────────────────────────────── */
.typing-bubble {
    padding: 16px 22px;
}

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

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--cb-sage);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.7);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* ─── QUICK REPLY BUTTONS ───────────────────────────────────── */
.chatbot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
    background: var(--cb-white);
    border-top: 1px solid rgba(139, 154, 122, 0.1);
    flex-shrink: 0;
}

.quick-reply-btn {
    background: linear-gradient(135deg, rgba(139, 154, 122, 0.08), rgba(139, 154, 122, 0.04));
    border: 1.5px solid rgba(139, 154, 122, 0.25);
    color: var(--cb-sage-dark);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--cb-transition);
    white-space: nowrap;
    font-family: inherit;
}

.quick-reply-btn:hover {
    background: linear-gradient(135deg, var(--cb-sage), var(--cb-sage-dark));
    color: var(--cb-white);
    border-color: var(--cb-sage);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 154, 122, 0.3);
}

.quick-reply-btn:active {
    transform: scale(0.95);
}

/* ─── INPUT AREA ────────────────────────────────────────────── */
.chatbot-input-area {
    padding: 14px 16px 12px;
    background: var(--cb-white);
    border-top: 1px solid rgba(139, 154, 122, 0.1);
    flex-shrink: 0;
}

.chatbot-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--cb-marble);
    border: 2px solid rgba(139, 154, 122, 0.15);
    border-radius: 28px;
    padding: 6px 6px 6px 20px;
    transition: var(--cb-transition);
}

.chatbot-input-wrapper:focus-within {
    border-color: var(--cb-sage);
    box-shadow: 0 0 0 4px rgba(139, 154, 122, 0.1);
    background: var(--cb-white);
}

.chatbot-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.92rem;
    color: var(--cb-gray-dark);
    font-family: inherit;
    outline: none;
    line-height: 1.4;
}

.chatbot-input::placeholder {
    color: var(--cb-gray);
    opacity: 0.6;
}

.chatbot-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--cb-sage), var(--cb-sage-dark));
    color: var(--cb-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: var(--cb-transition);
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(139, 154, 122, 0.3);
}

.chatbot-send-btn:hover {
    background: linear-gradient(135deg, var(--cb-gold), var(--cb-gold-light));
    transform: scale(1.1);
    box-shadow: 0 5px 18px rgba(212, 175, 55, 0.4);
}

.chatbot-send-btn:active {
    transform: scale(0.9);
}

.chatbot-powered {
    text-align: center;
    font-size: 0.7rem;
    color: var(--cb-gray);
    opacity: 0.5;
    padding-top: 8px;
    letter-spacing: 0.5px;
}

.chatbot-powered i {
    color: var(--cb-sage);
}

/* ─── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .loft-chatbot {
        bottom: 16px;
        right: 16px;
        z-index: 999999 !important;
        position: fixed !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .chatbot-toggle {
        width: 60px;
        height: 60px;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .chatbot-pulse {
        width: 60px;
        height: 60px;
    }

    .chatbot-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        max-height: calc(100vh - 120px);
        bottom: 76px;
        right: 0;
        left: auto;
        border-radius: 20px;
    }

    .chatbot-greeting::after {
        display: none;
    }

    .chatbot-header {
        padding: 16px;
    }

    .chatbot-messages {
        padding: 16px 12px;
    }

    .chatbot-msg {
        max-width: 95%;
    }

    .quick-reply-btn {
        padding: 7px 14px;
        font-size: 0.78rem;
    }
}

@media (max-width: 480px) {
    .loft-chatbot {
        bottom: 12px;
        right: 12px;
        z-index: 999999 !important;
        position: fixed !important;
        display: block !important;
        visibility: visible !important;
    }

    .chatbot-window {
        width: calc(100vw - 24px);
        height: calc(100dvh - 90px);
        max-height: calc(100dvh - 90px);
        bottom: 72px;
        right: 0;
        left: auto;
        border-radius: 20px 20px 0 0;
    }

    .chatbot-toggle {
        width: 56px;
        height: 56px;
    }

    .chatbot-toggle-inner i {
        font-size: 1.4rem;
    }

    .chatbot-pulse {
        width: 56px;
        height: 56px;
    }
}

/* ─── DARK MODE SUPPORT (optional) ──────────────────────────── */
@media (prefers-color-scheme: dark) {
    .chatbot-window {
        background: #1a1a1a;
        border-color: rgba(139, 154, 122, 0.2);
    }

    .chatbot-messages {
        background: linear-gradient(to bottom, #1e1e1e, #1a1a1a);
    }

    .bot-bubble {
        background: #2a2a2a;
        color: #e0e0e0;
        border-color: rgba(139, 154, 122, 0.2);
    }

    .bot-bubble strong {
        color: var(--cb-sage-light);
    }

    .chatbot-input-area {
        background: #1a1a1a;
    }

    .chatbot-input-wrapper {
        background: #2a2a2a;
        border-color: rgba(139, 154, 122, 0.2);
    }

    .chatbot-input {
        color: #e0e0e0;
    }

    .chatbot-quick-replies {
        background: #1a1a1a;
    }

    .quick-reply-btn {
        background: rgba(139, 154, 122, 0.15);
        border-color: rgba(139, 154, 122, 0.3);
        color: var(--cb-sage-light);
    }
}
