/* ===== 文本工具页面样式 ===== */

.json-tool-wrapper {
    padding: 0 0 2rem;
}

.json-tool-wrapper h2 {
    margin-bottom: 1.25rem;
}

/* ----- 工具栏整体布局 ----- */
.json-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
    flex-wrap: nowrap;
}

.json-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.json-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* ----- 按钮基础样式（复用 Pico CSS 变量，outline 风格） ----- */
.json-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    font-family: var(--pico-font-family);
    line-height: 1.4;
    color: var(--pico-secondary);
    background: transparent;
    border: var(--pico-border-width) solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    user-select: none;
    margin: 0;
}

.json-btn:hover {
    color: var(--pico-primary);
    border-color: var(--pico-primary);
    background: transparent;
}

.json-btn:active {
    opacity: 0.8;
}

.json-btn-copy.copied {
    color: #2d9e5f;
    border-color: #2d9e5f;
}

.json-btn-clear:hover {
    color: var(--pico-del-color, #c0392b);
    border-color: var(--pico-del-color, #c0392b);
}

/* 下拉箭头 */
.json-btn .arrow {
    font-size: 0.65rem;
    opacity: 0.7;
    margin-left: 0.1rem;
}

/* ----- 下拉菜单容器 ----- */
.json-dropdown {
    position: relative;
    display: inline-flex;
}

/* ----- 下拉菜单面板 ----- */
.json-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 999;
    min-width: 130px;
    padding: 0.3rem 0;
    margin: 0;
    list-style: none;
    background: var(--pico-background-color);
    border: var(--pico-border-width) solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.json-dropdown-menu li {
    margin: 0;
    padding: 0;
    list-style: none;
}

.json-dropdown-menu li a {
    display: block;
    padding: 0.4rem 0.9rem;
    font-size: 0.83rem;
    color: var(--pico-secondary);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.1s;
}

.json-dropdown-menu li a:hover {
    background: var(--pico-form-element-background-color);
    color: var(--pico-primary);
}

/* click 时展开 */
.json-dropdown.open .json-dropdown-menu {
    display: block;
}

/* ----- 编辑器容器（行号 + textarea 的 flex 包装层） ----- */
.json-editor-wrap {
    display: flex;
    width: 100%;
    height: calc(100vh - 320px);
    min-height: 400px;
    border: var(--pico-border-width) solid var(--pico-form-element-border-color);
    border-radius: var(--pico-border-radius);
    overflow: hidden;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.json-editor-wrap:focus-within {
    border-color: var(--pico-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--pico-primary) 15%, transparent);
}

/* ----- 行号区 ----- */
.json-line-numbers {
    flex-shrink: 0;
    width: 3.2rem;
    padding: 0.75rem 0.5rem 0.75rem 0.25rem;
    overflow-y: hidden;
    background: var(--pico-form-element-background-color);
    color: var(--pico-muted-color);
    font-family: var(--pico-font-family-monospace);
    font-size: 0.875rem;
    line-height: 1.6;
    text-align: right;
    user-select: none;
    border-right: var(--pico-border-width) solid var(--pico-muted-border-color);
    box-sizing: border-box;
}

.json-line-numbers span {
    display: block;
}

/* ----- textarea ----- */
#json-input {
    flex: 1;
    height: 100%;
    min-height: 0;
    padding: 0.75rem 1rem;
    font-family: var(--pico-font-family-monospace);
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--pico-form-element-color);
    background: var(--pico-form-element-background-color);
    border: none;
    border-radius: 0;
    resize: none;
    box-sizing: border-box;
    outline: none;
    tab-size: 2;
}

/* ----- 状态栏 ----- */
.json-statusbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.4rem;
    padding: 0.25rem 0.25rem;
    font-size: 0.78rem;
    color: var(--pico-muted-color);
    flex-wrap: wrap;
}

.json-statusbar span {
    line-height: 1.4;
}

/* 状态指示颜色 */
.json-status-valid.valid   { color: #2d9e5f; }
.json-status-valid.error   { color: #c0392b; }
.json-status-chars.warn    { color: #e08e00; }
.json-status-lines.warn    { color: #e08e00; }

/* ----- T2I 高亮只读层 ----- */
#t2i-highlight-view {
    display: none;
    flex: 1;
    height: 100%;
    min-height: 0;
    padding: 0.75rem 1rem;
    font-family: var(--pico-font-family-monospace);
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--pico-form-element-color);
    background: var(--pico-form-element-background-color);
    overflow: auto;
    user-select: none;
    box-sizing: border-box;
}

#t2i-highlight-view pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
}

/* 高亮激活：切换 textarea / highlight-view */
.hl-active #json-input { display: none; }
.hl-active #t2i-highlight-view { display: block; }

/* T2I 按钮高亮激活态 */
#dropdown-t2i.t2i-highlight-active > .json-btn {
    color: #C678DD;
    border-color: #C678DD;
}

/* ----- 响应式断点：移动端 ----- */
@media (max-width: 767px) {
    .json-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    .json-editor-wrap {
        height: 60vh;
        min-height: 300px;
    }

    #json-input {
        font-size: 0.82rem;
    }

    .json-line-numbers {
        font-size: 0.82rem;
        width: 2.8rem;
    }
}
