/* Seller Chat - Frontend Styles */

#seller-chat-app {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    direction: rtl;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    /* وقتی adminbar وردپرس هست (32px) زیرش شروع می‌شه */
    top: var(--sc-top, 0px);
    z-index: 9990;
    background: #fff;
}

/* adminbar استاندارد وردپرس */
body.admin-bar #seller-chat-app  { --sc-top: 32px; }
@media screen and (max-width: 782px) {
    body.admin-bar #seller-chat-app { --sc-top: 46px; }
}

/* ═══════════════════════════════════════════════════
   حالت CONTAINED — برای استفاده داخل تب المنتور یا هر
   جعبه‌ی دیگه؛ به‌جای گرفتن کل صفحه، فقط جای خودش رو
   با ارتفاع مشخص (--sc-height) پر می‌کنه.
   فعال می‌شه با: [seller_chat fullscreen="no" height="600px"]
═══════════════════════════════════════════════════ */
#seller-chat-app.sc-mode-contained {
    position: relative;
    inset: auto;
    left: auto;
    right: auto;
    bottom: auto;
    top: auto;
    z-index: auto;
    width: 100%;
    height: var(--sc-height, 600px);
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 0 0 1px #eee;
}

#sc-main {
    display: flex;
    height: 100%;
    width: 100%;
    border: none;
    border-radius: 0;
    overflow: hidden;
    background: #fff;
    box-shadow: none;
}

/* ===== SIDEBAR ===== */
.sc-sidebar {
    width: 280px;
    min-width: 280px;
    border-left: 1px solid #eeeeee;
    display: flex;
    flex-direction: column;
    background: #f9f9f7;
}

.sc-sidebar-header {
    padding: 10px 16px;
    border-bottom: 1px solid #eeeeee;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: bold;
    color: #222;
}

.sc-logo-img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.sc-search-wrap {
    padding: 10px 12px;
    border-bottom: 1px solid #eeeeee;
}

.sc-search-wrap input {
    width: 100%;
    padding: 7px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 13px;
    background: #fff;
    color: #333;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
}

.sc-list {
    flex: 1;
    overflow-y: auto;
}

/* ===== SELLER ITEM ===== */
.sc-seller-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0ee;
    transition: background 0.15s;
    position: relative;
}

.sc-seller-item:hover { background: #f0f0ee; }
.sc-seller-item.active {
    background: #fff;
    border-right: 3px solid #1D9E75;
}

.sc-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
    overflow: hidden;
    background: #E1F5EE;
    color: #0F6E56;
}

.sc-avatar img { width: 100%; height: 100%; object-fit: cover; }
/* sc-avatar-me replaced by sc-logo-img */

.sc-seller-info { flex: 1; min-width: 0; }

