/* ========== CHATBOT WIDGET — COSMO ========== */

/* Chat-Button (geschlossen) */
.chatbot-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 25%, rgba(123, 47, 247, 0.25) 0%, transparent 40%),
        radial-gradient(circle at 70% 60%, rgba(0, 212, 255, 0.12) 0%, transparent 35%),
        radial-gradient(circle at 55% 85%, rgba(255, 45, 149, 0.1) 0%, transparent 30%),
        radial-gradient(circle at 50% 50%, #0a0a0f 0%, #0d0520 50%, #1a0a3e 100%);
    border: 1.5px solid rgba(123, 47, 247, 0.3);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.3s ease;
    animation: cosmo-float 2.5s ease-in-out infinite;
    box-shadow:
        0 0 18px rgba(123, 47, 247, 0.3),
        0 0 35px rgba(0, 212, 255, 0.08),
        inset 0 0 15px rgba(123, 47, 247, 0.08);
    overflow: visible;
    will-change: transform;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.chatbot-btn:hover {
    animation: cosmo-float 2.5s ease-in-out infinite;
    transform: scale(1.1);
    border-color: rgba(0, 212, 255, 0.45);
    box-shadow:
        0 0 22px rgba(123, 47, 247, 0.4),
        0 0 45px rgba(0, 212, 255, 0.15),
        inset 0 0 20px rgba(123, 47, 247, 0.1);
}

.chatbot-btn svg {
    width: 82px;
    height: 90px;
    margin-top: -20px;
    margin-left: -5px;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
    overflow: visible;
}

/* Schwebende Animation — bouncy und einladend */
@keyframes cosmo-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* Dezenter Portal-Ring */
.chatbot-btn::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1.5px solid transparent;
    background: conic-gradient(from 0deg, rgba(123, 47, 247, 0.5), rgba(0, 212, 255, 0.3), rgba(255, 45, 149, 0.3), rgba(123, 47, 247, 0.5)) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: cosmo-ring-spin 4s linear infinite;
    opacity: 0.6;
}

.chatbot-btn:hover::before {
    opacity: 0.85;
}

@keyframes cosmo-ring-spin {
    to { transform: rotate(360deg); }
}

/* Subtiler Aura-Glow */
.chatbot-btn::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(123, 47, 247, 0.12), transparent 70%);
    z-index: -1;
    filter: blur(6px);
    animation: cosmo-aura 2.5s ease-in-out infinite alternate;
}

@keyframes cosmo-aura {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.3); opacity: 0.1; }
}

