:root {
    --chat-color: #007bff;
    --chat-bg: #fff;
    --chat-text: #333;
    --chat-border: #e0e0e0;
    --chat-shadow: 0 5px 30px rgba(0,0,0,0.15);
    --message-user-bg: #007bff;
    --message-user-text: #fff;
    --message-admin-bg: #f0f0f0;
    --message-admin-text: #333;
}

/* ویجت اصلی */
#mahan-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: IRANSans, Tahoma, Arial, sans-serif;
    direction: rtl;
}

#mahan-chat-widget.position-bottom-right {
    bottom: 20px;
    right: 20px;
}

#mahan-chat-widget.position-bottom-left {
    bottom: 20px;
    left: 20px;
}

#mahan-chat-toggle {
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #66ead4 0%, #3548f7 100%);
    border-radius: 50%;
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    padding: 0;
    width: 60px;
    height: 60px;
}

#mahan-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

#mahan-chat-toggle:active {
    transform: translateY(0);
}

#mahan-chat-toggle i {
    font-size: 20px;
    color: white;
}

/* بج تعداد پیام‌های نخوانده */
#mahan-chat-toggle .unread-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    min-width: 22px;
    height: 22px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 2px solid white;
}

/* وقتی دکمه در حالت hover هست */
#mahan-chat-toggle:hover .unread-badge {
    transform: scale(1.1);
}

/* انیمیشن برای جلب توجه */
@keyframes gentlePulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

#mahan-chat-toggle {
    animation: gentlePulse 2s infinite;
}

#mahan-chat-toggle:hover {
    animation: none;
}

/* برای حالت‌های مختلف */
#mahan-chat-toggle.has-new {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
}

/* ================ ریسپانسیو برای موبایل ================ */
@media (max-width: 768px) {
    #mahan-chat-widget.position-bottom-right,
    #mahan-chat-widget.position-bottom-left {
        bottom: 15px;
        right: 15px;
        left: auto;
    }
    
    /* دکمه موبایل - دایره‌ای با فقط آیکون */
    #mahan-chat-toggle {
        width: 60px;
        height: 60px;
        padding: 0;
        border-radius: 50%; /* دایره */
        gap: 0;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.5);
    }
    
    /* مخفی کردن متن در موبایل */
    #mahan-chat-toggle span:not(.unread-badge) {
        display: none;
    }
    
    /* بزرگتر کردن آیکون */
    #mahan-chat-toggle i {
        font-size: 26px;
    }
    
    /* تنظیم مجدد badge */
    #mahan-chat-toggle .unread-badge {
        top: -5px;
        right: -5px;
        min-width: 24px;
        height: 24px;
        font-size: 13px;
    }
}

/* برای موبایل‌های خیلی کوچک */
@media (max-width: 480px) {
    #mahan-chat-toggle {
        width: 55px;
        height: 55px;
    }
    
    #mahan-chat-toggle i {
        font-size: 24px;
    }
    
    #mahan-chat-toggle .unread-badge {
        min-width: 22px;
        height: 22px;
        font-size: 12px;
    }
}

/* موقعیت ویجت اصلی */
#mahan-chat-widget {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
}

#mahan-chat-widget.position-bottom-right {
    right: 20px;
}

#mahan-chat-widget.position-bottom-left {
    left: 20px;
}

/* کانتینر چت */
#mahan-chat-container {
    position: absolute;
    bottom: 0;
    width: 320px;
    height: 520px;
    background: var(--chat-bg);
    border-radius: 15px;
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

/* موقعیت کانتینر بر اساس موقعیت والد */
.position-bottom-right #mahan-chat-container {
    right: 0;
}

.position-bottom-left #mahan-chat-container {
    left: 0;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* هدر چت */
.mahan-chat-header {
    background: var(--chat-color) !important;
    color: white;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 50px;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: bold;
}

.status {
    font-size: 9px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
    max-height: 20px
}

.status svg,
.status i {
    font-size: 8px;
    display: block;
}

.status.online svg,
.status.online i {
    color: #00ff00;
}

.status.offline svg,
.status.offline i {
    color: #bdc3c7;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.header-actions button {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #000000;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 32px;
    line-height: 1;
    padding: 0;
    font-weight: bold;
}

.header-actions button:hover {
    background: rgba(0, 0, 0, 0.2);
}

.close-btn:hover {
    background: #e74c3c;
    color: white;
    border-color: #c0392b;
}

