@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500&display=swap');

/* =========================================
   1. استایل‌های اصلی چت‌بات (Main Chat UI)
   ========================================= */
#danak-chat-container {
    font-family: 'Vazirmatn', sans-serif;
    direction: rtl;
    width: 380px;
    max-width: 90vw;
    height: 70vh;
    max-height: 650px;
    border: 1px solid #333;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    background: #1a1a1a;
    display: flex;
    flex-direction: column;
    margin: 20px auto; 
}

/* نمایش در حالت شورتکد (غیر شناور) */
body > #danak-chat-container {
    position: fixed;
    bottom: 100px;
    left: 20px;
    margin: 0;
    z-index: 99998;
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out, visibility 0.3s;
}

body > #danak-chat-container.danak-chat-hidden {
    opacity: 0; visibility: hidden; transform: translateY(20px) scale(0.95);
}
body > #danak-chat-container.danak-chat-visible {
    opacity: 1; visibility: visible; transform: translateY(0) scale(1);
}

/* --- هدر چت --- */
#danak-chat-header {
    background: var(--danak-chatbot-primary-color);
    color: var(--danak-chatbot-title-color);
    padding: 12px 40px;
    text-align: center;
    font-size: 1.1em;
    font-weight: 500;
    border-bottom: 1px solid #444;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* دکمه‌های هدر */
#danak-header-close-btn, #danak-clear-history-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    cursor: pointer; width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.2s;
}
#danak-header-close-btn { left: 10px; }
#danak-clear-history-btn { right: 15px; transition: opacity 0.2s, transform 0.3s; }

#danak-header-close-btn svg, #danak-clear-history-btn svg {
    width: 20px; height: 20px; fill: var(--danak-chatbot-title-color);
}
#danak-header-close-btn:hover, #danak-clear-history-btn:hover { opacity: 0.7; }
#danak-clear-history-btn:hover { transform: translateY(-50%) rotate(-90deg); }

/* نشانگر آنلاین */
.danak-status-indicator {
    width: 10px; height: 10px;
    background-color: #2ecc71;
    border-radius: 50%;
    margin-left: 8px;
    animation: danakGlowPulse 2s infinite ease-in-out;
}
@keyframes danakGlowPulse {
    0% { transform: scale(1); box-shadow: 0 0 6px 0 rgba(46, 204, 113, 0.7); }
    50% { transform: scale(1.2); box-shadow: 0 0 10px 2px rgba(46, 204, 113, 0.8); }
    100% { transform: scale(1); box-shadow: 0 0 6px 0 rgba(46, 204, 113, 0.7); }
}

/* --- پنجره پیام‌ها --- */
#danak-chat-window {
    flex-grow: 1; padding: 20px; overflow-y: auto;
    background-color: #f5f2eb;
    display: flex; flex-direction: column;
}

.user-message, .bot-message {
    max-width: 80%; margin-bottom: 15px; padding: 10px 15px;
    border-radius: 20px; line-height: 1.6; word-wrap: break-word;
}
.user-message {
    background-color: var(--danak-chatbot-primary-color);
    color: #1a1a1a; border-bottom-right-radius: 5px; align-self: flex-end;
}
.bot-message {
    background-color: #ffffff;
    color: #333; border: 1px solid #e0e0e0; border-bottom-left-radius: 5px; align-self: flex-start;
}
.bot-message p, .user-message p { margin: 0; overflow-wrap: break-word; white-space: pre-wrap; }

/* لینک‌ها */
#danak-chat-window .bot-message p a {
    color: var(--danak-chatbot-primary-color);
    font-weight: 500; text-decoration: underline; transition: opacity 0.2s ease;
    word-break: break-all;
}
#danak-chat-window .bot-message p a:hover { opacity: 0.8; }

/* فوتر برندینگ */
.danak-chat-footer {
    text-align: center; padding: 2px 0;
    background-color: #f0f0f0; border-top: 1px solid #e0e0e0;
}
.danak-chat-footer a { font-size: 12px; color: #888; text-decoration: none; transition: color 0.2s; }
.danak-chat-footer a:hover { color: #555; text-decoration: underline; }

/* نشانگر تایپ */
.typing-indicator { align-self: flex-start; padding: 10px 15px; }
.typing-indicator span { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background-color: #999; animation: typing 1.4s infinite; margin: 0 2px; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }


/* =========================================
   2. ناحیه ورودی و دکمه‌ها (Input Area)
   ========================================= */
#danak-chat-input-area {
    border-top: 1px solid #333; padding: 10px; background-color: #f5f5f5;
}
#danak-chat-form {
    display: flex; align-items: center; gap: 5px;
}
#danak-user-input {
    flex-grow: 1; border: 1px solid #ccc; border-radius: 20px;
    padding: 10px 15px; font-size: 1em; font-family: 'Vazirmatn', sans-serif;
    outline: none; background: #fff; color: #333;
}
#danak-user-input:focus { border-color: var(--danak-chatbot-primary-color); }

