/* ============================================================
   LKG Chatbot · adaptiert vom Neo Orbis Design auf LKG-Branding
   Setzt tokens.css voraus (--green, --dark, --gray-*)
   ============================================================ */

/* ----- Toggle-Button (rechts unten) ----- */
#lkg-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
}

/* Aufklappbare Aktionen (Telefon, E-Mail, Facebook, Chat) */
.lkg-fab-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s;
}
#lkg-fab.fab-open .lkg-fab-actions {
    opacity: 1;
    visibility: visible;
}
.lkg-fab-action {
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
#lkg-fab.fab-open .lkg-fab-action { opacity: 1; transform: translateY(0) scale(1); }
#lkg-fab.fab-open .lkg-fab-action:nth-child(1) { transition-delay: 0.16s; }
#lkg-fab.fab-open .lkg-fab-action:nth-child(2) { transition-delay: 0.12s; }
#lkg-fab.fab-open .lkg-fab-action:nth-child(3) { transition-delay: 0.08s; }
#lkg-fab.fab-open .lkg-fab-action:nth-child(4) { transition-delay: 0.04s; }
.lkg-fab-label {
    background: var(--white);
    color: var(--dark);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(26, 43, 60, 0.18);
    white-space: nowrap;
}
.lkg-fab-ic {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    box-shadow: 0 8px 24px rgba(26, 43, 60, 0.22);
    flex: 0 0 auto;
    transition: transform 0.2s ease;
}
.lkg-fab-action:hover .lkg-fab-ic { transform: scale(1.1); }
.lkg-fab-ic svg { width: 22px; height: 22px; }
.ic-chat  { background: linear-gradient(135deg, var(--green), var(--green-dark)); }
.ic-fb    { background: #1877F2; }
.ic-mail  { background: var(--dark-lighter); }
.ic-phone { background: var(--green-dark); }

/* Haupt-Button (etwas größer) */
#lkg-fab-toggle {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--green), var(--green-dark));
    box-shadow: 0 10px 40px rgba(149, 193, 31, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: none;
    color: var(--white);
}
#lkg-fab-toggle svg { width: 30px; height: 30px; }
#lkg-fab-toggle:hover { transform: scale(1.08); }
#lkg-fab-toggle::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--green), var(--green-dark));
    filter: blur(16px);
    opacity: 0.45;
    z-index: -1;
    animation: chat-pulse-glow 3s ease-in-out infinite;
}
#lkg-fab.is-active #lkg-fab-toggle::after { animation: none; opacity: 0.2; }
@keyframes chat-pulse-glow {
    0%, 100% { opacity: 0.35; transform: scale(1); }
    50%      { opacity: 0.65; transform: scale(1.1); }
}
#lkg-fab-toggle .notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #ff5757;
    border: 2px solid var(--white);
}
#lkg-fab.is-active #lkg-fab-toggle .notification-dot { display: none; }

/* ----- Chat-Window ----- */
#chatbot-window {
    position: fixed;
    bottom: 108px;
    right: 24px;
    z-index: 60;
    width: calc(100vw - 48px);
    max-width: 400px;
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(26, 43, 60, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.96);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}
#chatbot-window.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* ----- Header ----- */
.chatbot-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, var(--dark), var(--dark-lighter));
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 12px;
}
.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--green), var(--green-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    color: var(--white);
}
.chatbot-avatar svg { width: 22px; height: 22px; }
.chatbot-avatar::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid var(--dark);
}
.chatbot-header-text { flex: 1; }
.chatbot-header-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    color: var(--white);
}
.chatbot-header-status {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.chatbot-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
}
#chatbot-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
}
#chatbot-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}
#chatbot-close svg { width: 20px; height: 20px; }

/* ----- Nachrichtenbereich ----- */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: var(--gray-100);
}
.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 2px;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: chat-msg-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes chat-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chat-msg.bot  { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; }
.chat-msg .bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.55;
    word-wrap: break-word;
}
.chat-msg.bot .bubble {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    border-bottom-left-radius: 4px;
}
.chat-msg.user .bubble {
    background: linear-gradient(135deg, var(--green), var(--green-dark));
    color: var(--white);
    border-bottom-right-radius: 4px;
}
.chat-msg .bubble a {
    color: var(--green-dark);
    text-decoration: underline;
    font-weight: 600;
}
.chat-msg.user .bubble a { color: var(--white); }
.chat-msg .bubble strong { font-weight: 700; }
.chat-msg.bot .bubble strong { color: var(--dark); }
.chat-msg.user .bubble strong { color: var(--white); }

/* ----- Tipp-Indikator ----- */
.chat-typing {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    animation: chat-msg-in 0.3s ease;
}
.chat-typing span {
    width: 6px;
    height: 6px;
    background: var(--gray-400);
    border-radius: 50%;
    animation: chat-typing-bounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-typing-bounce {
    0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* ----- Quick Replies (Themen-Buttons) ----- */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    align-self: flex-start;
    max-width: 100%;
}
.quick-reply-btn {
    background: var(--green-light);
    border: 1px solid rgba(149, 193, 31, 0.3);
    color: var(--green-dark);
    padding: 7px 12px;
    border-radius: 14px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-weight: 600;
}
.quick-reply-btn:hover {
    background: var(--green);
    border-color: var(--green-dark);
    color: var(--white);
    transform: translateY(-1px);
}

/* ----- Eingabezeile ----- */
.chatbot-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
    background: var(--white);
}
.chatbot-input-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 4px 4px 4px 14px;
    transition: border-color 0.2s;
}
.chatbot-input-wrap:focus-within {
    border-color: var(--green);
    background: var(--white);
}
#chatbot-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--gray-700);
    font-size: 0.9rem;
    padding: 8px 0;
    font-family: inherit;
}
#chatbot-input::placeholder { color: var(--gray-400); }
#chatbot-send {
    background: linear-gradient(135deg, var(--green), var(--green-dark));
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--white);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
#chatbot-send:hover    { transform: scale(1.05); }
#chatbot-send:disabled { opacity: 0.5; cursor: not-allowed; }
#chatbot-send svg { width: 16px; height: 16px; }

/* ----- Footer-CTAs ----- */
.chatbot-footer {
    display: flex;
    gap: 8px;
    padding: 0 16px 12px 16px;
    background: var(--white);
}
.chatbot-cta {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.2s ease;
    text-decoration: none;
    border: 1px solid var(--gray-200);
    color: var(--gray-700);
    background: var(--gray-100);
}
.chatbot-cta:hover {
    border-color: var(--green);
    background: var(--green-light);
    color: var(--green-dark);
}
.chatbot-cta svg { width: 14px; height: 14px; }

/* ----- Mobile ----- */
@media (max-width: 480px) {
    #chatbot-window {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 96px;
        height: calc(100vh - 120px);
    }
    #lkg-fab {
        bottom: 16px;
        right: 16px;
    }
}