.sc-seller-name {
    font-size: 14px;
    font-weight: bold;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sc-seller-preview {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

.sc-seller-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.sc-time { font-size: 11px; color: #aaa; }

.sc-badge {
    background: #1D9E75;
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.sc-online-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #1D9E75;
    position: absolute;
    bottom: 14px;
    right: 48px;
    border: 2px solid #f9f9f7;
}

/* ===== MAIN PANEL ===== */
.sc-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sc-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #aaa;
    gap: 8px;
}

.sc-empty-icon { font-size: 56px; }
.sc-empty p { font-size: 15px; color: #888; margin: 0; }
.sc-empty small { font-size: 12px; }

.sc-chat {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* ===== CHAT HEADER ===== */
.sc-chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
}

.sc-chat-header-info { flex: 1; }
.sc-chat-header-name { font-size: 15px; font-weight: bold; color: #222; }
.sc-chat-header-sub { font-size: 12px; color: #1D9E75; margin-top: 2px; }

/* ===== CHAT BODY ===== */
.sc-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f5f0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sc-day-label {
    font-size: 12px;
    color: #888;
    text-align: center;
    background: #fff;
    border-radius: 20px;
    padding: 4px 14px;
    margin: 4px auto;
    width: fit-content;
}

/* ===== FILE CARD ===== */
.sc-file-wrap {
    display: flex;
    flex-direction: column;
    max-width: 230px;
}

.sc-file-wrap.left { align-self: flex-start; align-items: flex-start; }
.sc-file-wrap.right { align-self: flex-end; align-items: flex-end; }

.sc-file-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    overflow: hidden;
    width: 230px;
    cursor: pointer;
    transition: box-shadow 0.15s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.sc-file-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.12); }

.sc-file-thumb {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.sc-file-thumb-placeholder {
    width: 100%;
    height: 140px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.sc-file-info {
    padding: 10px 12px;
}

.sc-file-title {
    font-size: 13px;
    font-weight: bold;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 0 4px;
}

.sc-file-meta {
    font-size: 11px;
    color: #999;
}

.sc-file-time {
    font-size: 11px;
    color: #bbb;
    margin-top: 4px;
    padding: 0 4px;
}

/* ===== DELETE BUTTON ===== */
.sc-file-card-wrap {
    position: relative;
    width: 230px;
}

.sc-delete-btn {
    position: absolute;
    top: 7px;
    left: 7px;
    z-index: 2;
    background: rgba(255,255,255,0.95);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.18s, background 0.18s, transform 0.15s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
    color: #cc3333;
    line-height: 1;
}
.sc-file-card-wrap:hover .sc-delete-btn { opacity: 1; }
.sc-delete-btn:hover { background: #ffe4e4; transform: scale(1.1); }
.sc-delete-btn svg { display: block; }

/* ===== TITLE VALIDATION ===== */
.sc-title-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sc-title-hint {
    font-size: 11px;
    color: #e04444;
    padding: 0 4px;
    animation: sc-shake 0.3s ease;
}

.sc-input-error {
    border-color: #e04444 !important;
    background: #fff8f8 !important;
}

@keyframes sc-shake {
    0%,100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}

/* ===== UNREAD DIVIDER ===== */
.sc-unread-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
    color: #e06020;
    font-size: 12px;
    font-weight: bold;
}
.sc-unread-divider::before,
.sc-unread-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #f0c090;
}
.sc-unread-divider span {
    white-space: nowrap;
    background: #fff8f0;
    padding: 2px 10px;
    border-radius: 20px;
    border: 1px solid #f0c090;
}

/* ===== UPLOAD BAR ===== */
.sc-upload-bar {
    border-top: 1px solid #eee;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* پیش‌نمایش فایل انتخاب‌شده */
.sc-preview-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 6px;
    background: #f0faf5;
    border-bottom: 1px solid #d8f0e5;
    font-size: 13px;
    color: #333;
}

.sc-preview-bar img {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid #ddd;
}

.sc-preview-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    color: #555;
}

.sc-preview-cancel {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 50%;
    line-height: 1;
    flex-shrink: 0;
}
.sc-preview-cancel:hover { background: #eee; color: #555; }

/* ردیف اصلی */
.sc-input-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 10px;
}

/* دکمه کلیپس */
.sc-clip-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    cursor: pointer;
    color: #aaa !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 8px !important;
    transition: background 0.15s, color 0.15s;
}
.sc-clip-btn:hover { background: #f0f0f0 !important; color: #1D9E75 !important; }
.sc-clip-btn svg,
.sc-send-btn svg {
    display: block !important;
    pointer-events: none;
    width: 100% !important;
    height: 100% !important;
    /* برخی قالب‌ها/المنتور روی svg سراسری fill می‌ذارن؛ این آیکون‌ها با stroke رسم شدن نه fill */
    fill: none !important;
    stroke: currentColor !important;
}

/* فیلد عنوان */
.sc-title-input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 22px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    direction: rtl;
    background: #f7f7f7;
    color: #333;
    transition: border-color 0.15s, background 0.15s;
}
.sc-title-input:focus { border-color: #1D9E75; background: #fff; }

/* دکمه ارسال */
.sc-send-btn {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    background: #1D9E75 !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 50%;
    cursor: pointer;
    color: #fff !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 9px !important;
    transition: background 0.15s, transform 0.1s;
}
.sc-send-btn:hover  { background: #0F6E56 !important; }
.sc-send-btn:active { transform: scale(0.93); }
.sc-send-btn:disabled { background: #b2dfcf !important; cursor: not-allowed; }

.sc-upload-status {
    font-size: 12px;
    color: #888;
    padding: 0 14px 6px;
    min-height: 16px;
}

/* ===== SPINNER ===== */
.sc-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: #1D9E75;
    border-radius: 50%;
    animation: sc-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 6px;
}

@keyframes sc-spin { to { transform: rotate(360deg); } }

/* ===== LOADING SKELETON ===== */
.sc-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: sc-shimmer 1.4s infinite;
    border-radius: 6px;
}

@keyframes sc-shimmer { to { background-position: -200% 0; } }

/* ═══════════════════════════════════════════════════
   MOBILE RESPONSIVE — واتساپ‌مانند
   روی موبایل: صفحه اول = لیست فروشنده‌ها
               بعد از کلیک = پنل فایل‌ها (slide از چپ)
═══════════════════════════════════════════════════ */
@media (max-width: 768px) {

    #seller-chat-app {
        position: fixed;
        inset: 0;
        top: var(--sc-top, 0px);
        overflow: hidden;
    }

    body.admin-bar #seller-chat-app  { --sc-top: 46px; }

    /* در موبایل هم حالت contained باید همچنان داخل جعبه‌ی خودش بمونه نه کل صفحه */
    #seller-chat-app.sc-mode-contained {
        position: relative;
        inset: auto;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        height: var(--sc-height, 600px);
    }

    #sc-main {
        position: relative;
        overflow: hidden;
        height: 100%;
    }

    /* ── سایدبار: تمام عرض، اسلاید ── */
    .sc-sidebar {
        position: absolute;
        inset: 0;
        width: 100%;
        min-width: 100%;
        border-left: none;
        z-index: 10;
        transform: translateX(0);
        transition: transform 0.28s cubic-bezier(.4,0,.2,1);
        background: #f9f9f7;
    }

    /* وقتی پنل باز است سایدبار به راست می‌رود */
    .sc-sidebar.sc-sidebar-hidden {
        transform: translateX(100%);
        pointer-events: none;
    }

    /* ── پنل اصلی (فایل‌ها): تمام عرض، پشت سایدبار ── */
    .sc-panel {
        position: absolute;
        inset: 0;
        width: 100%;
        z-index: 9;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(.4,0,.2,1);
        background: #fff;
        display: flex !important;
        flex-direction: column;
    }

    .sc-panel.sc-panel-visible {
        transform: translateX(0);
    }

    /* ── دکمه بازگشت در هدر ── */
    .sc-back-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        background: none;
        border: none;
        cursor: pointer;
        color: #1D9E75;
        border-radius: 50%;
        flex-shrink: 0;
        margin-left: 2px;
        -webkit-tap-highlight-color: transparent;
    }
    .sc-back-btn:active { background: #e6faf3; }
    .sc-back-btn svg { display: block; pointer-events: none; }

    /* هدر فایل‌ها در موبایل: ارتفاع مناسب */
    .sc-chat-header {
        min-height: 56px;
        padding: 8px 12px;
    }

    /* دکمه بک در سایدبار مخفی (مشکل عکس) */
    .sc-sidebar .sc-back-btn,
    .sc-sidebar-header .sc-back-btn {
        display: none !important;
    }

    /* ── چت پنل موبایل ── */
    #sc-chat-panel.sc-cp-open { height: 280px; }

    /* ── فایل‌ها یه‌ستونه در موبایل ── */
    .sc-file-wrap { max-width: 100%; }
    .sc-file-card-wrap { width: 100%; }
    .sc-file-card { width: 100%; }
    .sc-file-thumb { height: 200px; }

    /* ── اسکرول بهتر ── */
    .sc-chat-body { -webkit-overflow-scrolling: touch; }
    .sc-cp-body   { -webkit-overflow-scrolling: touch; }
    .sc-list      { -webkit-overflow-scrolling: touch; }
}

