/* AI Chatbot Frontend Styles */

#ai-chatbot-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* Default Position (bottom-right) */
    bottom: var(--widget-bottom-offset, 20px);
    right: var(--widget-right-offset, 20px);
}

/* Position Varianten */
#ai-chatbot-widget.bottom-left {
    bottom: var(--widget-bottom-offset, 20px);
    left: var(--widget-right-offset, 20px);
    right: auto;
}

#ai-chatbot-widget.top-right {
    top: var(--widget-bottom-offset, 20px);
    right: var(--widget-right-offset, 20px);
    bottom: auto;
}

#ai-chatbot-widget.top-left {
    top: var(--widget-bottom-offset, 20px);
    left: var(--widget-right-offset, 20px);
    bottom: auto;
    right: auto;
}

#ai-chatbot-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--button-bg-color, #007cba);
    color: var(--button-text-color, #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    border: none;
}

#ai-chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

#ai-chatbot-container {
    position: absolute;
    background-color: var(--chat-bg-color, #ffffff);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    
    /* Default Position für Chat-Container */
    bottom: 80px;
    right: 0;
    
    /* Default Größe (medium) */
    width: 380px;
    height: 500px;
}

/* Container-Positionierung je nach Widget-Position */
#ai-chatbot-widget.bottom-right #ai-chatbot-container {
    bottom: 80px;
    right: 0;
}

#ai-chatbot-widget.bottom-left #ai-chatbot-container {
    bottom: 80px;
    left: 0;
}

#ai-chatbot-widget.top-right #ai-chatbot-container {
    top: 80px;
    right: 0;
}

#ai-chatbot-widget.top-left #ai-chatbot-container {
    top: 80px;
    left: 0;
}

/* Größenvarianten */
#ai-chatbot-container.size-small {
    width: 320px;
    height: 400px;
}

#ai-chatbot-container.size-medium {
    width: 380px;
    height: 500px;
}

#ai-chatbot-container.size-large {
    width: 450px;
    height: 600px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideLeft {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Animationen je nach Position */
#ai-chatbot-widget.bottom-right #ai-chatbot-container,
#ai-chatbot-widget.bottom-left #ai-chatbot-container {
    animation: slideUp 0.3s ease;
}

#ai-chatbot-widget.top-right #ai-chatbot-container,
#ai-chatbot-widget.top-left #ai-chatbot-container {
    animation: slideDown 0.3s ease;
}

#ai-chatbot-header {
    background-color: var(--button-bg-color, #007cba);
    color: var(--button-text-color, #ffffff);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#ai-chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--header-text-color, #ffffff);
}

#ai-chatbot-close {
    background: none;
    border: none;
    color: var(--button-text-color, #ffffff);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

#ai-chatbot-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ai-chatbot-message {
    display: flex;
    max-width: 80%;
    word-wrap: break-word;
}

.ai-chatbot-message.user-message {
    align-self: flex-end;
}

.ai-chatbot-message.bot-message {
    align-self: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--chat-text-color, #333333);
}

.user-message .message-content {
    background-color: var(--user-bubble-color, #007cba);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    background-color: var(--bot-bubble-color, #f1f1f1);
    color: var(--chat-text-color, #333333);
    border-bottom-left-radius: 4px;
}

/* Links in Bot-Nachrichten */
.bot-message .message-content a {
    font-size: 14px !important;
    color: #0073aa !important;
    text-decoration: underline !important;
    transition: color 0.2s ease;
}

.bot-message .message-content a:hover {
    font-size: 14px !important;
    color: #005a87 !important;
    text-decoration: underline !important;
}

.bot-message .message-content a:visited {
    font-size: 14px !important;
    color: #5c2e91 !important;
}

/* Tel-Links spezielle Farbe */
.bot-message .message-content a[href^="tel:"] {
    font-size: 14px !important;
    color: #0d7377 !important;
}

.bot-message .message-content a[href^="tel:"]:hover {
    font-size: 14px !important;
    color: #0a5d61 !important;
}

/* E-Mail-Links spezielle Farbe */
.bot-message .message-content a[href^="mailto:"] {
    font-size: 14px !important;
    color: #d63031 !important;
}

.bot-message .message-content a[href^="mailto:"]:hover {
    font-size: 14px !important;
    color: #b71c1c !important;
}

#ai-chatbot-input-container {
    padding: 20px;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 10px;
    align-items: center;
}

#ai-chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

#ai-chatbot-input:focus {
    border-color: var(--button-bg-color, #007cba);
}

#ai-chatbot-send {
    padding: 0;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: var(--button-bg-color, #007cba);
    color: var(--button-text-color, #ffffff);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#ai-chatbot-send svg {
    width: 30px;
    height: 30px;
}

#ai-chatbot-send:hover {
    background-color: var(--button-bg-color, #005a87);
    transform: scale(1.05);
}

#ai-chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ai-chatbot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background-color: var(--bot-bubble-color, #f1f1f1);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 80%;
    align-self: flex-start;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #999;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #ai-chatbot-widget {
        /* Mobile: Feste Position unten rechts */
        bottom: 20px !important;
        right: 20px !important;
        left: auto !important;
        top: auto !important;
    }
    
    #ai-chatbot-container {
        /* Mobile: Angepasste Größe */
        width: 320px !important;
        height: 400px !important;
        bottom: 70px !important;
        right: 0 !important;
        left: auto !important;
        top: auto !important;
    }
    
    #ai-chatbot-button {
        width: 55px;
        height: 55px;
        z-index: 999;
    }
    
    /* Mobile: Container immer von rechts */
    #ai-chatbot-widget.bottom-left #ai-chatbot-container,
    #ai-chatbot-widget.top-left #ai-chatbot-container,
    #ai-chatbot-widget.top-right #ai-chatbot-container {
        bottom: 70px !important;
        right: 0 !important;
        left: auto !important;
        top: auto !important;
        z-index: 999;
    }
}

