
/* ──── دکمه اصلی چت ──── */
.goftani-chat-button {
    position: fixed;
    bottom: max(20px, 4vh);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    box-shadow: 0 5px 20px rgba(30, 60, 114, 0.4);
    cursor: pointer;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: none;
    outline: none;
    user-select: none;
}

.goftani-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(30, 60, 114, 0.5);
}

.goftani-chat-button.goftani-position-left {
    right: auto;
    left: max(20px, 3%);
}

.goftani-chat-button.goftani-position-right {
    right: max(20px, 3%);
    left: auto;
}

.goftani-chat-button  {
    width: 24px;
    height: 24px;
    fill: #ffffff;
    transition: transform 0.3s ease;
}

.goftani-chat-button:hover .goftani-btn-icon {
    transform: rotate(10deg);
}

/* ──── بدنه اصلی چت‌باکس ──── */
.goftani-chat-container {
    position: fixed;
    bottom: max(120px, 22%);
    width: clamp(300px, 90vw, 380px);
    height: clamp(450px, 80dvh, 550px);
    max-width: calc(100vw - 40px);
    max-height: calc(100dvh - 120px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
    z-index: 99998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Vazir', Tahoma, sans-serif;
    animation: goftani-bounceIn 0.3s ease-out;
}

.goftani-chat-container.goftani-position-left {
    right: auto;
    left: max(20px, 3%);
}

.goftani-chat-container.goftani-position-right {
    right: max(20px, 3%);
    left: auto;
}

.goftani-chat-container.active {
    display: flex;
}

/* ──── هدر ──── */
.goftani-chat-header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #fff;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.goftani-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.goftani-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.goftani-chat-avatar svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

.goftani-chat-title h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.goftani-chat-title p {
    margin: 3px 0 0;
    font-size: 11px;
    opacity: 0.9;
}

.goftani-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.goftani-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.goftani-chat-close svg {
    width: 12px;
    height: 12px;
    fill: #ffffff;
}

/* ──── بخش پیام‌ها ──── */
.goftani-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
}

.goftani-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 13px;
    line-height: 1.6;
    word-wrap: break-word;
    animation: goftani-bounceIn 0.3s ease-out;
}

.goftani-message.received {
    background: #fff;
    align-self: flex-start;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    color: #333;
}

.goftani-message.sent {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #fff;
    align-self: flex-end;
    border-bottom-left-radius: 4px;
}

.goftani-message-time {
    font-size: 9px;
    opacity: 0.7;
    margin-top: 5px;
    display: block;
}

/* ──── پیام خوش‌آمدگویی ──── */
.goftani-welcome-message {
    text-align: center;
    padding: 20px;
    background: #fff;
    border-radius: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
}

.goftani-welcome-message h4 {
    margin: 0 0 10px;
    color: #1e3c72;
    font-size: 16px;
}

.goftani-welcome-message p {
    margin: 0;
    color: #666;
    font-size: 13px;
    line-height: 1.6;
}

/* ========== بخش ورودی پیام (منظم و ریسپانسیو) ========== */
.goftani-chat-input-area {
    padding: 12px 15px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.goftani-chat-input {
    flex: 1;
    min-width: 0; /* جلوگیری از سرریز */
    padding: 10px 12px;
    border: 2px solid #e8e8e8;
    border-radius: 25px;
    font-family: 'Vazir', Tahoma, sans-serif;
    font-size: 13px;
    outline: none;
    transition: all 0.3s ease;
    width: auto;
}

.goftani-chat-input:focus {
    border-color: #1e3c72;
}

/* دکمه‌های گرد (ارسال، ضمیمه، ویس، ایموجی) */
.goftani-send-btn,
.goftani-attach-btn,
.goftani-voice-btn,
.goftani-emoji-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    border: none;
    background: #f0f0f0;
    color: #666;
    font-size: 20px;
    padding: 0;
}

