/* @import for Google Fonts Outfit */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Fallback variables in case wrapper style attribute doesn't load */
    --desim-primary: #094093;
    --desim-primary-light: #1d5cb8;
    --desim-primary-dark: #062b66;
    --desim-gradient: linear-gradient(135deg, #094093, #1e5fc1, #00c6ff);
    --desim-bg-light: #f8fafc;
    --desim-text-dark: #0f172a;
    --desim-text-muted: #64748b;
    --desim-glass-bg: rgba(255, 255, 255, 0.9);
    --desim-glass-border: rgba(255, 255, 255, 0.6);
    --desim-shadow-lg: 0 20px 40px -10px rgba(9, 64, 147, 0.2), 0 10px 20px -10px rgba(0, 0, 0, 0.05);
    --desim-shadow-sm: 0 4px 12px rgba(9, 64, 147, 0.08);
    --desim-radius-lg: 24px;
    --desim-radius-md: 16px;
    --desim-radius-sm: 10px;
    --desim-font: 'Outfit', 'Segoe UI', Roboto, sans-serif;
}

#desim-chat-wrapper {
    position: fixed !important;
    bottom: 24px !important; 
    right: 24px !important;  
    z-index: 999999 !important;
    font-family: var(--desim-font) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    user-select: none !important;
}

/* Floating Tooltip (Smart Welcome Bubble) */
.desim-chat-tooltip {
    background: white;
    color: var(--desim-text-dark);
    padding: 12px 18px;
    border-radius: var(--desim-radius-md) var(--desim-radius-md) 4px var(--desim-radius-md);
    box-shadow: var(--desim-shadow-lg);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 14px;
    max-width: 250px;
    position: relative;
    border: 1px solid rgba(9, 64, 147, 0.1);
    animation: desimSlideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
    pointer-events: auto;
    cursor: pointer;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 8px;
    transform-origin: bottom right;
}

.desim-chat-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 24px;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    border-right: 1px solid rgba(9, 64, 147, 0.1);
    border-bottom: 1px solid rgba(9, 64, 147, 0.1);
}

.desim-chat-tooltip .tooltip-close {
    background: none;
    border: none;
    color: var(--desim-text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    line-height: 1;
    transition: color 0.2s;
}

.desim-chat-tooltip .tooltip-close:hover {
    color: #ef4444;
}

/* Trigger Button */
#desim-chat-trigger {
    background: var(--desim-gradient) !important;
    width: 64px !important;
    height: 64px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 10px 30px rgba(9, 64, 147, 0.4) !important;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s !important;
    position: relative !important;
}

#desim-chat-trigger::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    border-radius: 50% !important;
    box-shadow: 0 0 0 0 rgba(9, 64, 147, 0.5) !important;
    animation: desimPulseRing 2s infinite cubic-bezier(0.25, 0, 0, 1) !important;
}

#desim-chat-trigger svg {
    width: 28px !important;
    height: 28px !important;
    fill: white !important;
    transition: transform 0.3s !important;
    display: inline-block !important;
}

#desim-chat-trigger:hover {
    transform: scale(1.08) translateY(-2px) !important;
    box-shadow: 0 15px 35px rgba(9, 64, 147, 0.5) !important;
}

#desim-chat-trigger:hover svg {
    transform: rotate(8deg) scale(1.05) !important;
}

.desim-notification-dot {
    position: absolute !important;
    top: -2px !important;
    right: -2px !important;
    background: #ff3b30 !important;
    color: white !important;
    width: 20px !important;
    height: 20px !important;
    border-radius: 50% !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 2px solid white !important;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.4) !important;
}

/* Chat Box Container */
#desim-chat-box {
    width: 380px;
    height: 600px;
    background: var(--desim-glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--desim-glass-border);
    border-radius: var(--desim-radius-lg);
    overflow: hidden;
    box-shadow: var(--desim-shadow-lg);
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    transform-origin: bottom right;
    transition: opacity 0.35s cubic-bezier(0.25, 1, 0.5, 1), transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    opacity: 1;
    transform: scale(1) translateY(0);
}

#desim-chat-box.desim-chat-hidden { 
    opacity: 0; 
    transform: scale(0.85) translateY(40px); 
    pointer-events: none; 
    position: absolute;
}

/* Chat Header */
.desim-chat-header {
    background: var(--desim-gradient) !important;
    color: white !important;
    padding: 20px 24px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    position: relative !important;
}

.desim-chat-header::after {
    content: '' !important;
    position: absolute !important;
    bottom: 0 !important; left: 0 !important; right: 0 !important;
    height: 1px !important;
    background: rgba(255, 255, 255, 0.1) !important;
}

.desim-header-info { 
    display: flex !important; 
    align-items: center !important; 
    gap: 14px !important; 
}

.desim-avatar-main {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.15) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1.5px solid rgba(255, 255, 255, 0.4) !important;
    box-shadow: var(--desim-shadow-sm) !important;
}

.desim-avatar-main svg {
    width: 22px !important;
    height: 22px !important;
    fill: white !important;
    display: inline-block !important;
}

.desim-header-text {
    display: flex !important;
    flex-direction: column !important;
}

