/* Chatbot Styles
   Farben aus main.css (:root), Fallbacks falls das Widget ohne main.css läuft */
#chatbot-container {
    --chat-primary: var(--light-brown, #2e5033);
    --chat-accent: var(--orange, #1c7521);
    --chat-surface: var(--cream, #f5f3e9);
    --chat-border: var(--border-grey, #e1dcd3);
    --chat-text: var(--dark, #333);
    --chat-muted: var(--grey, #6e6e6e);

    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: var(--font--secondary, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}

/* Chatbot Button */
.chatbot-button {
    background: var(--chat-primary);
    color: white;
    border: none;
    border-radius: 30px;
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(46, 80, 51, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    font-size: 14px;
    font-weight: 500;
}

.chatbot-button:hover {
    background: var(--chat-accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 80, 51, 0.45);
}

.chatbot-button:focus-visible,
.chatbot-close:focus-visible,
.chatbot-suggestion:focus-visible,
.feedback-btn:focus-visible,
#chatbot-send:focus-visible {
    outline: 2px solid var(--chat-accent);
    outline-offset: 2px;
}

.chatbot-button svg {
    width: 20px;
    height: 20px;
}

/* Chatbot Widget */
.chatbot-widget {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.chatbot-widget.hidden {
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    visibility: hidden;
}

/* Header */
.chatbot-header {
    background: var(--chat-primary);
    color: white;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
    line-height: 1.2;
}

.chatbot-title small {
    display: block;
    font-weight: 400;
    font-size: 12px;
    opacity: 0.8;
}

.chatbot-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    padding: 2px;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Messages */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--chat-surface);
}

.message {
    max-width: 85%;
    animation: messageSlide 0.25s ease;
}

.message.user-message {
    align-self: flex-end;
}

.message.bot-message {
    align-self: flex-start;
}

.message-content {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.user-message .message-content {
    background: var(--chat-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    background: white;
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-bottom-left-radius: 4px;
}

.bot-message .message-content a {
    color: var(--chat-accent);
    text-decoration: underline;
}

.error-message .message-content {
    border-color: #e0b4b4;
    background: #fff6f6;
}

/* Suggestions */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chatbot-suggestion {
    background: white;
    border: 1px solid var(--chat-primary);
    color: var(--chat-primary);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.chatbot-suggestion:hover {
    background: var(--chat-primary);
    color: white;
}

/* Typing Indicator */
.chatbot-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    background: white;
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.chatbot-typing.hidden {
    display: none;
}

.chatbot-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--chat-muted);
    animation: typing 1.4s infinite;
}

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

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

/* Input */
.chatbot-input {
    padding: 12px;
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 8px;
    background: white;
}

#chatbot-input-field {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 16px; /* < 16px zoomt iOS beim Fokus */
    outline: none;
    background: white;
}

#chatbot-input-field:focus {
    border-color: var(--chat-primary);
}

#chatbot-send {
    background: var(--chat-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

#chatbot-send:hover {
    background: var(--chat-accent);
}

#chatbot-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Disclaimer */
.chatbot-disclaimer {
    margin: 0;
    padding: 0 12px 10px;
    background: white;
    color: var(--chat-muted);
    font-size: 11px;
    text-align: center;
}

.chatbot-disclaimer a {
    color: var(--chat-muted);
}

/* Feedback Buttons */
.message-feedback {
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.feedback-btn {
    background: none;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.45;
    filter: grayscale(1);
    transition: opacity 0.15s ease, filter 0.15s ease;
}

.feedback-btn:hover:not(:disabled),
.feedback-btn.active {
    opacity: 1;
    filter: none;
}

.feedback-btn:disabled {
    cursor: default;
}

.feedback-thanks {
    font-size: 12px;
    color: var(--chat-muted);
    margin-left: 4px;
}

/* Animations */
@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-6px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .message,
    .chatbot-typing span {
        animation: none;
    }

    .chatbot-widget,
    .chatbot-button {
        transition: none;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    #chatbot-container {
        bottom: 12px;
        right: 12px;
    }

    .chatbot-button {
        padding: 12px;
    }

    .chatbot-button span {
        display: none;
    }
}

/* Auf dem Handy fast Vollbild, sonst bleibt neben der Tastatur kaum Platz */
@media (max-width: 480px) {
    .chatbot-widget {
        position: fixed;
        inset: 8px 8px 72px 8px;
        width: auto;
        max-width: none;
        height: auto;
        max-height: none;
    }
}
