/* =========================================
   Bale Chat Widget - ویجت چت دایره‌ای
   ========================================= */

/* کانتینر اصلی */
.bale-chat-widget {
    position: fixed;
    z-index: 999999;
    direction: rtl;
    font-family: IRANSans, Tahoma, Arial, sans-serif;
}

/* دایره شناور */
.bale-chat-circle {
    position: fixed;
    bottom: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999999;
    outline: none;
}

.bale-chat-circle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.bale-chat-circle:active {
    transform: scale(0.95);
}

/* موقعیت راست */
.bale-chat-widget[data-position="right"] .bale-chat-circle {
    right: 20px;
}

/* موقعیت چپ */
.bale-chat-widget[data-position="left"] .bale-chat-circle {
    left: 20px;
}

/* انیمیشن ضربان اولیه */
.bale-chat-circle::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    opacity: 0.3;
    animation: bale-pulse 2s infinite;
    z-index: -1;
}

@keyframes bale-pulse {
    0% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.3); opacity: 0.1; }
    100% { transform: scale(1); opacity: 0.3; }
}

/* =========================================
   باکس چت
   ========================================= */
.bale-chat-box {
    position: fixed;
    bottom: 90px;
    width: 360px;
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 999998;
    animation: bale-slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* موقعیت راست */
.bale-chat-widget[data-position="right"] .bale-chat-box {
    right: 20px;
}

/* موقعیت چپ */
.bale-chat-widget[data-position="left"] .bale-chat-box {
    left: 20px;
}

@keyframes bale-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.bale-chat-box.open {
    display: flex;
}

/* =========================================
   هدر
   ========================================= */
.bale-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    color: #fff;
    flex-shrink: 0;
}

.bale-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bale-chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bale-chat-header-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

.bale-chat-header-status {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 1px;
}

.bale-chat-header-status::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4CAF50;
    margin-left: 5px;
    vertical-align: middle;
}

.bale-chat-close {
    background: rgba(255, 255, 255, 0.15) !important;
    border: none !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    transition: all 0.2s !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0.85 !important;
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    min-height: 26px !important;
    outline: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    line-height: 1 !important;
    float: none !important;
    position: static !important;
}

.bale-chat-close:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    opacity: 1 !important;
    transform: rotate(90deg);
}

.bale-chat-close:active {
    transform: rotate(90deg) scale(0.9);
}

.bale-chat-close svg {
    display: block !important;
    width: 14px !important;
    height: 14px !important;
}

/* =========================================
   بدنه (پیام‌ها) - اسکرول میشود
   ========================================= */
.bale-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 8px;
    background: #f5f7fb;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

/* اسکرول بار */
.bale-chat-body::-webkit-scrollbar {
    width: 4px;
}

.bale-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.bale-chat-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

/* =========================================
   فوتر (ثابت در پایین - منو یا دکمه بازگشت)
   ========================================= */
.bale-chat-footer {
    flex-shrink: 0;
    padding: 8px 12px 10px;
    background: #f5f7fb;
    border-top: 1px solid #e8eef3;
}

.bale-chat-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bale-chat-back-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bale-chat-back-footer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    background: #fff;
    border: 1px solid #e0e8f0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: #555;
    transition: all 0.2s;
    width: 100%;
    text-align: center;
}

.bale-chat-back-footer-btn:hover {
    background: #f0f4f8;
    border-color: #c8d6e5;
}

/* =========================================
   پیام‌ها
   ========================================= */
.bale-chat-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: bale-msgIn 0.3s ease;
}

@keyframes bale-msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.bale-chat-message-bot {
    align-self: flex-start;
}

.bale-chat-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.bale-chat-message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    background: #e8eef3;
}

.bale-chat-message-user .bale-chat-message-avatar {
    background: #e3f2fd;
}

.bale-chat-message-content {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.6;
    color: #333;
    word-wrap: break-word;
}

.bale-chat-message-bot .bale-chat-message-content {
    background: #fff;
    border-radius: 14px 14px 14px 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.bale-chat-message-user .bale-chat-message-content {
    background: #e3f2fd;
    border-radius: 14px 14px 4px 14px;
}

/* =========================================
   دکمه‌های منو (داخل فوتر)
   ========================================= */
.bale-chat-menu-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e0e8f0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    transition: all 0.2s;
    font-family: inherit;
    text-align: right;
    width: 100%;
}

.bale-chat-menu-btn:hover {
    background: #f0f4f8;
    border-color: #c8d6e5;
}

.bale-chat-menu-btn:active {
    transform: scale(0.98);
}

.bale-chat-menu-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* =========================================
   فرم احراز هویت (پاپ‌آپ روی ویجت)
   ========================================= */
.bale-chat-auth-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(245, 247, 251, 0.97);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: bale-fadeIn 0.25s ease;
}

