/*
 * Webtool 基座样式
 *
 * 为所有在线工具箱页面提供统一的 CSS 变量和基础布局样式。
 * 新工具可直接引用 --wt-* 变量，无需重复定义。
 *
 * @package io-webtool
 */

/* ===== CSS 变量 =====
 * 定义在最外层包裹容器 .io-webtool-page-wrap 上，
 * 使面包屑（在 main 外）、工具内容（.io-webtool-root 内）、
 * 交叉推荐（main 内 root 外）都能继承使用 --wt-* 变量。
 * 保留 .io-webtool-root 选择器以保证向后兼容（变量可继承，冗余无害）。
 */
.io-webtool-page-wrap,
.io-webtool-root {
    --wt-accent: var(--theme-color, #f1404b);
    --wt-bg: var(--body-bg-color, #f2f4f7);
    --wt-card-bg: var(--main-bg-color, #fff);
    --wt-text: var(--main-color, #1e293b);
    --wt-text-muted: var(--muted-color, #64748b);
    --wt-border: var(--muted-bg-a-color, rgba(136, 136, 136, 0.12));
    --wt-shadow: var(--main-shadow, rgba(0, 0, 0, 0.06));
    --wt-radius: var(--main-radius, 12px);
    --wt-blur-bg: var(--main-blur-bg-color, rgba(245, 245, 245, 0.75));
    --wt-accent-soft: rgba(241, 64, 75, 0.1);
}
.io-webtool-root {
    font-family: inherit;
    color: var(--wt-text);
}

/* ===== 主题全局 CSS 隔离重置 =====
 * OneNav 主题对 a / code / pre / blockquote / table / th / td / img
 * 施加了全局样式，会覆盖工具页面的自定义样式。
 * 此处通过 .io-webtool-root 作用域前缀重置为中性值，
 * 让各工具自己的 CSS 自然接管。
 */
.io-webtool-root a {
    color: inherit;
    text-decoration: none;
}
.io-webtool-root a:hover {
    color: var(--wt-accent);
    text-decoration: none;
}
.io-webtool-root img {
    max-width: 100%;
    height: auto;
}
.io-webtool-root code {
    color: inherit;
    background: none;
    border-radius: 0;
    padding: 0;
    font-size: inherit;
}
.io-webtool-root pre {
    color: inherit;
    background: none;
    border: 0;
    border-radius: 0;
    padding: 0;
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.io-webtool-root blockquote {
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    border-radius: 0;
}
.io-webtool-root blockquote p:last-of-type {
    margin: 0;
}
.io-webtool-root table {
    width: auto;
}
.io-webtool-root th,
.io-webtool-root td {
    border: none;
    padding: 0;
}
/* 重置主题对 h1-h6 可能施加的边框/颜色 */
.io-webtool-root h1,
.io-webtool-root h2,
.io-webtool-root h3,
.io-webtool-root h4,
.io-webtool-root h5,
.io-webtool-root h6 {
    margin: 0;
    padding: 0;
    border: none;
    color: inherit;
}
/* 重置主题对 ul/ol 的间距 */
.io-webtool-root ul,
.io-webtool-root ol {
    margin: 0;
    padding: 0;
}
.io-webtool-root li {
    list-style: none;
}

/* ===== Sticky footer 包裹层 ===== */
.io-webtool-page-wrap {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.io-webtool-root {
    flex: 1 0 auto;
    width: 100%;
    padding-bottom: 20px;
}

/* ===== PJAX 统一内容容器 =====
 * 所有工具页内容被框架包进 <main data-webtool-main>，
 * 作为 webtool-pjax.js 局部切换的替换目标。
 * 同时作为 sticky footer 的 flex 子项（display:flex + flex:1），
 * 使内部 periodic-table 等依赖 flex:1 的布局正常撑开。
 */
.io-webtool-pjax-main {
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
    width: 100%;
    min-height: 0;
}

/* ===== 统一面包屑（首页 / 工具箱 / 当前工具）===== */
.io-webtool-crumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 20px;
    margin: 0;
    font-size: 0.8125rem;
    color: var(--wt-text-muted, #64748b);
    background: transparent;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.io-webtool-crumbs a {
    color: var(--wt-text-muted, #64748b);
    text-decoration: none;
    transition: color 0.2s;
}

.io-webtool-crumbs a:hover {
    color: var(--wt-accent, #f1404b);
    text-decoration: none;
}

.io-webtool-crumb-sep {
    color: var(--wt-text-muted, #64748b);
    opacity: 0.5;
    margin: 0 2px;
}

.io-webtool-crumb-current {
    color: var(--wt-text, #1e293b);
    font-weight: 600;
}

/* ===== 工具间交叉推荐 ===== */
.io-webtool-related {
    width: 100%;
    padding: 24px 0 8px;
}

.io-webtool-related .container {
    max-width: 1200px;
}

.io-webtool-related-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--wt-text, #1e293b);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.io-webtool-related-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 18px;
    background: var(--wt-accent, #f1404b);
    border-radius: 2px;
    flex-shrink: 0;
}

.io-webtool-related-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.io-webtool-related-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--wt-card-bg, #fff);
    border: 1px solid var(--wt-border, rgba(136,136,136,0.12));
    border-radius: 10px;
    color: var(--wt-text, #1e293b);
    text-decoration: none !important;
    transition: all 0.2s ease;
}

.io-webtool-related-item:hover {
    border-color: var(--wt-accent, #f1404b);
    color: var(--wt-accent, #f1404b);
    text-decoration: none !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px var(--wt-shadow, rgba(0,0,0,0.06));
}

.io-webtool-related-icon {
    font-size: 1.125rem;
    line-height: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}
.io-webtool-related-icon .iconify {
    font-size: 18px;
    width: 18px;
    height: 18px;
    color: var(--wt-accent);
}

.io-webtool-related-name {
    font-size: 0.8125rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== 列表页"最近使用" ===== */
.io-webtool-recent {
    max-width: 1200px;
    margin: 0 auto 8px;
    padding: 0 15px;
}

.io-webtool-recent-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--wt-text, #1e293b);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.io-webtool-recent-title .iconify {
    font-size: 18px;
    width: 18px;
    height: 18px;
    color: var(--wt-accent);
}

.io-webtool-recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.io-webtool-recent-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--wt-card-bg, #fff);
    border: 1px solid var(--wt-border, rgba(136,136,136,0.12));
    border-radius: 20px;
    color: var(--wt-text, #1e293b);
    text-decoration: none !important;
    font-size: 0.8125rem;
    transition: all 0.2s ease;
}

.io-webtool-recent-item:hover {
    border-color: var(--wt-accent, #f1404b);
    color: var(--wt-accent, #f1404b);
    text-decoration: none !important;
}

.io-webtool-recent-icon {
    font-size: 0.9375rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
}
.io-webtool-recent-icon .iconify {
    font-size: 15px;
    width: 15px;
    height: 15px;
    color: var(--wt-accent);
}

.io-webtool-recent-name {
    font-weight: 500;
}

/* ===== 暗色模式适配 ===== */
.io-black-mode .io-webtool-page-wrap,
.io-black-mode .io-webtool-root {
    --wt-card-bg: var(--main-bg-color, #2d2e2f);
    --wt-blur-bg: var(--main-blur-bg-color, rgba(46, 46, 46, 0.65));
}

/* 暗色模式：面包屑 / 交叉推荐 / 最近使用背景跟随 */
.io-black-mode .io-webtool-related-item,
.io-black-mode .io-webtool-recent-item {
    background: var(--main-bg-color, #2d2e2f);
}

/* ===== 公共工具容器 ===== */
.io-webtool-root .wt-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 15px;
}

.io-webtool-root .wt-wrap-sm {
    max-width: 700px;
    margin: 0 auto;
    padding: 0 15px;
}

/* ===== 公共卡片 ===== */
.io-webtool-root .wt-card {
    background: var(--wt-card-bg);
    border-radius: var(--wt-radius);
    box-shadow: 0 2px 12px var(--wt-shadow);
    padding: 20px 24px;
    margin-bottom: 16px;
    transition: box-shadow 0.2s;
    border: 1px solid var(--wt-border);
}

.io-webtool-root .wt-card:hover {
    box-shadow: 0 4px 16px var(--wt-shadow);
}

.io-webtool-root .wt-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--wt-text);
}

/* ===== 公共按钮 ===== */
.io-webtool-root .wt-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.io-webtool-root .wt-btn-primary {
    background: var(--wt-accent);
    color: #fff;
}

.io-webtool-root .wt-btn-primary:hover {
    filter: brightness(0.9);
}

.io-webtool-root .wt-btn-outline {
    background: transparent;
    border: 1.5px solid var(--wt-border);
    color: var(--wt-text-muted);
}

.io-webtool-root .wt-btn-outline:hover {
    border-color: var(--wt-accent);
    color: var(--wt-accent);
}

/* ===== Toast 提示 ===== */
.io-webtool-root .wt-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 22px;
    background: var(--wt-text);
    color: var(--wt-card-bg);
    border-radius: 10px;
    font-size: 14px;
    opacity: 0;
    transform: translateY(-8px);
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.io-webtool-root .wt-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ===== 加载状态 ===== */
.io-webtool-root .wt-loading {
    text-align: center;
    padding: 60px 0;
    color: var(--wt-text-muted);
}

.io-webtool-root .wt-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid var(--wt-border);
    border-top-color: var(--wt-accent);
    border-radius: 50%;
    animation: wt-spin 0.7s linear infinite;
    margin-bottom: 8px;
}

@keyframes wt-spin {
    to { transform: rotate(360deg); }
}

/* ===== 页面标题 ===== */
.io-webtool-root .wt-page-header {
    text-align: center;
    margin-bottom: 28px;
    padding: 28px 24px 24px;
}

.io-webtool-root .wt-page-header h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--wt-text);
}

.io-webtool-root .wt-page-header h1 span {
    color: var(--wt-accent);
}

.io-webtool-root .wt-page-header p {
    color: var(--wt-text-muted);
    font-size: 14px;
    margin-bottom: 0;
}

/* ===== 独立 webtool 页脚 ===== */
.io-webtool-footer {
    width: 100%;
    padding: 20px 0 14px;
    border-top: 1px solid var(--muted-bg-a-color, rgba(136,136,136,0.12));
    background: var(--main-bg-color, #fff);
    flex-shrink: 0;
    margin-top: auto;
}

.io-webtool-footer .io-wtf-copy {
    font-size: 13px;
    color: var(--muted-color, #64748b);
    line-height: 1.6;
}

.io-webtool-footer .io-wtf-copy a {
    color: var(--muted-color, #64748b);
    text-decoration: none;
    transition: color 0.2s;
}

.io-webtool-footer .io-wtf-copy a:hover {
    color: var(--theme-color, #f1404b);
    text-decoration: none;
}

/* 暗色模式 */
.io-black-mode .io-webtool-footer {
    background: var(--main-bg-color, #2d2e2f);
    border-top-color: var(--muted-bg-a-color, rgba(255,255,255,0.08));
}

/* ===== 工具列表页 — 侧边栏布局 ===== */
.io-webtool-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.io-webtool-sidebar {
    width: 180px;
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--main-nav-hight, 80px) + 20px);
}

.io-webtool-cat-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px;
    background: var(--wt-blur-bg);
    border-radius: var(--wt-radius);
    border: 1px solid var(--wt-border);
}

.io-webtool-cat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1.5px solid transparent;
    background: transparent;
    color: var(--wt-text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    user-select: none;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
}

.io-webtool-cat-item:hover {
    border-color: var(--wt-border);
    background: var(--wt-card-bg);
    color: var(--wt-accent);
    text-decoration: none;
}

.io-webtool-cat-item.active {
    background: var(--wt-accent);
    color: #fff;
    border-color: var(--wt-accent);
}

.io-webtool-cat-icon {
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}
.io-webtool-cat-icon .iconify {
    font-size: 18px;
    width: 18px;
    height: 18px;
}
.io-webtool-cat-item.active .io-webtool-cat-icon .iconify {
    color: #fff;
}

.io-webtool-cat-name {
    flex: 1;
}

.io-webtool-cat-num {
    font-size: 0.6875rem;
    opacity: 0.6;
    font-weight: 600;
}

.io-webtool-main {
    flex: 1;
    min-width: 0;
}

.io-webtool-cat-section {
    display: none;
}

.io-webtool-cat-section.active {
    display: block;
}

/* 卡片网格垂直间距 */
.io-webtool-main .row.g-3 > [class*="col-"] {
    margin-bottom: 1rem;
}

/* 响应式：移动端侧边栏改为水平滚动 */
@media (max-width: 768px) {
    .io-webtool-layout {
        flex-direction: column;
    }
    .io-webtool-sidebar {
        width: 100%;
        position: static;
    }
    .io-webtool-cat-nav {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 6px;
        gap: 4px;
        -webkit-overflow-scrolling: touch;
    }
    .io-webtool-cat-item {
        flex-shrink: 0;
        padding: 8px 12px;
        font-size: 0.8125rem;
    }
    .io-webtool-cat-num {
        display: none;
    }
}

/* ===== 工具列表页卡片设计（长方形小卡片，仿首页 posts-item）===== */
.io-webtool-page .io-webtool-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--wt-card-bg);
    border-radius: var(--wt-radius);
    box-shadow: 0 2px 12px var(--wt-shadow);
    border: 1px solid var(--wt-border);
    padding: 12px 14px;
    text-decoration: none !important;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.io-webtool-page .io-webtool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--wt-accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.io-webtool-page .io-webtool-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px var(--wt-shadow);
    border-color: var(--wt-accent);
    text-decoration: none !important;
}

.io-webtool-page .io-webtool-card:hover::before {
    transform: scaleX(1);
}

/* 左侧图标块（圆角底色） */
.io-webtool-page .io-webtool-card-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--wt-accent-soft, rgba(241, 64, 75, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
}
.io-webtool-page .io-webtool-card-icon .iconify {
    font-size: 24px;
    color: var(--wt-accent);
    width: 24px;
    height: 24px;
}

/* 右侧标题 + 描述 */
.io-webtool-page .io-webtool-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.io-webtool-page .io-webtool-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--wt-text);
    line-height: 1.4;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.io-webtool-page .io-webtool-card-desc {
    font-size: 0.75rem;
    color: var(--wt-text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 工具分类标题 */
.io-webtool-cat-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--wt-text);
    margin: 28px 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.io-webtool-cat-title .io-webtool-cat-dot {
    display: inline-block;
    width: 4px;
    height: 18px;
    background: var(--wt-accent);
    border-radius: 2px;
    flex-shrink: 0;
}

.io-webtool-cat-title .io-webtool-cat-count {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--wt-text-muted);
    margin-left: 4px;
}

/* 工具列表页头部 */
.io-webtool-page-header-hero {
    text-align: center;
    padding: 32px 20px 28px;
    margin-bottom: 8px;
}

.io-webtool-page-header-hero h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--wt-text);
    margin-bottom: 8px;
}

.io-webtool-page-header-hero p {
    color: var(--wt-text-muted);
    font-size: 0.9375rem;
    margin-bottom: 0;
}

/* ===== 工具搜索 ===== */
.io-webtool-search {
    position: relative;
    max-width: 560px;
    margin: 0 auto 4px;
    display: flex;
    align-items: center;
}
.io-webtool-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--wt-text-muted);
    font-size: 18px;
    pointer-events: none;
    display: flex;
    align-items: center;
}
.io-webtool-search-input {
    width: 100%;
    padding: 12px 44px;
    font-size: 15px;
    color: var(--wt-text);
    background: var(--wt-card-bg, #fff);
    border: 1.5px solid var(--wt-border, #e2e8f0);
    border-radius: 999px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    box-shadow: var(--wt-shadow, 0 1px 3px rgba(0,0,0,.06));
}
.io-webtool-search-input::placeholder { color: var(--wt-text-muted); }
.io-webtool-search-input:focus {
    border-color: var(--wt-accent, #f1404b);
    box-shadow: 0 0 0 3px rgba(241,64,75,.12);
}
.io-webtool-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    display: none;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--wt-border, #e2e8f0);
    color: var(--wt-text-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: all .2s;
    padding: 0;
}
.io-webtool-search-clear:hover { background: var(--wt-accent, #f1404b); color: #fff; }
.io-webtool-search-result {
    text-align: center;
    font-size: 14px;
    color: var(--wt-text-muted);
    margin: 4px 0 16px;
}
.io-webtool-search-result b { color: var(--wt-accent, #f1404b); }
.io-webtool-search-result-empty {
    display: inline-block;
    padding: 8px 18px;
    background: var(--wt-bg, #f8fafc);
    border: 1px dashed var(--wt-border, #e2e8f0);
    border-radius: 8px;
    color: var(--wt-text-muted);
}

/* 响应式 */
@media (max-width: 768px) {
    .io-webtool-footer {
        padding: 16px 0 12px;
    }
    .io-webtool-footer .io-wtf-copy {
        font-size: 12px;
    }

    .io-webtool-root .wt-wrap,
    .io-webtool-root .wt-wrap-sm {
        padding: 0 12px;
    }
    .io-webtool-root .wt-card {
        padding: 14px 16px;
    }
    .io-webtool-root .wt-page-header h1 {
        font-size: 20px;
    }

    .io-webtool-page .io-webtool-card {
        padding: 18px 16px;
    }
    .io-webtool-page .io-webtool-card-icon {
        font-size: 1.75rem;
    }
    .io-webtool-page-header-hero h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .io-webtool-page .io-webtool-card-icon {
        font-size: 1.5rem;
    }
}
