/* 在线工具页 — 与咸鱼风格模板集成 */
body.xy-tools {
    --c-primary: #1677ff;
    --c-primary-rgb: 22, 119, 255;
    --c-secondary: #52c41a;
    --c-secondary-rgb: 82, 196, 26;
    --text: #1f2937;
    --text-light: #6b7280;
    --text-muted: #9ca3af;
    --glass: rgba(255, 255, 255, 0.95);
    --glass-hover: rgba(255, 255, 255, 0.98);
    --glass-border: #e5e7eb;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 4px 16px rgba(15, 23, 42, 0.06);
    --radius: 12px;
    --blur: 12px;
    --transition: all 0.2s ease;
    --font-size-title: 1.35rem;
    --danger: #ff4d4f;
    overflow: hidden !important;
}

.xy-tools-wrap {
    padding: calc(var(--xy-nav-height, 64px) + 16px) 24px 16px;
    max-width: 1400px;
    margin: 0 auto;
    height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.xy-tools-wrap .animate-in {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.xy-tools-title {
    font-size: var(--font-size-title);
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    font-weight: 700;
    color: var(--text);
}

.xy-tools-title > i {
    color: var(--c-primary);
    font-size: 1.2em;
}

body.xy-tools .card.tools-panel {
    flex: 1;
    min-height: 0;
    background: #fff;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
}

body.xy-tools .card.tools-panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

body.xy-tools .tool-split-view {
    flex: 1;
    min-height: 300px;
}

body.xy-tools .toast-container {
    top: calc(var(--xy-nav-height, 64px) + 12px);
}

.toast.info {
    border-left: 4px solid #06b6d4;
}

.toast.warning {
    border-left: 4px solid #f59e0b;
}

.json-path-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    margin-bottom: 10px;
    background: rgba(22, 119, 255, 0.06);
    border: 1px solid rgba(22, 119, 255, 0.12);
    border-radius: 8px;
    font-size: 12px;
    color: var(--c-text-secondary);
    flex-shrink: 0;
}

.json-path-hint code {
    padding: 1px 6px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    font-size: 11px;
    color: var(--c-primary);
}

/* 结果区统一深色背景，避免移动端白底看不清 */
.tool-result-text {
    padding: 16px;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 13px;
    line-height: 1.8;
    color: #d4d4d4;
    background: #1e1e1e;
    white-space: pre-wrap;
    word-break: break-all;
    overflow: auto;
    flex: 1;
    min-height: 160px;
}

.hash-result-list {
    padding: 12px;
    overflow: auto;
    flex: 1;
    min-height: 160px;
    background: #1e1e1e;
}

.hash-result-item {
    display: grid;
    grid-template-columns: 80px 1fr 36px;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #2d2d2d;
    border: 1px solid #404040;
    border-radius: 8px;
}

.hash-result-item:last-child {
    margin-bottom: 0;
}

.hash-result-label {
    font-size: 12px;
    font-weight: 600;
    color: #79c0ff;
}

.hash-result-value {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12px;
    color: #e6edf3;
    word-break: break-all;
    cursor: pointer;
}

.hash-result-value:hover {
    color: #a5d6ff;
}

.hash-copy-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: #3d3d3d;
    color: #aaa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hash-copy-btn:hover {
    background: rgba(22, 119, 255, 0.3);
    color: #79c0ff;
}

/* 编码转换 - 筛选栏 */
.encode-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin-bottom: 12px;
    padding: 10px 14px;
    font-size: 13px;
    flex-shrink: 0;
    background: rgba(22, 119, 255, 0.04);
    border: 1px solid rgba(22, 119, 255, 0.1);
    border-radius: 8px;
}

.encode-filters-label {
    color: var(--text-light);
    font-weight: 500;
}

.encode-filter-item {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    color: var(--text);
    user-select: none;
}

.encode-filter-item input[type="checkbox"] {
    accent-color: var(--c-primary);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.encode-filters-hint {
    color: var(--text-muted);
    font-size: 11px;
    margin-left: auto;
}

/* 弹窗 & 加载遮罩 */
.tool-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10050;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.tool-modal.open {
    display: flex;
}

.tool-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    animation: toolModalFadeIn 0.2s ease;
}

.tool-modal-box {
    position: relative;
    background: #fff;
    border-radius: 14px;
    padding: 24px 24px 20px;
    min-width: 300px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
    animation: toolModalSlideIn 0.25s ease;
    text-align: center;
}

.tool-modal-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    font-size: 22px;
    background: color-mix(in srgb, var(--modal-accent, #1677ff) 12%, transparent);
    color: var(--modal-accent, #1677ff);
}

.tool-modal-icon-error   { --modal-accent: #ff4d4f; }
.tool-modal-icon-warning { --modal-accent: #faad14; }
.tool-modal-icon-info    { --modal-accent: #1677ff; }
.tool-modal-icon-success { --modal-accent: #52c41a; }

.tool-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.tool-modal-message {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.65;
    word-break: break-word;
    max-height: 40vh;
    overflow-y: auto;
}

.tool-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.tool-modal-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text);
}

.tool-modal-footer {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.tool-modal-footer .btn {
    min-width: 100px;
    padding: 8px 24px;
    border-radius: 8px;
}

.tool-loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10060;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(3px);
}

.tool-loading-overlay.open {
    display: flex;
}

.tool-loading-box {
    background: #fff;
    border-radius: 14px;
    padding: 28px 36px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    animation: toolModalSlideIn 0.25s ease;
}

.tool-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(22, 119, 255, 0.15);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: toolSpin 0.7s linear infinite;
}

.tool-loading-text {
    font-size: 14px;
    color: var(--text-light);
}

@keyframes toolModalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes toolModalSlideIn {
    from { opacity: 0; transform: scale(0.92) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes toolSpin {
    to { transform: rotate(360deg); }
}

#panel-base64 .base64-layout {
    display: flex;
    gap: 12px;
    flex: 1;
    min-height: 200px;
    overflow: hidden;
}

@media (max-width: 768px) {
    .xy-tools-wrap {
        padding-left: 12px;
        padding-right: 12px;
        padding-top: calc(var(--xy-nav-height, 64px) + 12px);
        height: auto;
        min-height: calc(100vh - 48px);
    }

    body.xy-tools {
        overflow: auto !important;
    }

    .xy-tools-wrap .animate-in {
        height: auto;
        overflow: visible;
    }

    body.xy-tools .card.tools-panel.active {
        min-height: 480px;
    }

    body.xy-tools .tool-split-view {
        min-height: 400px;
        overflow: visible;
    }

    .xy-tools-title {
        font-size: 1.15rem;
        flex-wrap: wrap;
    }

    .json-path-hint {
        font-size: 11px;
        line-height: 1.5;
    }

    .tool-split-right {
        min-height: 200px;
    }

    .tool-result-text,
    .hash-result-list,
    .code-viewer-simple {
        min-height: 180px !important;
    }

    #panel-base64 .base64-layout {
        flex-direction: column;
        overflow: visible;
        min-height: auto;
    }

    .encode-filters {
        gap: 8px 12px;
        padding: 10px 12px;
    }

    .encode-filters-hint {
        width: 100%;
        margin-left: 0;
        margin-top: 2px;
    }

    .tool-modal-box {
        padding: 20px 18px 16px;
        max-width: calc(100vw - 32px);
    }

    .tool-loading-box {
        padding: 24px 28px;
    }
}
