@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500&display=swap');

/* --- General Styles for Chatbot --- */
#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;
}

/* --- Positioning Logic: Shortcode vs Floating --- */
/* By default, it's inline for shortcode */
#danak-chat-container {
    margin: 20px auto;
}
/* When used with floating button, it becomes fixed */
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;
}

/* --- Visibility States for Floating Mode --- */
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);
}

/* --- Chat Header --- */
#danak-chat-header {
    background: var(--danak-chatbot-primary-color);
    color: var(--danak-chatbot-title-color);
    padding: 12px 20px;
    text-align: center;
    font-size: 1.1em;
    font-weight: 500;
    border-bottom: 1px solid #444;
}

/* --- Chat Window & Messages --- */
#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; }

/* --- Input Area --- */
#danak-chat-input-area {
    border-top: 1px solid #333;
    padding: 10px;
    background-color: #f5f5f5;
}
#danak-chat-form { display: flex; align-items: center; }
#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-send-btn {
    background-color: var(--danak-chatbot-primary-color);
    border: none; border-radius: 50%; width: 40px; height: 40px;
    margin-right: 10px; cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: filter 0.2s;
    overflow: hidden;
}
#danak-send-btn:hover { filter: brightness(0.9); }
#danak-send-btn svg { fill: #1a1a1a; transform: rotate(180deg); width: 22px; /* <<< این خط را اضافه کنید تا اندازه کنترل شود */
    height: 22px; /* <<< این خط را اضافه کنید تا اندازه کنترل شود */ }

/* --- Typing Indicator --- */
.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); } }

/* --- Floating Button --- */
#danak-floating-chat-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    background-color: var(--danak-chatbot-button-color);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99999;
    transition: transform 0.2s ease-in-out;
}
#danak-floating-chat-button:hover { transform: scale(1.1); }
#danak-floating-chat-button svg { fill: #ffffff; }

/* --- Popup Modal Styles --- */

#danak-fab {
    position: fixed;
    bottom: 25px;
    left: 25px;
    width: 60px;
    height: 60px;
    background: var(--danak-chatbot-button-color, #a88f59); /* Use variable with fallback */
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99998;
    transition: transform 0.2s ease-in-out;
}

#danak-fab:hover {
    transform: scale(1.1);
}

#danak-fab svg {
    fill: #ffffff;
}

#danak-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 99999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#danak-popup-overlay.active {
    display: block;
    opacity: 1;
}

/* Popup Modal Window - NEW Positioning */
#danak-popup-modal {
    position: fixed;
    bottom: 100px; 
    left: 25px;
    
    /* --- Animation Logic --- */
    transform: translateY(20px) scale(0.98); /* Start slightly lower and smaller */
    transform-origin: bottom left; 
    z-index: 100000;
    
    opacity: 0; /* Start fully transparent */
    visibility: hidden; /* Start completely hidden and unclickable */
    
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s; /* Animate all properties */
}

#danak-popup-modal.active {
    opacity: 1; /* Become fully visible */
    visibility: visible; /* Become visible and clickable */
    transform: translateY(0) scale(1); /* Move to final position and full size */
}

#danak-popup-content {
    background-color: transparent; /* The chatbot itself has the background */
    border-radius: 15px;
    overflow: hidden;
    width: 380px; /* Match chatbot width */
    max-width: 90vw;
    display: flex;
    flex-direction: column;
}

/* Override the main chatbot styles when inside the popup */
#danak-popup-content #danak-chat-container {
    width: 100%;
    height: 70vh; /* Match chatbot height */
    max-height: 650px;
    margin: 0;
    border: none;
    box-shadow: none;
}

#danak-popup-close {
    position: absolute;
    top: -15px;
    right: -15px;
    background-color: white;
    color: var(--danak-chatbot-primary-color, #d4af37);
    border: 2px solid var(--danak-chatbot-primary-color, #d4af37);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 28px;
    line-height: 32px;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* --- NEW: Animated Floating Button Styles (Original Structure + Fix) --- */

/* 1. Breathing animation for the main button */
@keyframes danakPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* 1b. INVERSE animation to keep the icon stable */
@keyframes danakIconInversePulse {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(0.952); } /* 1 / 1.05 ≈ 0.952 */
    100% { transform: translate(-50%, -50%) scale(1); }
}

/* 2. Base styles for the FAB */
#danak-fab {
    position: fixed;
    bottom: 25px;
    left: 25px;
    width: 60px;
    height: 60px;
    z-index: 99998;
    cursor: pointer;
    overflow: hidden;
    
    /* Apply the main pulse animation */
    animation: danakPulse 2.5s infinite ease-in-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* Keep the shadow static */
    transition: transform 0.2s ease-in-out; /* Add transition for hover */
}

