/* Tekkiveikot Chatbot – Veke */

.tvcb-chatbot {
    --tvcb-primary: #0b6e4f;
    --tvcb-primary-dark: #095a40;
    --tvcb-bg: #ffffff;
    --tvcb-msg-bg: #f1f5f9;
    --tvcb-user-bg: #0b6e4f;
    --tvcb-user-text: #ffffff;
    --tvcb-text: #1e293b;
    --tvcb-text-muted: #64748b;
    --tvcb-border: #e2e8f0;
    --tvcb-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --tvcb-radius: 16px;

    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* Toggle button */
.tvcb-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--tvcb-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(11, 110, 79, 0.4);
    transition: background 0.2s, transform 0.2s;
}

.tvcb-toggle:hover {
    background: var(--tvcb-primary-dark);
    transform: scale(1.05);
}

.tvcb-toggle svg {
    width: 26px;
    height: 26px;
}

/* Chat window */
.tvcb-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--tvcb-bg);
    border-radius: var(--tvcb-radius);
    box-shadow: var(--tvcb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--tvcb-border);
}

/* Header */
.tvcb-header {
    background: var(--tvcb-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.tvcb-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tvcb-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.tvcb-header strong {
    display: block;
    font-size: 15px;
}

.tvcb-status {
    font-size: 11px;
    opacity: 0.85;
}

.tvcb-close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.tvcb-close-btn:hover {
    opacity: 1;
}

/* Messages area */
.tvcb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tvcb-message {
    display: flex;
    gap: 8px;
    max-width: 88%;
    align-items: flex-end;
}

.tvcb-message.tvcb-bot {
    align-self: flex-start;
}

.tvcb-message.tvcb-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.tvcb-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--tvcb-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}

.tvcb-user .tvcb-msg-avatar {
    background: var(--tvcb-text-muted);
}

.tvcb-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    word-break: break-word;
    white-space: pre-wrap;
}

.tvcb-bot .tvcb-bubble {
    background: var(--tvcb-msg-bg);
    color: var(--tvcb-text);
    border-bottom-left-radius: 4px;
}

.tvcb-user .tvcb-bubble {
    background: var(--tvcb-user-bg);
    color: var(--tvcb-user-text);
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.tvcb-typing .tvcb-bubble {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
}

.tvcb-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tvcb-text-muted);
    animation: tvcb-bounce 1.4s ease-in-out infinite;
}

.tvcb-dot:nth-child(2) { animation-delay: 0.2s; }
.tvcb-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes tvcb-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input area */
.tvcb-input-area {
    padding: 12px;
    border-top: 1px solid var(--tvcb-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.tvcb-input {
    flex: 1;
    border: 1px solid var(--tvcb-border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.4;
}

.tvcb-input:focus {
    border-color: var(--tvcb-primary);
}

.tvcb-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--tvcb-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.tvcb-send:hover {
    background: var(--tvcb-primary-dark);
}

.tvcb-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tvcb-send svg {
    width: 18px;
    height: 18px;
}

/* Tablet */
@media (max-width: 768px) {
    .tvcb-window {
        width: 340px;
        height: 480px;
    }
}

/* Mobile – fullscreen overlay */
@media (max-width: 480px) {
    .tvcb-chatbot {
        bottom: 12px;
        right: 12px;
    }

    .tvcb-toggle {
        width: 54px;
        height: 54px;
    }

    .tvcb-toggle svg {
        width: 22px;
        height: 22px;
    }

    .tvcb-chatbot.tvcb-open {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
    }

    .tvcb-chatbot.tvcb-open .tvcb-toggle {
        display: none;
    }

    .tvcb-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
    }

    .tvcb-header {
        padding: 16px;
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .tvcb-messages {
        padding: 12px;
    }

    .tvcb-message {
        max-width: 92%;
    }

    .tvcb-input-area {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .tvcb-input {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
}