/* Scrollbar Styling */
#ai-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#ai-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#ai-chatbot-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

#ai-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

/* CTA Button Styling - Dezent wie Bot-Antwort */
.ai-chatbot-cta {
    display: flex;
    max-width: 80%;
    align-self: flex-start;
    margin-top: 5px;
    word-wrap: break-word;
}

.cta-button {
    background-color: var(--bot-bubble-color, #f1f1f1) !important;
    color: var(--chat-text-color, #333333) !important;
    padding: 12px 16px !important;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    text-decoration: none;
    font-size: 14px !important;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    text-align: left;
    display: block;
    width: 100%;
    line-height: 1.4;
    box-shadow: none;
}

.cta-button:hover {
    background-color: #e8e8e8;
    color: var(--button-bg-color, #007cba);
    text-decoration: underline;
    transform: none;
    box-shadow: none;
}

.cta-button:active {
    background-color: #e0e0e0;
    transform: none;
}

/* CTA responsive */
@media (max-width: 480px) {
    .cta-button {
        font-size: 14px;
        padding: 12px 16px;
    }
}

/* E-Mail-Fallback Styles */
.ai-chatbot-email-fallback {
    background: #f9f9f9;
    border: 1px solid #e1e1e1;
    border-radius: 12px;
    padding: 16px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.email-fallback-prompt {
    margin-bottom: 15px;
}

.email-fallback-prompt p {
    margin: 0;
    color: #333;
    font-size: 14px;
    line-height: 1.4;
}

.email-fallback-form {
    margin-bottom: 10px;
}

#email-fallback-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

#email-fallback-input:focus {
    outline: none;
    border-color: var(--button-bg-color, #007cba);
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.email-fallback-buttons {
    display: flex;
    gap: 8px;
}

.email-fallback-buttons .email-send-btn,
.email-fallback-buttons .email-cancel-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.email-fallback-buttons .email-send-btn {
    background-color: var(--button-bg-color, #007cba);
    color: white;
}

.email-send-btn:hover:not(:disabled) {
    background-color: #005a87;
    transform: translateY(-1px);
}

.email-send-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

.email-cancel-btn {
    background-color: #f5f5f5;
    color: #666;
    border: 1px solid #ddd;
}

.email-cancel-btn:hover {
    background-color: #e8e8e8;
    border-color: #bbb;
    transform: translateY(-1px);
}

.email-fallback-status {
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.4;
}

.email-fallback-status .success {
    color: #16a34a;
    font-weight: 500;
}

.email-fallback-status .error {
    color: #dc2626;
    font-weight: 500;
}

.email-fallback-status .sending {
    color: #2563eb;
    font-weight: 500;
}

/* E-Mail-Fallback responsive */
@media (max-width: 480px) {
    .ai-chatbot-email-fallback {
        padding: 14px;
    }
    
    .email-fallback-buttons {
        flex-direction: column;
    }
    
    .email-send-btn,
    .email-cancel-btn {
        width: 100%;
        margin-bottom: 6px;
    }
    
    .email-cancel-btn {
        margin-bottom: 0;
    }
}
