/* WR AI Chat Frontend Styles */
:root {
    --wr-ai-chat-header-bg: linear-gradient(135deg, #0073aa 0%, #00a0d2 100%);
    --wr-ai-chat-header-text: #ffffff;
    --wr-ai-chat-icon-size: 60px;
    --wr-ai-chat-icon-bg: #0073aa;
    --wr-ai-chat-transition: all 0.3s ease-in-out;
}

.wr-ai-chat-wrapper {
    position: fixed;
    bottom: 20px;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    transition: var(--wr-ai-chat-transition);
    pointer-events: none; /* Allow clicks to pass through when not interacting with chat */
}

/* When chat is not expanded, only the icon should be clickable */
.wr-ai-chat-wrapper:not(.expanded) .wr-ai-chat-container {
    display: none;
    pointer-events: none;
}

/* When chat is expanded, allow interaction with the container */
.wr-ai-chat-wrapper.expanded {
    pointer-events: auto;
}

.wr-ai-chat-wrapper.position-left {
    left: 0px;
    flex-direction: row;
}

.wr-ai-chat-wrapper.position-right {
    right: 0px;
    flex-direction: row-reverse;
}

.wr-ai-chat-wrapper.position-none {
    position: relative;
    width: 100%;
    max-width: 100%;
    bottom: 0;
    margin: 20px auto;
}

.wr-ai-chat-container {
    max-width: 100%;
    margin: 0;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background: #fff;
    height: 600px;
    display: flex;
    flex-direction: column;
    width: 400px;
    transition: var(--wr-ai-chat-transition);
    transform: translateX(0);
}

/* Icon styles */
.wr-ai-chat-icon {
    width: var(--wr-ai-chat-icon-size);
    height: var(--wr-ai-chat-icon-size);
    background: var(--wr-ai-chat-icon-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    margin: 0 5px;
    transition: var(--wr-ai-chat-transition);
    pointer-events: auto; /* Ensure the icon is always clickable */
}

.wr-ai-chat-icon:hover {
    transform: scale(1.1);
}

.wr-ai-chat-icon svg {
    width: 30px;
    height: 30px;
}

/* Position-specific styles */
.position-left .wr-ai-chat-container {
    margin-right: 20px;
    transform: translateX(calc(-100% - 80px));
}

.position-right .wr-ai-chat-container {
    margin-left: 20px;
    transform: translateX(calc(100% + 80px));
}

.position-none .wr-ai-chat-container {
    transform: none !important;
    margin: 0 auto;
}

/* Expanded state */
.wr-ai-chat-wrapper.expanded .wr-ai-chat-container {
    transform: translateX(0) !important;
}

/* Chat Header */
.wr-ai-chat-header {
    background: var(--wr-ai-chat-header-bg);
    color: var(--wr-ai-chat-header-text);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.wr-ai-chat-header:hover {
    opacity: 0.95;
}

.wr-ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wr-ai-chat-clear {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: auto;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.wr-ai-chat-clear:hover,
.wr-ai-chat-clear:focus {
    color: white;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
}

.wr-ai-chat-clear svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.wr-ai-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.wr-ai-chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

/* Chat Messages */
.wr-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wr-ai-chat-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.wr-ai-chat-message.wr-ai-chat-user {
    margin-left: auto;
    align-items: flex-end;
}

.wr-ai-chat-message.wr-ai-chat-bot {
    margin-right: auto;
    align-items: flex-start;
}

.wr-ai-chat-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 15px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    position: relative;
}

.wr-ai-chat-user .wr-ai-chat-message-content {
    background: #0073aa;
    color: white;
    border-bottom-right-radius: 4px;
    border-top-right-radius: 4px;
    border-top-left-radius: 18px;
}

.wr-ai-chat-bot .wr-ai-chat-message-content {
    background: #ffffff;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
    border-top-right-radius: 18px;
    border-top-left-radius: 18px;
}

/* Chat Input */
.wr-ai-chat-input {
    display: flex;
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    background: #fff;
    position: relative;
}

.wr-ai-chat-input textarea {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 12px 48px 12px 16px;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    transition: all 0.3s ease;
    max-height: 120px;
    overflow-y: auto;
    margin: 0;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
    height: auto !important;
}

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

.wr-ai-chat-send {
    position: absolute;
    right: 28px;
    bottom: 28px;
    background: none;
    border: none;
    color: #0073aa;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.wr-ai-chat-send:hover {
    background: rgba(0, 115, 170, 0.1);
}

.wr-ai-chat-send:active {
    transform: scale(0.95);
}

.wr-ai-chat-send svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Typing Indicator */
.wr-ai-chat-typing {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin: 8px 0 8px 15px;
    background: #f3f4f6;
    border-radius: 18px;
    align-self: flex-start;
    max-width: 80%;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
    position: relative;
    min-height: 44px;
    box-sizing: border-box;
    gap: 6px;
}

.wr-ai-chat-typing.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    display: flex;
}

/* Style for the typing dots */
.wr-ai-chat-typing span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #6b7280;
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

/* Animation for the typing dots */
@keyframes typingAnimation {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Individual dot delays */
.wr-ai-chat-typing span:nth-child(1) {
    animation-delay: 0s;
}

.wr-ai-chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.wr-ai-chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Scrollbar */
.wr-ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.wr-ai-chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.wr-ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.wr-ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Timestamp */
.wr-ai-chat-timestamp {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

/* Error Message */
.wr-ai-chat-error {
    background: #fff5f5;
    color: #e53e3e;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 8px 0;
    border: 1px solid #fed7d7;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wr-ai-chat-error svg {
    flex-shrink: 0;
}

/* Responsive Design */
@media (max-width: 480px) {
    .wr-ai-chat-container {
        /*height: 100vh;*/
        border-radius: 0;
        width: 300px;
        max-height: 80vh;
    }
    
    .wr-ai-chat-message {
        max-width: 90%;
    }
    
    .wr-ai-chat-input {
        padding: 12px;
    }
    
    .wr-ai-chat-input textarea {
        padding: 10px 44px 10px 12px;
        font-size: 14px;
    }
    
    .wr-ai-chat-send {
        right: 20px;
        bottom: 20px;
    }
}

/* Animation for new messages */
@keyframes newMessage {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.wr-ai-chat-message {
    animation: newMessage 0.3s ease-out;
}

.chat_wrapp {
    position: relative;
}