/* Halo 管理员评论管理按钮：仅在 GLOBAL_CONFIG.source.twikoo.haloAdmin 为 true 时由 twikoo.js 注入 */

/* 仅管理员模式下把 .tk-comment 设为定位上下文，普通访客的评论布局完全不受影响 */
#twikoo.tk-halo-admin .tk-comment {
    position: relative;
}

#twikoo .tk-halo-comment-admin {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--heo-border-color, rgba(0, 0, 0, 0.08));
    border-radius: 50%;
    background: var(--heo-white-color, #fff);
    color: var(--heo-gray-color, #909399);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s, background-color 0.2s;
}

#twikoo .tk-comment:hover > .tk-halo-comment-admin,
#twikoo .tk-halo-comment-admin:focus-visible {
    opacity: 1;
}

#twikoo .tk-halo-comment-admin:hover {
    color: var(--heo-danger-color, #f56c6c);
    background: var(--heo-danger-light-color, #fef0f0);
}

#twikoo .tk-halo-comment-admin svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

#twikoo .tk-halo-comment-admin.is-loading {
    opacity: 1;
    pointer-events: none;
}

#twikoo .tk-halo-comment-admin.is-loading::after {
    content: '';
    width: 13px;
    height: 13px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: tk-halo-spin 0.7s linear infinite;
}

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

@media screen and (max-width: 768px) {
    /* 触屏没有 hover，常驻显示 */
    #twikoo .tk-halo-comment-admin {
        opacity: 1;
        width: 26px;
        height: 26px;
        top: 8px;
        right: 8px;
    }
}

/* ==================== 评论管理面板 ==================== */

#hao-twikoo-admin {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: stretch;
    justify-content: flex-end;
    font-family: var(--heo-font-family, inherit);
}

#hao-twikoo-admin .twka-mask {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
}

#hao-twikoo-admin .twka-panel {
    position: relative;
    /* 必须高于 .twka-mask：同层级下后写的遮罩会盖住面板，导致删除等按钮点不动 */
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(960px, 92vw);
    height: 100%;
    background: var(--heo-bg-color, #fff);
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.16);
    animation: twka-slide-in 0.22s ease;
}

@keyframes twka-slide-in {
    from { transform: translateX(24px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

#hao-twikoo-admin .twka-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--heo-border-color, rgba(0, 0, 0, 0.08));
}

#hao-twikoo-admin .twka-title {
    font-size: 16px;
    font-weight: 600;
}

#hao-twikoo-admin .twka-title i {
    margin-right: 6px;
}

#hao-twikoo-admin .twka-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

#hao-twikoo-admin .twka-close:hover {
    background: var(--heo-gray-hover-color, rgba(0, 0, 0, 0.06));
    color: var(--heo-main-color, #425aef);
}

#hao-twikoo-admin .twka-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--heo-border-color, rgba(0, 0, 0, 0.08));
}

#hao-twikoo-admin .twka-input {
    flex: 1 1 240px;
    min-width: 0;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--heo-border-color, rgba(0, 0, 0, 0.12));
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font-size: 14px;
    outline: none;
}

#hao-twikoo-admin .twka-input:focus {
    border-color: var(--heo-main-color, #425aef);
}

#hao-twikoo-admin .twka-btn {
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--heo-border-color, rgba(0, 0, 0, 0.12));
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

#hao-twikoo-admin .twka-btn:hover:not(:disabled) {
    border-color: var(--heo-main-color, #425aef);
    color: var(--heo-main-color, #425aef);
}

#hao-twikoo-admin .twka-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#hao-twikoo-admin .twka-btn.is-danger {
    border-color: var(--heo-danger-color, #f56c6c);
    color: var(--heo-danger-color, #f56c6c);
}

#hao-twikoo-admin .twka-btn.is-danger:hover:not(:disabled) {
    background: var(--heo-danger-light-color, #fef0f0);
}

#hao-twikoo-admin .twka-search {
    width: 34px;
    padding: 0;
}

#hao-twikoo-admin .twka-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

#hao-twikoo-admin .twka-tab {
    height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--heo-gray-hover-color, rgba(0, 0, 0, 0.05));
    color: var(--heo-gray-color, #909399);
    font-size: 12px;
    line-height: 28px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s, color 0.2s;
}

