/**
Chatbot - CSS
 */
#chatbot-sticker {
    position: fixed;
    bottom: 10px;
    right: 10px;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 30px;
    cursor: pointer;
    z-index: 99999;
    background: linear-gradient(135deg, #3170B5 0%, #1f4a7a 100%);
    border-radius: 50% !important;
    color: white;
    box-shadow: 0 4px 12px rgba(49, 112, 181, 0.4);
    transition: all 0.3s ease;
    border: 2px solid white;
}

#chatbot-sticker:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(49, 112, 181, 0.6);
}

#chatbot-sticker > i {
    font-size: 30px;
}

#chatbox {
    position: fixed;
    bottom: 15px;
    right: 15px;
    min-width: 400px;
    max-width: 500px;
    height: 500px;
    max-height: 70vh;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all .4s ease;
}

#chatbox.expand {
    min-width: 1000px;
    max-width: 95%;
    height: 800px;
    max-height: 80%;
}


@media all and (max-width: 767px) {
    #chatbox {
        right: 0;
    }

    #chatbot-toggle {
        width: 18px;
        right: -18px;
    }

    .chatbot-hide-button {
        display: none !important;
    }
}

@media all and (max-width: 425px) {
    #chatbox {
        width: 95%;
        min-width: 100px;
    }

    #resize-chat {
        display: none;
    }

    #chatbot-toggle {
        width: 16px;
        right: -16px;
    }
}

#chatbox-header {
    background-color: #3170B5;
    color: #fff;
    padding: 15px;
    text-align: center;
    font-size: 16px;
    border-radius: 10px 10px 0 0;
}

.clear-chat-button,
.resize-chat-button {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 14px;
    right: 40px;
    z-index: 10;
}

.clear-chat-button:hover {
    color: #ffcc00;
}

.resize-chat-button {
    right: 80px;
}

#chatbox-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #ffffff;
    scroll-behavior: smooth;
}

.chat-message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.gpt {
    align-items: flex-start;
}

.chat-message.agent {
    align-items: flex-start;
}

.chat-message .sender {
    font-weight: bold;
    font-size: 12px;
    color: #888;
    margin-bottom: 5px;
}

.chat-message .message {
    max-width: 100%;
    padding: 12px 15px;
    border-radius: 10px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

#chatbox.expand .chat-message .message {
    max-width: 90%;
}

.chat-message.user .message {
    background-color: #477db2;
    color: #fff;
    border-top-right-radius: 0;
}

/* Speech bubble arrow for user messages (right side) */
.chat-message.user .message::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 15px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 0 solid transparent;
    border-bottom: 8px solid #477db2;
}

.chat-message.user .message a {
    color: #fff;
    text-decoration: underline;
}

.chat-message.user .message p {
    margin: 0;
}

.chat-message .message p:last-child {
    margin-bottom: 0 !important;
}

.chat-message.user .message a:hover {
    text-decoration: none;
}

.chat-message.gpt .message {
    background-color: #f1f1f1;
    color: #333;
    border-top-left-radius: 0;
}

/* Speech bubble arrow for bot messages (left side) */
.chat-message.gpt .message::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 15px;
    width: 0;
    height: 0;
    border-left: 0 solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #f1f1f1;
}

/* Agent messages - light blue background */
.chat-message.agent .message {
    background-color: #e3f2fd;
    color: #333;
    border-top-left-radius: 0;
}

/* Speech bubble arrow for agent messages (left side) */
.chat-message.agent .message::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 15px;
    width: 0;
    height: 0;
    border-left: 0 solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #e3f2fd;
}

.chat-message .suggestions {
    background: #DDD;
    margin: 1em 0 !important;
    margin-bottom: 0 !important;
    padding: 1em 2em !important;
    color: #666;
}

.chat-message .suggestions li {
    padding: 0 !important;
    list-style-type: disclosure-closed;
}

.chat-message .suggestions a.question {
}

