/* --- 1. Import Vazirmatn Font --- */
@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

/* --- 2. Apply Font and General Styles --- */
#ssa-chat-container {
    /* Main Container */
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    max-width: 90%;
    height: 500px;
    max-height: 80vh;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    transition: opacity 0.3s ease, transform 0.3s ease;
    /* Apply Font to the entire container and its children */
    font-family: 'Vazirmatn', sans-serif;
    direction: rtl; /* Set direction to Right-to-Left */
}

#ssa-chat-container.ssa-hidden,
#ssa-chat-toggle.ssa-hidden {
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
}

/* Chat Toggle Button */
#ssa-chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #0073aa;
    color: white;
    font-size: 30px;
    line-height: 60px;
    text-align: center;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 9998;
    transition: transform 0.2s ease, opacity 0.3s ease;
}
#ssa-chat-toggle:hover {
    transform: scale(1.1);
}

/* Chat Header */
#ssa-chat-header {
    background-color: #0073aa;
    color: white;
    padding: 10px 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
#ssa-chat-header span {
    flex-grow: 1;
}
#ssa-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

/* Avatar Styles */
.ssa-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-left: 10px;
    border: 2px solid rgba(255,255,255,0.5);
}

/* Chat Body & Messages */
#ssa-chat-body {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f9f9f9;
}
.ssa-message {
    padding: 8px 12px;
    border-radius: 15px;
    margin-bottom: 10px;
    max-width: 80%;
    line-height: 1.6; /* Improved line height for Persian */
    word-wrap: break-word;
    text-align: right; /* Align text to the right */
}
.ssa-user {
    background-color: #0073aa;
    color: white;
    border-bottom-right-radius: 3px;
    margin-left: auto;
}
.ssa-assistant {
    background-color: #e5e5e5;
    color: #333;
    border-bottom-left-radius: 3px;
    margin-right: auto;
}

/* Typing Indicator Styles */
.ssa-typing-indicator {
    display: flex;
    align-items: center;
    padding-top: 12px;
    padding-bottom: 12px;
}
.ssa-typing-indicator span:not(.ssa-typing-dot) {
    margin-left: 5px;
}
.ssa-typing-indicator .ssa-typing-dot {
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: #aaa;
    border-radius: 50%;
    animation: ssa-dot-pulse 1.4s infinite ease-in-out both;
}
.ssa-typing-indicator .ssa-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}
.ssa-typing-indicator .ssa-typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}
@keyframes ssa-dot-pulse {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1.0);
    }
}

/* Chat Footer */
#ssa-chat-footer {
    display: flex;
    padding: 10px;
    border-top: 1px solid #ddd;
    background-color: #fff;
    flex-shrink: 0;
}
#ssa-chat-input {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 8px 15px;
    margin-left: 10px;
    font-size: 14px;
    font-family: 'Vazirmatn', sans-serif; /* Ensure font is applied here too */
}
#ssa-send-btn {
    border: none;
    background-color: #0073aa;
    color: white;
    border-radius: 20px;
    padding: 8px 15px;
    cursor: pointer;
    font-weight: bold;
    font-family: 'Vazirmatn', sans-serif; /* And here */
}
#ssa-send-btn:hover {
    background-color: #005a87;
}