/* فونت فارسی */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap');

#chat-box,
#chat-box *,
#chat-toggle,
#chat-toggle * {
    box-sizing: border-box;
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* دکمه باز کردن چت */
#chat-toggle {
    position: fixed;
    right: 20px;
    bottom: 20px;

    width: 70px;
    height: 70px;
    padding: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    background:
        url('../images/polarisbot.png') center / cover no-repeat,
        #ffffff;

    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 9998;

    box-shadow: 0 4px 16px rgba(26, 155, 142, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(26, 155, 142, 0.4);
}

#chat-toggle svg {
    width: 32px;
    height: 32px;
    fill: #ffffff;
}

/* باکس اصلی چت */
#chat-box {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999;

    display: none;
    flex-direction: column;

    width: 400px;
    max-width: calc(100vw - 48px);

    height: 600px;
    max-height: calc(100vh - 48px);

    /*
     * برای مرورگرهای جدید که ارتفاع واقعی صفحه موبایل را پشتیبانی می‌کنند
     */
    max-height: calc(100dvh - 48px);

    min-width: 280px;
    min-height: 420px;

    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    overflow: hidden;

    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
}

#chat-box.active {
    display: flex;
}

/* هدر چت */
#chat-header {
    display: flex;
    align-items: center !important;
    justify-content: space-between;

    flex: 0 0 auto;

    padding: 16px 20px;

    color: #ffffff;
    background: linear-gradient(135deg, #1a9b8e 0%, #16857a 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

#chat-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;
    flex: 0 0 40px;

    font-size: 24px;
    background: #ffffff;
    border-radius: 50%;
}

#chat-header-text {
    min-width: 0;
}

#chat-header-text h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    color: white;
}

#chat-header-text p {
    margin: 2px 0 0;
    font-size: 13px;
    font-weight: 400;
    opacity: 0.9;
}

/* دکمه بستن */
#chat-close {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    align-self: center !important;
    flex: 0 0 36px !important;

    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;

    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;

    margin: 0 !important;
    padding: 0 !important;

    color: #ffffff !important;
    font-size: 24px !important;
    line-height: 1 !important;

    background: rgba(255, 255, 255, 0.15) !important;
    border: none !important;
    border-radius: 50% !important;
    cursor: pointer !important;

    transition: transform 0.2s ease, background 0.2s ease !important;
}

#chat-close:hover {
    background: rgba(255, 255, 255, 0.25) !important;
    transform: rotate(90deg);
}

/* بخش پیام‌ها */
#chat-messages {
    flex: 1 1 auto;
    min-height: 0;

    padding: 20px;
    overflow-y: auto;

    direction: rtl;
    background-color: #f3f3f3;
    background-image: url('../images/bgchat.png');
    background-repeat: round;
    background-size: auto;
}

/* پیام‌ها */
.message-wrapper {
    display: flex;
    flex-direction: column;  
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

.message-wrapper.user {
    align-items: flex-start;  
}

.message-wrapper.bot {
    align-items: flex-end; 
}

.user-message,
.bot-message {
    max-width: 75%;
    padding: 12px 18px;

    position: relative;

    font-size: 15px;
    line-height: 1.5;
    overflow-wrap: break-word;

    border-radius: 18px;
}

.user-message {
    color: #ffffff;
    background: #5b7ced;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(91, 124, 237, 0.2);
}

.bot-message {
    color: #2d3748;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.bot-message.loading {
    color: #5b7ced;
    background: #e6f2ff;
    border-color: #d0e5ff;
    font-style: italic;
}

.bot-message.error {
    color: #e53e3e;
    background: #fff5f5;
    border-color: #feb2b2;
}

/* بخش ورودی */
#chat-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;

    padding: 16px 20px 20px;

    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

#chat-input {
    flex: 1 1 auto;
    min-width: 0;

    padding: 14px 20px;

    color: #2d3748;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    text-align: right;
    direction: rtl;

    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 25px;
    outline: none;

    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#chat-input::placeholder {
    color: #a0aec0;
}

