/* ==========================================================================
   الحضور الآن + محادثة مباشرة
   لوحة و زر عائم. الألوان متوافقة مع لوحة الدعم الفني (تركوازي).
   زر الدعم الفني في هذه الصفحة على اليسار، وهذا على اليمين.
   ========================================================================== */

.epm-pc-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    min-width: 56px;
    height: 56px;
    padding: 0 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, #0a7a6d, #005957);
    color: #fff;
    border: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: 700 14px/1 var(--epc-font, "Almarai", system-ui, sans-serif);
    box-shadow: 0 10px 28px -6px rgba(0, 89, 87, .5);
    z-index: 9998;
    transition: transform .25s ease, box-shadow .25s ease;
}
.epm-pc-fab:hover { transform: translateY(-3px) scale(1.04); }
.epm-pc-fab__count {
    background: rgba(255, 255, 255, .22);
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 99px;
    min-width: 26px;
    padding: 3px 7px;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
}
.epm-pc-fab.has-unread {
    background: linear-gradient(135deg, #0a7a6d, #005957);
    box-shadow: 0 10px 28px -6px rgba(0, 89, 87, .5), 0 0 0 0 rgba(239, 68, 68, .5);
}
.epm-pc-fab__dot {
    position: absolute;
    top: -5px;
    left: -5px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 99px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}
.epm-pc-fab__dot.is-on { display: inline-flex; }

/* ------------------------------- اللوحة ------------------------------- */

.epm-pc-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 372px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 130px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 24px 60px -18px rgba(2, 44, 43, .38);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e3efec;
    font-family: var(--epc-font, "Almarai", system-ui, sans-serif);
    direction: rtl;
}
.epm-pc-panel[hidden] { display: none; }

