/**
 * FAQ Chatbot Styles
 * 
 * Minimal, namespaced CSS for the FAQ chatbot widget.
 * All styles are prefixed with .faq-chatbot to avoid conflicts.
 */

/* Main widget container */
.faq-chatbot {
    max-width: 400px;
    margin: 20px 0;
    border: 1px solid #ddd;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    height: 550px;
    overflow: hidden;
}

/* Header */
.faq-chatbot__header {
    padding: 16px 20px;
    background: #07391E;
    border-radius: 12px 12px 0 0;
    color: white !important;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.faq-chatbot__header::before {
    content: "🤖";
    font-size: 20px;
}

.faq-chatbot__header h3 {
    margin: 0;
    font-size: 22px !important;
    font-weight: 600;
    color: white !important;
}

/* Chat messages area */
.faq-chatbot__content {
    flex: 1;
    padding: 16px;
    overflow-y: scroll;
    overflow-x: hidden;
    background: #f8f9fa;
    position: relative;
    min-height: 0;
    height: 350px;
    -webkit-overflow-scrolling: touch;
}

/* Chat message bubbles */
.faq-chatbot__message {
    display: flex;
    margin-bottom: 12px;
    animation: fadeInUp 0.3s ease;
}

.faq-chatbot__message--bot {
    justify-content: flex-start;
}

.faq-chatbot__message--user {
    justify-content: flex-end;
}

.faq-chatbot__message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.faq-chatbot__message--bot .faq-chatbot__message-bubble {
    background: #fff;
    border: 1px solid #e1e8ed;
    color: #333;
    border-bottom-left-radius: 4px;
}

.faq-chatbot__message--user .faq-chatbot__message-bubble {
    background: #88C43F;
    color: white;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.faq-chatbot__typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e1e8ed;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 80px;
    margin-bottom: 12px;
}

.faq-chatbot__typing-dots {
    display: flex;
    gap: 4px;
}

.faq-chatbot__typing-dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.faq-chatbot__typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.faq-chatbot__typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingDot {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Service and question buttons in chat */
.faq-chatbot__options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.faq-chatbot__option-btn {
    padding: 10px 14px;
    border: 1px solid #07391E;
    border-radius: 20px;
    background: #fff;
    color: #07391E;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    max-width: 100%;
}

.faq-chatbot__option-btn:hover,
.faq-chatbot__option-btn:focus {
    background: #07391E;
    color: #fff;
    outline: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(133, 23, 46, 0.3);
}

/* Action buttons */
.faq-chatbot__action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.faq-chatbot__action-btn {
    padding: 8px 16px;
    border: 1px solid #28a745;
    border-radius: 16px;
    background: #28a745;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 100px;
    text-align: center;
}

.faq-chatbot__action-btn:hover,
.faq-chatbot__action-btn:focus {
    background: #07391E;
    border-color: #07391E;
    outline: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

/* Contact form in chat */
.faq-chatbot__contact-form {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #e1e8ed;
    margin-top: 8px;
}

.faq-chatbot__form-header {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.faq-chatbot__form-intro {
    margin: 0 0 16px 0;
    color: #666;
    font-size: 13px;
}

.faq-chatbot__form-group {
    margin-bottom: 12px;
}

.faq-chatbot__label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: #333;
    font-size: 12px;
}

.faq-chatbot__label .required {
    color: #dc3545;
}

.faq-chatbot__input,
.faq-chatbot__select,
.faq-chatbot__textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.faq-chatbot__input:focus,
.faq-chatbot__select:focus,
.faq-chatbot__textarea:focus {
    outline: none;
    border-color: #88C43F;
    box-shadow: 0 0 0 2px rgba(133, 23, 46, 0.2);
}

.faq-chatbot__textarea {
    resize: vertical;
    min-height: 60px;
}

.faq-chatbot__form-actions {
    margin-top: 16px;
}

.faq-chatbot__submit-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    background: #88C43F;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.faq-chatbot__submit-btn:hover,
.faq-chatbot__submit-btn:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(133, 23, 46, 0.4);
    outline: none;
}

.faq-chatbot__submit-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

/* Form messages */
.faq-chatbot__form-message {
    padding: 10px 12px;
    border-radius: 4px;
    margin-top: 15px;
    font-size: 14px;
}

.faq-chatbot__form-message--success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.faq-chatbot__form-message--error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Input area */
.faq-chatbot__input-area {
    padding: 12px 16px;
    border-top: 1px solid #e1e8ed;
    background: #fff;
    border-radius: 0 0 12px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.faq-chatbot__quick-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.faq-chatbot__quick-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 16px;
    background: #f8f9fa;
    color: #666;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
}

.faq-chatbot__quick-btn:hover,
.faq-chatbot__quick-btn:focus {
    background: #88C43F;
    color: #fff;
    border-color: #88C43F;
    outline: none;
}

.faq-chatbot__restart-btn {
    padding: 6px 12px;
    border: 1px solid #28a745;
    border-radius: 16px;
    background: #28a745;
    color: #fff;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
}

.faq-chatbot__restart-btn:hover,
.faq-chatbot__restart-btn:focus {
    background: #218838;
    border-color: #218838;
    outline: none;
    transform: translateY(-1px);
}

/* Error state */
.faq-chatbot__error {
    text-align: center;
    color: #dc3545;
    padding: 20px;
    font-style: italic;
}

/* Responsive design */
@media (max-width: 600px) {
    .faq-chatbot {
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        height: 100vh;
        max-width: none;
    }

    .faq-chatbot__header {
        border-radius: 0;
    }

    .faq-chatbot__content {
        padding: 12px;
    }

    .faq-chatbot__input-area {
        padding: 12px;
        border-radius: 0;
    }

    .faq-chatbot__action-buttons {
        flex-direction: column;
    }

    .faq-chatbot__action-btn {
        flex: none;
        min-width: auto;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {

    .faq-chatbot *,
    .faq-chatbot *::before,
    .faq-chatbot *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .faq-chatbot {
        border-width: 2px;
    }

    .faq-chatbot__service-btn,
    .faq-chatbot__question-btn,
    .faq-chatbot__action-btn,
    .faq-chatbot__submit-btn,
    .faq-chatbot__back-btn {
        border-width: 2px;
    }
}

/* Focus indicators for keyboard navigation */
.faq-chatbot button:focus-visible,
.faq-chatbot input:focus-visible,
.faq-chatbot select:focus-visible,
.faq-chatbot textarea:focus-visible {
    outline: 2px solid #88C43F;
    outline-offset: 2px;
}

/* Sticky Chatbot Button */
.faq-chatbot-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #88C43F;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(133, 23, 46, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: all 0.3s ease;
    border: none;
    overflow: hidden;
    color: #07391E;
}

.faq-chatbot-button:hover {
    transform: scale(1.1);
}

.faq-chatbot-button__icon {
    font-size: 24px;
    color: #07391E !important;
    transition: all 0.3s ease;
}

.faq-chatbot-button__text {
    position: absolute;
    right: 70px;
    color: #07391E;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.faq-chatbot-button:hover .faq-chatbot-button__text {
    opacity: 1;
    transform: translateX(0);
}

.faq-chatbot-button:hover .faq-chatbot-button__icon {
    transform: rotate(10deg);
}

/* Sticky Chatbot Widget */
.faq-chatbot--sticky {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 500px;
    z-index: 9998;
    margin: 0;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    animation: slideInUp 0.3s ease;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 120px);
    overflow-y: scroll;
    overflow-x: hidden;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Close button in header */
.faq-chatbot__close-btn {
    position: absolute;
    top: -50px;
    right: 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white !important;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.faq-chatbot__close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.15) rotate(90deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.faq-chatbot__close-btn:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.25);
    border-color: white;
    transform: scale(1.1);
}

.faq-chatbot__close-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive adjustments for sticky widget */
@media (max-width: 600px) {
    .faq-chatbot--sticky {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        border-radius: 0;
        animation: slideInUp 0.3s ease;
        max-height: 100vh;
    }

    .faq-chatbot__content {
        max-height: calc(100vh - 140px);
        min-height: 0;
    }

    .faq-chatbot-button {
        bottom: 15px;
        right: 15px;
        width: 55px;
        height: 55px;
    }

    .faq-chatbot-button__icon {
        font-size: 22px;
    }

    .faq-chatbot-button__text {
        display: none;
    }
}

@media (max-width: 420px) {
    .faq-chatbot--sticky {
        width: 100vw;
        right: 0;
    }
}

/* Hide sticky elements when shortcode is present */
body.has-chatbot-shortcode .faq-chatbot-button,
body.has-chatbot-shortcode .faq-chatbot--sticky {
    display: none !important;
}