/* دسکتاپ: نوار موبایل مخفی */
@media (min-width: 769px) {
    .sc-back-btn      { display: none !important; }
    .sc-mobile-topbar { display: none !important; }
}

/* دکمه بک فقط داخل پنل اصلی (لیست قیمت) نشون داده بشه */
.sc-sidebar .sc-back-btn { display: none !important; }

/* ══════════════════════════════════════════════════════
   CHAT BUTTON روی کارت فایل
══════════════════════════════════════════════════════ */
.sc-chat-btn {
    position: absolute;
    top: 7px;
    right: 7px;
    z-index: 2;
    background: rgba(255,255,255,0.95);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    padding: 0;
    cursor: pointer;
    /* مرکز کردن SVG داخل دکمه در همه مرورگرها */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    vertical-align: middle;
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
    color: #1D9E75;
    transition: background 0.15s, transform 0.15s;
}
.sc-chat-btn svg,
.sc-delete-btn svg {
    display: block;
    flex-shrink: 0;
    pointer-events: none;
}
.sc-chat-btn:hover       { background:#e6faf3; transform:scale(1.1); }
.sc-chat-btn-active      { background:#1D9E75 !important; color:#fff !important; }
.sc-chat-btn-active:hover{ background:#0F6E56 !important; }

/* badge عددی روی دکمه چت */
.sc-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e03030;
    color: #fff;
    border-radius: 50%;
    min-width: 16px;
    height: 16px;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 1.5px solid #fff;
    line-height: 1;
}

/* دکمه حذف قفل‌شده */
.sc-delete-locked {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
}
.sc-delete-locked:hover { transform: none !important; background: rgba(255,255,255,0.95) !important; }

/* ══════════════════════════════════════════════════════
   CHAT PANEL (پنل slide-up)
══════════════════════════════════════════════════════ */
#sc-chat-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0;
    overflow: hidden;
    background: #fff;
    border-top: 2px solid #1D9E75;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
    transition: height 0.28s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    z-index: 100;
}
#sc-chat-panel.sc-cp-open { height: 340px; }

/* sc-chat باید position:relative داشته باشه */
.sc-chat { position: relative; }

/* هدر پنل */
.sc-cp-header {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    background: #f9fdf9;
    flex-shrink: 0;
}
.sc-cp-title {
    flex: 1;
    font-size: 13px;
    font-weight: bold;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sc-cp-close {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 15px;
    padding: 2px 6px;
    border-radius: 50%;
    line-height: 1;
}
.sc-cp-close:hover { background:#f0f0f0; color:#555; }

/* بدنه پیام‌ها */
.sc-cp-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f5f5f0;
}
.sc-cp-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sc-cp-empty {
    text-align: center;
    color: #aaa;
    font-size: 13px;
    margin: auto;
}

/* پیام‌ها */
.sc-msg {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    max-width: 85%;
}
.sc-msg-mine  { align-self: flex-end;  flex-direction: row-reverse; }
.sc-msg-other { align-self: flex-start; }

.sc-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.sc-msg-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sc-msg-mine  .sc-msg-body { align-items: flex-end; }
.sc-msg-other .sc-msg-body { align-items: flex-start; }

.sc-msg-sender {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 0 4px 2px;
    flex-wrap: wrap;
}
.sc-msg-mine .sc-msg-sender  { flex-direction: row-reverse; }
.sc-msg-other .sc-msg-sender { flex-direction: row; }

.sc-msg-sender > span:first-child {
    font-size: 12px;
    font-weight: bold;
    color: #555;
}
.sc-msg-mine .sc-msg-sender > span:first-child { color: #0F6E56; }

.sc-msg-datetime {
    font-size: 10px;
    color: #bbb;
    font-weight: normal;
}
.sc-msg-bubble {
    padding: 7px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}
.sc-msg-mine  .sc-msg-bubble { background: #1D9E75; color: #fff; border-bottom-right-radius: 4px; }
.sc-msg-other .sc-msg-bubble { background: #fff;    color: #222; border-bottom-left-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* sc-msg-time deprecated - replaced by sc-msg-datetime inside sender */

/* فوتر پنل - input ارسال */
.sc-cp-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}
.sc-cp-footer-info {
    justify-content: center;
    font-size: 12px;
    color: #aaa;
    padding: 10px;
}
.sc-cp-input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 22px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    direction: rtl;
    background: #f7f7f7;
    transition: border-color 0.15s;
}
.sc-cp-input:focus { border-color: #1D9E75; background: #fff; }

/* ══════════════════════════════════════════════════════
   MOBILE TOPBAR (نوار بک بالای صفحه لیست قیمت)
══════════════════════════════════════════════════════ */
.sc-mobile-topbar {
    display: none; /* پیش‌فرض مخفی - موبایل نمایش می‌دهد */
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #fff;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    min-height: 50px;
}

@media (max-width: 768px) {
    .sc-mobile-topbar {
        display: flex;
    }
}

.sc-mobile-topbar-title {
    font-size: 15px;
    font-weight: bold;
    color: #222;
    flex: 1;
    text-align: right;
}

.sc-mobile-topbar .sc-back-btn {
    display: inline-flex !important;
    width: 40px;
    height: 40px;
    color: #1D9E75;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.sc-mobile-topbar .sc-back-btn:active { background: #e6faf3; }
.sc-mobile-topbar .sc-back-btn svg { display: block; pointer-events: none; }
