/**
 * AI 工具箱 — 前台样式
 * 通过复用子比主题的 .zib-widget 容器与 CSS 变量（--main-bg-color / --main-color / --theme-color）
 * 自动适配主题配色与暗黑模式，避免与主题样式冲突。
 */

.aitb-wrap {
    --aitb-accent: var(--main-color, var(--theme-color, #2196f3));
    --aitb-border: rgba(128, 128, 128, 0.14);
    margin: 15px 0;
}

/* ===== 顶部工具条 ===== */
.aitb-toolbar {
    padding: 14px 16px;
    margin-bottom: 15px;
}

.aitb-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 8px;
    background: rgba(128, 128, 128, 0.08);
    transition: box-shadow 0.2s;
}

.aitb-search:focus-within {
    box-shadow: 0 0 0 2px var(--aitb-accent);
}

.aitb-search svg {
    color: rgba(128, 128, 128, 0.7);
    flex: none;
}

.aitb-search input {
    flex: 1;
    border: 0 !important;
    outline: none !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 14px;
    color: inherit;
    min-width: 0;
}

.aitb-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.aitb-filter {
    border: 1px solid var(--aitb-border);
    background: transparent;
    color: inherit;
    border-radius: 999px;
    padding: 4px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.aitb-filter:hover {
    border-color: var(--aitb-accent);
    color: var(--aitb-accent);
}

.aitb-filter.is-active {
    background: var(--aitb-accent);
    border-color: var(--aitb-accent);
    color: #fff;
}

/* ===== 布局 ===== */
.aitb-layout {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.aitb-side {
    width: 200px;
    flex: none;
    position: sticky;
    top: 70px;
}

.aitb-side-inner {
    padding: 12px;
}

.aitb-side-title {
    font-size: 13px;
    color: rgba(128, 128, 128, 0.8);
    padding: 4px 10px 8px;
}

.aitb-side-nav {
    display: flex;
    flex-direction: column;
}

.aitb-side-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
    color: inherit !important;
    font-size: 14px;
    text-decoration: none !important;
    transition: all 0.15s;
}

.aitb-side-link em {
    font-style: normal;
    font-size: 12px;
    color: rgba(128, 128, 128, 0.7);
    background: rgba(128, 128, 128, 0.1);
    border-radius: 999px;
    padding: 0 8px;
    line-height: 18px;
}

.aitb-side-link:hover,
.aitb-side-link.is-current {
    background: var(--aitb-accent);
    color: #fff !important;
}

.aitb-side-link:hover em,
.aitb-side-link.is-current em {
    color: #fff;
    background: rgba(255, 255, 255, 0.25);
}

.aitb-main {
    flex: 1;
    min-width: 0;
}

/* ===== 分类区块 ===== */
.aitb-section {
    padding: 18px 20px 20px;
    margin-bottom: 15px;
    scroll-margin-top: 70px;
}

.aitb-section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 14px;
}

.aitb-section-title {
    font-size: 19px;
    font-weight: 700;
    margin: 0;
    padding: 0;
    border: 0;
}

.aitb-section-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: var(--aitb-accent);
    margin-right: 8px;
    vertical-align: -2px;
}

.aitb-section-more {
    font-size: 13px;
    color: rgba(128, 128, 128, 0.8) !important;
    text-decoration: none !important;
}

.aitb-section-more:hover {
    color: var(--aitb-accent) !important;
}

/* ===== 工具卡片网格 ===== */
.aitb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.aitb-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--aitb-border);
    border-radius: 10px;
    color: inherit !important;
    text-decoration: none !important;
    background: transparent;
    transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}

.aitb-card:hover {
    transform: translateY(-3px);
    border-color: var(--aitb-accent);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.aitb-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.aitb-logo,
.aitb-logo-img,
.aitb-logo-fallback {
    width: 40px;
    height: 40px;
    flex: none;
}

.aitb-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.aitb-logo-img {
    border-radius: 9px;
    object-fit: cover;
}

.aitb-logo-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
}

.aitb-card-name {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aitb-badge {
    flex: none;
    font-size: 11px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 500;
}

.aitb-badge-free {
    color: #16a34a;
    background: rgba(22, 163, 74, 0.12);
}

.aitb-badge-freemium {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.12);
}

.aitb-badge-paid {
    color: #ea580c;
    background: rgba(234, 88, 12, 0.12);
}