/* بدنه چت */
.mahan-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="320" height="520" viewBox="0 0 320 520"%3E%3Crect width="320" height="520" fill="%23ffffff"/%3E%3Cg transform="rotate(-15 280 55)"%3E%3Ccircle cx="280" cy="55" r="22" fill="%23e8d5a3"/%3E%3Ccircle cx="292" cy="43" r="17" fill="%23ffffff"/%3E%3C/g%3E%3Cg transform="rotate(25 45 65)"%3E%3Ccircle cx="45" cy="65" r="18" fill="%23e8d5a3"/%3E%3Ccircle cx="55" cy="55" r="14" fill="%23ffffff"/%3E%3C/g%3E%3Cg transform="rotate(-35 160 35)"%3E%3Ccircle cx="160" cy="35" r="15" fill="%23e8d5a3"/%3E%3Ccircle cx="168" cy="27" r="12" fill="%23ffffff"/%3E%3C/g%3E%3Cg transform="rotate(45 235 170)"%3E%3Ccircle cx="235" cy="170" r="13" fill="%23e8d5a3"/%3E%3Ccircle cx="242" cy="163" r="10" fill="%23ffffff"/%3E%3C/g%3E%3Cg transform="rotate(-20 85 210)"%3E%3Ccircle cx="85" cy="210" r="12" fill="%23e8d5a3"/%3E%3Ccircle cx="92" cy="203" r="9" fill="%23ffffff"/%3E%3C/g%3E%3Cg transform="rotate(-55 160 490)"%3E%3Ccircle cx="160" cy="490" r="24" fill="%23e8d5a3"/%3E%3Ccircle cx="174" cy="476" r="19" fill="%23ffffff"/%3E%3C/g%3E%3Cg transform="rotate(30 65 405)"%3E%3Ccircle cx="65" cy="405" r="11" fill="%23e8d5a3"/%3E%3Ccircle cx="71" cy="399" r="8" fill="%23ffffff"/%3E%3C/g%3E%3Cg transform="rotate(15 25 115)"%3E%3Cpolygon points="25,105 27,113 35,113 29,118 31,126 25,121 19,126 21,118 15,113 23,113" fill="%23d4c5a9" opacity="0.9"/%3E%3C/g%3E%3Cg transform="rotate(-30 100 135)"%3E%3Cpolygon points="100,127 102,134 108,134 103,138 105,145 100,141 95,145 97,138 92,134 98,134" fill="%23d4c5a9" opacity="0.9"/%3E%3C/g%3E%3Cg transform="rotate(45 255 100)"%3E%3Cpolygon points="255,92 257,99 263,99 258,103 260,110 255,106 250,110 252,103 247,99 253,99" fill="%23d4c5a9" opacity="0.9"/%3E%3C/g%3E%3Cg transform="rotate(-60 295 145)"%3E%3Cpolygon points="295,137 297,144 303,144 298,148 300,155 295,151 290,155 292,148 287,144 293,144" fill="%23d4c5a9" opacity="0.8"/%3E%3C/g%3E%3Cg transform="rotate(25 40 280)"%3E%3Cpolygon points="40,272 42,279 48,279 43,283 45,290 40,286 35,290 37,283 32,279 38,279" fill="%23d4c5a9" opacity="0.8"/%3E%3C/g%3E%3Cg transform="rotate(-45 140 310)"%3E%3Cpolygon points="140,302 142,309 148,309 143,313 145,320 140,316 135,320 137,313 132,309 138,309" fill="%23d4c5a9" opacity="0.8"/%3E%3C/g%3E%3Cg transform="rotate(55 215 290)"%3E%3Cpolygon points="215,282 217,289 223,289 218,293 220,300 215,296 210,300 212,293 207,289 213,289" fill="%23d4c5a9" opacity="0.7"/%3E%3C/g%3E%3Cg transform="rotate(35 75 375)"%3E%3Cpolygon points="75,367 77,374 83,374 78,378 80,385 75,381 70,385 72,378 67,374 73,374" fill="%23d4c5a9" opacity="0.7"/%3E%3C/g%3E%3Cg transform="rotate(-50 225 415)"%3E%3Cpolygon points="225,407 227,414 233,414 228,418 230,425 225,421 220,425 222,418 217,414 223,414" fill="%23d4c5a9" opacity="0.7"/%3E%3C/g%3E%3Cg transform="rotate(20 290 455)"%3E%3Cpolygon points="290,447 292,454 298,454 293,458 295,465 290,461 285,465 287,458 282,454 288,454" fill="%23d4c5a9" opacity="0.6"/%3E%3C/g%3E%3Cg transform="rotate(-65 45 495)"%3E%3Cpolygon points="45,487 47,494 53,494 48,498 50,505 45,501 40,505 42,498 37,494 43,494" fill="%23d4c5a9" opacity="0.6"/%3E%3C/g%3E%3Cg fill="%23d4c5a9" opacity="0.4"%3E%3Ccircle cx="10" cy="25" r="1.5"/%3E%3Ccircle cx="310" cy="30" r="1.5"/%3E%3Ccircle cx="60" cy="160" r="2"/%3E%3Ccircle cx="260" cy="195" r="1.5"/%3E%3Ccircle cx="18" cy="345" r="2"/%3E%3Ccircle cx="300" cy="385" r="1.5"/%3E%3Ccircle cx="140" cy="25" r="1.5"/%3E%3Ccircle cx="185" cy="150" r="2"/%3E%3Ccircle cx="40" cy="245" r="1.5"/%3E%3Ccircle cx="280" cy="305" r="2"/%3E%3Ccircle cx="80" cy="500" r="1.5"/%3E%3Ccircle cx="220" cy="520" r="2"/%3E%3C/g%3E%3C/svg%3E');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.welcome-message {
    text-align: center;
    margin-bottom: 20px;
}