/* دکمه میکروفون */
#danak-mic-btn {
    background: transparent; border: none; cursor: pointer; padding: 5px;
    color: #888; display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%; transition: all 0.2s ease;
    flex-shrink: 0;
}
#danak-mic-btn:hover {
    background-color: rgba(0,0,0,0.05); color: var(--danak-chatbot-primary-color);
}
#danak-mic-btn.is-listening {
    color: #e74c3c !important; background-color: rgba(231, 76, 60, 0.1);
    animation: micPulse 1.5s infinite;
}
@keyframes micPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(231, 76, 60, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

/* دکمه ارسال */
#danak-send-btn {
    flex-shrink: 0; background-color: var(--danak-chatbot-primary-color);
    border: none; border-radius: 50%; width: 40px; height: 40px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: filter 0.2s; padding: 0;
}
#danak-send-btn:hover { filter: brightness(0.9); }
#danak-send-btn svg { fill: #1a1a1a; transform: rotate(180deg); width: 24px; height: 24px; }


/* =========================================
   3. لایه‌بندی و مودال (Z-Index Fixed)
   ========================================= */

/* دکمه شناور */
#danak-fab {
    position: fixed !important;
    bottom: 25px; left: 25px;
    width: 60px; height: 60px;
    background: var(--danak-chatbot-button-color, #a88f59);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; overflow: hidden;
    transition: transform 0.2s ease-in-out;
    animation: danakPulse 2.5s infinite ease-in-out;
    
    /* لایه: روی Overlay، زیر Modal */
    z-index: 999999995 !important;
}
#danak-fab:hover { animation-play-state: paused; transform: scale(1.1); }
@keyframes danakPulse {
    0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); }
}

/* آیکون‌های دکمه شناور */
.danak-fab-icon {
    position: absolute; top: 50%; left: 50%;
    animation: danakIconInversePulse 2.5s infinite ease-in-out;
    transition: opacity 0.3s ease-out; color: #ffffff;
}
@keyframes danakIconInversePulse {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(0.952); }
    100% { transform: translate(-50%, -50%) scale(1); }
}
#danak-fab:hover .danak-fab-icon { animation: none; transform: translate(-50%, -50%) scale(1) !important; }
.danak-fab-icon svg { display: block; }
.danak-fab-svg-chat { width: 35px; height: 35px; }
.danak-fab-svg-robot { width: 62px; height: 62px; }
.danak-fab-icon-close svg { width: 28px; height: 28px; }

#danak-fab .danak-fab-icon-open { opacity: 1; }
#danak-fab .danak-fab-icon-close { opacity: 0; pointer-events: none; }
#danak-fab.is-open .danak-fab-icon-open { opacity: 0; pointer-events: none; }
#danak-fab.is-open .danak-fab-icon-close { opacity: 1; }

/* لایه سیاه (Overlay) */
#danak-popup-overlay {
    position: fixed !important; top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none; opacity: 0; transition: opacity 0.3s ease;
    
    /* لایه: پایین‌ترین */
    z-index: 999999990 !important;
}
#danak-popup-overlay.active { display: block; opacity: 1; }

/* پنجره اصلی (Modal) */
#danak-popup-modal {
    position: fixed !important;
    transform: translateY(20px) scale(0.98);
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
    
    /* لایه: بالاترین */
    z-index: 999999999 !important;
}
#danak-popup-modal.active { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

/* محتوای داخلی پنجره */
#danak-popup-content {
    background-color: transparent;
    border-radius: 15px; overflow: hidden;
    width: 380px; max-width: 90vw;
    display: flex; flex-direction: column;
    position: relative;
    z-index: 1000000000 !important;
}
#danak-popup-content #danak-chat-container {
    width: 100%; height: 70vh; max-height: 650px;
    margin: 0; border: none; box-shadow: none;
}
#danak-popup-close { display: none; }


