/* ============================================================
   工单系统 + 系统消息（前台样式，独立文件，不改动加密的 script.js）
   ============================================================ */

/* ---------- 右上角入口按钮 ---------- */
.acct-menu .tk-entry { position: relative; }
/* 未读小红点：只有点「已读」后才会消失 */
.tk-dot {
    position: absolute; top: -4px; right: -4px;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px; background: #ff4d4f; color: #fff;
    font-size: 11px; line-height: 16px; text-align: center;
    box-shadow: 0 0 0 2px rgba(15, 21, 34, .85);
    pointer-events: none;
}

/* ---------- 通用弹窗 ---------- */
.tk-modal {
    position: fixed; inset: 0; z-index: 10002;
    display: none; align-items: center; justify-content: center;
    padding: 18px; background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tk-modal.show { display: flex; }
.tk-card {
    width: 100%; max-width: 480px; max-height: 88vh; overflow: auto;
    background: rgba(23, 31, 48, .96); color: #e8edf6;
    border: 1px solid rgba(255, 255, 255, .14); border-radius: 14px;
    padding: 20px 22px; box-shadow: 0 18px 60px rgba(0, 0, 0, .5);
}
.tk-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.tk-card h3 { margin: 0; font-size: 17px; font-weight: 600; }
.tk-close {
    background: transparent; border: 0; color: inherit; opacity: .6;
    font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.tk-close:hover { opacity: 1; }
.tk-hint { margin: 2px 0 14px; font-size: 12px; color: #c3cddd; }

.tk-label { display: block; font-size: 13px; color: #c3cddd; margin: 12px 0 6px; }
.tk-input, .tk-textarea {
    width: 100%; background: rgba(255, 255, 255, .05); color: #e8edf6;
    border: 1px solid rgba(255, 255, 255, .14); border-radius: 10px;
    padding: 10px 12px; font: inherit; font-size: 14px;
}
.tk-textarea { min-height: 110px; resize: vertical; }
.tk-input:focus, .tk-textarea:focus { outline: none; border-color: rgba(106, 161, 255, .6); }
.tk-input::placeholder, .tk-textarea::placeholder { color: #9aa6bb; }

/* ---------- 工单类型二选一 ---------- */
.tk-types { display: flex; gap: 10px; margin-top: 6px; }
.tk-type {
    flex: 1; cursor: pointer; text-align: center;
    padding: 12px 8px; border-radius: 10px; font-size: 14px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .14);
    transition: background .15s ease, border-color .15s ease;
}
.tk-type:hover { background: rgba(255, 255, 255, .08); }
.tk-type.on { background: rgba(106, 161, 255, .16); border-color: rgba(106, 161, 255, .65); }
.tk-type b { display: block; font-size: 14px; margin-bottom: 4px; font-weight: 600; }
.tk-type span { font-size: 12px; color: #c3cddd; }

/* 类型配色：BUG 上报 = 红色系，提出建议 = 绿色系 */
.tk-type[data-tk-type="bug"] b { color: #ff8080; }
.tk-type[data-tk-type="bug"]:hover {
    border-color: rgba(255, 107, 107, .55); background: rgba(255, 107, 107, .10);
}
.tk-type[data-tk-type="bug"].on {
    background: rgba(255, 107, 107, .16); border-color: rgba(255, 107, 107, .75);
}
.tk-type[data-tk-type="suggest"] b { color: #7fd88f; }
.tk-type[data-tk-type="suggest"]:hover {
    border-color: rgba(127, 216, 143, .55); background: rgba(127, 216, 143, .10);
}
.tk-type[data-tk-type="suggest"].on {
    background: rgba(127, 216, 143, .16); border-color: rgba(127, 216, 143, .75);
}

/* ---------- 图片上传 ---------- */
.tk-imgs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.tk-img {
    position: relative; width: 74px; height: 74px; border-radius: 8px; overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .05);
}
.tk-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tk-img-del {
    position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
    border: 0; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff;
    font-size: 13px; line-height: 18px; cursor: pointer; padding: 0;
}
.tk-pick {
    width: 74px; height: 74px; border-radius: 8px; cursor: pointer;
    border: 1px dashed rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .03);
    color: #c3cddd; font-size: 22px; display: flex; align-items: center; justify-content: center;
}
.tk-pick:hover { border-color: rgba(106, 161, 255, .6); color: #6aa1ff; }

/* ---------- 按钮与提示 ---------- */
.tk-ops { display: flex; gap: 10px; margin-top: 16px; }
.tk-btn {
    flex: 1; padding: 11px 18px; border-radius: 10px; cursor: pointer;
    font: inherit; font-size: 14px; border: 1px solid transparent;
}
.tk-btn-primary { background: #6aa1ff; color: #0f1522; font-weight: 600; }
.tk-btn-ghost { background: transparent; color: #c3cddd; border-color: rgba(255, 255, 255, .18); }
.tk-btn:disabled { opacity: .55; cursor: not-allowed; }
.tk-msg { margin-top: 10px; font-size: 13px; min-height: 20px; }
.tk-msg.is-ok { color: #7fd88f; }
.tk-msg.is-err { color: #ff8080; }

/* ---------- 系统消息列表 ---------- */
.tk-msglist { list-style: none; margin: 10px 0 0; padding: 0; max-height: 52vh; overflow: auto; }
.tk-msglist li {
    border: 1px solid rgba(255, 255, 255, .1); border-radius: 10px;
    padding: 12px 14px; margin-bottom: 10px; background: rgba(255, 255, 255, .03);
}
.tk-msglist li.unread { border-color: rgba(255, 77, 79, .45); background: rgba(255, 77, 79, .07); }
.tk-msg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tk-msg-title { font-size: 14px; font-weight: 600; }
.tk-msg-time { font-size: 12px; color: #c3cddd; }
.tk-msg-body { margin: 8px 0 10px; font-size: 13px; white-space: pre-wrap; word-break: break-word; color: #cfd8e6; }
.tk-msg-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tk-read-btn {
    padding: 5px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px;
    background: rgba(106, 161, 255, .18); border: 1px solid rgba(106, 161, 255, .5); color: #9bd0ff;
}
.tk-read-btn:disabled { opacity: .5; cursor: default; }
.tk-badge {
    font-size: 11px; padding: 2px 8px; border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .18); color: #c3cddd;
}
.tk-empty { text-align: center; color: #c3cddd; font-size: 13px; padding: 26px 0; }

/* 浅色主题适配 */
:root[data-theme='light'] .tk-card { background: rgba(255, 255, 255, .96); color: #1a1f2b; }
:root[data-theme='light'] .tk-input,
:root[data-theme='light'] .tk-textarea { background: rgba(0, 0, 0, .04); color: #1a1f2b; border-color: rgba(0, 0, 0, .14); }
:root[data-theme='light'] .tk-msglist li { background: rgba(0, 0, 0, .03); border-color: rgba(0, 0, 0, .1); }
:root[data-theme='light'] .tk-msg-body { color: #4a5568; }
/* 提亮过的辅助文字在浅色下要换成深灰，否则反而看不见 */
:root[data-theme='light'] .tk-hint,
:root[data-theme='light'] .tk-label,
:root[data-theme='light'] .tk-type span,
:root[data-theme='light'] .tk-msg-time,
:root[data-theme='light'] .tk-badge,
:root[data-theme='light'] .tk-empty,
:root[data-theme='light'] .tk-pick,
:root[data-theme='light'] .tk-btn-ghost { color: #5a6478; }
:root[data-theme='light'] .tk-input::placeholder,
:root[data-theme='light'] .tk-textarea::placeholder { color: #8a94a6; }
:root[data-theme='light'] .tk-type { border-color: rgba(0, 0, 0, .14); background: rgba(0, 0, 0, .02); }
/* 浅色主题下红/绿都要压深一档，才在白底上看得清 */
:root[data-theme='light'] .tk-type[data-tk-type="bug"] b { color: #d64545; }
:root[data-theme='light'] .tk-type[data-tk-type="suggest"] b { color: #2f9e44; }
:root[data-theme='light'] .tk-type[data-tk-type="bug"].on { border-color: rgba(214, 69, 69, .7); background: rgba(214, 69, 69, .10); }
:root[data-theme='light'] .tk-type[data-tk-type="suggest"].on { border-color: rgba(47, 158, 68, .7); background: rgba(47, 158, 68, .10); }

@media (max-width: 600px) {
    .tk-card { padding: 16px 14px; }
    .tk-types { flex-direction: column; }
}

/* ============================================================
   我的工单（用户端查看自己提交过的工单）
   ============================================================ */

/* 宽版卡片（列表与详情用） */
.tk-card-wide { max-width: 640px; }

/* 详情层叠在列表层之上 */
.tk-modal-2 { z-index: 10003; }

/* ---------- 列表 ---------- */
.tk-mine-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    max-height: 52vh;
    overflow: auto;
}
.tk-mine-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    padding: 11px 13px;
    text-align: left;
    font: inherit;
    color: inherit;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .11);
    border-radius: 11px;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.tk-mine-item:hover,
.tk-mine-item:focus-visible {
    background: rgba(255, 255, 255, .09);
    border-color: rgba(106, 161, 255, .45);
    transform: translateY(-1px);
    outline: none;
}
.tk-mine-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.tk-mine-no {
    font-size: 12px;
    font-weight: 700;
    color: #8fa3bf;
    font-variant-numeric: tabular-nums;
}
.tk-mine-type {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.tk-mine-type.is-bug {
    color: #ff8080;
    background: rgba(255, 107, 107, .14);
    border: 1px solid rgba(255, 107, 107, .3);
}
.tk-mine-type.is-suggest {
    color: #7fd88f;
    background: rgba(125, 216, 143, .14);
    border: 1px solid rgba(125, 216, 143, .3);
}
.tk-mine-status {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
}
.tk-mine-status.is-pending {
    color: #ffc978;
    background: rgba(255, 201, 120, .14);
    border: 1px solid rgba(255, 201, 120, .3);
}
.tk-mine-status.is-done {
    color: #7fd88f;
    background: rgba(125, 216, 143, .14);
    border: 1px solid rgba(125, 216, 143, .3);
}
.tk-mine-status.is-rejected {
    color: #ff9a9a;
    background: rgba(255, 107, 107, .12);
    border: 1px solid rgba(255, 107, 107, .28);
}
.tk-mine-tag {
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 11px;
    color: #6aa1ff;
    background: rgba(106, 161, 255, .14);
    border: 1px solid rgba(106, 161, 255, .3);
}
.tk-mine-title {
    font-size: 14px;
    font-weight: 600;
    color: #e8edf6;
    overflow-wrap: anywhere;
}
.tk-mine-time {
    font-size: 11.5px;
    color: #9aa6bb;
}

/* ---------- 详情 ---------- */
.tk-dt-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 4px 0 10px;
}
.tk-dt-time {
    font-size: 11.5px;
    color: #9aa6bb;
}
.tk-dt-title {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 600;
    color: #e8edf6;
    overflow-wrap: anywhere;
}
.tk-dt-block {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .045);
    border: 1px solid rgba(255, 255, 255, .09);
}
.tk-dt-block-label {
    margin-bottom: 7px;
    font-size: 12px;
    font-weight: 600;
    color: #8fa3bf;
}
.tk-dt-content {
    font-size: 13.5px;
    line-height: 1.7;
    color: #cfd8e6;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.tk-dt-reply {
    background: rgba(106, 161, 255, .09);
    border-color: rgba(106, 161, 255, .3);
}
.tk-dt-reply .tk-dt-block-label { color: #6aa1ff; }
.tk-dt-reject {
    background: rgba(255, 107, 107, .09);
    border-color: rgba(255, 107, 107, .3);
}
.tk-dt-reject .tk-dt-block-label { color: #ff9a9a; }
.tk-dt-wait {
    background: rgba(255, 201, 120, .08);
    border-color: rgba(255, 201, 120, .26);
}
.tk-dt-wait .tk-dt-content { color: #d9c39c; }

/* 详情里的截图：可点开看原图 */
.tk-imgs-view { margin-top: 4px; }
.tk-imgs-view .tk-img { width: 84px; height: 84px; }
.tk-imgs-view .tk-img:hover { border-color: rgba(106, 161, 255, .6); }

@media (max-width: 768px) {
    .tk-card-wide { max-width: 100%; }
    .tk-mine-list { max-height: 46vh; }
}

/* ==================== 会话式工单（对话时间线 + 回复框） ==================== */
.tk-conv {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 46vh;
    overflow-y: auto;
    padding: 10px 6px;
    margin: 10px 0 4px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 10px;
    background: rgba(255, 255, 255, .02);
}
.tk-conv-msg { display: flex; flex-direction: column; max-width: 86%; }
.tk-conv-msg.is-user { align-self: flex-end; align-items: flex-end; }
.tk-conv-msg.is-admin { align-self: flex-start; align-items: flex-start; }
.tk-conv-msg.is-system { align-self: center; max-width: 96%; align-items: center; }
.tk-conv-meta { font-size: 11px; color: #93a0b5; margin: 0 2px 3px; }
.tk-conv-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}
.tk-conv-msg.is-user .tk-conv-bubble {
    background: rgba(106, 161, 255, .16);
    border: 1px solid rgba(106, 161, 255, .3);
}
.tk-conv-msg.is-admin .tk-conv-bubble {
    background: rgba(127, 216, 143, .1);
    border: 1px solid rgba(127, 216, 143, .26);
}
.tk-conv-msg.is-system .tk-conv-bubble {
    background: rgba(255, 107, 107, .08);
    border: 1px solid rgba(255, 107, 107, .26);
    color: #ff9a9a;
    font-size: 12px;
}
.tk-conv-msg .tk-imgs-view { justify-content: flex-end; }
.tk-reply-box { margin-top: 10px; }
.tk-reply-input {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    min-height: 64px;
    padding: 9px 11px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: rgba(255, 255, 255, .04);
    color: inherit;
    font-size: 13px;
    line-height: 1.55;
    font-family: inherit;
}
.tk-reply-input:focus { outline: none; border-color: rgba(106, 161, 255, .55); }
.tk-reply-ops {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}
.tk-reply-msg { font-size: 12px; color: #93a0b5; }

/* 「新回复」未读红点标记 */
.tk-mine-tag.is-new {
    color: #ff6b6b;
    border-color: rgba(255, 107, 107, .45);
    background: rgba(255, 107, 107, .08);
    font-weight: 600;
}

/* 列表里的「标记已读」小按钮（已结单且有未看消息时显示） */
.tk-read-mark {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(106, 161, 255, .45);
    color: #6aa1ff;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.tk-read-mark:hover { background: rgba(106, 161, 255, .12); }

/* 未读工单回复常驻提醒条：不点开也一直显示，点「查看回复」直达我的工单 */
.tk-notice-bar {
    position: fixed; top: 16px; right: 18px; z-index: 10011;
    display: none; align-items: center; gap: 10px;
    max-width: min(92vw, 380px);
    padding: 10px 12px 10px 14px;
    border-radius: 12px;
    background: rgba(23, 31, 48, .96); color: #e8edf6;
    border: 1px solid rgba(255, 107, 107, .5);
    box-shadow: 0 10px 34px rgba(0, 0, 0, .42);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    font-size: 13px; line-height: 1.4;
}
.tk-notice-bar.show { display: flex; }
.tkn-dot {
    flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%;
    background: #ff4d4f; box-shadow: 0 0 0 4px rgba(255, 77, 79, .18);
    animation: tkn-pulse 1.6s ease-in-out infinite;
}
@keyframes tkn-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(255, 77, 79, .18); }
    50% { box-shadow: 0 0 0 7px rgba(255, 77, 79, .05); }
}
.tkn-text { flex: 1 1 auto; min-width: 0; }
.tkn-open {
    flex: 0 0 auto; cursor: pointer;
    padding: 5px 11px; border-radius: 8px;
    background: #ff4d4f; color: #fff; border: 1px solid #ff4d4f;
    font-size: 12px; font-weight: 600;
}
.tkn-open:hover { background: #ff7875; border-color: #ff7875; }
.tkn-close {
    flex: 0 0 auto; cursor: pointer; border: 0; background: transparent;
    color: #9aa6bb; font-size: 18px; line-height: 1; padding: 0 2px;
}
.tkn-close:hover { color: #e8edf6; }

/* 网页上方的新消息 Toast 轻提示 */
.tk-toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translate(-50%, -12px);
    z-index: 10010;
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(23, 31, 48, .95);
    color: #e8edf6;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .35);
    border: 1px solid rgba(255, 255, 255, .16);
    opacity: 0;
    transition: opacity .35s ease, transform .35s ease;
    pointer-events: none;
    max-width: 86vw;
}
.tk-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}
