/**
 * CHAT BUBBLE N8N - CSS
 * Version: 3.3 - Left Position
 */

/* -- Bong bóng chat -- */
#cbn8n-bubble {
    position: fixed;
    bottom: 120px;
    right: 55px;
    width: 55px;
    height: 55px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9998;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#cbn8n-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

#cbn8n-bubble img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* -- Thông báo chào tự động -- */
#cbn8n-greeting {
    position: fixed;
    bottom: 180px;
    right: 50px;
    width: 300px;
    max-width: 85vw;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 20px;
    z-index: 9997;
    display: none;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#cbn8n-greeting-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 20px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
    line-height: 1;
}

#cbn8n-greeting-close:hover {
    background-color: #f3f4f6;
    color: #1f2937;
}

.cbn8n-greeting-title {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px 0;
    text-align: center;
}

.cbn8n-greeting-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin: 0 0 16px 0;
    text-align: center;
    line-height: 1.4;
}

.cbn8n-greeting-form-group {
    margin-bottom: 12px;
}

.cbn8n-greeting-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.cbn8n-greeting-form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: #1f2937;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    background-color: #f9fafb;
}

.cbn8n-greeting-form-group input:focus {
    border-color: #2563eb;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.cbn8n-greeting-form-group input::placeholder {
    color: #9ca3af;
}

#cbn8n-greeting-submit {
    width: 100%;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 11px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    margin-top: 8px;
}

#cbn8n-greeting-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

#cbn8n-greeting-submit:active {
    transform: translateY(0);
}

/* -- Cửa sổ chat chính -- */
#cbn8n-window {
    position: fixed;
    bottom: 180px;
    right: 50px;
    width: 290px;
    max-width: 90vw;
    height: 420px;
    max-height: 65vh;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    box-sizing: border-box;
}

/* Responsive cho mobile */
@media (max-width: 768px) {
    /* Bong bóng chat trên mobile */
    #cbn8n-bubble {
        bottom: 120px;
        right: 50px;
        width: 60px;
        height: 60px;
    }

    /* Thông báo chào trên mobile */
    #cbn8n-greeting {
        bottom: 180px;
        right: 20px;
        width: calc(100vw - 40px);
        max-width: 340px;
    }

    /* Cửa sổ chat chính trên mobile */
    #cbn8n-window {
        width: calc(100vw - 40px);
        max-width: 400px;
        height: 500px;
        max-height: 70vh;
        bottom: 180px;
        right: 20px;
    }
}

/* -- Header Facebook Style -- */
#cbn8n-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 8px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.cbn8n-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.cbn8n-header-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.cbn8n-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cbn8n-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cbn8n-header-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    color: white;
}

.cbn8n-header-subtitle {
    font-size: 11px;
    opacity: 0.9;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.95);
}

#cbn8n-close-btn {
    background: rgba(255, 255, 255, 0.2) !important;
    border: none !important;
    color: white !important;
    font-size: 18px !important;
    line-height: 1 !important;
    cursor: pointer;
    padding: 0 !important;
    margin: 0 !important;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
    box-shadow: none !important;
}

#cbn8n-close-btn:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

/* ========================================
   USER INFO FORM SCREEN - Facebook Style
   ======================================== */
#cbn8n-userinfo-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 16px 20px;
    background-color: #fff;
    overflow-y: auto;
}

.cbn8n-userinfo-title {
    font-size: 17px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 4px 0 !important;
    text-align: center;
}

.cbn8n-userinfo-text {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 14px 0 !important;
    line-height: 1.4;
    text-align: center;
}

#cbn8n-userinfo-form {
    width: 100%;
}

.cbn8n-form-group {
    margin-bottom: 10px;
}

.cbn8n-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}

.cbn8n-form-group input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: #1f2937;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    background-color: #f9fafb;
}

.cbn8n-form-group input:focus {
    border-color: #2563eb;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.cbn8n-form-group input::placeholder {
    color: #9ca3af;
}

#cbn8n-userinfo-submit {
    width: 100%;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.3);
    margin-top: 4px;
}

#cbn8n-userinfo-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(37, 99, 235, 0.4);
}

#cbn8n-userinfo-submit:active {
    transform: translateY(0);
}

/* ========================================
   CHAT INTERFACE CONTAINER
   ======================================== */
#cbn8n-chat-interface {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    overflow: hidden;
    background-color: #f9fafb;
}

/* -- Khu vực tin nhắn -- */
#cbn8n-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#cbn8n-messages::-webkit-scrollbar {
    width: 6px;
}
#cbn8n-messages::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 3px;
}

.cbn8n-message {
    padding: 10px 16px;
    border-radius: 18px;
    max-width: 75%;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 15px;
    animation: messageSlideIn 0.2s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-message {
    background-color: #e5e7eb;
    color: #1f2937;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.user-message {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* -- Khu vực nhập liệu -- */
#cbn8n-input-container {
    padding: 16px 20px 20px 20px;
    background-color: #fff;
    border-top: 1px solid #e5e7eb;
    position: relative;
    box-sizing: border-box;
    flex-shrink: 0;
}

.cbn8n-input-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    background-color: #f3f4f6;
    border-radius: 24px;
    padding: 2px;
}

#cbn8n-input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    padding: 10px 16px !important;
    font-size: 15px !important;
    outline: none !important;
    color: #374151 !important;
    box-shadow: none !important;
    margin: 0 !important;
    line-height: normal !important;
}

#cbn8n-input::placeholder {
    color: #9ca3af;
}

#cbn8n-send-btn {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 4px 0 0 !important;
    width: 36px !important;
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3) !important;
    flex-shrink: 0;
}

#cbn8n-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4) !important;
}

#cbn8n-send-btn:active {
    transform: scale(0.95);
}

#cbn8n-send-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
    stroke: none;
    display: block;
}

/* Style phụ trợ */
.cbn8n-message-image {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 5px;
    cursor: pointer;
}

.cbn8n-typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.cbn8n-typing-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #6b7280;
    animation: cbn8n-blink 1.4s infinite both;
}

.cbn8n-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.cbn8n-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes cbn8n-blink {
    0%, 60%, 100% { 
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% { 
        opacity: 1;
        transform: scale(1);
    }
}

.cbn8n-empty-state {
    text-align: center;
    color: #9ca3af;
    font-size: 12px;
    margin: 10px 0;
    padding: 8px 12px;
    background-color: #f3f4f6;
    border-radius: 12px;
}