/* ========================================
   在线工具箱 /tools 公共样式
   布局：与 /ticket/index 同落位（1400px 居中 + 140px/1fr + gap 30px）
   主色：#2563eb（与 /license/add 立即申请按钮一致）
   ======================================== */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --text-strong: #0f172a;
    --text-main: #334155;
    --text-sub: #64748b;
    --text-faint: #94a3b8;
    --border-color: #e2e8f0;
    --border-soft: #eef2f7;
    --bg-soft: #f8fafc;
    --bg-brand-soft: #eff6ff;
}

/* 页面外壳：落位与 /ticket/index 一致（xc_main_content margin-top:60px + 页面级 padding 30px 40px） */
.xc_tools_wrapper {
    padding: 30px 40px 0;
}

/* 主布局：与 /ticket/index 的 xc_points_container 完全一致（1400px 居中 + 140px/1fr + gap 30px） */
.xc_tools_shell {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 30px;
    align-items: start;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* 左侧菜单：与用户中心侧边栏完全同款（xc_sidebar 由 app.css 提供卡片外观与吸顶） */
.xc_tools_shell > .xc_sidebar {
    width: 140px;
    min-width: 140px;
    margin: 0;
}

.xc_tools_shell > .xc_sidebar .xc_menu_item {
    display: block;
    padding: 12px 8px;
    font-size: 13px;
    text-align: center;
    text-decoration: none;
    color: #64748b;
}

.xc_tools_shell > .xc_sidebar .xc_menu_item:hover {
    text-decoration: none;
}

/* 选中态：显式白字（此处 3 类选择器优先级高于 app.css 的 .xc_menu_item.xc_active，
   不写 color 会导致蓝底配灰蓝字、几乎不可读）+ 与 /license/add 立即申请按钮一致的 #2563eb */
.xc_tools_shell > .xc_sidebar .xc_menu_item.xc_active {
    background: #2563eb;
    color: #fff;
}

body.xc_page_marketing .xc_tools_shell > .xc_sidebar .xc_tool_menu_disabled:hover {
    background: #fff;
    color: #64748b;
}

/* 右侧工作区 */
.xc_tools_main { min-width: 0; padding: 0 0 100px; }

/* ==================== 工具面板 ==================== */
.xc_tool_panel {
    display: none;
    background: #fff;
    border: 1px solid #e8ecf2;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.xc_tool_panel.active { display: block; }

/* 面板头部：图标 + 标题 + 说明 + 格式标签 */
.xc_tool_head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 34px 40px 28px;
    border-bottom: 1px solid var(--border-soft);
}
.xc_tool_icon {
    width: 46px; height: 46px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-brand-soft); color: var(--primary-color);
    border-radius: 12px; font-size: 20px;
}
.xc_tool_icon svg { width: 22px; height: 22px; }
.xc_tool_title {
    margin: 0; font-size: 20px; font-weight: 700;
    color: var(--text-strong); line-height: 1.3;
}
.xc_tool_sub {
    margin: 7px 0 0; font-size: 13px; color: var(--text-sub); line-height: 1.75;
}
.xc_tool_tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.xc_tool_based { margin: 10px 0 0; font-size: 12px; color: var(--text-faint); line-height: 1.6; }
.xc_tool_based a { color: var(--primary-color); text-decoration: none; }
.xc_tool_based a:hover { text-decoration: underline; }
.xc_ver_tag {
    display: inline-block; padding: 3px 12px;
    background: var(--bg-soft); border: 1px solid var(--border-soft);
    color: #475569; font-size: 12px; font-weight: 600; border-radius: 999px; white-space: nowrap;
}

/* 面板主体 */
.xc_tool_body { padding: 30px 40px 44px; }

/* 输入区标签行 */
.xc_input_label {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
    font-size: 13px; font-weight: 600; color: var(--text-main);
}
.xc_input_label_tip { font-size: 12px; font-weight: 400; color: var(--text-faint); }