.admin-message {
    background: var(--message-admin-bg);
    color: var(--message-admin-text);
    padding: 10px 10px;
    border-radius: 15px;
    display: inline-block;
    max-width: 90%;
}

/* پیام‌ها */
#mahan-chat-messages {
    display: flex;
    flex-direction: column;
}

.message {
    display: flex;
    flex-direction: column; /* تغییر از row به column */
    margin-bottom: 12px;
    position: relative;
}

.message:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.message-sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.8;
}

.message-bubble {
    max-width: 80%;
    width: fit-content;
    min-width: 40px;
    padding: 8px 12px;
    border-radius: 15px;
    position: relative;
    word-wrap: break-word;
    word-break: break-word;
}

.message.customer {
    align-items: flex-start !important;
}

.message.customer .message-sender {
    color: #666;
    text-align: left;
    padding-right: 5px;
}

.message.customer .message-bubble {
    background: #dbd7a9;
    color: black;
    border-top-right-radius: 3px;
}

.message.customer .message-bubble .time {
    text-align: left;
}

.message.admin {
    align-items: flex-end !important;
}

.message.admin .message-sender {
    color: #666;
    text-align: right;
    padding-left: 5px;
}

.message.admin .message-bubble {
    background: #f0f0f0;
    color: #333;
    border-top-left-radius: 3px;
}

.message.admin .message-bubble .time {
    text-align: right;
}

.message.system {
    justify-content: center;
}

.message.system .message-content {
    background: #ffc107;
    color: #000;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 5px;
}

.message-content {
    max-width: 80%;
    font-size: 16px;
    padding: 5px 10px;
    border-radius: 15px;
    position: relative;
    word-wrap: break-word;
}

.message.customer .message-content {
    background: var(--message-user-bg);
    color: var(--message-user-text);
    border-bottom-right-radius: 5px;
}

.message.admin .message-content {
    background: var(--message-admin-bg);
    color: var(--message-admin-text);
    border-bottom-left-radius: 5px;
}

/* زمان داخل باکس */
.message-bubble .time {
    font-size: 9px;
    opacity: 0.7;
    display: block;
}

/* متن پیام */
.message-bubble .text {
    white-space: pre-wrap;
    line-height: 1.4;
}

/* فایل پیوست */
.file-attachment {
    margin-bottom: 5px;
}

.file-attachment a {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px;
    background: rgba(255,255,255,0.1);
    border-radius: 5px;
}