#chatbox-input {
    display: flex;
    border-top: 1px solid #ddd;
    padding: 10px;
    background-color: #f9f9f9;
}

#chatbox-input input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

#chatbox-input input:focus {
    outline: none;
    border-color: #ddd;
    box-shadow: none;
}

#chatbox-input button {
    margin-left: 5px;
    background: #3170B5;
    color: #fff;
    border: none;
    padding: 12px 18px;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#chatbox-input button:hover {
    background-color: #27568f;
}

/* Voice Input Button */
#voice-input-btn {
    background: #6c757d !important;
    padding: 12px 18px !important;
    margin-left: 5px !important;
}

#voice-input-btn:hover {
    background-color: #5a6268 !important;
}

#voice-input-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#voice-input-btn i {
    font-size: 16px;
}

/* Pulsing animation when listening */
#voice-input-btn.listening {
    background: #ffc107 !important;
    animation: pulse 1s infinite;
}

#voice-input-btn.listening i {
    animation: iconBounce 0.6s infinite;
    color: white;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 179, 237, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(99, 179, 237, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(99, 179, 237, 0);
    }
}

@keyframes iconBounce {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.1);
    }
    75% {
        transform: scale(0.95);
    }
}

#loading-indicator {
    display: none;
    align-self: center;
    margin: 10px 0;
    color: #3170B5;
    font-size: 14px;
    font-weight: bold;
    animation: fadeInOut 1s infinite;
}

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 1;
    }
}

.close-chat-button {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 14px;
    right: 10px;
}

.close-chat-button:hover {
    color: #f00;
}

#chatbox ul,
#chatbox ol {
    padding: .2em 1em .2em;
}

#chatbox li {
    padding: .1em 0;
}

#chatbox ul li {
    list-style-type: '- ';
}

#chatbox li p {
    margin: 0;
}

#chatbox h1,
#chatbox h2,
#chatbox h3,
#chatbox h4,
#chatbox h5,
#chatbox h6 {
    font-size: 1.3em;
    font-weight: bold !important;
    margin-top: 15px;
    margin-bottom: 15px;
}

#chatbox h1 {
    font-size: 1.7em;
}

#chatbox h2 {
    font-size: 1.5em;
}


/* X-Button zum Ausblenden des Stickers */
#chatbot-sticker {
    position: relative;
}

.chatbot-hide-button {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 22px;
    height: 22px;
    background: #787878;
    border: none;
    border-radius: 50% !important;
    cursor: pointer;
    z-index: 1001;
    transition: background 0.2s ease, transform 0.2s ease;
    padding: 0;
    display: flex !important;
    justify-content: center;
    align-items: center;
    color: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.chatbot-hide-button i {
    font-size: 12px !important;
}

#chatbot-sticker:hover .chatbot-hide-button {
    background: #666666;
}

.chatbot-hide-button:hover {
    color: #ff4444;
    transform: scale(1.15);
}

/* Hide X-Button when chatbox is open */
#chatbot-sticker.chat-open .chatbot-hide-button {
    opacity: 0;
    pointer-events: none;
}

/* Toggle Button für Chatbot-Sticker */
#chatbot-toggle {
    position: fixed;
    bottom: 30px;
    left: auto;
    right: -24px;
    width: 24px;
    height: 40px;
    background: rgba(100, 100, 100, 0.6);
    color: white;
    border-radius: 3px 0 0 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 99998;
    transition: right 0.3s ease, background 0.2s ease, opacity 0.3s ease;
    box-shadow: -1px 1px 3px rgba(0, 0, 0, 0.1);
    opacity: 0;
    pointer-events: none;
    border: none;
}

#chatbot-toggle:hover {
    background: rgba(80, 80, 80, 0.8);
}

#chatbot-toggle i {
    font-size: 18px;
    transition: transform 0.3s ease;
}

/* Wenn Sticker ausgeblendet ist */
#chatbot-sticker.collapsed {
    transform: translateX(calc(100% + 20px));
}

