/* ══════════════════════════════════════════════
   STIVO Chatbot Widget
   ══════════════════════════════════════════════ */

/* ── Toggle Button ── */
.chatbot-toggle {
    position: fixed;
    bottom: 100px;
    right: 28px;
    z-index: 9999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 1px solid rgba(45, 138, 95, 0.4);
    background: linear-gradient(135deg, #1a5841 0%, #2d8a5f 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 30px rgba(26, 88, 65, 0.4),
        0 0 60px rgba(26, 88, 65, 0.1);
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        box-shadow 0.35s ease,
        background 0.35s ease;
}

.chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 40px rgba(26, 88, 65, 0.55),
        0 0 80px rgba(26, 88, 65, 0.15);
}

.chatbot-toggle svg {
    width: 28px;
    height: 28px;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.chatbot-toggle .chatbot-icon-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.8);
}

.chatbot-toggle.active .chatbot-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.8);
}

.chatbot-toggle.active .chatbot-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ── Notification badge ── */
.chatbot-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #4ae89a;
    border-radius: 50%;
    border: 2px solid #000;
    animation: chatbot-pulse-badge 2s ease-in-out infinite;
}

.chatbot-toggle.active .chatbot-badge {
    display: none;
}

@keyframes chatbot-pulse-badge {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* ── Backdrop overlay ── */
.chatbot-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9997;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.chatbot-backdrop.open {
    opacity: 1;
    visibility: visible;
}

/* ── Chat Widget Container ── */
.chatbot-widget {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.92);
    z-index: 9998;
    width: 860px;
    max-width: calc(100vw - 40px);
    height: 720px;
    max-height: calc(100vh - 40px);
    background: #0d0f11;
    border: 1px solid rgba(26, 88, 65, 0.25);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6),
        0 0 100px rgba(26, 88, 65, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease,
        visibility 0.35s ease,
        transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.chatbot-widget.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* ── Glow line on top ── */
.chatbot-widget::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg,
            transparent 0%,
            #1a5841 20%,
            #2d8a5f 50%,
            #1a5841 80%,
            transparent 100%);
    z-index: 1;
}

/* ── Header ── */
.chatbot-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    background: #131416;
    border-bottom: 1px solid rgba(26, 88, 65, 0.15);
    flex-shrink: 0;
}

.chatbot-header-close {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
    margin-left: auto;
}

.chatbot-header-close:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.chatbot-header-close svg {
    width: 18px;
    height: 18px;
}

.chatbot-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(26, 88, 65, 0.15);
    border: 1px solid rgba(26, 88, 65, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.chatbot-header-avatar svg {
    width: 22px;
    height: 22px;
    color: #4ae89a;
}

.chatbot-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbot-header-info {
    flex: 1;
    min-width: 0;
}

.chatbot-header-name {
    font-family: "PP Object Sans", sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    letter-spacing: -0.2px;
}

.chatbot-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.chatbot-header-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ae89a;
    animation: chatbot-online-pulse 2s ease-in-out infinite;
}

@keyframes chatbot-online-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.chatbot-header-status span {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Messages Area ── */
.chatbot-messages {
    flex: 1 1 0%;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
}

/* Custom scrollbar */
.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(45, 138, 95, 0.3);
    border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(45, 138, 95, 0.5);
}

/* ── Message Bubbles ── */
.chatbot-msg {
    display: flex;
    gap: 10px;
    max-width: 88%;
    animation: chatbot-msg-in 0.3s ease;
}

@keyframes chatbot-msg-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-msg--assistant {
    align-self: flex-start;
}

.chatbot-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.chatbot-msg--assistant .chatbot-msg-avatar {
    background: rgba(26, 88, 65, 0.15);
    border: 1px solid rgba(26, 88, 65, 0.25);
    overflow: hidden;
}

.chatbot-msg--assistant .chatbot-msg-avatar svg {
    width: 16px;
    height: 16px;
    color: #4ae89a;
}

.chatbot-msg--assistant .chatbot-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbot-msg--user .chatbot-msg-avatar {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-msg--user .chatbot-msg-avatar svg {
    width: 16px;
    height: 16px;
    color: rgba(255, 255, 255, 0.6);
}

.chatbot-msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-family: "PP Object Sans", sans-serif;
    font-size: 13.5px;
    line-height: 170%;
    word-break: break-word;
}

.chatbot-msg--assistant .chatbot-msg-bubble {
    background: #131416;
    border: 1px solid rgba(26, 88, 65, 0.12);
    color: rgba(255, 255, 255, 0.8);
    border-top-left-radius: 4px;
}