/* =========================================
   4. سوالات متداول (FAQ)
   ========================================= */
#danak-faq-container { padding: 0; border-top: 1px solid #e0e0e0; background-color: #f5f2eb; }
.danak-faq-header {
    font-size: 14px; font-weight: 500; color: #555;
    padding: 8px 15px; cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: background-color 0.2s, color 0.2s; position: relative;
}
.danak-faq-header::after {
    content: ''; position: absolute; bottom: 0; right: 15px; left: 15px; height: 1px;
    background-color: #e0e0e0; transform: scaleX(0); transition: transform 0.3s ease;
}
.danak-faq-header:hover::after { transform: scaleX(1); }
.danak-faq-header svg { width: 22px; height: 22px; fill: #888; transition: transform 0.3s ease-in-out, fill 0.2s; }
.danak-faq-header:hover svg { fill: var(--danak-chatbot-primary-color); }
.danak-faq-header.active svg { transform: rotate(90deg); }
.danak-faq-header.active { color: var(--danak-chatbot-primary-color); }

.danak-faq-items-wrapper {
    display: none; background-color: #ffffff;
    border-top: 1px solid #e0e0e0; padding: 5px 0;
    max-height: 150px; overflow-y: auto;
}
.danak-faq-items-wrapper::-webkit-scrollbar { width: 6px; }
.danak-faq-items-wrapper::-webkit-scrollbar-track { background: #f1f1f1; }
.danak-faq-items-wrapper::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.danak-faq-items { display: flex; flex-direction: column; }
.danak-faq-question {
    font-family: 'Vazirmatn', sans-serif;
    display: flex; align-items: center; width: 100%; text-align: right;
    padding: 10px 20px; background: none; border: none; cursor: pointer;
    font-size: 14px; color: #444; position: relative;
    transition: background-color 0.2s, color 0.2s, padding-right 0.2s ease;
}
.danak-faq-question::after {
    content: ''; position: absolute; bottom: 0; right: 20px; left: 20px; height: 1px; background-color: #f0f0f0;
}
.danak-faq-items .danak-faq-question:last-child::after { display: none; }
.danak-faq-question:hover {
    background-color: rgba(212, 175, 55, 0.05);
    color: var(--danak-chatbot-primary-color);
    padding-right: 25px;
    box-shadow: inset 3px 0 0 0 var(--danak-chatbot-primary-color);
}
.danak-faq-question .danak-faq-q-icon {
    width: 16px; height: 16px; fill: #bbb;
    margin-left: 10px; transition: fill 0.2s;
}
.danak-faq-question:hover .danak-faq-q-icon { fill: var(--danak-chatbot-primary-color); }
.danak-faq-question span { flex-grow: 1; }


/* =========================================
   5. کارت محصول (Product Card)
   ========================================= */
.danak-product-card {
    display: flex; background: #fff;
    border: 1px solid #e0e0e0; border-radius: 12px;
    padding: 10px; margin-top: 10px; gap: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: transform 0.2s; align-items: center; max-width: 100%;
}
.danak-product-card:hover {
    transform: translateY(-2px); box-shadow: 0 5px 12px rgba(0,0,0,0.1);
}

.danak-pc-img {
    position: relative; width: 70px; height: 70px; flex-shrink: 0;
}
.danak-pc-img img {
    width: 100%; height: 100%; object-fit: cover; border-radius: 8px;
}
.danak-out-stock {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(255,0,0,0.7); color: #fff; font-size: 10px;
    text-align: center; padding: 2px;
    border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;
}

.danak-pc-info {
    flex-grow: 1; display: flex; flex-direction: column; justify-content: space-between;
}
.danak-pc-title {
    margin: 0 0 5px 0; font-size: 13px; line-height: 1.3; font-weight: bold;
}
.danak-pc-title a { text-decoration: none; color: #333; }

.danak-pc-price {
    font-size: 13px; color: #2ecc71; font-weight: bold; margin-bottom: 8px;
}
.danak-pc-price del { color: #999; font-size: 11px; margin-left: 5px; }

.danak-pc-btn {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--danak-chatbot-primary-color);
    color: #1a1a1a !important; text-decoration: none !important;
    padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 500;
    transition: opacity 0.2s; width: fit-content;
}
.danak-pc-btn:hover { opacity: 0.9; }
.danak-pc-btn svg { margin-right: 5px; fill: currentColor; }