/* ========== Chat-Fenster ========== */
.chatbot-window {
    position: fixed;
    bottom: 114px;
    right: 28px;
    width: 380px;
    max-height: min(600px, calc(100vh - 140px));
    background:
        /* Nebel-Wolken */
        radial-gradient(ellipse at 12% 25%, rgba(123, 47, 247, 0.09) 0%, transparent 40%),
        radial-gradient(ellipse at 88% 65%, rgba(0, 212, 255, 0.06) 0%, transparent 35%),
        radial-gradient(ellipse at 60% 45%, rgba(255, 45, 149, 0.04) 0%, transparent 30%),
        radial-gradient(ellipse at 25% 80%, rgba(123, 47, 247, 0.05) 0%, transparent 30%),
        /* Sternenfeld */
        radial-gradient(1.2px 1.2px at 5% 12%, rgba(255,255,255,0.55), transparent),
        radial-gradient(1px 1px at 12% 28%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1.2px 1.2px at 22% 18%, rgba(0,212,255,0.5), transparent),
        radial-gradient(1px 1px at 35% 8%, rgba(255,255,255,0.35), transparent),
        radial-gradient(1.2px 1.2px at 48% 22%, rgba(255,255,255,0.45), transparent),
        radial-gradient(1px 1px at 65% 12%, rgba(255,45,149,0.35), transparent),
        radial-gradient(1.2px 1.2px at 78% 18%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 92% 15%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 8% 42%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1.2px 1.2px at 18% 50%, rgba(123,47,247,0.45), transparent),
        radial-gradient(1px 1px at 30% 38%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 45% 45%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1.2px 1.2px at 58% 35%, rgba(0,212,255,0.35), transparent),
        radial-gradient(1px 1px at 72% 42%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 88% 38%, rgba(255,255,255,0.35), transparent),
        radial-gradient(1.2px 1.2px at 95% 48%, rgba(255,45,149,0.3), transparent),
        radial-gradient(1px 1px at 6% 62%, rgba(0,212,255,0.35), transparent),
        radial-gradient(1.2px 1.2px at 15% 72%, rgba(255,255,255,0.45), transparent),
        radial-gradient(1px 1px at 28% 65%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 42% 58%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1.2px 1.2px at 55% 68%, rgba(123,47,247,0.3), transparent),
        radial-gradient(1px 1px at 68% 60%, rgba(255,255,255,0.35), transparent),
        radial-gradient(1px 1px at 82% 65%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1.2px 1.2px at 93% 58%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 10% 85%, rgba(255,255,255,0.35), transparent),
        radial-gradient(1px 1px at 25% 90%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1.2px 1.2px at 40% 82%, rgba(0,212,255,0.3), transparent),
        radial-gradient(1px 1px at 55% 88%, rgba(255,255,255,0.35), transparent),
        radial-gradient(1px 1px at 70% 82%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 85% 90%, rgba(255,45,149,0.25), transparent),
        radial-gradient(1.2px 1.2px at 95% 80%, rgba(255,255,255,0.35), transparent),
        rgba(6, 6, 16, 0.94);
    border: 1px solid rgba(123, 47, 247, 0.2);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 20px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.5),
        0 0 60px rgba(123, 47, 247, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Saturn-Planet im Chat-Fenster (fixiert) */
.chatbot-window::after {
    content: '';
    position: absolute;
    top: 62px;
    right: 18px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 30%, #8b6fbf, #5a3d8a 50%, #2a1558);
    box-shadow:
        inset -4px -3px 5px rgba(0,0,0,0.35),
        inset 2px 2px 4px rgba(160,120,220,0.2),
        0 0 10px rgba(123,47,247,0.15);
    opacity: 0.45;
    pointer-events: none;
    z-index: 0;
}

/* Saturn-Ring */
.chatbot-window::before {
    content: '';
    position: absolute;
    top: 68px;
    right: 8px;
    width: 42px;
    height: 12px;
    border: 1.5px solid rgba(212, 168, 83, 0.3);
    border-radius: 50%;
    transform: rotate(-20deg);
    pointer-events: none;
    z-index: 0;
}

.chatbot-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header — Galaxie-Cockpit Feeling */
.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(123, 47, 247, 0.15);
    background:
        radial-gradient(ellipse at 70% 50%, rgba(0, 212, 255, 0.05) 0%, transparent 60%),
        linear-gradient(180deg, rgba(123, 47, 247, 0.1), rgba(123, 47, 247, 0.02));
    position: relative;
}

/* Sterne im Header (CSS-only) */
.chatbot-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 15% 30%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 45% 70%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 75% 20%, rgba(0,212,255,0.5), transparent),
        radial-gradient(1px 1px at 90% 60%, rgba(255,45,149,0.4), transparent),
        radial-gradient(1px 1px at 30% 85%, rgba(255,255,255,0.3), transparent);
    pointer-events: none;
}

.chatbot-header__left {
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1;
}

.chatbot-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%, rgba(123, 47, 247, 0.3), transparent 50%),
        radial-gradient(circle at 65% 70%, rgba(0, 212, 255, 0.15), transparent 50%),
        rgba(10, 10, 25, 0.95);
    border: 1px solid rgba(0, 212, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
    flex-shrink: 0;
    z-index: 2;
}

.chatbot-avatar svg {
    width: 42px;
    height: 42px;
    filter: drop-shadow(0 0 3px rgba(0, 212, 255, 0.4));
    overflow: visible;
}

/* Online-Punkt */
.chatbot-avatar::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #00d4ff;
    border: 2px solid rgba(8, 8, 18, 0.95);
    box-shadow: 0 0 6px rgba(0, 212, 255, 0.6);
    animation: cosmo-pulse 2.5s ease-in-out infinite;
}

