/* Kompetivo Agent — Chat Widget */

:root {
    --ka-primary: #004B8D;
    --ka-primary-dark: #003567;
    --ka-radius: 16px;
    --ka-shadow: 0 8px 32px rgba(0,0,0,0.18);
    --ka-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.ka-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: var(--ka-font);
}

/* --- Bubble --- */
.ka-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--ka-primary);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 14px 22px 14px 18px;
    cursor: pointer;
    box-shadow: var(--ka-shadow);
    font-size: 15px;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}
.ka-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 36px rgba(0,0,0,0.22);
}
.ka-bubble.ka-open {
    border-radius: 50%;
    padding: 16px;
}
.ka-bubble.ka-open .ka-bubble-label { display: none; }

/* --- Chat-Fenster --- */
.ka-chat {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    max-height: 580px;
    background: #fff;
    border-radius: var(--ka-radius);
    box-shadow: var(--ka-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ka-slide-up 0.25s ease;
}
@keyframes ka-slide-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ka-chat[hidden] { display: none; }

/* --- Header --- */
.ka-header {
    background: var(--ka-primary);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ka-header-info { display: flex; align-items: center; gap: 12px; }
.ka-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}
.ka-bot-name { font-weight: 700; font-size: 15px; }
.ka-status { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 5px; }
.ka-status-dot {
    width: 7px; height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}
.ka-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.8;
    line-height: 1;
    padding: 4px;
}
.ka-close:hover { opacity: 1; }

/* --- Nachrichten --- */
.ka-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f8fc;
}

.ka-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
}
.ka-msg-bot {
    background: #fff;
    color: #1a1a2e;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.ka-msg-user {
    background: var(--ka-primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.ka-msg-typing {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
}
.ka-dot {
    width: 7px; height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: ka-bounce 1.2s infinite;
}
.ka-dot:nth-child(2) { animation-delay: 0.2s; }
.ka-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ka-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-6px); }
}

/* Kurs-Karte */
.ka-course-card {
    background: #f0f5ff;
    border: 1px solid #d0e0ff;
    border-radius: 10px;
    padding: 12px 14px;
    margin-top: 8px;
    font-size: 13px;
}
.ka-course-card strong { display: block; margin-bottom: 4px; color: var(--ka-primary); font-size: 14px; }
.ka-course-card .ka-price { font-weight: 700; color: #1a1a2e; margin-top: 4px; }
.ka-course-card .ka-badge {
    display: inline-block;
    background: #d1fae5;
    color: #065f46;
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 11px;
    margin-top: 4px;
}
.ka-course-link {
    display: inline-block;
    margin-top: 10px;
    background: var(--ka-primary);
    color: #fff !important;
    text-decoration: none;
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s;
}
.ka-course-link:hover { background: var(--ka-primary-dark); }

/* --- Doppeltes CTA (Lead + Termin) --- */
.ka-cta-block {
    padding: 14px 16px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ka-cta-block[hidden] { display: none; }
.ka-cta-title { font-size: 13px; font-weight: 600; color: #333; margin: 0 0 2px; }
.ka-cta-subtitle { font-size: 12px; color: #666; margin: 0 0 8px; }
.ka-cta-buttons { display: flex; gap: 8px; }
.ka-btn-primary {
    flex: 1;
    background: var(--ka-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
}
.ka-btn-primary:hover { background: var(--ka-primary-dark); }
.ka-btn-secondary {
    flex: 1;
    background: #fff;
    color: var(--ka-primary);
    border: 2px solid var(--ka-primary);
    border-radius: 8px;
    padding: 9px 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.ka-btn-secondary:hover { background: #f0f5ff; }

/* --- Lead-Formular --- */
.ka-lead-form {
    padding: 14px 16px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ka-lead-form[hidden] { display: none; }
.ka-lead-title { font-size: 13px; font-weight: 600; color: #333; margin: 0 0 4px; }
.ka-lead-form input {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    font-family: var(--ka-font);
    outline: none;
    transition: border-color 0.2s;
}
.ka-lead-form input:focus { border-color: var(--ka-primary); }
.ka-lead-btn {
    background: var(--ka-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.ka-lead-btn:hover { background: var(--ka-primary-dark); }

/* --- Eingabe --- */
.ka-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid #eee;
}
.ka-input-area input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: var(--ka-font);
    outline: none;
    transition: border-color 0.2s;
}
.ka-input-area input:focus { border-color: var(--ka-primary); }
#ka-send {
    background: var(--ka-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}
#ka-send:hover { background: var(--ka-primary-dark); }

.ka-footer {
    text-align: center;
    font-size: 11px;
    color: #aaa;
    padding: 6px;
    background: #fff;
}

/* Mobile */
@media (max-width: 480px) {
    .ka-chat {
        width: calc(100vw - 32px);
        right: 0;
        bottom: 76px;
        max-height: 70vh;
    }
    .ka-widget { bottom: 16px; right: 16px; }
}
