/* ============================================
   KT FAQ Agent - Aligned to Keller Treuhand Design
   ============================================ */

/* Floating button - bottom right, same size as calendar */
.kt-faq-bubble {
    position: fixed;
    bottom: 30px;
    right: 20px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: white;
    color: #1B2021;
    border: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    transition: transform 0.2s ease-in-out, background 0.3s ease;
    user-select: none;
}

.kt-faq-bubble:hover {
    transform: scale(1.1);
}

/* Bubble when open */
.kt-faq-bubble.kt-open {
    background: #5398BE;
    color: white;
    border-color: transparent;
}

/* Chat panel */
.kt-faq-panel {
    position: fixed;
    bottom: 110px;
    right: 20px;
    width: 420px;
    max-width: calc(100vw - 40px);
    max-height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    /* Ensure panel overlays nearby UI */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Poppins', sans-serif;
    animation: kt-slideUp 0.3s ease-out;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.kt-faq-panel.kt-expanded {
    max-height: 80vh;
    height: 80vh;
}

@keyframes kt-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kt-faq-panel.kt-hidden {
    display: none;
}

/* Header */
.kt-faq-header {
    background: linear-gradient(135deg, #5398BE 0%, #3a82a8 100%);
    color: white;
    padding: 20px 22px;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Playfair Display', serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.kt-faq-header-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
}

.kt-faq-expand,
.kt-faq-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: transform 0.2s ease;
}

.kt-faq-expand {
    font-size: 1.2rem;
}

.kt-faq-expand:hover,
.kt-faq-close:hover {
    transform: scale(1.1);
}

.kt-faq-close:hover {
    transform: scale(1.2);
}

/* Body */
.kt-faq-body {
    flex: 1;
    padding: 22px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8f9fa;
    max-height: 480px;
    scroll-behavior: smooth;
}

/* Input container */
.kt-faq-input-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px 20px 20px;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.kt-faq-input-box input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    background: #f8f9fa;
    transition: all 0.3s ease;
    min-width: 0;
}

.kt-faq-input-box input:focus {
    outline: none;
    border-color: #5398BE;
    background: white;
    box-shadow: 0 0 0 3px rgba(83, 152, 190, 0.15);
}

.kt-faq-input-box button {
    background: #5398BE;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 24px;
    width: 48px;
    min-width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    box-shadow: 0 2px 8px rgba(83, 152, 190, 0.3);
}

.kt-faq-input-box button:hover {
    background: #3a82a8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(83, 152, 190, 0.4);
}

/* Answer area - Chat bubble style */
.kt-faq-answer {
    background: white;
    padding: 16px 18px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    font-size: 0.9rem;
    color: #1B2021;
    line-height: 1.6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(83, 152, 190, 0.25);
    position: relative;
    align-self: flex-start;
    max-width: 95%;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.kt-faq-answer strong {
    display: block;
    margin-bottom: 8px;
    color: #5398BE;
    font-size: 0.95rem;
    font-weight: 600;
}

/* Suggestions - Chat bubble style */
.kt-faq-suggestions {
    background: white;
    padding: 16px 18px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    font-size: 0.9rem;
    color: #1B2021;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(83, 152, 190, 0.25);
    align-self: flex-start;
    max-width: 95%;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.kt-faq-suggestions strong {
    display: block;
    margin-bottom: 10px;
    color: #5398BE;
    font-weight: 600;
    font-size: 0.95rem;
}

.kt-faq-suggestions ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.kt-faq-suggestions li {
    padding: 8px 12px;
    margin: 4px 0;
    cursor: pointer;
    color: #5398BE;
    transition: all 0.2s ease;
    border-radius: 8px;
    background: #f8f9fa;
}

.kt-faq-suggestions li:hover {
    background: #e8f4f8;
    color: #1B2021;
    transform: translateX(4px);
}


/* Fallback button */
.kt-faq-fallback-btn {
    background: white;
    border: 2px solid #5398BE;
    padding: 12px 20px;
    border-radius: 24px;
    font-size: 0.9rem;
    cursor: pointer;
    color: #5398BE;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
    font-family: 'Poppins', sans-serif;
    box-shadow: 0 2px 8px rgba(83, 152, 190, 0.2);
    align-self: center;
    margin-top: 8px;
}

.kt-faq-fallback-btn:hover {
    background: #5398BE;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(83, 152, 190, 0.35);
}

/* Fallback message - Chat bubble style */
.kt-faq-fallback {
    background: #fff8e1;
    padding: 16px 18px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    font-size: 0.9rem;
    color: #1B2021;
    line-height: 1.6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(83, 152, 190, 0.3);
    align-self: flex-start;
    max-width: 95%;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.kt-faq-fallback strong {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: #5398BE;
    font-weight: 600;
}

/* Info message - Welcome bubble */
.kt-faq-info {
    background: white;
    color: #30343F;
    font-size: 0.9rem;
    padding: 14px 16px;
    text-align: center;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.06);
    line-height: 1.5;
}

/* Welcome message */
.kt-faq-welcome {
    background: white;
    padding: 16px 18px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(83, 152, 190, 0.15);
    align-self: flex-start;
    max-width: 95%;
    position: relative;
}

.kt-faq-welcome::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 8px 0;
    border-color: transparent white transparent transparent;
}

.kt-faq-greeting {
    font-size: 1rem;
    color: #5398BE;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
}

.kt-faq-frequent {
    font-size: 0.9rem;
    color: #1B2021;
    margin-bottom: 8px;
}

.kt-faq-frequent-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kt-faq-frequent-item {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #5398BE;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(83, 152, 190, 0.1);
}

.kt-faq-frequent-item:hover {
    background: #e8f4f8;
    color: #1B2021;
    transform: translateX(4px);
    border-color: rgba(83, 152, 190, 0.2);
}

.kt-faq-user-msg {
    background: linear-gradient(135deg, #5398BE 0%, #3a82a8 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-right-radius: 4px;
    font-size: 0.9rem;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(83, 152, 190, 0.3);
    align-self: flex-end;
    max-width: 85%;
    margin-bottom: 4px;
    position: relative;
}

.kt-faq-user-msg::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 8px 8px;
    border-color: transparent transparent #3a82a8 transparent;
}

/* Typing indicator */
.kt-faq-typing {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(83, 152, 190, 0.15);
    align-self: flex-start;
    max-width: 95%;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kt-faq-typing::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 8px 0;
    border-color: transparent white transparent transparent;
}

.kt-faq-typing-dots {
    display: flex;
    gap: 4px;
}

.kt-faq-typing-dots span {
    width: 6px;
    height: 6px;
    background: #5398BE;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.kt-faq-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.kt-faq-typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.kt-faq-typing-text {
    font-size: 0.85rem;
    color: #5398BE;
    font-style: italic;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .kt-faq-panel {
        width: calc(100vw - 40px);
        max-height: 560px;
        right: 20px;
        /* Position above mobile keyboard */
        bottom: max(110px, env(keyboard-inset-height, 0px) + 20px);
    }

    .kt-faq-bubble {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
        right: 20px;
    }

    .calendar-icon {
        width: 60px;
        height: 60px;
        left: 20px;
    }

    .calendar-icon img {
        width: 35px;
    }
}

@media (max-width: 420px) {
    .kt-faq-panel {
        bottom: max(100px, env(keyboard-inset-height, 0px) + 20px);
        max-height: calc(100vh - env(keyboard-inset-height, 0px) - 120px);
    }

    .kt-faq-input-box {
        flex-wrap: wrap;
    }

    .kt-faq-input-box input {
        width: 100%;
    }

    .kt-faq-input-box button {
        width: 100%;
    }
}