/* ==========================================================================
   WandTech Live Chat - Frontend Styles
   Version: 1.3.2
   ========================================================================== */

:root {
    --chat-primary-color: #0088cc; /* Default Telegram Blue */
    --chat-whatsapp-color: #25D366;
    --chat-white: #ffffff;
    --chat-text-dark: #1e1e1e;
    --chat-text-light: #555;
    --chat-border-color: #e5e7eb;
    --chat-box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
    --chat-bubble-bg: #ffffff;
    --chat-bubble-text: #333333;
}

/* ==========================================================================
   1. Animations
   ========================================================================== */

/* Default Pulse (Blue) */
@keyframes pulse-animation {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 136, 204, 0.7);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(0, 136, 204, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 136, 204, 0);
    }
}

/* WhatsApp Pulse (Green) */
@keyframes pulse-whatsapp {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(37, 211, 102, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

/* ==========================================================================
   2. Base Layout & Positioning
   ========================================================================== */

#wtc-live-chat-box {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99999;
    /* font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; */
    /* direction: ltr; Reset direction for the container logic */
    direction: rtl; /* Reset direction for the container logic */
}

/* RTL Support for Positioning */
body.rtl #wtc-live-chat-box {
    right: auto;
    left: 30px;
}

/* ==========================================================================
   3. Toggle Button (FAB)
   ========================================================================== */

.wtc-chat-box__toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--chat-primary-color);
    color: var(--chat-white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--chat-box-shadow);
    transition: transform 0.2s ease-in-out, background-color 0.2s ease-in-out;
    animation: pulse-animation 2s infinite;
    position: relative;
}

.wtc-chat-box__toggle:hover {
    transform: scale(1.1);
    animation-play-state: paused;
}

/* Platform Specific Colors */
#wtc-live-chat-box.platform-whatsapp .wtc-chat-box__toggle {
    background-color: var(--chat-whatsapp-color);
    animation-name: pulse-whatsapp;
}

/* Icons styling */
.wtc-chat-box__toggle svg {
    transition: opacity 0.2s ease, transform 0.2s ease;
    width: 28px;
    height: 28px;
    pointer-events: none;
}

/* Icon Visibility Logic */
.wtc-chat-box__toggle .icon-close {
    display: none;
}

/* When Closed: Show Platform Icons */
#wtc-live-chat-box.wtc-chat-box--closed.platform-whatsapp .icon-whatsapp {
    display: block;
}
#wtc-live-chat-box.wtc-chat-box--closed.platform-whatsapp .icon-telegram {
    display: none;
}

#wtc-live-chat-box.wtc-chat-box--closed.platform-telegram .icon-telegram {
    display: block;
}
#wtc-live-chat-box.wtc-chat-box--closed.platform-telegram .icon-whatsapp {
    display: none;
}

/* When Open: Show Close Icon */
#wtc-live-chat-box:not(.wtc-chat-box--closed) .icon-platform {
    display: none;
}
#wtc-live-chat-box:not(.wtc-chat-box--closed) .icon-close {
    display: block;
}
#wtc-live-chat-box:not(.wtc-chat-box--closed) .wtc-chat-box__toggle {
    animation: none;
    transform: scale(1);
}

/* ==========================================================================
   4. Chat Window Container
   ========================================================================== */

.wtc-chat-box__container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    max-width: calc(100vw - 40px);
    background: var(--chat-white);
    border-radius: 12px;
    box-shadow: var(--chat-box-shadow);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    text-align: left;
}

/* RTL Support for Window */
body.rtl .wtc-chat-box__container {
    right: auto;
    left: 0;
    text-align: right;
}

/* Open State */
#wtc-live-chat-box:not(.wtc-chat-box--closed) .wtc-chat-box__container {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Header */
.wtc-chat-box__header {
    background-color: var(--chat-primary-color);
    color: var(--chat-white);
    padding: 20px;
    text-align: center;
}

