/* ============================================================
   我的工单页面 - ticket.css
   原创设计：统一卡片列表 + 左边框状态色 + 现代聊天面板
   与moban3的桌面表格+移动卡片双布局完全不同
   ============================================================ */

/* ====== 统计卡片 ====== */
.tk-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 22px;
    animation: fadeUp .3s var(--ease-out) both;
}

.tk-stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 22px;
    border-radius: var(--radius-lg);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.tk-stat-card::after {
    content: '';
    position: absolute;
    right: -20px;
    bottom: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    pointer-events: none;
}

.tk-stat-card.card-all {
    background: linear-gradient(135deg, #7C6CF0, #6C5CE7);
}

.tk-stat-card.card-pending {
    background: linear-gradient(135deg, #FBBD23, #F59E0B);
}

.tk-stat-card.card-closed {
    background: linear-gradient(135deg, #36D399, #22C55E);
}

.tk-stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tk-stat-icon svg {
    width: 20px;
    height: 20px;
    stroke: #fff;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tk-stat-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tk-stat-num {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.tk-stat-label {
    font-size: 12px;
    color: rgba(255,255,255,.8);
}

/* ====== 列表标题栏 ====== */
.tk-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    animation: fadeUp .3s var(--ease-out) .05s both;
}

.tk-list-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.tk-new-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 18px;
    cursor: pointer;
    transition: all .18s var(--ease-out);
}

.tk-new-btn:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
}

.tk-new-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ====== 工单卡片列表 ====== */
.tk-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: fadeUp .3s var(--ease-out) .1s both;
}

.tk-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
    border: 1px solid var(--divider);
    cursor: pointer;
    transition: all .2s var(--ease-out);
}

.tk-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,.08);
    transform: translateY(-2px);
    border-color: transparent;
}

.tk-card.status-open:hover {
    box-shadow: 0 6px 20px rgba(234,179,8,.12);
}

.tk-card.status-closed:hover {
    box-shadow: 0 6px 20px rgba(34,197,94,.12);
}

/* 状态图标 */
.tk-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tk-card-icon svg {
    width: 20px;
    height: 20px;
    stroke: #fff;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tk-card-icon.pending {
    background: linear-gradient(135deg, #FBBD23, #F59E0B);
}

.tk-card-icon.closed {
    background: linear-gradient(135deg, #36D399, #22C55E);
}

/* 卡片主体 */
.tk-card-body {
    flex: 1;
    min-width: 0;
}

.tk-card-subject {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tk-card-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* 状态药丸 */
.tk-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
}

.tk-pill-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.tk-pill.pending {
    color: #B45309;
    background: rgba(234,179,8,.15);
}

.tk-pill.pending .tk-pill-dot {
    background: #EAB308;
}

.tk-pill.closed {
    color: #16A34A;
    background: rgba(34,197,94,.12);
}

.tk-pill.closed .tk-pill-dot {
    background: #22C55E;
}

/* 级别标签 */
.tk-level {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 8px;
}

.tk-level.low {
    color: #16A34A;
    background: rgba(34,197,94,.1);
}

.tk-level.medium {
    color: #D97706;
    background: rgba(234,179,8,.1);
}

.tk-level.high {
    color: #DC2626;
    background: rgba(220,38,38,.1);
}

/* 时间 */
.tk-card-time {
    font-size: 11px;
    color: var(--text-muted);
}

/* 卡片右侧操作 */
.tk-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.tk-act-btn {
    padding: 7px 16px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.tk-act-btn.view {
    background: rgba(108,92,231,.1);
    color: var(--accent);
}

.tk-act-btn.view:hover {
    background: rgba(108,92,231,.2);
}

.tk-act-btn.close {
    background: rgba(220,38,38,.08);
    color: #DC2626;
}

.tk-act-btn.close:hover {
    background: rgba(220,38,38,.15);
}

.tk-act-btn:disabled {
    opacity: .3;
    cursor: not-allowed;
    pointer-events: none;
}

/* ====== 空状态 ====== */
.tk-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 20px;
    color: var(--text-muted);
    animation: fadeUp .3s var(--ease-out) both;
}

.tk-empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--surface-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.tk-empty-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--text-muted);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tk-empty p {
    margin: 0;
    font-size: 13px;
}

/* ============================================================
   弹窗通用
   ============================================================ */
.tk-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9000;
    animation: tkOverIn .2s var(--ease-out);
}

@keyframes tkOverIn { from { opacity: 0; } }

.tk-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 440px;
    max-width: calc(100% - 32px);
    background: #fff;
    border-radius: var(--radius-lg);
    z-index: 9001;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0,0,0,.18);
    animation: tkModalIn .3s var(--ease-out);
}

@keyframes tkModalIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(.95); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.tk-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--divider);
}

.tk-modal-head span {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.tk-modal-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--surface-alt);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}

.tk-modal-close:hover {
    background: var(--divider);
    color: var(--text-primary);
}

.tk-modal-close svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tk-modal-body {
    padding: 20px;
}

/* 表单字段 */
.tk-field {
    margin-bottom: 14px;
}

.tk-field:last-child {
    margin-bottom: 0;
}

.tk-field label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.tk-field .char-hint {
    font-weight: 400;
    font-size: 11px;
    color: var(--text-muted);
}

.tk-field input,
.tk-field textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--card-bg);
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
    outline: none;
    box-sizing: border-box;
    transition: border-color .2s, box-shadow .2s;
}

.tk-field textarea {
    min-height: 100px;
    resize: vertical;
    line-height: 1.6;
}

