.chatbox-toggle {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #29618E;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(41, 97, 142, 0.4);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
    white-space: nowrap;
    padding: 0;
}

.chatbox-toggle:hover {
    width: 135px;
    border-radius: 26px;
    padding: 0 16px;
    background: #2d6aa1;
    box-shadow: 0 6px 20px rgba(41, 97, 142, 0.55);
}

.chatbox-toggle svg {
    width: 24px;
    height: 24px;
    fill: #fff;
    flex-shrink: 0;
}

.chatbox-toggle-text {
    font-weight: 600;
    font-size: 14px;
    opacity: 0;
    width: 0;
    margin-left: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
    pointer-events: none;
    display: inline-block;
    vertical-align: middle;
}

.chatbox-toggle:hover .chatbox-toggle-text {
    opacity: 1;
    width: auto;
    margin-left: 10px;
    transform: translateX(0);
}

.chatbox-toggle .chatbox-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #e74c3c;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* Chatbox Container */
.chatbox-container {
    position: fixed;
    bottom: 140px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    z-index: 99998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbox-container.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.chatbox-header {
    background: #29618E;
    color: #fff;
    border-bottom: none;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chatbox-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbox-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbox-header-avatar svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.chatbox-header-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.chatbox-header-subtitle {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 1px;
}

.chatbox-header-actions {
    display: flex;
    gap: 6px;
}

.chatbox-header-actions button {
    width: 30px;
    height: 30px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-size: 14px;
}

.chatbox-header-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Area */
.chatbox-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f5f7fb;
}

.chatbox-messages::-webkit-scrollbar {
    width: 5px;
}

.chatbox-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbox-messages::-webkit-scrollbar-thumb {
    background: #c1c9d6;
    border-radius: 10px;
}

/* Message Bubbles */
.chatbox-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: chatbox-fadeIn 0.3s ease;
}

@keyframes chatbox-fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbox-message.user {
    align-self: flex-end;
}

.chatbox-message.bot {
    align-self: flex-start;
}

.chatbox-message .bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chatbox-message.user .bubble {
    background: #29618E;
    color: #fff;
    border-bottom-right-radius: 4px;
    border: none;
}

.chatbox-message.bot .bubble {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.chatbox-message .msg-time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

.chatbox-message.user .msg-time {
    text-align: right;
}

.chatbox-message.bot .msg-time {
    text-align: left;
}

/* Typing Indicator */
.chatbox-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    max-width: 70px;
    animation: chatbox-fadeIn 0.3s ease;
}

.chatbox-typing span {
    width: 7px;
    height: 7px;
    background: #b0b8c9;
    border-radius: 50%;
    animation: chatbox-bounce 1.4s infinite ease-in-out both;
}

.chatbox-typing span:nth-child(1) {
    animation-delay: -0.32s;
}

.chatbox-typing span:nth-child(2) {
    animation-delay: -0.16s;
}

.chatbox-typing span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes chatbox-bounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Welcome Message */
.chatbox-welcome {
    text-align: center;
    padding: 30px 20px;
    color: #8e99a9;
}

.chatbox-welcome svg {
    width: 48px;
    height: 48px;
    fill: #c1c9d6;
    margin-bottom: 12px;
}

.chatbox-welcome h4 {
    font-size: 15px;
    color: #555;
    margin: 0 0 6px 0;
    font-weight: 600;
}

.chatbox-welcome p {
    font-size: 12px;
    margin: 0;
    line-height: 1.5;
}

/* Input Area */
.chatbox-input-area {
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid #e8ecf1;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.chatbox-input-area textarea {
    flex: 1;
    box-sizing: border-box;
    border: 1px solid #dde1e8;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    height: 42px;
    min-height: 42px;
    max-height: 80px;
    line-height: 20px;
    outline: none;
    transition: border-color 0.2s;
    background: #f8f9fb;
    overflow-y: auto;
}

.chatbox-input-area textarea:focus {
    border-color: #29618E;
    background: #fff;
}

.chatbox-input-area textarea::placeholder {
    color: #adb5c2;
}

.chatbox-send-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    background: #29618E;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chatbox-send-btn:hover {
    transform: scale(1.05);
    background: #2d6aa1;
    box-shadow: 0 3px 10px rgba(41, 97, 142, 0.3);
}

.chatbox-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chatbox-send-btn svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* Clear Chat Button */
.chatbox-clear-btn {
    width: 100%;
    padding: 6px;
    background: none;
    border: none;
    border-top: 1px solid #e8ecf1;
    color: #adb5c2;
    font-size: 11px;
    cursor: pointer;
    transition: color 0.2s;
    flex-shrink: 0;
}

.chatbox-clear-btn:hover {
    color: #e74c3c;
}

/* Links in chat messages */
.chatbox-message .bubble a.chatbox-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
    font-weight: 500;
}

.chatbox-message.user .bubble a.chatbox-link {
    color: #fff;
}

.chatbox-message.bot .bubble a.chatbox-link {
    color: #29618E;
}

.chatbox-message .bubble a.chatbox-link:hover {
    opacity: 0.8;
}