:root {
    --mlc-primary: #6366f1;
    --mlc-accent: #8b5cf6;
    --mlc-bg: #ffffff;
    --mlc-text: #1f2937;
}

#mlc-widget { font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; z-index: 99999; }

#mlc-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--mlc-primary), var(--mlc-accent));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100000;
    animation: mlcPulse 2.5s infinite;
}
@keyframes mlcPulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35); }
    50% { box-shadow: 0 6px 28px rgba(99, 102, 241, 0.55); }
}
#mlc-button:hover { transform: scale(1.1); animation: none; box-shadow: 0 10px 30px rgba(99, 102, 241, 0.5); }

#mlc-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 130px);
    background: var(--mlc-bg);
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 100000;
    animation: mlcSlideUp 0.3s ease;
}
@keyframes mlcSlideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

#mlc-widget[data-position="bottom-left"] #mlc-button,
#mlc-widget[data-position="bottom-left"] #mlc-window { right: auto; left: 24px; }

#mlc-header {
    background: linear-gradient(135deg, var(--mlc-primary), var(--mlc-accent));
    color: white;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mlc-header-info { display: flex; align-items: center; gap: 10px; }
.mlc-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.25);
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.mlc-status { font-size: 12px; opacity: 0.95; display: flex; align-items: center; gap: 4px; }
.mlc-status::before { content: ''; width: 8px; height: 8px; background: #4ade80; border-radius: 50%; display: inline-block; }
#mlc-close { background: none; border: none; color: white; font-size: 26px; cursor: pointer; line-height: 1; }

#mlc-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.mlc-msg {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.45;
    word-wrap: break-word;
    position: relative;
}
.mlc-msg.visitor {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--mlc-primary), var(--mlc-accent));
    color: white;
    border-bottom-right-radius: 4px;
}
.mlc-msg.admin {
    align-self: flex-start;
    background: #e2e8f0;
    color: var(--mlc-text);
    border-bottom-left-radius: 4px;
}
.mlc-typing {
    align-self: flex-start;
    background: #e2e8f0;
    padding: 12px 16px;
    border-radius: 16px;
    display: flex;
    gap: 5px;
}
.mlc-typing span {
    width: 7px; height: 7px; background: #64748b; border-radius: 50%;
    animation: mlcBounce 1.4s infinite ease-in-out both;
}
.mlc-typing span:nth-child(1) { animation-delay: -0.32s; }
.mlc-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes mlcBounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

#mlc-input-area { display: flex; padding: 12px; border-top: 1px solid #e2e8f0; background: white; }
#mlc-input { flex: 1; padding: 11px 16px; border: 1px solid #cbd5e1; border-radius: 24px; outline: none; font-size: 14px; }
#mlc-input:focus { border-color: var(--mlc-primary); }
#mlc-send, .mlc-btn {
    margin-left: 8px; padding: 0 18px; background: linear-gradient(135deg, var(--mlc-primary), var(--mlc-accent));
    color: white; border: none; border-radius: 24px; cursor: pointer; font-weight: 600;
}

@media (max-width: 480px) {
    #mlc-window { width: calc(100vw - 16px); right: 8px; left: 8px; height: 72vh; bottom: 82px; border-radius: 16px; }
    #mlc-button { right: 16px; bottom: 16px; }
}