/* ایندیکیتور تایپ */
.typing-indicator {
    display: flex;
    gap: 3px;
    padding: 10px;
    justify-content: center;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* فرم اطلاعات */
.mahan-chat-info-form {
    background: rgba(226,218,207,0.53);
    border-radius: 16px;
    margin: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

/* اطمینان از اینکه هدر و فوتر شفاف باشند */
.mahan-chat-header,
.mahan-chat-footer {
    background: transparent;
}

/* بخش پیام‌ها شفاف */
.mahan-chat-messages {
    background: transparent;
}

.mahan-chat-info-form p {
    margin-bottom: 15px;
    font-weight: bold;
    color: #333;
}

.mahan-chat-info-form input {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid var(--chat-border);
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.mahan-chat-info-form input:focus {
    outline: none;
    border-color: var(--chat-color);
}

.mahan-chat-submit {
    width: 100%;
    padding: 12px;
    background: var(--chat-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.3s;
}

.mahan-chat-submit:hover {
    background: #0056b3;
}

/* فوتر چت */
/* ================ ناحیه ورود پیام با آیکون‌ها ================ */
.mahan-chat-footer {
    border-top: 1px solid var(--chat-border);
    background: white;
    padding: 5px;
}

/* نوار ابزار بالای ورودی */
.chat-toolbar {
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
    padding: 0 5px;
}

.toolbar-btn {
    width: 40px;
    height: 40px;
    border-radius: 50% !important;
    border: none !important;
    padding: 0 !important;
    background: #f0f0f0;
    cursor: pointer;
    color: #666;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    font-size: 0 !important;
    line-height: 0 !important;
}

.toolbar-btn:hover {
    background: var(--chat-color);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
}

.toolbar-btn i {
    font-size: 18px;
}

.toolbar-btn input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ناحیه ورود پیام */
.chat-input-area {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 0 5px;
}

#chat-message-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 10px 15px;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    max-height: 100px;
    min-height: 40px;
    box-sizing: border-box;
    transition: all 0.3s ease;
    outline: none;
    background: #f9f9f9;
}

#chat-message-input:focus {
    border-color: var(--chat-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* دکمه ارسال */
.send-btn {
    width: 45px;
    height: 45px;
    border-radius: 50% !important;
    border: none !important;
    padding: 0 !important;
    background: var(--chat-color);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
    margin-bottom: 0;
    font-size: 0 !important;
    line-height: 0 !important;
}

.send-btn:hover {
    background: #0056b3;
    transform: scale(1.05);
    box-shadow: 0 6px 15px rgba(0, 123, 255, 0.4);
}

.send-btn i {
    font-size: 18px;
}

/* پیش‌نمایش فایل */
.file-preview {
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: #f5f5f5;
    border-radius: 10px;
    margin-bottom: 10px;
}

.file-preview-item {
    width: 50px;
    height: 50px;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.file-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-preview-item .remove-file {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: red;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
}

/* ریسپانسیو برای موبایل */
@media (max-width: 480px) {
    .toolbar-btn {
        width: 32px;
        height: 32px;
    }
    
    .toolbar-btn i {
        font-size: 16px;
    }
    
    .send-btn {
        width: 40px;
        height: 40px;
    }
    
    .send-btn i {
        font-size: 16px;
    }
}


/* پیش‌نمایش فایل */
.file-preview {
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: #f5f5f5;
}

.file-preview-item {
    width: 50px;
    height: 50px;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.file-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-preview-item .remove-file {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: red;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
}

/* اسکرول‌بار */
.mahan-chat-body::-webkit-scrollbar {
    width: 6px;
}

.mahan-chat-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.mahan-chat-body::-webkit-scrollbar-thumb {
    background: var(--chat-color);
    border-radius: 3px;
}

/* ریسپانسیو */
@media (max-width: 480px) {
    #mahan-chat-container {
        width: 100%;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    #mahan-chat-toggle {
        width: 50px;
        height: 50px;
    }
    
    #mahan-chat-toggle i {
        font-size: 20px;
    }
}

/* حالت RTL */
.rtl #mahan-chat-container {
    font-family: IRANSans, Tahoma, Arial, sans-serif;
}

.rtl .message.customer .message-content {
    border-bottom-right-radius: 15px;
    border-top-left-radius: 5px;
}

.rtl .message.admin .message-content {
    border-bottom-left-radius: 15px;
    border-top-right-radius: 5px;
}

/* ================ استایل فایل‌ها در ویجت مشتری ================ */

.file-message {
    margin: 5px 0;
}

.file-preview-container {
    max-width: 200px;
    border-radius: 8px;
    overflow: hidden;
}

.file-preview-container img {
    width: 100%;
    cursor: pointer;
}

.file-preview-image {
    width: 100%;
    height: auto;
    cursor: pointer;
    transition: transform 0.3s;
    display: block;
}

.file-preview-image:hover {
    transform: scale(1.02);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: #f0f0f0;
    font-size: 11px;
    border-top: 1px solid #e0e0e0;
}

.file-info i {
    color: #666;
    font-size: 12px;
}

.file-name {
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
}

.file-attachment {
    margin: 5px 0;
}

.file-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f0f0f0;
    border-radius: 8px;
    text-decoration: none;
    color: #2271b1;
    font-size: 13px;
    transition: background 0.3s;
}

.file-link:hover {
    background: #e0e0e0;
    text-decoration: none;
    color: #135e96;
}

.file-link i {
    font-size: 16px;
    color: #666;
}

/* برای پیام‌های مشتری (سمت راست) */
.message.customer .file-preview-container {
    background: var(--chat-color);
    border: 1px solid rgba(255,255,255,0.1);
}

.message.customer .file-info {
    background: rgba(0,0,0,0.2);
    border-top: 1px solid rgba(255,255,255,0.1);
}

.message.customer .file-info i,
.message.customer .file-name {
    color: white;
}

.message.customer .file-link {
    background: rgba(0,0,0,0.2);
    color: white;
}

.message.customer .file-link:hover {
    background: rgba(0,0,0,0.3);
}

.message.customer .file-link i {
    color: white;
}

/* برای پیام‌های ادمین (سمت چپ) */
.message.admin .file-preview-container {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
}

.message.admin .file-link {
    background: #f0f0f0;
    color: #2271b1;
}

/* ================ پنل ایموجی ================ */

.emoji-panel {
    position: absolute;
    bottom: 100px;
    right: 10px;
    width: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.15);
    z-index: 1000;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* ۶ ستون */
    gap: 5px;
    padding: 10px;
    /* حذف max-height و overflow */
}

/* اگه می‌خوای فقط یه ردیف باشه، تعداد ایموجی‌ها رو محدود کن */
.emoji-grid span {
    font-size: 24px;
    text-align: center;
    padding: 8px 5px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-grid span:hover {
    background: #f0f0f0;
    transform: scale(1.2);
}

.emoji-grid span img.emoji {
    width: 24px;
    height: 24px;
    pointer-events: none;
}

/* برای موبایل */
@media (max-width: 480px) {
    .emoji-panel {
        width: 250px;
        bottom: 90px;
        right: 5px;
    }
    
    .emoji-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 3px;
        padding: 8px;
    }
    
    .emoji-grid span {
        font-size: 20px;
        padding: 6px 3px;
    }
    
    .emoji-grid span img.emoji {
        width: 20px;
        height: 20px;
    }
}

/* وقتی پنل باز هست */
.emoji-panel.show {
    display: block;
}

/* استایل برای پیام‌های حاوی فایل */
.message.file-message .message-content {
    max-width: 250px;
    padding: 0;
    background: transparent !important;
}

.message.admin.file-message .message-content {
    background: transparent !important;
}

.message.customer.file-message .message-content {
    background: transparent !important;
}

.file-preview-container {
    background: #f5f5f5;
    border-radius: 12px;
    overflow: hidden;
    padding: 5px;
}

.message.customer .file-preview-container {
    background: rgba(0, 123, 255, 0.1);
}

.file-preview-image {
    width: 100%;
    max-width: 200px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.file-preview-image:hover {
    transform: scale(1.02);
}

.file-info {
    font-size: 12px;
}

.file-link {
    text-decoration: none;
}

.file-link:hover {
    text-decoration: underline;
}

/* دایره وضعیت آنلاین/آفلاین - بزرگ */
.mahan-chat-header .status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    margin-top: 5px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    transition: all 0.3s ease;
}

.status.online .status-dot {
    background-color: #00f808;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.8);
    animation: pulse 1.5s infinite;
}

.status.offline .status-dot {
    background-color: #c5c5c5;
    box-shadow: none;
    animation: none;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 5px rgba(76, 175, 80, 0.3);
        transform: scale(1.1);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
        transform: scale(1);
    }
}