.epm-pc-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #0a7a6d, #005957);
    color: #fff;
    flex: 0 0 auto;
}
.epm-pc-panel__tabs { display: flex; gap: 6px; }
.epm-pc-tab {
    background: rgba(255, 255, 255, .14);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 9px;
    padding: 7px 14px;
    font: 700 13px/1 var(--epc-font, "Almarai", sans-serif);
    cursor: pointer;
    transition: background .2s;
}
.epm-pc-tab.is-active { background: #fff; color: #005957; }
.epm-pc-panel__close {
    background: rgba(255, 255, 255, .14);
    border: 0;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.epm-pc-panel__close:hover { background: rgba(255, 255, 255, .28); }

.epm-pc-view { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; }
.epm-pc-view[hidden] { display: none; }

.epm-pc-list { padding: 8px; }

/* حقل اسم الزائر — يظهر للزائر غير المسجّل فقط */
.epm-pc-namebar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #e6eeec;
    background: #f6faf9;
}
.epm-pc-namebar[hidden] { display: none; }
.epm-pc-namebar label {
    font-size: 12px;
    color: #5c6f6c;
    white-space: nowrap;
}
.epm-pc-namebar input {
    flex: 1;
    min-width: 0;
    padding: 7px 10px;
    font: inherit;
    font-size: 13px;
    color: #16302c;
    border: 1px solid #d6e2df;
    border-radius: 9px;
    background: #fff;
    outline: none;
}
.epm-pc-namebar input:focus { border-color: #17a3a0; }

/* الزائر: قائمة الإدارة المتصلة ليبدأ محادثة */
.epm-pc-teams__title {
    padding: 12px 14px 6px;
    font-size: 12px;
    font-weight: 700;
    color: #5c6f6c;
    letter-spacing: .2px;
}
.epm-pc-teams .epm-pc-list { padding-top: 0; }
.epm-pc-team__none,
.epm-pc-teams__none {
    padding: 10px 14px 16px;
    font-size: 13px;
    line-height: 1.7;
    color: #7b8f8c;
}
.epm-pc-teams + .epm-pc-chats .epm-pc-empty { padding-top: 12px; }

/* زر المحادثة للزائر: أخف من زر المتصلين، ولا badge إلا عند وجود رسالة */
.epm-pc-fab--chat { background: #0f766e; }
.epm-pc-fab--chat .epm-pc-fab__count { background: #b91c1c; }

.epm-pc-empty {
    padding: 44px 20px;
    text-align: center;
    color: #7b8f8c;
    font-size: 14px;
    line-height: 1.9;
}
.epm-pc-empty svg { opacity: .35; display: block; margin: 0 auto 12px; }

/* ------------------------------- الأشخاص ------------------------------ */

.epm-pc-row {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 10px 11px;
    border: 0;
    background: transparent;
    border-radius: 13px;
    cursor: pointer;
    text-align: right;
    font-family: inherit;
    transition: background .16s;
}
.epm-pc-row:hover { background: #f1f8f6; }
.epm-pc-row + .epm-pc-row { margin-top: 2px; }

.epm-pc-avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 17px;
    color: #fff;
    background: linear-gradient(135deg, #12a594, #0a7a6d);
    position: relative;
}
.epm-pc-avatar.is-online::after {
    content: '';
    position: absolute;
    left: -1px;
    bottom: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #22c55e;
    border: 2.5px solid #fff;
}
.epm-pc-avatar.is-off { background: linear-gradient(135deg, #94a3b8, #64748b); }

.epm-pc-row__body { flex: 1 1 auto; min-width: 0; }
.epm-pc-row__name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 14.5px;
    color: #0f2a29;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.epm-pc-row__sub {
    font-size: 12.5px;
    color: #6b827f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.epm-pc-row__sub.is-typing { color: #0a7a6d; font-weight: 700; }

.epm-pc-chip {
    flex: 0 0 auto;
    font-size: 10.5px;
    font-weight: 700;
    padding: 2.5px 7px;
    border-radius: 99px;
    background: #e6f4f1;
    color: #0a7a6d;
    white-space: nowrap;
}
.epm-pc-chip--staff { background: #fef3c7; color: #92400e; }
.epm-pc-chip--mob { background: #eef2ff; color: #4338ca; }

.epm-pc-unread {
    flex: 0 0 auto;
    min-width: 21px;
    height: 21px;
    padding: 0 6px;
    border-radius: 99px;
    background: #ef4444;
    color: #fff;
    font-size: 11.5px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.epm-pc-row__time { flex: 0 0 auto; font-size: 11px; color: #93a5a2; }

/* ------------------------------ المحادثة ------------------------------ */

.epm-pc-chat { position: absolute; inset: 0; background: #fff; display: flex; flex-direction: column; z-index: 3; }
.epm-pc-chat[hidden] { display: none; }

.epm-pc-chat__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    background: linear-gradient(135deg, #0a7a6d, #005957);
    color: #fff;
    flex: 0 0 auto;
}
.epm-pc-chat__back {
    background: rgba(255, 255, 255, .14);
    border: 0;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}
.epm-pc-chat__back:hover { background: rgba(255, 255, 255, .28); }
.epm-pc-chat__who { min-width: 0; }
.epm-pc-chat__name {
    font-weight: 800;
    font-size: 14.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.epm-pc-chat__status { font-size: 11.5px; opacity: .85; margin-top: 1px; }

.epm-pc-msgs {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f6fbfa;
}
.epm-pc-msg {
    max-width: 78%;
    padding: 9px 13px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.75;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    background: #fff;
    border: 1px solid #e3efec;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}
.epm-pc-msg.is-mine {
    align-self: flex-end;
    background: linear-gradient(135deg, #0a7a6d, #005957);
    color: #fff;
    border-color: transparent;
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 5px;
}
.epm-pc-msg__at { display: block; font-size: 10.5px; opacity: .6; margin-top: 3px; }
.epm-pc-msg.is-mine .epm-pc-msg__at { text-align: left; }

.epm-pc-bar {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    padding: 11px 12px;
    border-top: 1px solid #e3efec;
    background: #fff;
}
.epm-pc-bar input {
    flex: 1 1 auto;
    min-width: 0;
    border: 1px solid #cfe3df;
    border-radius: 11px;
    padding: 11px 14px;
    font-family: inherit;
    font-size: 14px;
    background: #fbfefd;
}
.epm-pc-bar input:focus { outline: 2px solid rgba(10, 122, 109, .22); border-color: #0a7a6d; }
.epm-pc-bar button {
    flex: 0 0 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, #0a7a6d, #005957);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.epm-pc-bar button:disabled { opacity: .5; cursor: default; }
.epm-pc-bar button svg { transform: scaleX(-1); }

/* شارة "يكتب" داخل قائمة الأشخاص */
.epm-pc-typing-live { color: #0a7a6d; font-weight: 700; font-size: 12px; }

/* --------------------- القائمة داخل صفحة الدعم الفني ------------------ */

.epc-people-pane { display: none; }
.epc-people-pane[hidden] { display: none !important; }

.epm-pc-inline { text-align: right; }

.epm-pc-inline__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 11px 14px;
    margin-bottom: 12px;
    background: #f1f8f6;
    border: 1px solid #d9ece7;
    border-radius: 13px;
}
.epm-pc-inline__live {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 800;
    font-size: 14px;
    color: #0a7a6d;
}
.epm-pc-inline__live i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, .55);
    animation: epmPcPulse 2s infinite;
}
@keyframes epmPcPulse {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, .5); }
    70%  { box-shadow: 0 0 0 9px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.epm-pc-inline__hint { font-size: 12.5px; color: #6b827f; }

.epm-pc-inline-count {
    background: rgba(255, 255, 255, .9);
    border: 1px solid #bfe0d8;
    color: #005957;
    border-radius: 99px;
    min-width: 24px;
    padding: 1px 8px;
    font-size: 12.5px;
    font-weight: 800;
    display: inline-block;
    text-align: center;
}
.epc-tab-btn .epm-pc-inline-count {
    background: rgba(255, 255, 255, .22);
    border-color: rgba(255, 255, 255, .3);
    color: #fff;
}
.epc-tab-btn.is-active .epm-pc-inline-count {
    background: #0a7a6d;
    border-color: rgba(5, 89, 87, .18);
    color: #fff;
}

/* شبكتان على الشاشات الواسعة، عمود واحد على الموبايل */
.epm-pc-people--grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}
.epm-pc-people--grid .epm-pc-empty { grid-column: 1 / -1; }
.epm-pc-people--grid .epm-pc-row { border: 1px solid #e3efec; background: #fbfefd; }
.epm-pc-people--grid .epm-pc-row:hover { border-color: #0a7a6d; }

@media (max-width: 640px) {
    .epm-pc-people--grid { grid-template-columns: 1fr; }
}

/* ------------------------------ استجابة ------------------------------- */

@media (max-width: 640px) {
    .epm-pc-fab { bottom: 148px; right: 14px; height: 50px; min-width: 50px; padding: 0 13px; border-radius: 16px; }
    .epm-pc-panel { right: 10px; left: 10px; width: auto; bottom: 208px; height: min(520px, calc(100vh - 250px)); border-radius: 18px; }
}