.goftani-send-btn {
    background: linear-gradient(135deg, #F0F0F0 0%, #F0F0F0 100%);
    color: #fff;
}

.goftani-send-btn svg {
    width: 16px;
    height: 16px;
    fill: #000000;
}

.goftani-attach-btn:hover,
.goftani-voice-btn:hover,
.goftani-emoji-btn:hover {
    background: #e0e0e0;
    color: #1e3c72;
}

.goftani-send-btn:hover {
    transform: scale(1.05);
}

/* دکمه ویس در حالت ضبط */
.goftani-voice-btn.recording {
    background: #ff4444;
    color: #fff;
    animation: goftani-pulse 1.5s infinite;
}

/* تایپینگ ایندیکیتور */
.goftani-typing-indicator {
    display: none;
    padding: 10px 14px;
    background: #fff;
    border-radius: 18px;
    border-bottom-right-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.goftani-typing-indicator.active {
    display: flex;
}

.goftani-typing-dots {
    display: flex;
    gap: 4px;
}

.goftani-typing-dots span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: goftani-typing 1.4s infinite;
}

.goftani-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.goftani-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes goftani-typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* واترمارک */
.goftani-watermark {
    text-align: center;
    padding: 6px;
    font-size: 9px;
    color: #999;
    background: #f5f5f5;
    border-top: 1px solid #eee;
}

/* فایل ضمیمه */
.goftani-message-attachment {
    margin-top: 8px;
}

.goftani-message-attachment img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
}

.goftani-message-attachment audio {
    max-width: 220px;
    border-radius: 20px;
    margin-top: 5px;
}

.goftani-file-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
}

.goftani-message.received .goftani-file-box {
    background: rgba(0, 0, 0, 0.05);
}

.goftani-file-box-icon {
    font-size: 20px;
}

.goftani-file-box-info {
    flex: 1;
    min-width: 0;
}

.goftani-file-box-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.goftani-file-box-size {
    font-size: 10px;
    opacity: 0.7;
}

/* پیش‌نمایش فایل */
.goftani-file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f0f4ff;
    border-radius: 12px;
    margin-bottom: 10px;
    position: relative;
}

.goftani-file-preview-image img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 10px;
}

.goftani-remove-file {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #dc3545;
    color: #fff;
    border: 2px solid #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.goftani-upload-progress,
.goftani-error-message {
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 10px;
    font-size: 12px;
}

.goftani-upload-progress {
    background: #fff3cd;
    color: #856404;
}

.goftani-error-message {
    background: #f8d7da;
    color: #721c24;
}

/* ایموجی پیکر */
#goftani-emoji-picker {
    position: absolute;
    bottom: 55px;
    right: 5px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 999999;
    width: 270px;
    max-height: 250px;
    overflow-y: auto;
    direction: rtl;
}

#goftani-emoji-picker .goftani-emoji-btn {
    cursor: pointer;
    font-size: 22px;
    padding: 4px;
    display: inline-block;
    background: transparent;
}

/* فرم احراز هویت */
#goftani-auth-form {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    background: white;
    border-radius: 20px;
    overflow: hidden;
}

/* ریسپانسیو موبایل */
@media (max-width: 480px) {
    .goftani-chat-container {
        width: 100%;
        height: 100dvh;
        max-width: 100%;
        max-height: 100dvh;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0;
        border-radius: 0;
    }
    .goftani-chat-button {
        width: 55px;
        height: 55px;
        bottom: 20px;
        right: 20px;
    }
    .goftani-message {
        max-width: 88%;
    }
    .goftani-send-btn,
    .goftani-attach-btn,
    .goftani-voice-btn,
    .goftani-emoji-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    .goftani-chat-input {
        padding: 8px 10px;
    }
    #goftani-emoji-picker {
        width: 240px;
        right: 0;
        bottom: 60px;
    }
}

/* انیمیشن‌ها */
@keyframes goftani-bounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes goftani-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(30, 60, 114, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 15px rgba(30, 60, 114, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(30, 60, 114, 0); }
}

.goftani-chat-button.bounceIn { animation: goftani-bounceIn 0.8s ease-out; }
.goftani-chat-button.pulse    { animation: goftani-pulse   2s infinite; }

/* دراگ و دراپ */
.goftani-drag-over {
    border: 2px dashed #1e3c72 !important;
    background: #f0f4ff !important;
}









.goftani-voice-btn {
    width: 40px; height: 40px; border-radius: 50%;
    background: #f0f0f0; border: none; cursor: pointer;
    font-size: 20px; display: flex; align-items: center; justify-content: center;
}
.goftani-voice-btn.recording {
    background: #ff4444; color: #fff; animation: pulse 1.5s infinite;
}