.status-text {
    font-size: 12px;
    font-weight: 500;
}

.status.online .status-text {
    color: #00f808;
}

.status.offline .status-text {
    color: #9e9e9e;
}

/* دکمه ضبط صدا */
.voice-record-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50% !important;
    transition: all 0.2s ease;
    color: #666;
}

.voice-record-btn:hover {
    background: #f0f0f0;
}

.voice-record-btn.recording-active {
    background: #ff4757;
    color: white;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ناحیه ضبط صدا */
.audio-recording-area {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: #fff3e0;
    border-radius: 8px;
    margin-bottom: 10px;
}

.recording-timer {
    font-size: 18px;
    font-weight: bold;
    color: #ff4757;
    font-family: monospace;
}

.recording-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 30px;
}

.recording-wave span {
    width: 3px;
    background: #ff4757;
    border-radius: 2px;
    animation: wave 0.8s ease infinite alternate;
}

.recording-wave span:nth-child(1) { height: 10px; animation-delay: 0s; }
.recording-wave span:nth-child(2) { height: 20px; animation-delay: 0.1s; }
.recording-wave span:nth-child(3) { height: 30px; animation-delay: 0.2s; }
.recording-wave span:nth-child(4) { height: 20px; animation-delay: 0.3s; }
.recording-wave span:nth-child(5) { height: 10px; animation-delay: 0.4s; }

