/* ============================================================
   GESPANN-LEXIKON CHATBOT WIDGET
   Version: 2026-02-18
   Nutzt CSS-Variablen aus user.css (--primary-color: #D32F2F)
   ============================================================ */

/* ========================================
   TOGGLE-BUTTON (Floating Action Button)
   ======================================== */

.chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color, #D32F2F);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    padding: 0;
}

.chatbot-toggle:hover {
    background: var(--primary-hover, #b71c1c);
    transform: scale(1.05);
}

.chatbot-toggle svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

/* ========================================
   CHAT-PANEL
   ======================================== */

.chatbot-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--font-main, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif);
}

.chatbot-panel.open {
    display: flex;
}

/* ========================================
   HEADER
   ======================================== */

.chatbot-header {
    background: var(--primary-color, #D32F2F);
    color: #fff;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chatbot-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-header-title svg {
    width: 20px;
    height: 20px;
    fill: #fff;
    flex-shrink: 0;
}

.chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-reset,
.chatbot-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    padding: 2px 6px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
    border-radius: 4px;
}

.chatbot-reset {
    font-size: 16px;
}

.chatbot-reset:hover,
.chatbot-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* ========================================
   NACHRICHTENBEREICH
   ======================================== */

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

/* ========================================
   NACHRICHTEN-BUBBLES
   ======================================== */

.chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

/* Nutzer-Nachricht (rot, rechts) */
.chatbot-msg-user {
    align-self: flex-end;
    background: var(--primary-color, #D32F2F);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Assistenten-Nachricht (weiß, links) */
.chatbot-msg-assistant {
    align-self: flex-start;
    background: #fff;
    color: var(--text-color, #2c3e50);
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.chatbot-msg-assistant p {
    margin: 0 0 8px 0 !important;
    text-align: left !important;
    hyphens: none !important;
    font-size: 14px !important;
}

.chatbot-msg-assistant p:last-child {
    margin-bottom: 0 !important;
}

.chatbot-msg-assistant strong {
    font-weight: 600;
}

.chatbot-msg-assistant em {
    font-style: italic;
}

.chatbot-msg-assistant code {
    background: #f0f0f0;
    border-radius: 3px;
    padding: 1px 5px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
}

.chatbot-msg-assistant ul,
.chatbot-msg-assistant ol {
    margin: 4px 0 8px 0 !important;
    padding-left: 20px !important;
}

.chatbot-msg-assistant li {
    margin-bottom: 3px;
    line-height: 1.5;
}

.chatbot-msg-assistant a {
    color: var(--primary-color, #D32F2F) !important;
    text-decoration: none !important;
}

.chatbot-msg-assistant a:hover {
    text-decoration: underline !important;
}

/* ========================================
   QUELLEN-CHIPS
   ======================================== */

.chatbot-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.chatbot-source-chip {
    display: inline-block;
    padding: 3px 10px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 12px;
    color: var(--primary-color, #D32F2F);
    text-decoration: none;
    transition: background 0.2s;
}

.chatbot-source-chip:hover {
    background: #e3e3e3;
    text-decoration: none;
}

/* ========================================
   BEISPIELFRAGEN
   ======================================== */

.chatbot-examples {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-self: stretch;
}

.chatbot-example-btn {
    background: #fff;
    border: 1px solid var(--primary-color, #D32F2F);
    color: var(--primary-color, #D32F2F);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 13px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    line-height: 1.4;
}

.chatbot-example-btn:hover {
    background: var(--primary-color, #D32F2F);
    color: #fff;
}

/* ========================================
   TYPING-INDIKATOR
   ======================================== */

.chatbot-typing {
    align-self: flex-start;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.chatbot-typing-dot {
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
    animation: chatbot-bounce 1.4s infinite ease-in-out both;
}

.chatbot-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chatbot-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.chatbot-typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes chatbot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ========================================
   FEHLER-NACHRICHT
   ======================================== */

.chatbot-msg-error {
    align-self: flex-start;
    background: #fff3f3;
    color: #c62828;
    border: 1px solid #ffcdd2;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
}

/* ========================================
   EINGABEBEREICH
   ======================================== */

.chatbot-input-area {
    display: flex;
    padding: 12px;
    border-top: 1px solid #e9ecef;
    background: #fff;
    flex-shrink: 0;
    gap: 8px;
}

.chatbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
}

.chatbot-input:focus {
    border-color: var(--primary-color, #D32F2F);
}

.chatbot-input::placeholder {
    color: #aaa;
}

.chatbot-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-color, #D32F2F);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
    padding: 0;
}

.chatbot-send:hover {
    background: var(--primary-hover, #b71c1c);
}

.chatbot-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.chatbot-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* ========================================
   RESPONSIVE (Mobile: Vollbreite unter 480px)
   ======================================== */

@media (max-width: 480px) {
    .chatbot-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .chatbot-toggle {
        bottom: 16px;
        right: 16px;
    }
}

/* ========================================
   DRUCK: Widget ausblenden
   ======================================== */

@media print {
    .chatbot-toggle,
    .chatbot-panel {
        display: none !important;
    }
}