.chatbot-msg--user .chatbot-msg-bubble {
    background: linear-gradient(135deg, #1a5841, #2d8a5f);
    border: 1px solid rgba(45, 138, 95, 0.3);
    color: #fff;
    border-top-right-radius: 4px;
}

/* Markdown-like formatting inside bubbles */
.chatbot-msg-bubble strong {
    font-weight: 700;
    color: #fff;
}

.chatbot-msg-bubble ul,
.chatbot-msg-bubble ol {
    margin: 6px 0;
    padding-left: 18px;
}

.chatbot-msg-bubble li {
    margin-bottom: 3px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
}

.chatbot-msg-bubble p {
    margin-bottom: 6px;
    font-size: 13.5px;
    color: inherit;
}

.chatbot-msg-bubble p:last-child {
    margin-bottom: 0;
}

/* ── Typing Indicator ── */
.chatbot-typing {
    display: flex;
    gap: 10px;
    max-width: 88%;
    align-self: flex-start;
    animation: chatbot-msg-in 0.3s ease;
}

.chatbot-typing-bubble {
    padding: 14px 20px;
    background: #131416;
    border: 1px solid rgba(26, 88, 65, 0.12);
    border-radius: 16px;
    border-top-left-radius: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chatbot-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(45, 138, 95, 0.5);
    animation: chatbot-typing-bounce 1.4s ease-in-out infinite;
}

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

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

@keyframes chatbot-typing-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ── Quick Actions (Welcome) ── */
.chatbot-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.chatbot-quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    font-family: "PP Object Sans", sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(26, 88, 65, 0.1);
    border: 1px solid rgba(26, 88, 65, 0.2);
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.chatbot-quick-btn:hover {
    background: rgba(26, 88, 65, 0.2);
    border-color: rgba(45, 138, 95, 0.4);
    color: rgba(255, 255, 255, 0.85);
}

/* ── Input Area ── */
.chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: #131416;
    border-top: 1px solid rgba(26, 88, 65, 0.12);
    flex-shrink: 0;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    font-family: "PP Object Sans", sans-serif;
    font-size: 13.5px;
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    outline: none;
    resize: none;
    min-height: 44px;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.3s ease, background 0.3s ease;
}

.chatbot-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.chatbot-input:focus {
    border-color: rgba(45, 138, 95, 0.4);
    background: rgba(255, 255, 255, 0.06);
}

.chatbot-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(45, 138, 95, 0.3);
    background: linear-gradient(135deg, #1a5841, #2d8a5f);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.3s ease,
        box-shadow 0.3s ease,
        transform 0.2s ease,
        opacity 0.3s ease;
}

.chatbot-send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #2d8a5f, #3ba872);
    box-shadow: 0 4px 20px rgba(26, 88, 65, 0.3);
    transform: translateY(-1px);
}

.chatbot-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chatbot-send-btn svg {
    width: 20px;
    height: 20px;
}

/* ── Powered by footer ── */
.chatbot-footer {
    padding: 8px 16px;
    text-align: center;
    background: #0d0f11;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    flex-shrink: 0;
}

.chatbot-footer span {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.2);
    letter-spacing: 0.5px;
}

/* ══════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════ */

/* Tablet */
@media (max-width: 900px) {
    .chatbot-toggle {
        bottom: 100px;
        right: 20px;
    }

    .chatbot-widget {
        width: 560px;
    }
}

/* Mobile */
@media (max-width: 600px) {
    .chatbot-widget {
        top: 0;
        left: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        transform: translate(0, 0) scale(0.95);
    }

    .chatbot-widget.open {
        transform: translate(0, 0) scale(1);
    }

    .chatbot-header {
        padding: 14px 16px;
        padding-top: calc(14px + env(safe-area-inset-top, 0px));
    }

    .chatbot-messages {
        padding: 16px 14px;
    }

    .chatbot-input-area {
        padding: 12px 14px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .chatbot-footer {
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }

    .chatbot-msg {
        max-width: 92%;
    }

    .chatbot-msg-bubble {
        padding: 10px 14px;
        font-size: 14px;
        line-height: 165%;
    }

    .chatbot-msg-bubble li {
        font-size: 13.5px;
    }

    .chatbot-quick-actions {
        gap: 5px;
    }

    .chatbot-quick-btn {
        font-size: 11.5px;
        padding: 6px 12px;
    }

    .chatbot-toggle {
        bottom: 90px;
        right: 16px;
        width: 54px;
        height: 54px;
    }

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

    .chatbot-toggle.active {
        display: none;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .chatbot-header-name {
        font-size: 13px;
    }

    .chatbot-header-avatar {
        width: 34px;
        height: 34px;
    }

    .chatbot-msg-bubble {
        font-size: 13.5px;
    }
}