/* 输入框（文本域通用） */
.xc_analyze_input {
    display: block; width: 100%; box-sizing: border-box;
    padding: 16px 18px; border: 1.5px solid var(--border-color); border-radius: 12px;
    font-size: 14px; font-family: 'Monaco', 'Consolas', 'SFMono-Regular', monospace;
    color: var(--text-strong); background: var(--bg-soft);
    transition: border-color .2s, background .2s, box-shadow .2s;
    resize: vertical; min-height: 150px; line-height: 1.8;
}
.xc_analyze_input:focus {
    outline: none; border-color: var(--primary-color); background: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .09);
}
.xc_analyze_input.error { border-color: #ef4444; }
.xc_analyze_input.error:focus { box-shadow: 0 0 0 4px rgba(239, 68, 68, .09); }

/* 动作行：左侧提示/错误，右侧按钮 */
.xc_action_row {
    display: flex; align-items: center; gap: 12px;
    margin-top: 14px; min-height: 42px;
}
.xc_action_spacer { flex: 1; }
.xc_input_error { display: none; font-size: 13px; color: #ef4444; }

/* 按钮 */
.xc_btn_primary {
    flex-shrink: 0; padding: 11px 32px;
    background: var(--primary-color); color: #fff; border: none; border-radius: 10px;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: background .2s, box-shadow .2s;
    white-space: nowrap; box-shadow: 0 1px 2px rgba(37, 99, 235, .35);
}
.xc_btn_primary:hover { background: var(--primary-dark); }
.xc_btn_primary:disabled { opacity: .6; cursor: not-allowed; }
.xc_btn_ghost {
    flex-shrink: 0; padding: 11px 22px;
    background: #fff; color: #475569; border: 1px solid var(--border-color); border-radius: 10px;
    font-size: 14px; font-weight: 500; cursor: pointer; transition: all .2s; white-space: nowrap;
}
.xc_btn_ghost:hover:not(:disabled) { border-color: #c7d7fe; color: var(--primary-color); background: var(--bg-brand-soft); }
.xc_btn_ghost:disabled { opacity: .5; cursor: not-allowed; }

/* 小号幽灵按钮（结果卡片内：复制 / 转换 / 全屏） */
.xc_btn_small {
    flex-shrink: 0; margin-left: auto;
    padding: 6px 16px; background: #fff; color: #475569;
    border: 1px solid var(--border-color); border-radius: 8px;
    font-size: 12px; font-weight: 600; cursor: pointer; transition: all .2s; white-space: nowrap;
}
.xc_btn_small:hover:not(:disabled) { border-color: #c7d7fe; color: var(--primary-color); background: var(--bg-brand-soft); }
.xc_btn_small:disabled { opacity: .5; cursor: not-allowed; }

/* ==================== 结果区 ==================== */
.xc_result_area { margin-top: 28px; }

.xc_result_loading {
    display: none; align-items: center; gap: 12px;
    padding: 26px; color: var(--text-sub); font-size: 14px;
}
.xc_spinner {
    width: 18px; height: 18px; border: 2px solid #bfdbfe; border-top-color: var(--primary-color);
    border-radius: 50%; animation: xc_spin .8s linear infinite; flex-shrink: 0;
}
@keyframes xc_spin { to { transform: rotate(360deg); } }

/* 失败/提示条 */
.xc_result_fail {
    display: none; padding: 16px 20px; text-align: left;
    font-size: 13px; color: #b45309; background: #fffbeb;
    border: 1px solid #fde68a; border-radius: 12px; line-height: 1.7;
}
.xc_result_error {
    display: none; padding: 16px 20px;
    font-size: 13px; color: #b91c1c; background: #fef2f2;
    border: 1px solid #fecaca; border-radius: 12px; line-height: 1.8;
}
.xc_result_error_title { font-weight: 700; margin-bottom: 4px; }

/* 结果卡片 */
.xc_result_card {
    display: none; border: 1px solid var(--border-color);
    border-radius: 14px; overflow: hidden;
}
.xc_result_head {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 14px 20px; background: var(--bg-soft); border-bottom: 1px solid var(--border-soft);
}
.xc_algo_tag {
    font-size: 13px; font-weight: 700; color: var(--primary-color);
    background: rgba(37, 99, 235, .08); border: 1px solid #c7d7fe; border-radius: 8px; padding: 4px 14px;
}
.xc_expire_tag { font-size: 12px; font-weight: 600; border-radius: 8px; padding: 3px 12px; }
.xc_expire_tag.ok { color: #059669; background: #ecfdf5; border: 1px solid #a7f3d0; }
.xc_expire_tag.expired { color: #b45309; background: #fffbeb; border: 1px solid #fde68a; }
.xc_result_tip { font-size: 12px; color: var(--text-faint); }

/* 字段网格 */
.xc_field_grid { display: grid; grid-template-columns: 1fr 1fr; }
.xc_field_item { padding: 15px 20px; border-bottom: 1px solid var(--border-soft); min-width: 0; }
.xc_field_item:nth-last-child(-n+2) { border-bottom: none; }
.xc_field_item:nth-child(odd) { border-right: 1px solid var(--border-soft); }
.xc_field_label { font-size: 11px; color: var(--text-faint); margin-bottom: 4px; letter-spacing: .04em; }
.xc_field_value { font-size: 13px; color: var(--text-strong); word-break: break-all; line-height: 1.6; }

/* 深色代码块（转换结果 / 解码结果 / JSON 结果） */
.xc_code_block {
    margin: 0; padding: 18px 20px;
    font-family: 'Monaco', 'Consolas', 'SFMono-Regular', monospace;
    font-size: 12.5px; line-height: 1.8;
    color: #e2e8f0; background: var(--text-strong);
    word-break: break-all; white-space: pre-wrap;
    max-height: 420px; overflow-y: auto;
}

/* ==================== 识别JSON：左右对比 ==================== */
.xc_json_split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: stretch;
}
.xc_json_pane { display: flex; flex-direction: column; min-width: 0; }
.xc_json_input {
    height: 280px; min-height: 280px;
    resize: none;
}
.xc_json_pane .xc_code_block {
    height: 280px; max-height: none;
    border-radius: 12px;
    flex: 1;
}
.xc_json_result { display: none; flex: 1; min-height: 0; }
.xc_json_pane .xc_result_card { border: none; }
.xc_json_placeholder {
    flex: 1; min-height: 280px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; padding: 20px; text-align: center;
    border: 1.5px dashed var(--border-color); border-radius: 12px; background: var(--bg-soft);
    color: var(--text-faint); font-size: 13px;
}
.xc_json_placeholder_icon { font-size: 30px; opacity: .5; font-family: 'Monaco', 'Consolas', monospace; }

/* x1 转 x2 结果盒 */
.xc_convert_box {
    display: none; margin-top: 16px;
    border: 1px solid var(--border-color); border-radius: 14px; overflow: hidden;
}
.xc_convert_box_head {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 14px 20px; background: var(--bg-soft); border-bottom: 1px solid var(--border-soft);
}
.xc_convert_box_title { font-size: 13px; font-weight: 700; color: var(--text-strong); }
.xc_convert_box_tip { font-size: 12px; color: var(--text-faint); }

/* ==================== 识别模型 ==================== */
.xc_model_drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 200px; padding: 28px 24px; text-align: center; cursor: pointer;
    border: 1.5px dashed #cbd5e1; border-radius: 14px; background: var(--bg-soft);
    transition: border-color .2s, background .2s; user-select: none; box-sizing: border-box; width: 100%;
}
.xc_model_drop:hover, .xc_model_drop.dragover {
    border-color: var(--primary-color); background: var(--bg-brand-soft);
}
.xc_model_drop.error { border-color: #ef4444; }
.xc_model_drop_icon {
    width: 42px; height: 42px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    background: #fff; border: 1px solid var(--border-color);
    color: var(--primary-color); margin-bottom: 12px; line-height: 1;
}
.xc_model_drop_icon svg { width: 22px; height: 22px; }
.xc_model_drop.dragover .xc_model_drop_icon { background: var(--bg-brand-soft); border-color: #c7d7fe; }
.xc_model_drop_title { font-size: 14px; font-weight: 600; color: var(--text-strong); }
/* 假按钮仅作视觉引导：pointer-events:none 让点击统一落在拖拽区（单一入口触发文件框） */
.xc_model_pick_btn {
    pointer-events: none; margin-top: 14px;
    padding: 9px 28px; font-size: 13px; border-radius: 8px; box-shadow: none;
}
.xc_model_drop_tip { font-size: 12px; color: var(--text-faint); line-height: 1.8; margin-top: 12px; max-width: 620px; }
.xc_model_drop.has_file {
    border-style: solid; border-color: var(--border-color); background: #fff;
    min-height: 0; padding: 18px 20px; cursor: default;
}
.xc_model_file_chip {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%;
}
.xc_model_file_info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.xc_model_file_ok {
    flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: #ecfdf5; border: 1px solid #a7f3d0; color: #059669; font-size: 12px;
}
.xc_model_file_name { font-size: 13px; font-weight: 600; color: var(--text-strong); word-break: break-all; }
.xc_model_file_size { font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.xc_model_file_remove {
    flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-soft); border: 1px solid var(--border-color); color: var(--text-sub);
    font-size: 13px; cursor: pointer; transition: all .2s;
}
.xc_model_file_remove:hover { border-color: #fecaca; color: #ef4444; background: #fef2f2; }
.xc_model_file_input { display: none; }

/* 模型查看器 */
.xc_model_viewer {
    display: none; margin-top: 24px;
    border: 1px solid var(--border-color); border-radius: 14px; overflow: hidden; background: #fff;
}
.xc_model_viewer_head {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 13px 20px; background: var(--bg-soft); border-bottom: 1px solid var(--border-soft);
}
.xc_model_viewer_title { font-size: 13px; font-weight: 700; color: var(--text-strong); }
.xc_model_viewer_tip { font-size: 12px; color: var(--text-faint); }
.xc_model_iframe { display: block; width: 100%; height: clamp(560px, 76vh, 1040px); border: 0; background: #fff; }

/* 模型查看器全屏 */
.xc_model_viewer.is_fullscreen {
    position: fixed; inset: 0; z-index: 3000; margin: 0;
    border: none; border-radius: 0;
    display: flex !important; flex-direction: column;
}
.xc_model_viewer.is_fullscreen .xc_model_iframe { height: auto; flex: 1; min-height: 0; }

/* Toast */
.xc_toast {
    position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: #1e293b; color: #fff; padding: 12px 24px; border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0,0,0,.2); opacity: 0; visibility: hidden;
    transition: all .3s; z-index: 4000; font-weight: 500; font-size: 14px;
}
.xc_toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.xc_toast.error { background: #ef4444; }

/* 响应式 */
@media (max-width: 992px) {
    .xc_tools_wrapper { padding: 16px 16px 0; }
    .xc_tools_shell { grid-template-columns: 1fr; gap: 16px; }
    .xc_tools_shell > .xc_sidebar {
        width: auto; min-width: 0; margin: 0; position: static; height: auto;
        display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 10px;
    }
    .xc_tools_shell > .xc_sidebar .xc_menu_item {
        margin: 0; white-space: nowrap; text-align: center; padding: 11px 8px;
    }
    .xc_tools_main { padding: 0 0 80px; }
    .xc_tool_head { padding: 26px 22px 22px; }
    .xc_tool_body { padding: 24px 22px 34px; }
    .xc_json_split { grid-template-columns: 1fr; gap: 16px; }
    .xc_json_input, .xc_json_pane .xc_code_block, .xc_json_placeholder { height: 240px; min-height: 240px; }
    .xc_field_grid { grid-template-columns: 1fr; }
    .xc_field_item:nth-last-child(-n+2) { border-bottom: 1px solid var(--border-soft); }
    .xc_field_item:last-child { border-bottom: none; }
    .xc_field_item:nth-child(odd) { border-right: none; }
}