@keyframes bale-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.bale-chat-auth-box {
    width: 100%;
    max-width: 300px;
    background: #fff;
    border-radius: 16px;
    padding: 24px 20px 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bale-chat-auth-icon {
    font-size: 36px;
    text-align: center;
    margin-bottom: 2px;
}

.bale-chat-auth-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    text-align: center;
    line-height: 1.5;
}

.bale-chat-auth-desc {
    font-size: 12px;
    color: #888;
    text-align: center;
    margin-bottom: 4px;
}

.bale-chat-auth-input {
    padding: 12px 14px;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

.bale-chat-auth-input:focus {
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.bale-chat-auth-btn {
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    font-weight: 500;
}

.bale-chat-auth-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.bale-chat-auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.bale-chat-auth-btn-secondary {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    padding: 6px;
    transition: color 0.2s;
    text-align: center;
}

.bale-chat-auth-btn-secondary:hover {
    color: #333;
}

/* =========================================
   لیست FAQ
   ========================================= */
.bale-chat-faq-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.bale-chat-faq-item {
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e8eef3;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    transition: all 0.2s;
    font-family: inherit;
    text-align: right;
    width: 100%;
}

.bale-chat-faq-item:hover {
    background: #f0f4f8;
    border-color: #c8d6e5;
}

.bale-chat-faq-answer {
    padding: 12px 14px;
    background: #fff;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
    color: #555;
    margin-top: 4px;
}

/* =========================================
   نتایج جستجو
   ========================================= */
.bale-chat-search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.bale-chat-product-card {
    background: #fff;
    border: 1px solid #e8eef3;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
}

.bale-chat-product-card:hover {
    border-color: #c8d6e5;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.bale-chat-product-img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.bale-chat-product-info {
    padding: 10px 12px;
}

.bale-chat-product-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.bale-chat-product-price {
    font-size: 12px;
    color: #4CAF50;
    font-weight: 600;
}

.bale-chat-product-link {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 14px;
    border-radius: 8px;
    color: #fff;
    font-size: 12px;
    text-decoration: none;
    transition: opacity 0.2s;
}

.bale-chat-product-link:hover {
    opacity: 0.9;
}

/* =========================================
   پشتیبانی
   ========================================= */
.bale-chat-support-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.bale-chat-support-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #e8eef3;
    border-radius: 10px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-align: right;
    width: 100%;
}

.bale-chat-support-item:hover {
    background: #f0f4f8;
    border-color: #c8d6e5;
}

/* =========================================
   لودینگ
   ========================================= */
.bale-chat-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 14px 14px 14px 4px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.bale-chat-loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #bbb;
    animation: bale-bounce 1.4s infinite ease-in-out both;
}

.bale-chat-loading-dot:nth-child(1) { animation-delay: -0.32s; }
.bale-chat-loading-dot:nth-child(2) { animation-delay: -0.16s; }
.bale-chat-loading-dot:nth-child(3) { animation-delay: 0s; }

@keyframes bale-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* =========================================
   دکمه‌های اکشن در پیام
   ========================================= */
.bale-chat-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.bale-chat-action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    color: #fff;
}

.bale-chat-action-btn:hover {
    opacity: 0.9;
}

.bale-chat-action-btn-secondary {
    background: #e8eef3;
    color: #555;
}

.bale-chat-action-btn-secondary:hover {
    background: #d5dee6;
}

/* =========================================
   ورودی متن
   ========================================= */
.bale-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid #e8eef3;
    background: #fff;
    flex-shrink: 0;
}

.bale-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e8eef3;
    border-radius: 24px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    background: #f5f7fb;
}

.bale-chat-input:focus {
    border-color: #2196F3;
    background: #fff;
}

.bale-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

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

.bale-chat-send-btn:active {
    transform: scale(0.95);
}

.bale-chat-send-btn svg {
    display: block !important;
    margin: 0 auto !important;
}

/* دکمه ارسال - حالت نمایش */
.bale-chat-send-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    min-width: 40px !important;
    min-height: 40px !important;
    width: 40px !important;
    height: 40px !important;
}

/* =========================================
   اعلان (ناتیفیکیشن)
   ========================================= */
.bale-chat-notification {
    position: fixed;
    bottom: 90px;
    background: #333;
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 999997;
    animation: bale-notifIn 0.3s ease;
    cursor: pointer;
    max-width: 300px;
    display: none;
}

.bale-chat-widget[data-position="right"] .bale-chat-notification {
    right: 20px;
}

.bale-chat-widget[data-position="left"] .bale-chat-notification {
    left: 20px;
}

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

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 480px) {
    .bale-chat-box {
        width: calc(100vw - 20px) !important;
        height: calc(100vh - 100px) !important;
        max-height: calc(100vh - 100px) !important;
        bottom: 80px;
        border-radius: 12px;
    }

    .bale-chat-widget[data-position="right"] .bale-chat-box,
    .bale-chat-widget[data-position="left"] .bale-chat-box {
        right: 10px;
        left: 10px;
    }

    .bale-chat-circle {
        width: 50px;
        height: 50px;
    }
}