.tk-field input:focus,
.tk-field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,92,231,.1);
}

.tk-field input::placeholder,
.tk-field textarea::placeholder {
    color: var(--text-muted);
}

/* 下拉选择 */
.tk-select-wrap {
    position: relative;
}

.tk-select-trigger {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-primary);
    box-sizing: border-box;
    transition: border-color .2s;
}

.tk-select-trigger.open {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,92,231,.1);
}

.tk-select-trigger svg {
    width: 16px;
    height: 16px;
    fill: var(--text-muted);
    transition: transform .2s;
}

.tk-select-trigger.open svg {
    transform: rotate(180deg);
}

.tk-select-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    z-index: 100;
    overflow: hidden;
    animation: tkDropIn .2s var(--ease-out);
}

@keyframes tkDropIn {
    from { opacity: 0; transform: translateY(-6px); }
}

.tk-select-opt {
    padding: 10px 14px;
    font-size: 14px;
    cursor: pointer;
    transition: background .12s;
    color: var(--text-primary);
}

.tk-select-opt:hover {
    background: var(--surface-alt);
}

.tk-select-opt.selected {
    color: var(--accent);
    font-weight: 600;
    background: rgba(108,92,231,.06);
}

/* 弹窗底部按钮 */
.tk-modal-foot {
    display: flex;
    gap: 10px;
    padding: 0 20px 20px;
}

.tk-modal-btn {
    flex: 1;
    height: 40px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all .15s;
}

.tk-modal-btn.cancel {
    background: var(--surface-alt);
    color: var(--text-secondary);
}

.tk-modal-btn.cancel:hover {
    background: var(--divider);
}

.tk-modal-btn.confirm {
    background: var(--accent);
    color: #fff;
}

.tk-modal-btn.confirm:hover {
    background: var(--accent-dark);
}

.tk-modal-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ============================================================
   聊天详情弹窗
   ============================================================ */
.tk-chat {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 520px;
    max-width: calc(100% - 32px);
    max-height: 80vh;
    background: #fff;
    border-radius: var(--radius-lg);
    z-index: 9001;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0,0,0,.18);
    animation: tkModalIn .3s var(--ease-out);
}

.tk-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--divider);
    flex-shrink: 0;
}

.tk-chat-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tk-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

/* 聊天气泡 */
.tk-msg {
    margin-bottom: 18px;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
}

.tk-msg:last-child {
    margin-bottom: 0;
}

.tk-msg.me {
    flex-direction: row-reverse;
}

.tk-msg.other {
    flex-direction: row;
}

/* 圆形头像 */
.tk-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.tk-msg-avatar.me {
    background: linear-gradient(135deg, #7C6CF0, #6C5CE7);
}

.tk-msg-avatar.other {
    background: linear-gradient(135deg, #36D399, #22C55E);
}

/* 消息内容列 */
.tk-msg-content {
    display: flex;
    flex-direction: column;
    max-width: 75%;
}

.tk-msg.me .tk-msg-content {
    align-items: flex-end;
}

.tk-msg.other .tk-msg-content {
    align-items: flex-start;
}

.tk-msg-bubble {
    padding: 10px 16px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
    border-radius: 14px;
}

.tk-msg.me .tk-msg-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.tk-msg.other .tk-msg-bubble {
    background: var(--surface-alt);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.tk-msg-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 6px;
}

/* 回复输入区 */
.tk-chat-reply {
    padding: 16px 20px;
    border-top: 1px solid var(--divider);
    flex-shrink: 0;
}

/* 确认关闭弹窗 */
.tk-confirm {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 340px;
    max-width: calc(100% - 32px);
    background: #fff;
    border-radius: var(--radius-lg);
    z-index: 9002;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0,0,0,.18);
    animation: tkModalIn .3s var(--ease-out);
    text-align: center;
    padding: 28px 24px 20px;
}

.tk-confirm-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.tk-confirm-msg {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.tk-confirm-actions {
    display: flex;
    gap: 10px;
}

/* ====== 响应式 ====== */
@media (max-width: 768px) {
    .tk-stats {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .tk-stat-card {
        padding: 16px 20px 16px 17px;
    }

    .tk-stat-icon {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .tk-stat-icon svg {
        width: 17px;
        height: 17px;
    }

    .tk-stat-num {
        font-size: 20px;
    }

    .tk-card {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
        gap: 4px 12px;
        padding: 14px 16px;
        align-items: center;
    }

    .tk-card-icon {
        grid-row: 1 / 3;
        grid-column: 1;
        width: 46px;
        height: 46px;
        border-radius: 12px;
    }

    .tk-card-icon svg {
        width: 22px;
        height: 22px;
    }

    .tk-card-body {
        display: contents;
    }

    .tk-card-subject {
        grid-row: 1;
        grid-column: 2;
        font-size: 14px;
        margin-bottom: 0;
    }

    .tk-card-info {
        grid-row: 2;
        grid-column: 2 / 4;
        gap: 6px;
        margin-top: 2px;
    }

    .tk-card-actions {
        grid-row: 1;
        grid-column: 3;
    }

    .tk-chat {
        max-height: 90vh;
    }

    .tk-chat-body {
        padding: 14px;
    }

    .tk-msg-bubble {
        max-width: 90%;
    }
}

@media (max-width: 380px) {
    .tk-stat-card {
        padding: 14px 16px 14px 15px;
    }

    .tk-stat-num {
        font-size: 16px;
    }

    .tk-card-subject {
        font-size: 13px;
    }

    .tk-act-btn {
        padding: 5px 10px;
        font-size: 11px;
    }
}
