/* =============================================================================
   style-chat.css — پنجره گفتگو با پشتیبانی کسب و کار
   -----------------------------------------------------------------------------
   این استایل‌ها پیش‌تر داخل style-place.css بودند و حالا مشترک شده‌اند تا هم
   صفحه کسب و کار و هم صفحه اختصاصی کالا از یک پنجره گفتگو استفاده کنند.
   موبایل: تمام‌صفحه | دسکتاپ: پنل چسبیده به گوشه صفحه
   ========================================================================== */

        /* --- Business Support Chat (messenger popup) ---
           موبایل: تمام‌صفحه | دسکتاپ: پنل چسبیده به گوشه صفحه */
        .chat-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 1001; opacity: 0; visibility: hidden; transition: all 0.3s ease; }
        .chat-overlay.active { opacity: 1; visibility: visible; }
        .chat-panel { position: fixed; inset: 0; z-index: 1002; display: flex; flex-direction: column; background: var(--light); transform: translateY(100%); opacity: 0; visibility: hidden; transition: transform 0.35s cubic-bezier(0.4,0,0.2,1), opacity 0.25s ease, visibility 0.35s; }
        .chat-panel.active { transform: translateY(0); opacity: 1; visibility: visible; }

        .chat-head { flex-shrink: 0; background: linear-gradient(135deg, var(--footer-bg-start) 0%, var(--footer-bg-end) 100%); padding: 13px 15px; display: flex; align-items: center; gap: 11px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
        .chat-head img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold); flex-shrink: 0; }
        .chat-head-info { min-width: 0; }
        .chat-head-info h4 { font-size: 14px; color: var(--gold-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .chat-head-info span { font-size: 11px; color: #bdbdbd; display: flex; align-items: center; gap: 5px; margin-top: 3px; }
        .chat-head-info span i { font-size: 7px; color: #2ecc71; }
        .chat-head-actions { margin-right: auto; display: flex; gap: 6px; flex-shrink: 0; }
        .chat-head-btn { width: 34px; height: 34px; border: none; border-radius: 10px; background: rgba(255,255,255,0.1); color: var(--gold); font-size: 14px; cursor: pointer; transition: background 0.2s, color 0.2s; }
        .chat-head-btn:hover { background: var(--gold); color: var(--footer-bg-start); }

        .chat-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 15px; display: flex; flex-direction: column; gap: 10px; }
        .chat-date { align-self: center; background: rgba(0,0,0,0.07); color: var(--gray); font-size: 11px; padding: 4px 13px; border-radius: 12px; }
        .chat-sys { align-self: center; max-width: 85%; text-align: center; background: var(--white); color: var(--gray); font-size: 11px; line-height: 1.9; padding: 8px 13px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
        .msg { max-width: 80%; display: flex; flex-direction: column; gap: 5px; }
        .msg.in { align-self: flex-start; }
        .msg.out { align-self: flex-end; align-items: flex-end; }
        .msg-bubble { padding: 10px 13px; font-size: 13px; line-height: 1.9; border-radius: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); word-break: break-word; }
        .msg.in .msg-bubble { background: var(--white); color: var(--dark); border-top-right-radius: 4px; }
        .msg.out .msg-bubble { background: var(--primary); color: #fff; border-top-left-radius: 4px; }
        .msg-time { font-size: 10px; color: var(--gray); display: flex; align-items: center; gap: 4px; }
        /* تیک خاکستری = رسیده، تیک آبی = فروشنده خوانده است */
        .msg-time .ticks { color: var(--gray); transition: color .2s; }
        .msg-time .ticks.seen { color: #2d9cdb; }
        .chat-media { display: block; position: relative; border-radius: 16px; overflow: hidden; width: 210px; max-width: 100%; box-shadow: 0 4px 14px rgba(0,0,0,0.12); cursor: zoom-in; background: #000; }
        .chat-media img, .chat-media video { width: 100%; height: 150px; object-fit: cover; display: block; }
        .chat-media .chat-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.25); }
        .chat-media .chat-play i { width: 46px; height: 46px; border-radius: 50%; background: rgba(0,0,0,0.55); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; padding-right: 3px; }
        .chat-media .chat-dur { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,0.6); color: #fff; font-size: 10px; padding: 2px 7px; border-radius: 8px; direction: ltr; }
        .chat-file { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; background: var(--white); box-shadow: 0 2px 8px rgba(0,0,0,0.05); min-width: 210px; cursor: pointer; }
        .msg.out .chat-file { background: var(--primary); color: #fff; }
        .chat-file-icon { width: 38px; height: 38px; border-radius: 11px; background: var(--light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
        .msg.out .chat-file-icon { background: rgba(255,255,255,0.22); color: #fff; }
        .chat-file-info { min-width: 0; }
        .chat-file-info b { display: block; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
        .chat-file-info span { font-size: 11px; opacity: 0.7; }
        .chat-file-dl { margin-right: auto; font-size: 14px; opacity: 0.8; }
        .chat-typing { align-self: flex-start; background: var(--white); border-radius: 16px; border-top-right-radius: 4px; padding: 13px 15px; display: none; align-items: center; gap: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
        .chat-typing.show { display: flex; }
        .chat-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--gray); animation: chatTyping 1s infinite; }
        .chat-typing i:nth-child(2) { animation-delay: 0.15s; }
        .chat-typing i:nth-child(3) { animation-delay: 0.3s; }
        @keyframes chatTyping { 0%, 60%, 100% { transform: translateY(0); opacity: 0.35; } 30% { transform: translateY(-4px); opacity: 1; } }

        .chat-quick { flex-shrink: 0; display: flex; gap: 8px; padding: 0 12px 10px; }
        .chat-quick.hidden { display: none; }
        .chat-quick button { background: var(--white); border: 1px solid rgba(0,0,0,0.08); border-radius: 20px; padding: 7px 13px; font-family: inherit; font-size: 12px; color: var(--dark); white-space: nowrap; flex-shrink: 0; cursor: pointer; transition: all 0.2s; }
        .chat-quick button:hover { border-color: var(--primary); color: var(--primary); }
        .chat-foot { flex-shrink: 0; position: relative; background: var(--white); border-top: 1px solid rgba(0,0,0,0.06); padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 8px; }
        .chat-input { flex: 1; min-width: 0; border: none; outline: none; resize: none; background: none; font-family: inherit; font-size: 14px; line-height: 1.8; color: var(--dark); max-height: 96px; padding: 9px 0; }
        .chat-input:disabled { color: var(--gray); cursor: not-allowed; }

        /* دعوت به ورود وقتی کاربر وارد حساب نشده است */
        .chat-login-cta {
            flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
            margin: 0 12px 10px; padding: 12px; border-radius: 12px;
            background: var(--primary); color: #fff; font-size: 13.5px; font-weight: bold;
            text-decoration: none; transition: background 0.2s;
        }
        .chat-login-cta:hover { background: var(--primary-dark); }
        .chat-btn { width: 38px; height: 38px; flex-shrink: 0; border: none; border-radius: 12px; background: var(--light); color: var(--gray); font-size: 15px; cursor: pointer; transition: all 0.2s; }
        .chat-btn:hover { background: rgba(239, 58, 75, 0.1); color: var(--primary); }
        .chat-btn.chat-send { background: var(--primary); color: #fff; }
        .chat-btn.chat-send:hover { background: var(--primary-dark); color: #fff; }
        .chat-attach-menu { position: absolute; bottom: calc(100% + 8px); right: 12px; background: var(--white); border-radius: 14px; box-shadow: 0 12px 30px rgba(0,0,0,0.18); padding: 8px; display: none; flex-direction: column; z-index: 5; }
        .chat-attach-menu.show { display: flex; }
        .chat-attach-menu button { display: flex; align-items: center; gap: 11px; background: none; border: none; font-family: inherit; font-size: 13px; color: var(--dark); padding: 10px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; transition: background 0.2s, color 0.2s; }
        .chat-attach-menu button:hover { background: var(--light); color: var(--primary); }
        .chat-attach-menu button i { width: 16px; text-align: center; color: var(--primary); }

        /* --- نوار کالای موضوع گفتگو ---
           وقتی گفتگو از صفحه اختصاصی یک کالا آغاز شود، زیر سربرگ نمایش
           داده می‌شود تا هم کاربر و هم فروشنده بدانند بحث درباره کدام کالاست. */
        .chat-product {
            flex-shrink: 0; display: flex; align-items: center; gap: 10px;
            padding: 9px 12px; background: var(--white); text-decoration: none;
            border-bottom: 1px solid rgba(0,0,0,0.06); color: var(--dark);
            transition: background 0.2s;
        }
        .chat-product:hover { background: var(--light); }
        .chat-product.hidden { display: none; }
        .chat-product img { width: 44px; height: 44px; border-radius: 11px; object-fit: cover; background: var(--light); flex-shrink: 0; }
        .chat-product-info { min-width: 0; flex: 1; }
        .chat-product-info b { display: block; font-size: 12.5px; font-weight: 600; line-height: 1.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .chat-product-info span { font-size: 11.5px; color: var(--primary); font-weight: bold; }
        .chat-product > i { font-size: 12px; color: var(--gray); flex-shrink: 0; }

        /* نشان پیام خوانده‌نشده روی دکمه گفتگو در جعبه خرید صفحه کالا */
        #pdChatBtn { position: relative; }
        .pd-chat-badge {
            position: absolute; top: -6px; left: -6px; min-width: 18px; height: 18px;
            padding: 0 5px; border-radius: 9px; background: var(--primary); color: #fff;
            font-size: 10px; font-weight: bold; display: flex; align-items: center; justify-content: center;
        }
        .pd-chat-badge.hidden { display: none; }

        @media (min-width: 768px) {
            .chat-overlay { display: none; }
            .chat-panel { inset: auto; left: 24px; bottom: 24px; width: 380px; height: min(620px, calc(100vh - 48px)); border-radius: 20px; overflow: hidden; box-shadow: 0 25px 60px rgba(0,0,0,0.28); border: 1px solid rgba(0,0,0,0.06); transform: translateY(24px) scale(0.97); }
            .chat-panel.active { transform: translateY(0) scale(1); }
        }