#hao-twikoo-admin .twka-tab.active {
    background: var(--heo-main-color, #425aef);
    color: #fff;
}

#hao-twikoo-admin .twka-status {
    min-height: 20px;
    padding: 0 18px;
    color: var(--heo-gray-color, #909399);
    font-size: 12px;
    line-height: 20px;
}

#hao-twikoo-admin .twka-status.is-error {
    color: var(--heo-danger-color, #f56c6c);
}

#hao-twikoo-admin .twka-table-wrap {
    flex: 1;
    overflow: auto;
    padding: 0 18px;
}

#hao-twikoo-admin .twka-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

#hao-twikoo-admin .twka-table th,
#hao-twikoo-admin .twka-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--heo-border-color, rgba(0, 0, 0, 0.06));
    text-align: left;
    vertical-align: top;
}

#hao-twikoo-admin .twka-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--heo-bg-color, #fff);
    font-weight: 500;
    color: var(--heo-gray-color, #909399);
    font-size: 12px;
}

#hao-twikoo-admin .twka-col-check {
    width: 34px;
}

#hao-twikoo-admin .twka-col-time {
    width: 118px;
    white-space: nowrap;
}

#hao-twikoo-admin .twka-col-act {
    width: 148px;
}

#hao-twikoo-admin tr.is-spam {
    opacity: 0.6;
}

#hao-twikoo-admin .twka-nick {
    font-weight: 600;
}

#hao-twikoo-admin .twka-meta {
    margin-top: 4px;
    color: var(--heo-gray-color, #909399);
    font-size: 11px;
    word-break: break-all;
}

#hao-twikoo-admin .twka-content {
    word-break: break-word;
    white-space: pre-wrap;
}

#hao-twikoo-admin .twka-url {
    display: inline-block;
    margin-top: 6px;
    color: var(--heo-gray-color, #909399);
    font-size: 11px;
    text-decoration: none;
    word-break: break-all;
}

#hao-twikoo-admin .twka-url:hover {
    color: var(--heo-main-color, #425aef);
}

#hao-twikoo-admin .twka-time {
    color: var(--heo-gray-color, #909399);
    font-size: 12px;
    white-space: nowrap;
}

#hao-twikoo-admin .twka-actions button {
    margin-right: 6px;
    height: 26px;
    padding: 0 10px;
    border: 1px solid var(--heo-border-color, rgba(0, 0, 0, 0.12));
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-size: 12px;
    cursor: pointer;
}

#hao-twikoo-admin .twka-actions button:hover:not(:disabled) {
    border-color: var(--heo-main-color, #425aef);
    color: var(--heo-main-color, #425aef);
}

#hao-twikoo-admin .twka-actions button.is-danger {
    border-color: var(--heo-danger-color, #f56c6c);
    color: var(--heo-danger-color, #f56c6c);
}

#hao-twikoo-admin .twka-actions button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#hao-twikoo-admin .twka-empty {
    padding: 40px 0 !important;
    text-align: center !important;
    color: var(--heo-gray-color, #909399);
}

#hao-twikoo-admin .twka-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 18px;
    border-top: 1px solid var(--heo-border-color, rgba(0, 0, 0, 0.08));
    font-size: 13px;
}

#hao-twikoo-admin .twka-pager {
    display: flex;
    align-items: center;
    gap: 8px;
}

@media screen and (max-width: 768px) {
    #hao-twikoo-admin .twka-panel {
        width: 100vw;
    }

    #hao-twikoo-admin .twka-col-time,
    #hao-twikoo-admin .twka-meta {
        display: none;
    }

    #hao-twikoo-admin .twka-col-act {
        width: auto;
    }

    /* 触屏：让「删除选中」这类主按钮占满一行更好点 */
    #hao-twikoo-admin .twka-footer {
        gap: 8px;
    }

    #hao-twikoo-admin .twka-footer .twka-btn {
        height: 38px;
    }
}

/* ==================== 隐藏 Twikoo 底部署名链接 ==================== */
/* 该链接是 Heo 版 Twikoo 的署名，移除前请自行确认是否符合上游许可要求 */

#twikoo .tk-footer-copy {
    display: none !important;
}

/* 包裹它的 tooltip trigger 需要一并隐藏；:has() 不支持时上一条规则仍生效 */
#twikoo .heo-twikoo-tip-trigger:has(.tk-footer-copy) {
    display: none !important;
}