#chat-input:focus {
    background: #ffffff;
    border-color: #5b7ced;
    box-shadow: 0 0 0 3px rgba(91, 124, 237, 0.1);
}

/* دکمه ارسال */
#chat-send {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 50px !important;

    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;

    height: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;

    margin: 0 !important;
    padding: 0 !important;

    color: #ffffff !important;
    font-size: 16px !important;
    font-weight: 600 !important;

    background: #5b7ce4 !important;
    border: none !important;
    border-radius: 50% !important;
    cursor: pointer !important;

    box-shadow: 0 4px 12px rgba(91, 124, 237, 0.3) !important;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease !important;
}

#chat-send:hover {
    background: #4c6fd8 !important;
    transform: scale(1.05) !important;
    box-shadow: 0 6px 16px rgba(91, 124, 237, 0.4) !important;
}

#chat-send:active {
    transform: scale(0.95) !important;
}

/* اسکرول‌بار */
#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* انیمیشن */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* موبایل و تبلت کوچک */
@media (max-width: 600px) {
    #chat-box {
        right: 10px;
        bottom: 10px;

        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);

        height: calc(100vh - 20px);
        max-height: calc(100vh - 20px);

        min-width: 0;
        min-height: 0;

        border-radius: 16px;
    }

    #chat-box {
        height: calc(100dvh - 20px);
        max-height: calc(100dvh - 20px);
    }

    #chat-toggle {
        right: 15px;
        bottom: 15px;
        width: 56px;
        height: 56px;
    }

    .user-message,
    .bot-message {
        max-width: 88%;
    }

    #chat-input-container {
        padding: 12px;
    }

    #chat-messages {
        padding: 14px;
    }
}

/* موبایل‌های خیلی کوچک */
@media (max-width: 360px) {
    #chat-box {
        right: 5px;
        bottom: 5px;

        width: calc(100vw - 10px);
        max-width: calc(100vw - 10px);

        height: calc(100vh - 10px);
        max-height: calc(100vh - 10px);

        border-radius: 12px;
    }

    #chat-box {
        height: calc(100dvh - 10px);
        max-height: calc(100dvh - 10px);
    }
}

/* آیکون پولاریس */
.polaris-icon {
    display: inline-block;

    width: 70px;
    height: 70px;

    background: url('../images/polarisbot.png') center / contain no-repeat;
}
.chat-product-keyboard {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    direction: ltr;
    width: 100%;
}

.chat-product-btn {
    direction: rtl;
    text-align: right;
    padding: 6px 12px;
    border: 1px solid var(--accent, #0077cc);
    border-radius: 16px;
    background: transparent;
    color: var(--accent, #0077cc);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
}

.chat-product-btn:hover {
    background: var(--accent, #0077cc);
    color: #fff;
}

.chat-product-btn:focus-visible {
    outline: 2px solid var(--accent, #0077cc);
    outline-offset: 2px;
}
 
.telegram-album-card {
    max-width: 400px;
    background: #ffffff;
    border-top-right-radius: 12px;
    border-top-left-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    font-family: system-ui, -apple-system, sans-serif;
    direction: rtl;
    border: 1px solid #e0e0e0;
}

 
.telegram-album-grid {
    display: grid;
    gap: 4px;
    width: 100%;
    height: 100%;
    background-color: #f0f2f5;
}

 
.telegram-album-grid.count-1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

 
.telegram-album-grid.count-2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

 
.telegram-album-grid.count-3 {
    grid-template-columns: 1.2fr 1fr;
    grid-template-rows: 1fr 1fr;
}
.telegram-album-grid.count-3 .album-img:first-child {
    grid-row: span 2;
}

 
.telegram-album-grid.count-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

 
.album-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.album-img:hover {
    filter: brightness(0.95);
}

 
.telegram-album-caption {
    padding: 12px 14px;
    font-size: 14px;
    color: #222222;
    line-height: 1.5;
    background: #ffffff;
    border-top: 1px solid #f0f0f0;
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 12px;
}
.bot-message:has(.telegram-album-card) {
    padding: 0;
    overflow: hidden;
    background: transparent;
    border: none;
    box-shadow: none;
}