/* ===== AI Chat Widget Container ===== */
#authyo-ai-chat-widget {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9998;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ===== Launcher Button ===== */
.authyo-ai-launcher {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    color: #fff;
    font-size: 24px;
}

.authyo-ai-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.authyo-ai-launcher:focus {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.authyo-ai-launcher .authyo-ai-icon-chat,
.authyo-ai-launcher .authyo-ai-icon-close {
    position: absolute;
    transition: opacity 0.2s, transform 0.2s;
}

.authyo-ai-launcher .authyo-ai-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.authyo-ai-launcher.authyo-ai-open .authyo-ai-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.authyo-ai-launcher.authyo-ai-open .authyo-ai-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ===== Chat Window ===== */
.authyo-ai-window {
    position: absolute;
    bottom: 70px;
    left: 0;
    width: 370px;
    max-height: min(500px, calc(100vh - 120px));
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: authyo-ai-slide-up 0.3s ease-out;
}

.authyo-ai-window.authyo-ai-visible {
    display: flex;
}

@keyframes authyo-ai-slide-up {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===== Header ===== */
.authyo-ai-header {
    padding: 16px 18px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.authyo-ai-header-title {
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.authyo-ai-header-title svg {
    width: 18px;
    height: 18px;
}

.authyo-ai-close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.authyo-ai-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== Messages Area ===== */
.authyo-ai-messages {
    flex: 1 1 auto;
    padding: 16px;
    overflow-y: auto;
    background: #f8f9fa;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Message Bubble */
.authyo-ai-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    animation: authyo-ai-msg-in 0.3s ease-out;
    word-wrap: break-word;
}

@keyframes authyo-ai-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.authyo-ai-msg.bot {
    background: #e9ecef;
    color: #212529;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.authyo-ai-msg.user {
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Typing Indicator */
.authyo-ai-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #e9ecef;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 70px;
}

.authyo-ai-typing-dot {
    width: 7px;
    height: 7px;
    background: #adb5bd;
    border-radius: 50%;
    animation: authyo-ai-typing-bounce 1.4s infinite ease-in-out;
}

.authyo-ai-typing-dot:nth-child(1) { animation-delay: 0s; }
.authyo-ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.authyo-ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes authyo-ai-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== Input Area ===== */
.authyo-ai-input-area {
    padding: 12px 14px;
    border-top: 1px solid #e9ecef;
    background: #fff;
    flex-shrink: 0;
}

.authyo-ai-input-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.authyo-ai-input-form textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    min-height: 40px;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.2s;
}

.authyo-ai-input-form textarea:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
}

.authyo-ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.authyo-ai-send-btn:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.authyo-ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.authyo-ai-send-btn svg {
    width: 18px;
    height: 18px;
}

/* ===== Fallback Actions ===== */
.authyo-ai-fallback-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.authyo-ai-fallback-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s;
}

.authyo-ai-fallback-btn:hover {
    opacity: 0.85;
}

.authyo-ai-fallback-btn.primary {
    color: #fff;
}

.authyo-ai-fallback-btn.secondary {
    background: #e9ecef;
    color: #495057;
}

/* ===== Contact Form (Inline) ===== */
.authyo-ai-contact-form {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 14px;
    margin-top: 8px;
    align-self: flex-start;
    max-width: 90%;
    animation: authyo-ai-msg-in 0.3s ease-out;
}

.authyo-ai-contact-form label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 4px;
    margin-top: 10px;
}

.authyo-ai-contact-form label:first-child {
    margin-top: 0;
}

.authyo-ai-contact-form input,
.authyo-ai-contact-form textarea,
.authyo-ai-contact-form select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.authyo-ai-contact-form input:focus,
.authyo-ai-contact-form textarea:focus {
    border-color: #0073aa;
}

.authyo-ai-contact-form textarea {
    resize: vertical;
    min-height: 50px;
}

.authyo-ai-contact-submit {
    margin-top: 12px;
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.authyo-ai-contact-submit:hover {
    opacity: 0.9;
}

.authyo-ai-contact-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.authyo-ai-contact-error {
    color: #dc3545;
    font-size: 11px;
    margin-top: 2px;
}

/* ===== Footer ===== */
.authyo-ai-footer {
    padding: 6px 14px;
    text-align: center;
    font-size: 11px;
    color: #adb5bd;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.authyo-ai-footer a {
    color: #adb5bd;
    text-decoration: none;
}

.authyo-ai-footer a:hover {
    color: #6c757d;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 480px) {
    #authyo-ai-chat-widget {
        bottom: 10px;
        left: 10px;
        right: 10px;
    }

    .authyo-ai-window {
        width: calc(100vw - 20px);
        max-width: none;
        left: 0;
        right: 0;
        bottom: 70px;
        max-height: calc(100vh - 100px);
    }

    .authyo-ai-launcher {
        width: 50px;
        height: 50px;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    .authyo-ai-window,
    .authyo-ai-msg,
    .authyo-ai-contact-form {
        animation: none;
    }

    .authyo-ai-typing-dot {
        animation-duration: 2s;
    }
}

/* ===== High Contrast ===== */
@media (prefers-contrast: high) {
    .authyo-ai-msg.bot {
        border: 1px solid #999;
    }

    .authyo-ai-msg.user {
        border: 1px solid currentColor;
    }

    .authyo-ai-input-form textarea {
        border-width: 2px;
    }
}
