:root { --dify-primary: #1c64f2; }

#dify-chatbot-root * { box-sizing: border-box; }

#dify-toggle {
    position: fixed; right: 24px; bottom: 24px; z-index: 99999;
    width: 56px; height: 56px; border-radius: 50%; border: none;
    background: var(--dify-primary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,.25); transition: transform .2s;
}
#dify-toggle:hover { transform: scale(1.08); }

#dify-window {
    position: fixed; right: 24px; bottom: 92px; z-index: 99999;
    width: 370px; max-width: calc(100vw - 32px);
    height: 540px; max-height: calc(100vh - 120px);
    background: #fff; border-radius: 14px; overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,.22);
    font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
#dify-window.dify-hidden { display: none; }

#dify-header {
    background: var(--dify-primary); color: #fff;
    padding: 12px 14px; display: flex; align-items: center; gap: 10px;
}
#dify-header .dify-logo { height: 32px; width: auto; max-width: 140px; object-fit: contain; display: block; }
#dify-header .dify-title { font-weight: 600; font-size: 15px; flex: 1; }
#dify-close { background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; line-height: 1; }

#dify-messages {
    flex: 1; overflow-y: auto; padding: 14px;
    background: #f6f7f9; display: flex; flex-direction: column; gap: 10px;
}

.dify-msg {
    max-width: 85%; padding: 9px 12px; border-radius: 12px;
    font-size: 14px; line-height: 1.5; word-wrap: break-word; white-space: normal;
}
.dify-user {
    align-self: flex-end; background: var(--dify-primary); color: #fff;
    border-bottom-right-radius: 4px;
}
.dify-bot {
    align-self: flex-start; background: #fff; color: #1f2937;
    border: 1px solid #e5e7eb; border-bottom-left-radius: 4px;
}
.dify-typing { opacity: .6; font-style: italic; }

/* ----- Định dạng nội dung markdown trong tin nhắn bot ----- */
.dify-bot strong { font-weight: 700; }
.dify-bot em { font-style: italic; }
.dify-bot a { color: var(--dify-primary); text-decoration: underline; word-break: break-all; }
.dify-bot .dify-h { margin: 8px 0 4px; font-weight: 700; line-height: 1.3; }
.dify-bot h2.dify-h { font-size: 16px; }
.dify-bot h3.dify-h { font-size: 15px; }
.dify-bot h4.dify-h { font-size: 14px; }
.dify-bot .dify-list { margin: 6px 0; padding-left: 20px; }
.dify-bot .dify-list li { margin: 3px 0; }
.dify-bot .dify-inline-code {
    background: #eef0f3; padding: 1px 5px; border-radius: 4px;
    font-family: monospace; font-size: 13px;
}
.dify-bot .dify-code {
    background: #1f2937; color: #f3f4f6; padding: 10px 12px;
    border-radius: 8px; overflow-x: auto; margin: 6px 0;
}
.dify-bot .dify-code code { font-family: monospace; font-size: 13px; white-space: pre; }

#dify-form { display: flex; padding: 10px; gap: 8px; border-top: 1px solid #e5e7eb; background: #fff; }
#dify-input {
    flex: 1; padding: 9px 12px; border: 1px solid #d1d5db;
    border-radius: 20px; font-size: 14px; outline: none;
}
#dify-input:focus { border-color: var(--dify-primary); }
#dify-send {
    background: var(--dify-primary); color: #fff; border: none;
    border-radius: 20px; padding: 0 16px; cursor: pointer; font-size: 14px;
}