.aitb-card-desc {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    color: rgba(128, 128, 128, 0.95);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 0;
}

.aitb-card-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.aitb-card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.aitb-chip {
    font-style: normal;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(128, 128, 128, 0.1);
    color: rgba(128, 128, 128, 0.95);
}

.aitb-chip-region {
    background: var(--aitb-accent);
    color: #fff;
    opacity: 0.9;
}

.aitb-card-go {
    color: rgba(128, 128, 128, 0.5);
    transition: all 0.18s;
}

.aitb-card:hover .aitb-card-go {
    color: var(--aitb-accent);
    transform: translate(2px, -2px);
}

.aitb-no-result {
    text-align: center;
    color: rgba(128, 128, 128, 0.7);
    font-size: 14px;
    padding: 20px 0 4px;
}

.aitb-empty {
    padding: 30px;
    text-align: center;
    color: rgba(128, 128, 128, 0.8);
}

.aitb-section-count {
    font-size: 13px;
    font-weight: 400;
    color: rgba(128, 128, 128, 0.7);
}

.aitb-more-wrap {
    text-align: center;
    margin-top: 14px;
}

.aitb-more {
    border: 1px solid var(--aitb-border);
    background: transparent;
    color: inherit;
    border-radius: 8px;
    padding: 8px 26px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.aitb-more:hover {
    border-color: var(--aitb-accent);
    color: var(--aitb-accent);
}

/* ===== 单工具页 ===== */
.aitb-single-page {
    margin: 15px auto;
}

/* 详情页正文不在 .aitb-wrap 内，accent 变量需在这里补一份定义，
   否则 h2 竖条/FAQ 徽章等的 var(--aitb-accent) 解析失败变透明。
   zibll 的 --main-color 是正文灰、--theme-color 才是品牌色（与访问按钮一致），故此处优先取 --theme-color */
.aitb-single-page,
.aitb-single-content {
    --aitb-accent: var(--theme-color, #2196f3);
    --aitb-border: rgba(128, 128, 128, 0.14);
}

.aitb-single-head {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.aitb-logo-lg .aitb-logo-img,
.aitb-logo-lg .aitb-logo-fallback {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    font-size: 28px;
}

.aitb-single-info {
    flex: 1;
    min-width: 200px;
}

.aitb-single-title {
    margin: 0 0 8px;
    padding: 0;
    border: 0;
    font-size: 24px;
}

.aitb-single-badges {
    display: flex;
    gap: 8px;
    align-items: center;
}

.aitb-single-badges .aitb-badge {
    font-size: 12px;
}

.aitb-visit-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    /* 注意：暗色模式下 --main-color 会变成近白色，用它做底色会导致白字看不清，
       这里固定用品牌色（--theme-color）打底，保证明暗两种模式都是深底白字 */
    background: var(--theme-color, #2196f3) !important;
    color: #fff !important;
    text-decoration: none !important;
    padding: 10px 22px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.4;
    max-width: 100%;
    text-align: center;
    transition: opacity 0.15s, filter 0.15s;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
}

/* 暗黑模式：再兜一次底（防止主题或插件改写按钮颜色） */
.dark-theme .aitb-visit-btn,
body.dark-theme .aitb-visit-btn,
[data-theme="dark"] .aitb-visit-btn {
    background: var(--theme-color, #2196f3) !important;
    color: #fff !important;
}

.aitb-visit-btn .aitb-visit-arrow {
    font-size: 13px;
    opacity: 0.9;
}

.aitb-visit-btn:hover {
    opacity: 0.92;
    filter: brightness(1.06);
}

.aitb-single-excerpt {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(128, 128, 128, 0.07);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.7;
}

.aitb-single-meta {
    margin-top: 14px;
    font-size: 13px;
}

.aitb-meta-row {
    margin: 4px 0;
    color: rgba(128, 128, 128, 0.95);
}

.aitb-meta-row a {
    text-decoration: none !important;
}

.aitb-single-content {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--aitb-border, rgba(128, 128, 128, 0.14));
    font-size: 15px;
    line-height: 1.8;
}

/* 正文末尾：居中的官网跳转按钮（外观复用头部 .aitb-visit-btn） */
.aitb-single-visit {
    margin: 28px 0 4px;
    padding-top: 22px;
    border-top: 1px dashed rgba(128, 128, 128, 0.28);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.aitb-single-visit .aitb-visit-btn {
    padding: 12px 30px;
    font-size: 16px;
    border-radius: 10px;
}

.aitb-single-back {
    margin-top: 24px;
    font-size: 14px;
}

.aitb-single-back a {
    text-decoration: none !important;
}

.aitb-fallback-title {
    margin: 20px 0;
}

/* ===== 详情页正文（来自 ai-bot.cn 的结构化内容） ===== */
/* 全部颜色用 rgba 灰阶 + 主题变量，明暗两种模式都清晰，不写死深浅底色 */
.aitb-single-content > *:first-child {
    margin-top: 0;
}

.aitb-single-content p {
    margin: 0 0 14px;
}

.aitb-single-content h2 {
    position: relative;
    font-size: 19px;
    line-height: 1.5;
    font-weight: 700;
    margin: 26px 0 12px;
    padding: 0 0 0 12px;
    border: 0;
}

.aitb-single-content h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.28em;
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: var(--aitb-accent);
}

/* 覆盖子比主题 .wp-posts-content>h2:not([class]):before（40x3px 主题色横条，会压住正文文字）。
   注意：.wp-posts-content 与 .aitb-single-content 在同一个 div 上，必须用链类+子代选择器
   （后代选择器 .A .B 匹配不到同一元素）。这里 (0,3,2)+important，反超主题的 (0,2,2)important。
   主题对 h3/h4 也有同样横条（还有 25x2px 的 important 规则），一并覆盖。 */
.wp-posts-content.aitb-single-content > h2:not([class])::before,
.wp-posts-content.aitb-single-content > h3:not([class])::before,
.wp-posts-content.aitb-single-content > h4:not([class])::before,
.wp-posts-content.aitb-single-content > h2.wp-block-heading::before,
.wp-posts-content.aitb-single-content > h3.wp-block-heading::before,
.wp-posts-content.aitb-single-content > h4.wp-block-heading::before {
    position: absolute !important;
    left: 0 !important;
    top: 0.28em !important;
    bottom: auto !important;
    width: 4px !important;
    height: 16px !important;
    margin: 0 !important;
    border-radius: 2px !important;
    box-shadow: none !important;
    background: var(--aitb-accent) !important;
}

.aitb-single-content h3,
.aitb-single-content .aitb-faq-q {
    font-size: 16px;
    line-height: 1.6;
    font-weight: 600;
    margin: 22px 0 8px;
    padding: 0;
    border: 0;
    color: inherit;
}

.aitb-single-content .aitb-faq-q {
    position: relative;
    padding-left: 24px;
}

.aitb-single-content .aitb-faq-q::before {
    content: 'Q';
    position: absolute;
    left: 0;
    top: 0.1em;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: var(--aitb-accent);
}

.aitb-single-content .aitb-faq-a {
    margin: 0 0 10px;
    padding: 12px 16px;
    border-radius: 8px;
    background: rgba(128, 128, 128, 0.09);
    border-left: 3px solid rgba(128, 128, 128, 0.25);
    font-size: 14px;
    line-height: 1.8;
}

.aitb-single-content ol,
.aitb-single-content ul {
    margin: 0 0 14px;
    padding-left: 22px;
}

.aitb-single-content li {
    margin: 0 0 8px;
    line-height: 1.8;
}

.aitb-single-content li::marker {
    color: var(--aitb-accent);
    font-weight: 700;
}

.aitb-single-content a {
    color: var(--aitb-accent);
    text-decoration: none;
}

.aitb-single-content a:hover {
    text-decoration: underline;
}

.aitb-single-content strong {
    font-weight: 600;
}

.aitb-single-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* 去掉子比正文样式可能带来的多余首行缩进/大间距 */
.aitb-single-content blockquote {
    margin: 0 0 14px;
    padding: 10px 16px;
    border-left: 3px solid var(--aitb-accent);
    background: rgba(128, 128, 128, 0.07);
    border-radius: 0 8px 8px 0;
}

/* ===== 详情页「同类工具推荐」 ===== */
.aitb-single-related {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--aitb-border, rgba(128, 128, 128, 0.14));
}

.aitb-related-title {
    position: relative;
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 14px;
    padding: 0 0 0 12px;
    border: 0;
}

.aitb-related-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.3em;
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: var(--aitb-accent);
}

.aitb-single-related .aitb-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.aitb-single-related .aitb-card {
    padding: 12px;
}

.aitb-page-intro {
    margin-bottom: 15px;
}

/* ===== 响应式 ===== */
@media (max-width: 860px) {
    .aitb-side {
        display: none;
    }
    .aitb-grid {
        grid-template-columns: repeat(auto-fill, minmax(46%, 1fr));
    }
}

@media (max-width: 480px) {
    .aitb-grid {
        grid-template-columns: 1fr;
    }
    .aitb-section {
        padding: 14px;
    }
}

/* 暗黑模式下微调（子比通过 --main-bg-color 变量控制卡片背景，此处仅处理阴影） */
@media (prefers-color-scheme: dark) {
    .aitb-card:hover {
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
    }
}

/* ===== IE10 / IE11 兜底（360、搜狗等浏览器切到「兼容模式」时走这里）=====
   IE 完全不支持 CSS 自定义属性 var()，而且一条声明里只要出现 var()，整条声明会被丢弃，
   于是按钮底色、标题竖条、边框、链接色等会一起消失（页面看起来像没加载样式）。
   -ms-high-contrast 是 IE 专有的媒体特性，只有 IE10/IE11 会进这个块，
   其他浏览器（含 360 的极速模式）完全不受影响。
   品牌色 #f04494 取自子比主题的 --theme-color，换主题色时同步改这里即可。 */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .aitb-search:focus-within { box-shadow: 0 0 0 2px #f04494; }
    .aitb-search input { margin-left: 8px; }

    .aitb-filter { border: 1px solid rgba(128, 128, 128, 0.14); }
    .aitb-filter:hover { border-color: #f04494; color: #f04494; }
    .aitb-filter.is-active { background: #f04494; border-color: #f04494; color: #fff; }
    .aitb-filters .aitb-filter { margin: 0 8px 8px 0; }

    .aitb-side { margin-right: 15px; }
    .aitb-side-link:hover,
    .aitb-side-link.is-current { background: #f04494; color: #fff !important; }

    .aitb-section-title::before { background: #f04494; }
    .aitb-section-more:hover { color: #f04494 !important; }

    .aitb-card { border: 1px solid rgba(128, 128, 128, 0.14); }
    .aitb-card > * + * { margin-top: 8px; }
    .aitb-card-top > * + * { margin-left: 10px; }
    .aitb-card:hover { border-color: #f04494; }
    .aitb-card:hover .aitb-card-go { color: #f04494; }
    .aitb-card-tags .aitb-chip { margin-right: 6px; }

    .aitb-chip-region { background: #f04494; color: #fff; }

    .aitb-more { border: 1px solid rgba(128, 128, 128, 0.14); }
    .aitb-more:hover { border-color: #f04494; color: #f04494; }

    /* 头部与文末的「访问XX官网」按钮：没有这条在 IE 下就是白字透明底，等于看不见 */
    .aitb-visit-btn,
    body.dark-theme .aitb-visit-btn,
    .aitb-single-visit .aitb-visit-btn { background: #f04494 !important; color: #fff !important; }

    .aitb-single-head .aitb-single-info { margin-left: 16px; }

    .aitb-single-content { border-top: 1px solid rgba(128, 128, 128, 0.14); }
    .aitb-single-content h2::before,
    .aitb-single-content h3::before,
    .aitb-single-content h4::before,
    .wp-posts-content.aitb-single-content > h2:not([class])::before,
    .wp-posts-content.aitb-single-content > h3:not([class])::before,
    .wp-posts-content.aitb-single-content > h4:not([class])::before { background: #f04494 !important; }
    .aitb-single-content .aitb-faq-q::before { background: #f04494; }
    .aitb-single-content li::marker { color: #f04494; }
    .aitb-single-content a { color: #f04494; }
    .aitb-single-content blockquote { border-left: 3px solid #f04494; }

    .aitb-single-related { border-top: 1px solid rgba(128, 128, 128, 0.14); }
    .aitb-related-title::before { background: #f04494; }

    /* 文末官网按钮：IE11 的 flex 居中不稳，退回块级 + text-align 居中 */
    .aitb-single-visit { display: block; text-align: center; }

    /* IE11 不支持 CSS Grid：卡片网格退化成 flex 换行，否则会挤成单列 */
    .aitb-grid { display: flex; flex-wrap: wrap; margin: -6px; }
    .aitb-grid > * {
        flex-grow: 1;
        flex-shrink: 1;
        flex-basis: 220px;
        min-width: 0;
        margin: 6px;
        box-sizing: border-box;
    }
}