@keyframes wave {
    from { height: 5px; }
    to { height: 30px; }
}

.cancel-recording-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 5px;
    cursor: pointer;
}

/* پیام صوتی */
.message .audio-message audio {
    max-width: 250px;
    border-radius: 20px;
}

.message.customer .audio-message audio {
    background: #e3f2fd;
}

.message.admin .audio-message audio {
    background: #f5f5f5;
}

/* استایل دکمه ضبط صدا در حالت نگه داشته شده */
#voice-record-btn.recording-active {
    background-color: #ff4757 !important;
    animation: pulse 1s infinite;
}

#voice-record-btn.recording-active svg {
    stroke: white !important;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.4);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(255, 71, 87, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0);
    }
}

/* استایل تذکر نگه داشتن دکمه */
.mahan-chat-voice-warning {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 10px 20px;
    border-radius: 40px;
    font-size: 14px;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    white-space: nowrap;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.mahan-chat-voice-warning.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.mahan-chat-voice-warning:before {
    content: "👆";
    font-size: 16px;
    margin-left: 5px;
}

/* برای موبایل - تذکر در پایین صفحه */
@media (max-width: 768px) {
    .mahan-chat-voice-warning {
        bottom: 80px;
        font-size: 12px;
        padding: 8px 16px;
        white-space: nowrap;
    }
}

/* انیمیشن لرزش برای دکمه (اختیاری - برای جلب توجه) */
@keyframes shakeHint {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

.mahan-chat-voice-warning.show ~ #voice-record-btn {
    animation: shakeHint 0.3s ease-in-out;
}

/* استایل دکمه پاسخ - اصلاح شده */
/* ================ دکمه پاسخ ================ */
.reply-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 50%;
    background: #fff;
    color: #666;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.reply-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
}

.reply-btn:hover {
    background: var(--chat-color, #007bff);
    border-color: var(--chat-color, #007bff);
    color: white;
    transform: translateY(-50%) scale(1.05);
}

/* ================ موقعیت دکمه در کنار حباب ================ */
.message-bubble {
    position: relative;
}

/* پیام مشتری (حباب آبی) - دکمه در سمت چپ - فلش عادی */
.message.customer .reply-btn {
    left: -35px;
    right: auto;
}

.message.customer .reply-btn svg {
    transform: scaleX(-1);
}

/* پیام ادمین (حباب خاکستری) - دکمه در سمت راست - فلش برعکس */
.message.admin .reply-btn {
    right: -35px;
    left: auto;
}

.message.admin .reply-btn svg {
    transform: scaleX(1);
}

/* نمایش دکمه هنگام هاور روی کل ردیف پیام */
.message:hover .reply-btn {
    opacity: 1 !important;
    visibility: visible !important;
}

/* اجازه خروج از محدوده */
.mahan-chat-messages {
    overflow: visible !important;
}

.mahan-chat-body {
    overflow-x: visible !important;
}

/* باکس پاسخ در حال تایپ */
.reply-preview {
    background: #f0f2f5;
    border-radius: 12px;
    padding: 8px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-right: 3px solid var(--chat-color, #007bff);
}

.reply-preview-content {
    flex: 1;
    font-size: 12px;
    overflow: hidden;
}

.reply-preview-content strong {
    display: block;
    font-size: 11px;
    color: var(--chat-color, #007bff);
    margin-bottom: 3px;
}

.reply-preview-content p {
    margin: 0;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
}

.cancel-reply {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #999;
    padding: 0 5px;
}

.cancel-reply:hover {
    color: #ff4757;
}

/* استایل پیام پاسخ داده شده */
.message.replied {
    background-color: rgba(0, 0, 0, 0.02);
}

.reply-to-badge {
    font-size: 11px;
    color: #888;
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px dashed #1a202c;
    display: inline-block;
}
