/* =============================================================
   訂單編輯中 loader
   基於 Nifty v4.2.0 loader.css 的 Ball scale Multiple,壓縮成 inline 尺寸給列表按鈕內用。
   出處:demo/assets/vendors/loader.css/loader.css → .ball-scale-multiple
   ============================================================= */

@keyframes presence-ball-scale-multiple {
    0%   { transform: scale(0); opacity: 0; }
    5%   { opacity: 1; }
    100% { transform: scale(1); opacity: 0; }
}

.presence-loader {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 24px;
    height: 24px;
    margin-left: 4px;
    vertical-align: middle;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
}

.presence-loader .presence-loader-inner {
    position: relative;
    width: 24px;
    height: 24px;
    display: inline-block;
}

.presence-loader .presence-loader-inner > div {
    position: absolute;
    left: 0;
    top: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #dc3545;
    opacity: 0;
    animation: presence-ball-scale-multiple 1s 0s linear infinite;
}

.presence-loader .presence-loader-inner > div:nth-child(2) { animation-delay: -0.4s; }
.presence-loader .presence-loader-inner > div:nth-child(3) { animation-delay: -0.2s; }

/* -------- Popover -------- */
.presence-popover {
    position: absolute;
    z-index: 1080;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 10px 12px;
    min-width: 355px;
    max-width: 340px;
    text-align: left;
    color: #212529;
    font-size: 0.95rem;
    cursor: default;
}

.presence-popover-header {
    font-weight: 600;
    color: #dc3545;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.presence-popover-header .btn-close {
    padding: 0;
    background: transparent;
    border: none;
    font-size: 1.1rem;
    line-height: 1;
    color: #6c757d;
    cursor: pointer;
}

.presence-popover-holder {
    padding: 6px 0;
    border-top: 1px dashed #e9ecef;
}
.presence-popover-holder:first-of-type { border-top: none; padding-top: 0; }

.presence-popover-holder .name { font-weight: 600; }
.presence-popover-holder .dept { color: #6c757d; margin-left: 4px; }
.presence-popover-holder .meta { color: #6c757d; font-size: 0.85rem; margin-top: 2px; }

.presence-popover-notify {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e9ecef;
}

.presence-popover-notify textarea {
    width: 100%;
    min-height: 60px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.9rem;
    resize: vertical;
}

.presence-popover-notify .btn-send {
    margin-top: 6px;
    padding: 4px 10px;
    font-size: 0.85rem;
}

.presence-popover-sent {
    color: #198754;
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ================= 聊天視窗 ================= */
.presence-chat-window {
    position: fixed;
    top: 20rem;
    right: 1rem;
    z-index: 1090;
    width: 27rem;
    height: 40rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    font-size: 0.95rem;
    overflow: hidden;
}

.presence-chat-header {
    background: #0d6efd;
    color: #fff;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.presence-chat-header .title { font-weight: 600; }
.presence-chat-header .dept  { opacity: 0.85; font-size: 0.85rem; margin-left: 4px; }
.presence-chat-header .close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    padding: 0 4px;
    cursor: pointer;
    line-height: 1;
}

.presence-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9fa;
}

.presence-chat-msg { display: flex; margin-bottom: 8px; }
.presence-chat-msg.me   { justify-content: flex-end; }
.presence-chat-msg.peer { justify-content: flex-start; }

.presence-chat-bubble {
    padding: 6px 10px;
    border-radius: 12px;
    max-width: 78%;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.35;
    /* 顯式指定靠左,避免從表格 / Nifty 版型的 text-align:center 繼承過來 */
    text-align: left;
}
.presence-chat-msg.me   .presence-chat-bubble { background: #0d6efd; color: #fff; border-bottom-right-radius: 3px; }
.presence-chat-msg.peer .presence-chat-bubble { background: #e9ecef; color: #212529; border-bottom-left-radius: 3px; }
.presence-chat-msg.system .presence-chat-bubble {
    background: transparent;
    color: #6c757d;
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
    width: 100%;
    max-width: 100%;
}
.presence-chat-msg.system { justify-content: center; }

.presence-chat-msg .meta {
    font-size: 0.72rem;
    color: #6c757d;
    align-self: flex-end;
    margin: 0 4px;
}

.presence-chat-footer {
    border-top: 1px solid #dee2e6;
    padding: 8px;
    display: flex;
    gap: 6px;
    background: #fff;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}
.presence-chat-footer textarea {
    flex: 1;
    resize: none;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.9rem;
    min-height: 36px;
    max-height: 100px;
}
.presence-chat-footer .send {
    align-self: flex-end;
    padding: 4px 12px;
    font-size: 0.9rem;
}