#wtc-live-chat-box.platform-whatsapp .wtc-chat-box__header {
    background-color: var(--chat-whatsapp-color);
}

.wtc-chat-box__header h3 {
    margin: 0 0 5px;
    font-size: 18px;
    font-weight: 600;
    color: inherit;
}

.wtc-chat-box__header p {
    margin: 0;
    font-size: 14px;
    opacity: 0.95;
    color: inherit;
}

/* Body */
.wtc-chat-box__body {
    padding: 20px;
}

/* ==========================================================================
   5. Form Elements
   ========================================================================== */

.wtc-form-group {
    margin-bottom: 15px;
}

.wtc-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--chat-text-dark);
    margin-bottom: 6px;
}

.wtc-form-group input[type="text"],
.wtc-form-group input[type="tel"],
.wtc-form-group select,
.wtc-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--chat-border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: #fff;
    color: #333;
}

/* Focus States */
.wtc-form-group input:focus,
.wtc-form-group select:focus,
.wtc-form-group textarea:focus {
    outline: none;
    border-color: var(--chat-primary-color);
    box-shadow: 0 0 0 3px rgba(0, 136, 204, 0.15);
}

#wtc-live-chat-box.platform-whatsapp .wtc-form-group input:focus,
#wtc-live-chat-box.platform-whatsapp .wtc-form-group select:focus,
#wtc-live-chat-box.platform-whatsapp .wtc-form-group textarea:focus {
    border-color: var(--chat-whatsapp-color);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

/* Submit Button */
.wtc-chat-submit-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    background: var(--chat-primary-color);
    color: var(--chat-white);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    margin-top: 5px;
}

.wtc-chat-submit-btn:hover {
    background-color: #0073aa;
}

.wtc-chat-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

#wtc-live-chat-box.platform-whatsapp .wtc-chat-submit-btn {
    background-color: var(--chat-whatsapp-color);
}

#wtc-live-chat-box.platform-whatsapp .wtc-chat-submit-btn:hover {
    background-color: #128C7E;
}

/* Error Message */
.wtc-chat-error-message {
    color: #d63638;
    font-size: 13px;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    text-align: center;
    line-height: 1.4;
}

/* ==========================================================================
   6. Welcome Bubble (New Feature)
   ========================================================================== */

.wtc-chat-bubble {
    position: absolute;
    bottom: 15px;
    right: 80px; /* LTR Position */
    background: var(--chat-bubble-bg);
    color: var(--chat-bubble-text);
    padding: 10px 16px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateX(10px);
    transition: opacity 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), visibility 0.4s;
    pointer-events: none;
    z-index: 10;
}

/* Bubble Arrow (LTR) */
.wtc-chat-bubble::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    border-width: 6px 0 6px 8px;
    border-style: solid;
    border-color: transparent transparent transparent var(--chat-bubble-bg);
}

/* Bubble Show State */
.wtc-chat-bubble.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* RTL Support for Bubble */
body.rtl .wtc-chat-bubble {
    right: auto;
    left: 80px;
    transform: translateX(-10px);
}

body.rtl .wtc-chat-bubble::after {
    right: auto;
    left: -6px;
    border-width: 6px 8px 6px 0;
    border-color: transparent var(--chat-bubble-bg) transparent transparent;
}

body.rtl .wtc-chat-bubble.show {
    transform: translateX(0);
}

/* ==========================================================================
   7. Mobile Responsiveness adjustments
   ========================================================================== */

@media screen and (max-width: 768px) {
    #wtc-live-chat-box {
        /* در حالت دسکتاپ 30px است، اینجا آن را بیشتر می‌کنیم */
        bottom: 65px; 
    }

    /* اگر خواستید دکمه در موبایل کمی کوچک‌تر شود (اختیاری) */
    /*
    .wtc-chat-box__toggle {
        width: 50px;
        height: 50px;
    }
    .wtc-chat-box__toggle svg {
        width: 24px;
        height: 24px;
    }
    */
}