#danak-fab:hover {
    animation-play-state: paused;
    transform: scale(1.1);
}

/* 3. Style for the icon wrappers */
.danak-fab-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    
    /* Apply the INVERSE pulse animation */
    animation: danakIconInversePulse 2.5s infinite ease-in-out;
    
    /* Transition for the open/close FADE effect */
    transition: opacity 0.3s ease-out;
    color: #ffffff;
}
/* <<< این بلوک کد جدید را اضافه کنید >>> */
.danak-fab-icon svg {
    display: block; /* Removes any extra space below the svg */
}

/* Specific size for the chat icon */
.danak-fab-svg-chat {
    width: 35px;
    height: 35px;
}

/* Specific (and larger) size for the robot icon to compensate for its viewBox */
.danak-fab-svg-robot {
    width: 62px;
    height: 62px;
}

/* Don't forget the close icon! */
.danak-fab-icon-close svg {
    width: 28px;
    height: 28px;
}

#danak-fab:hover .danak-fab-icon {
    animation: none; /* Stop the icon's inverse animation on hover */
    transform: translate(-50%, -50%) scale(1) !important; /* Force icon to reset to its original state */
}


.danak-fab-icon svg {
    display: block;
}

/* 4. Icon visibility logic (Simplified to FADE only, no rotation/scale) */
#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;
}

/* --- NEW: Live Status Indicator Styles (Upgraded with Glow Effect) --- */

/* 1. Make the header a flex container to align items easily */
#danak-chat-header {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 2. Style the indicator dot itself */
.danak-status-indicator {
    width: 10px;
    height: 10px;
    background-color: #2ecc71; /* A vibrant green */
    border-radius: 50%;
    margin-left: 8px; /* Space between the dot and the text */
    
    /* 3. Attach the animation */
    animation: danakGlowPulse 2s infinite ease-in-out;
}

/* 4. Define the NEW pulse animation that includes the glow effect */
@keyframes danakGlowPulse {
    0% {
        transform: scale(1);
        /* The initial, subtle glow */
        box-shadow: 0 0 6px 0 rgba(46, 204, 113, 0.7);
    }
    50% {
        transform: scale(1.2);
        /* The expanded, more intense glow at the peak of the pulse */
        box-shadow: 0 0 10px 2px rgba(46, 204, 113, 0.8);
    }
    100% {
        transform: scale(1);
        /* Return to the initial glow */
        box-shadow: 0 0 6px 0 rgba(46, 204, 113, 0.7);
    }
}

/* --- NEW: Branding Footer Styles --- */
.danak-chat-footer {
    text-align: center;
    padding: 2px 0;
    background-color: #f0f0f0; /* A slightly different background */
    border-top: 1px solid #e0e0e0;
}

.danak-chat-footer a {
    font-size: 12px;
    color: #888; /* Subtle gray color */
    text-decoration: none;
    transition: color 0.2s;
}

.danak-chat-footer a:hover {
    color: #555; /* Slightly darker on hover */
    text-decoration: underline;
}

/*
 * ===============================================
 * Universal Link Styling for Readability
 * ===============================================
 * Ensures links inside the chat window are always visible and match the theme color.
*/

#danak-chat-window .bot-message p a {
    /* Use the primary color variable defined by the user in settings */
    color: var(--danak-chatbot-primary-color, #d4af37);
    
    /* Make it slightly bolder and underlined to stand out */
    font-weight: 500; /* Use 500 for a semi-bold look */
    text-decoration: underline;
    
    /* Smooth transition for hover effect */
    transition: opacity 0.2s ease;
}

/* Make the link slightly lighter/faded on hover */
#danak-chat-window .bot-message p a:hover {
    opacity: 0.8;
}