/* ==========================================================================
   TCBPay Chatbot Widget Styles
   All classes namespaced with .tcb-chatbot-* to avoid conflicts
   ========================================================================== */

/* --- FAB (Floating Action Button) --- */
/* Default: lower position when no fixed bottom button (e.g. Charge) */
.tcb-chatbot-fab {
    position: fixed;
    bottom: 28px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 100px;
    background-color: #397AB7;
    box-shadow: 0px 5px 10px rgba(57, 122, 183, 0.14);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99998;
    transition: transform 0.2s ease, opacity 0.2s ease, bottom 0.2s ease;
    padding: 0;
    outline: none;
}
/* When fixed bottom button (e.g. Charge) is present, raise FAB so it sits above it */
body.tcb-chatbot-has-fixed-btn .tcb-chatbot-fab {
    bottom: 60px;
}

.tcb-chatbot-fab:hover {
    transform: scale(1.05);
}

.tcb-chatbot-fab svg {
    width: 26px;
    height: 26px;
}

/* --- Chat Window Container --- */
/* Positioned above FAB with a gap; bottom follows FAB position so window never covers icon */
.tcb-chatbot-window {
    position: fixed;
    bottom: 84px; /* FAB at 24px + 50px height + 10px gap when no fixed button */
    right: 30px;
    width: 400px;
    height: 650px;
    max-height: calc(100vh - 100px);
    border-radius: 8px;
    box-shadow: 0px 5px 10px rgba(57, 122, 183, 0.14);
    display: flex;
    flex-direction: column;
    z-index: 99999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease, bottom 0.2s ease;
    overflow: hidden;
}
body.tcb-chatbot-has-fixed-btn .tcb-chatbot-window {
    bottom: 110px; /* FAB at 50px + 50px height + 10px gap when fixed button present */
}

.tcb-chatbot-window.tcb-chatbot-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* --- Header --- */
.tcb-chatbot-header {
    position: relative;
    min-height: 170px;
    padding: 20px;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    background-color: #D9D9D9;
}

.tcb-chatbot-header::before {
    content: '';
    position: absolute;
    top: -20%;
    left: -20%;
    width: 140%;
    height: 140%;
    background: conic-gradient(from 202deg at 81.78% 23.22%, #71A0CC 0deg, #FFF 128.0769181251526deg, #FDE4AF 221.53846979141235deg, #FFF 270deg, #FFDFAB 323.6538362503052deg), #D9D9D9;
    animation: tcb-chatbot-drift 12s ease-in-out infinite;
    z-index: 0;
}

.tcb-chatbot-header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.01);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 8px 8px 0 0;
    pointer-events: none;
    z-index: 0;
}

.tcb-chatbot-header > * {
    position: relative;
    z-index: 1;
}

.tcb-chatbot-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.tcb-chatbot-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 47px;
    height: 22px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50px;
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    font-size: 11px;
    color: #ffffff;
    line-height: 1;
    letter-spacing: 0.5px;
}

.tcb-chatbot-close {
    width: 40px;
    height: 40px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.4);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    outline: none;
    transition: background 0.2s ease;
}

.tcb-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.6);
}

.tcb-chatbot-close svg {
    width: 16px;
    height: 16px;
}

.tcb-chatbot-title {
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    font-size: 22px;
    color: #ffffff;
    margin: 0 0 6px 0;
    line-height: 1.2;
}

.tcb-chatbot-subtitle {
    font-family: 'Open Sans', sans-serif;
    font-weight: 400;
    font-size: 12px;
    line-height: 20px;
    color: #ffffff;
    margin: 0;
}

/* --- Messages Area --- */
.tcb-chatbot-messages {
    background: #ffffff;
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 25px;
    min-height: 0;
}

/* Scrollbar styling */
.tcb-chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

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

.tcb-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(57, 122, 183, 0.2);
    border-radius: 10px;
}

/* --- Message Wrappers --- */
.tcb-chatbot-msg {
    display: flex;
    flex-direction: column;
}

/* --- User Message (right-aligned) --- */
.tcb-chatbot-msg-user {
    align-items: flex-end;
}

.tcb-chatbot-msg-user .tcb-chatbot-bubble {
    background: #397AB7;
    color: #ffffff;
    font-family: 'Open Sans', sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 24px;
    padding: 12px 18px;
    border-radius: 20px 0 20px 20px; /* top outer (top-right) sharp */
    word-wrap: break-word;
}