/* Toggle Button sichtbar machen wenn Sticker collapsed */
body.chatbot-collapsed #chatbot-toggle {
    right: 0;
    opacity: 1;
    pointer-events: all;
}

/* Pfeil-Icon drehen */
body.chatbot-collapsed #chatbot-toggle i {
    transform: rotate(180deg);
}

/* Ensure fixed positioning is maintained */
#chatbot-sticker {
    position: fixed !important;
    transition: transform 0.3s ease;
}

/* Speaker Button for Text-to-Speech */
.btn-speak {
    background: transparent;
    border: none;
    color: #999;
    font-size: 14px;
    cursor: pointer;
    margin-left: 8px;
    padding: 0;
    transition: color 0.2s ease, transform 0.2s ease;
    display: inline-block;
    vertical-align: middle;
}

.chat-message.user .btn-speak {
    color: rgba(255, 255, 255, 0.7);
}

.chat-message.gpt .btn-speak {
    color: #999;
}

.chat-message.agent .btn-speak {
    color: #999;
}

.btn-speak:hover {
    transform: scale(1.2);
}

.chat-message.user .btn-speak:hover {
    color: rgba(255, 255, 255, 1);
}

.chat-message.gpt .btn-speak:hover {
    color: #3170B5;
}

.chat-message.agent .btn-speak:hover {
    color: #3170B5;
}

.btn-speak i {
    font-size: 14px;
}

/* Request Agent Button */
#request-agent-btn {
    background: transparent;
    border: none;
    color: #fff;
    padding: 0;
    margin-left: 8px;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

#request-agent-btn:hover:not(:disabled):not(.disabled) {
    color: #ffcc00;
    transform: scale(1.15);
}

#request-agent-btn:disabled,
#request-agent-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

#request-agent-btn i {
    font-size: 16px;
}

/* Ensure tooltips are always visible above chatbox */
.tooltip {
    z-index: 100001 !important;
}

.tooltip-inner {
    z-index: 100001 !important;
}

/* Agent name display in header */
#agent-name-display {
    font-size: 0.9em;
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.8);
}

/* Chat closed message */
.chat-closed-message {
    text-align: center;
    padding: 20px 15px;
    margin: 20px 0;
}

/* ChatBot Agent Request Modal */
.chatbot-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100002;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.chatbot-modal-content {
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    z-index: 2;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chatbot-modal-header {
    padding: 20px 20px 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-modal-header h4 {
    margin: 0;
    font-size: 18px;
    color: #333;
    font-weight: 600;
}

.chatbot-modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #888;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.chatbot-modal-close:hover {
    color: #f00;
}

.chatbot-modal-body {
    padding: 20px;
}

.chatbot-modal-body .form-group {
    margin-bottom: 15px;
}

.chatbot-modal-body .form-group:last-child {
    margin-bottom: 0;
}

.chatbot-modal-body label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

.chatbot-modal-body input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-modal-body input:focus {
    outline: none;
    border-color: #3170B5;
    box-shadow: 0 0 0 3px rgba(49, 112, 181, 0.1);
}

.chatbot-modal-body input.error {
    border-color: #dc3545;
}

.chatbot-modal-body input.error:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.chatbot-modal-body span.error-text {
    display: block;
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
}

.chatbot-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.chatbot-modal-footer .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.chatbot-modal-footer .btn:active {
    transform: scale(0.98);
}

.chatbot-modal-footer .btn-default {
    background: #f5f5f5;
    color: #333;
}

.chatbot-modal-footer .btn-default:hover {
    background: #e0e0e0;
}

.chatbot-modal-footer .btn-primary {
    background: #3170B5;
    color: white;
}

.chatbot-modal-footer .btn-primary:hover {
    background: #27568f;
}

@media all and (max-width: 500px) {
    .chatbot-modal-content {
        max-width: 95%;
        margin: 0 10px;
    }
}