@keyframes cosmo-pulse {
    0%, 100% { box-shadow: 0 0 6px rgba(0, 212, 255, 0.6); }
    50% { box-shadow: 0 0 12px rgba(0, 212, 255, 0.9), 0 0 20px rgba(0, 212, 255, 0.3); }
}

.chatbot-header__info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    z-index: 1;
}

.chatbot-header__name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text-primary);
}

.chatbot-header__status {
    font-size: 0.68rem;
    color: rgba(0, 212, 255, 0.6);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.chatbot-close {
    width: 30px;
    height: 30px;
    z-index: 1;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

/* ========== Chat-Bereich ========== */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
    max-height: 290px;
    scrollbar-width: thin;
    scrollbar-color: rgba(123, 47, 247, 0.15) transparent;
    position: relative;
    background: transparent;
    z-index: 1;
}

.chatbot-messages::-webkit-scrollbar { width: 3px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(123, 47, 247, 0.2);
    border-radius: 3px;
}

/* Nachrichten-Bubbles */
.chatbot-msg {
    max-width: 88%;
    padding: 11px 15px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.6;
    animation: cosmo-msg-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cosmo-msg-in {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.chatbot-msg--bot {
    align-self: flex-start;
    background: linear-gradient(135deg, rgba(123, 47, 247, 0.1), rgba(123, 47, 247, 0.05));
    border: 1px solid rgba(123, 47, 247, 0.15);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}

.chatbot-msg--bot a {
    color: #00d4ff;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 212, 255, 0.3);
    transition: border-color 0.2s;
}

.chatbot-msg--bot a:hover {
    border-color: #00d4ff;
}

.chatbot-msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.12), rgba(0, 212, 255, 0.06));
    border: 1px solid rgba(0, 212, 255, 0.15);
    border-bottom-right-radius: 4px;
    color: var(--text-primary);
}

/* Antwort-Aktionen */
.chatbot-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.chatbot-actions button,
.chatbot-actions a {
    padding: 7px 14px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.chatbot-action-back {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.chatbot-action-back:hover {
    background: rgba(123, 47, 247, 0.1);
    border-color: rgba(123, 47, 247, 0.25);
    color: var(--text-primary);
}

.chatbot-action-contact {
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.25);
    color: #00d4ff;
}

.chatbot-action-contact:hover {
    background: rgba(0, 212, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.4);
}

/* Vorgefertigte Fragen */
.chatbot-questions {
    padding: 14px 18px;
    border-top: 1px solid rgba(123, 47, 247, 0.12);
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: rgba(6, 6, 16, 0.3);
    position: relative;
    z-index: 1;
}

.chatbot-question-btn {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.chatbot-question-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(123, 47, 247, 0.4);
    opacity: 0;
    transition: opacity 0.2s;
}

.chatbot-question-btn:hover {
    background: rgba(123, 47, 247, 0.08);
    border-color: rgba(123, 47, 247, 0.2);
    color: var(--text-primary);
    padding-left: 18px;
}

.chatbot-question-btn:hover::before {
    opacity: 1;
}

/* Typing-Indikator */
.chatbot-typing {
    display: flex;
    gap: 5px;
    padding: 11px 15px;
    align-self: flex-start;
    background: linear-gradient(135deg, rgba(123, 47, 247, 0.08), transparent);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(123, 47, 247, 0.1);
}

.chatbot-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(0, 212, 255, 0.6);
    animation: cosmo-typing 1.4s ease-in-out infinite;
}

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

@keyframes cosmo-typing {
    0%, 70%, 100% { transform: translateY(0); opacity: 0.3; }
    35% { transform: translateY(-8px); opacity: 1; }
}