.desim-title-row {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

.desim-status-dot { 
    width: 8px !important; 
    height: 8px !important; 
    background: #10b981 !important; 
    border-radius: 50% !important; 
    box-shadow: 0 0 0 2.5px rgba(16, 185, 129, 0.4) !important; 
    display: inline-block !important;
    animation: desimGlowPulse 1.8s infinite !important;
}

.desim-widget-title { 
    font-size: 16px !important; 
    font-weight: 600 !important;
    letter-spacing: -0.2px !important;
    color: white !important;
    line-height: 1.2 !important;
}

.desim-sub-text { 
    font-size: 11.5px !important; 
    color: rgba(255, 255, 255, 0.85) !important; 
    display: block !important;
    margin-top: 1px !important;
    line-height: 1.2 !important;
}

.desim-header-actions {
    display: flex !important;
    gap: 8px !important;
    align-items: center !important;
}

.desim-action-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    border: none !important;
    color: white !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s, transform 0.2s !important;
}

.desim-action-btn:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: scale(1.05) !important;
}

.desim-action-btn svg {
    width: 16px !important;
    height: 16px !important;
    fill: #ffffff !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Chat Scrollable Pane */
#desim-chat-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: var(--desim-bg-light);
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-behavior: smooth;
}

/* Message Bubbles (Natural UI) */
.desim-msg-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    max-width: 90%;
    animation: desimPopIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

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

.desim-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--desim-shadow-sm);
    border: 1px solid rgba(9, 64, 147, 0.08);
    flex-shrink: 0;
    margin-top: 2px;
}

.desim-msg-avatar svg {
    width: 18px;
    height: 18px;
    fill: var(--desim-primary);
}

.desim-msg-bubble {
    padding: 12px 18px;
    font-size: 14.5px;
    line-height: 1.55;
    border-radius: var(--desim-radius-md);
    box-shadow: var(--desim-shadow-sm);
    word-break: break-word;
}

.desim-bot-row .desim-msg-bubble {
    background: white;
    color: var(--desim-text-dark);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.desim-bot-row .desim-msg-bubble a {
    color: var(--desim-primary);
    text-decoration: underline;
    font-weight: 500;
}

.desim-bot-row .desim-msg-bubble a:hover {
    color: var(--desim-primary-light);
}

.desim-user-row .desim-msg-bubble {
    background: var(--desim-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.desim-bot-row .desim-msg-bubble strong {
    color: var(--desim-primary-dark);
}

.desim-bot-row .desim-msg-bubble ul,
.desim-bot-row .desim-msg-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.desim-bot-row .desim-msg-bubble li {
    margin-bottom: 4px;
}

/* Options Area */
#desim-chat-options {
    padding: 12px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background: white;
    max-height: 160px;
    overflow-y: auto;
}

.desim-opt-btn {
    background: white;
    border: 1.5px solid var(--desim-primary);
    color: var(--desim-primary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.desim-opt-btn:hover { 
    background: var(--desim-primary); 
    color: white; 
    transform: translateY(-1px); 
    box-shadow: 0 4px 10px rgba(9, 64, 147, 0.15); 
}

.desim-opt-btn:active {
    transform: translateY(0);
}

/* Typing Input Bar */
#desim-chat-input-container {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background: white;
    gap: 10px;
}

#desim-chat-input {
    flex: 1;
    border: none;
    padding: 8px 4px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: transparent;
    color: var(--desim-text-dark);
}

#desim-chat-input::placeholder {
    color: #94a3b8;
}

#desim-chat-send {
    background: none !important;
    border: none !important;
    color: var(--desim-text-muted) !important;
    cursor: pointer !important;
    padding: 4px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: color 0.2s, transform 0.2s !important;
}

#desim-chat-send:hover {
    color: var(--desim-primary) !important;
    transform: scale(1.05) !important;
}

#desim-chat-send svg {
    width: 20px !important;
    height: 20px !important;
    fill: currentColor !important;
    display: inline-block !important;
}

/* Typing Indicator */
.desim-typing-msg { 
    display: flex; 
    gap: 4px; 
    align-items: center; 
    padding: 10px 16px; 
    width: fit-content; 
    background: white;
    border: 1px solid rgba(0,0,0,0.04);
    border-radius: var(--desim-radius-md) var(--desim-radius-md) var(--desim-radius-md) 4px;
    align-self: flex-start;
    box-shadow: var(--desim-shadow-sm);
    margin-left: 42px; /* aligns with avatar messages */
}

.desim-typing-dot { 
    width: 6px; 
    height: 6px; 
    background-color: var(--desim-text-muted); 
    border-radius: 50%; 
    animation: desimBounce 1.4s infinite ease-in-out both; 
}

.desim-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.desim-typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* Scrollbars */
#desim-chat-content::-webkit-scrollbar { 
    width: 6px; 
}

#desim-chat-content::-webkit-scrollbar-track { 
    background: transparent; 
}

#desim-chat-content::-webkit-scrollbar-thumb { 
    background: #cbd5e1; 
    border-radius: 10px; 
}

#desim-chat-content::-webkit-scrollbar-thumb:hover { 
    background: #94a3b8; 
}

/* Animations */
@keyframes desimPulseRing {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(9, 64, 147, 0.5); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 12px rgba(9, 64, 147, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(9, 64, 147, 0); }
}

@keyframes desimGlowPulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.4); opacity: 0.8; }
    50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.4); opacity: 1; }
}

@keyframes desimPopIn {
    0% { opacity: 0; transform: scale(0.9) translateY(12px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes desimSlideUpFade {
    0% { opacity: 0; transform: translateY(12px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes desimBounce { 
    0%, 80%, 100% { transform: scale(0); } 
    40% { transform: scale(1); } 
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #desim-chat-wrapper { 
        bottom: 16px; 
        right: 16px; 
        width: 100%;
        align-items: flex-end;
    }
    .desim-chat-tooltip {
        right: 16px;
        max-width: 70%;
    }
    #desim-chat-box { 
        width: calc(100vw - 32px); 
        height: 80vh;
        max-height: 520px;
        position: fixed; 
    }
}
