/* =========================================================
   360graddenken — Chatbot-Widget
   Nutzt die Theme-Variablen (--grad-primary etc.) mit Fallbacks.
   ========================================================= */

.gradchat {
    --gc-primary: var(--grad-primary, #408ec6);
    --gc-tertiary: var(--grad-tertiary, #1e2761);
    --gc-bot-bg: #f4f5f7;
    --gc-bot-text: #1e2761;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99999;
    font-family: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* --- Toggle-Bubble --- */
.gradchat-toggle {
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    background: var(--gc-primary);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(30, 39, 97, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.15s ease;
}
.gradchat-toggle:hover {
    transform: translateY(-2px) scale(1.04);
    background: var(--gc-tertiary);
}
.gradchat-toggle svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}
.gradchat.is-open .gradchat-toggle {
    transform: scale(0.9);
    opacity: 0;
    pointer-events: none;
}

/* --- Panel --- */
.gradchat-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 370px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(30, 39, 97, 0.30);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: gradchat-in 0.18s ease;
}
/* Panel nur sichtbar, wenn geöffnet (verhindert das aufgeklappte Starten) */
.gradchat.is-open .gradchat-panel {
    display: flex;
}
@keyframes gradchat-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.gradchat-header {
    background: var(--gc-tertiary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
}
.gradchat-title {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.2px;
}
.gradchat-close {
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.85;
    padding: 0 4px;
}
.gradchat-close:hover { opacity: 1; }

/* --- Log --- */
.gradchat-log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fff;
}
.gradchat-msg {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.gradchat-msg a { color: var(--gc-primary); text-decoration: underline; }
.gradchat-user {
    align-self: flex-end;
    background: var(--gc-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.gradchat-bot {
    align-self: flex-start;
    background: var(--gc-bot-bg);
    color: var(--gc-bot-text);
    border-bottom-left-radius: 4px;
}

/* --- Typing-Indikator --- */
.gradchat-typing { display: inline-flex; gap: 4px; align-items: center; }
.gradchat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9aa3b2;
    animation: gradchat-bounce 1.1s infinite ease-in-out;
}
.gradchat-typing span:nth-child(2) { animation-delay: 0.18s; }
.gradchat-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes gradchat-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* --- Eingabe --- */
.gradchat-form {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e6e8ee;
    background: #fff;
}
.gradchat-input {
    flex: 1 1 auto;
    border: 1px solid #cfd4de;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.gradchat-input:focus { border-color: var(--gc-primary); box-shadow: 0 0 0 3px rgba(64, 142, 198, 0.18); }
.gradchat-send {
    flex: 0 0 auto;
    border: 0;
    border-radius: 10px;
    background: var(--gc-primary);
    color: #fff;
    width: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}
.gradchat-send:hover { background: var(--gc-tertiary); }
.gradchat-send:disabled { opacity: 0.5; cursor: default; }
.gradchat-send svg { width: 20px; height: 20px; fill: currentColor; }

.gradchat-powered {
    text-align: center;
    font-size: 11px;
    color: #9aa3b2;
    padding: 0 12px 10px;
    background: #fff;
}

/* --- Mobile --- */
@media (max-width: 480px) {
    .gradchat { right: 16px; bottom: 16px; }
    .gradchat-panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 90px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .gradchat-panel, .gradchat-toggle, .gradchat-typing span { animation: none; transition: none; }
}