.tcb-chatbot-user-group {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    align-items: flex-end; /* bubble/attachment right-aligned */
}

/* Time left-aligned within group; bubble/attachment stay right */
.tcb-chatbot-msg-user .tcb-chatbot-time,
.tcb-chatbot-msg-user .tcb-chatbot-time-user {
    align-self: flex-start;
}

.tcb-chatbot-msg-user .tcb-chatbot-time {
    font-family: 'Open Sans', sans-serif;
    font-weight: 400;
    font-size: 11px;
    color: rgba(57, 122, 183, 0.4);
    margin-top: 6px;
    text-align: left;
}

.tcb-chatbot-msg-user .tcb-chatbot-time.tcb-chatbot-time-hidden {
    display: none;
}

/* Tighter gap when back-to-back user messages (timestamp only on last) */
.tcb-chatbot-msg-user.tcb-chatbot-follows-user {
    margin-top: -17px;
}

/* --- Bot Message (left-aligned) --- */
.tcb-chatbot-msg-bot {
    align-items: flex-start;
    align-self: flex-start;
}

.tcb-chatbot-msg-bot-inner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 80%;
    margin-right: auto;
}

.tcb-chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tcb-chatbot-bot-content {
    display: flex;
    flex-direction: column;
}

.tcb-chatbot-bot-label {
    font-family: 'Open Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: #0D082C;
    margin-bottom: 6px;
}

.tcb-chatbot-msg-bot .tcb-chatbot-bubble {
    background: #F5F5F5;
    color: #0D082C;
    font-family: 'Open Sans', sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 24px;
    padding: 10px 15px;
    border-radius: 0 10px 10px 10px;
    word-wrap: break-word;
}

.tcb-chatbot-msg-bot .tcb-chatbot-time {
    font-family: 'Open Sans', sans-serif;
    font-weight: 400;
    font-size: 11px;
    color: rgba(57, 122, 183, 0.4);
    margin-top: 6px;
    text-align: right;
}

.tcb-chatbot-time-user {
    font-family: 'Open Sans', sans-serif;
    font-weight: 400;
    font-size: 11px;
    color: rgba(57, 122, 183, 0.4);
    margin-top: 6px;
    text-align: left;
}

/* --- Typing Indicator (match bot bubble length/spacing per Figma) --- */
.tcb-chatbot-typing {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 80%;
}

.tcb-chatbot-typing .tcb-chatbot-bot-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tcb-chatbot-typing .tcb-chatbot-bot-label {
    margin-bottom: 0;
}

.tcb-chatbot-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #F5F5F5;
    padding: 10px 12px;
    border-radius: 0 10px 10px 10px;
    width: fit-content;
}

.tcb-chatbot-typing-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #397AB7;
    opacity: 0.4;
    animation: tcb-chatbot-dot-pulse 1.4s ease-in-out infinite;
}

.tcb-chatbot-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.tcb-chatbot-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}


@keyframes tcb-chatbot-drift {
    0% {
        transform: translate(0, 0);
    }
    35% {
        transform: translate(-15%, 6%);
    }
    65% {
        transform: translate(8%, -4%);
    }
    100% {
        transform: translate(0, 0);
    }
}

@keyframes tcb-chatbot-dot-pulse {
    0%, 60%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* --- Attachment Card (Finder-like preview, clickable) --- */
.tcb-chatbot-attachment {
    background: #ffffff;
    border: 1px solid rgba(57, 122, 183, 0.2);
    border-radius: 10px;
    padding: 0;
    max-width: 200px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: block;
}

.tcb-chatbot-attachment-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.tcb-chatbot-attachment-link:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    border-color: rgba(57, 122, 183, 0.4);
}

.tcb-chatbot-attachment-preview-wrap {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 90px;
}

.tcb-chatbot-attachment-preview-wrap.tcb-chatbot-attachment-preview-pdf::after {
    content: '';
    position: absolute;
    inset: 0;
    background: #397ab780;
    pointer-events: none;
}

.tcb-chatbot-attachment-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
}

.tcb-chatbot-file-icon {
    width: 40px;
    height: 40px;
}

.tcb-chatbot-attachment-file {
    background: #f5f7fa;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tcb-chatbot-attachment-file.tcb-chatbot-file-pdf {
    background: #fef3f2;
}