/* ========== MOBILE ========== */
@media (max-width: 768px) {
    /* Button — kleiner, weniger Effekte fuer Performance */
    .chatbot-btn {
        bottom: 20px;
        right: 20px;
        width: 62px;
        height: 62px;
        box-shadow: 0 0 12px rgba(123, 47, 247, 0.25);
    }

    .chatbot-btn svg {
        width: 62px;
        height: 68px;
        margin-top: -16px;
        margin-left: -4px;
    }

    /* Ring-Animation auf Mobile deaktivieren (spart GPU) */
    .chatbot-btn::before {
        animation: none;
        opacity: 0.4;
    }

    /* Aura auf Mobile deaktivieren */
    .chatbot-btn::after {
        animation: none;
        opacity: 0.2;
    }

    /* Chat-Fenster — Fullscreen, smooth */
    .chatbot-window {
        inset: 0;
        width: 100%;
        max-height: 100%;
        height: 100dvh;
        height: 100%;
        border-radius: 0;
        bottom: 0;
        right: 0;
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background:
            radial-gradient(ellipse at 12% 25%, rgba(123, 47, 247, 0.07) 0%, transparent 40%),
            radial-gradient(ellipse at 88% 65%, rgba(0, 212, 255, 0.04) 0%, transparent 35%),
            radial-gradient(1px 1px at 5% 12%, rgba(255,255,255,0.4), transparent),
            radial-gradient(1px 1px at 22% 18%, rgba(0,212,255,0.35), transparent),
            radial-gradient(1px 1px at 48% 22%, rgba(255,255,255,0.35), transparent),
            radial-gradient(1px 1px at 78% 18%, rgba(255,255,255,0.4), transparent),
            radial-gradient(1px 1px at 18% 50%, rgba(123,47,247,0.3), transparent),
            radial-gradient(1px 1px at 58% 35%, rgba(0,212,255,0.25), transparent),
            radial-gradient(1px 1px at 88% 38%, rgba(255,255,255,0.3), transparent),
            radial-gradient(1px 1px at 15% 72%, rgba(255,255,255,0.35), transparent),
            radial-gradient(1px 1px at 55% 68%, rgba(123,47,247,0.2), transparent),
            radial-gradient(1px 1px at 82% 65%, rgba(255,255,255,0.25), transparent),
            radial-gradient(1px 1px at 40% 82%, rgba(0,212,255,0.2), transparent),
            radial-gradient(1px 1px at 85% 90%, rgba(255,45,149,0.15), transparent),
            rgba(6, 6, 16, 0.98);
        will-change: transform;
    }

    .chatbot-window.open {
        transform: translateY(0);
    }

    /* Header — safe area fuer Notch */
    .chatbot-header {
        padding: 14px 18px;
        padding-top: max(14px, env(safe-area-inset-top));
    }

    /* Messages — smooth scrollen */
    .chatbot-messages {
        max-height: none;
        flex: 1;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Fragen — safe area fuer Home-Indicator */
    .chatbot-questions {
        padding: 12px 16px;
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }

    .chatbot-question-btn {
        padding: 12px 14px;
        min-height: 44px;
        -webkit-tap-highlight-color: transparent;
    }

    /* Avatar etwas kleiner */
    .chatbot-avatar {
        width: 44px;
        height: 44px;
    }

    .chatbot-avatar svg {
        width: 38px;
        height: 38px;
    }

    /* Close-Button groesser fuer Touch */
    .chatbot-close {
        width: 36px;
        height: 36px;
    }

    /* Nachrichten-Bubbles Touch-optimiert */
    .chatbot-msg {
        -webkit-tap-highlight-color: transparent;
    }

    .chatbot-actions button,
    .chatbot-actions a {
        padding: 10px 16px;
        min-height: 44px;
        -webkit-tap-highlight-color: transparent;
    }

    /* Saturn auf Mobile kleiner */
    .chatbot-window::after {
        width: 16px;
        height: 16px;
        top: max(58px, calc(env(safe-area-inset-top) + 50px));
        opacity: 0.35;
    }

    .chatbot-window::before {
        width: 32px;
        height: 9px;
        top: max(63px, calc(env(safe-area-inset-top) + 55px));
        right: 10px;
    }
}

/* Kleine Handys */
@media (max-width: 380px) {
    .chatbot-btn {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .chatbot-btn svg {
        width: 54px;
        height: 58px;
        margin-top: -14px;
        margin-left: -3px;
    }

    .chatbot-msg {
        max-width: 92%;
        font-size: 0.82rem;
    }

    .chatbot-question-btn {
        font-size: 0.8rem;
    }
}