.tcb-chatbot-attachment-file.tcb-chatbot-file-doc {
    background: #eef4ff;
}

.tcb-chatbot-attachment-file.tcb-chatbot-file-txt {
    background: #f0fdf4;
}

.tcb-chatbot-attachment-file.tcb-chatbot-file-generic {
    background: #f5f7fa;
}

/* Fallback: solid blue + white icon when preview cannot load */
.tcb-chatbot-attachment-file-fallback {
    background: #397AB7 !important;
    height: 90px;
    min-height: 90px;
}

.tcb-chatbot-attachment-file-fallback .tcb-chatbot-file-icon-fallback {
    color: #ffffff;
}

.tcb-chatbot-attachment-name {
    font-family: 'Open Sans', sans-serif;
    font-weight: 400;
    font-size: 12px;
    color: #397AB7;
    background: #ffffff;
    padding: 8px 10px;
    word-break: break-word;
    white-space: normal;
    line-height: 1.35;
    display: block;
    border-top: 1px solid rgba(57, 122, 183, 0.15);
}

.tcb-chatbot-attachment-link .tcb-chatbot-attachment-name {
    color: #397AB7;
}

.tcb-chatbot-attachment-link:hover .tcb-chatbot-attachment-name {
    color: #2e6a9e;
}

/* --- Attachment Preview Bar (above input) --- */
.tcb-chatbot-attach-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    background: #f5f5f5;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.tcb-chatbot-attach-preview img {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    object-fit: cover;
}

.tcb-chatbot-attach-preview-fallback {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 4px;
    background: #397AB7;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tcb-chatbot-attach-preview-fallback .tcb-chatbot-file-icon-fallback {
    width: 20px;
    height: 20px;
    color: #ffffff;
}

.tcb-chatbot-attach-preview-icon {
    font-size: 24px;
    line-height: 1;
}

.tcb-chatbot-attach-preview-name {
    flex: 1;
    font-family: 'Open Sans', sans-serif;
    font-size: 12px;
    color: #0D082C;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tcb-chatbot-attach-preview-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #999;
    padding: 0 4px;
    line-height: 1;
}

.tcb-chatbot-attach-preview-remove:hover {
    color: #333;
}

/* --- Input Area --- */
.tcb-chatbot-input-area {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 15px !important;
    background: #ffffff !important;
    border-top: 1px solid rgba(0, 0, 0, 0.05) !important;
    border-radius: 0 0 8px 8px !important;
    flex-shrink: 0 !important;
}

.tcb-chatbot-attach {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    outline: none;
}

.tcb-chatbot-attach svg,
.tcb-chatbot-attach img {
    width: 24px;
    height: 24px;
    opacity: 0.35;
    transition: opacity 0.2s ease;
}

.tcb-chatbot-attach:hover svg,
.tcb-chatbot-attach:hover img {
    opacity: 0.95;
}

.tcb-chatbot-input {
    flex: 1 !important;
    border: none !important;
    border-radius: 0 !important;
    outline: none !important;
    font-family: 'Open Sans', sans-serif;
    font-weight: 400 !important;
    font-size: 14px !important;
    color: #0D082C !important;
    background: transparent !important;
    padding: 0 !important;
    line-height: 24px !important;
}

.tcb-chatbot-input::placeholder {
    color: rgba(13, 8, 44, 0.4);
}

.tcb-chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #397AB7;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    outline: none;
    transition: background 0.2s ease;
}

.tcb-chatbot-send:hover {
    background: #2e6a9e;
}

.tcb-chatbot-send svg {
    width: 24px;
    height: 24px;
}

/* --- Responsive --- */
@media (max-width: 500px) {
    .tcb-chatbot-window {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 75px; /* above FAB (15px + 50px + 10px gap) */
        max-height: calc(100vh - 100px);
    }
    body.tcb-chatbot-has-fixed-btn .tcb-chatbot-window {
        bottom: 95px;
    }

    .tcb-chatbot-fab {
        bottom: 15px;
        right: 15px;
    }
    body.tcb-chatbot-has-fixed-btn .tcb-chatbot-fab {
        bottom: 50px;
    }

    .tcb-chatbot-header {
        padding: 20px;
    }

    .tcb-chatbot-title {
        font-size: 24px;
    }

    .tcb-chatbot-messages {
        padding: 20px;
    }

    .tcb-chatbot-input-area {
        padding: 15px 20px !important;
    }
}
