/**
 * aiapps：嵌入主站 header/footer 时的补丁（在 style.css、主站 bundle、各页 extra_css 之后加载）
 * 对齐 AI智能应用 原型视觉，修正 logo、首页 banner 渐变、详情页整页背景等。
 */

/* -------------------------------------------------------------------------- */
/* 顶栏 Logo：主站 index-ded8e127.css 常把 logo 压得过小 */
/* -------------------------------------------------------------------------- */
header.header.header-home .logo .logo-img {
    height: 48px !important;
    width: auto !important;
    max-height: none !important;
    max-width: 220px !important;
    object-fit: contain;
}

header.header .mobile-nav {
    display: none;
}

@media (max-width: 768px) {
    header.header.header-home .logo .logo-img {
        height: 40px !important;
        max-width: 180px !important;
    }
}

/* -------------------------------------------------------------------------- */
/* 详情页：与各模板 extra_css 里的 body { background:#... } 对抗，保持 ai-tool-detail 渐变底 */
/* -------------------------------------------------------------------------- */
html.aiapps-detail body {
    background: linear-gradient(135deg, #ede9fe 0%, #dbeafe 50%, #ede9fe 100%) !important;
    background-attachment: fixed !important;
}

/* -------------------------------------------------------------------------- */
/* 原型 ai-tool-detail 里 .main-content 指「侧栏+右侧」横向区；本站外层已是 <main class="main-content"> */
/* -------------------------------------------------------------------------- */
body > .main-content {
    display: block !important;
    max-width: none !important;
    margin: 0 !important;
    width: 100% !important;
    padding: 88px 0 24px !important;
    gap: normal !important;
}

/*
 * 首页（base.html 仅在非 index 时为 html 加 .aiapps-detail）：顶栏为 header-home 且不占文档流，
 * 若 main 仍保留 padding-top:88px，留白区落在首个 .hero-section 之上，露出 body 白底，表现为导航与 Banner 间白条。
 * 详情/工具页仍走上面的 88px 顶栏避让。
 */
html:not(.aiapps-detail) body > .main-content {
    padding: 0 0 24px !important;
}

/*
 * 首页 Hero：主站 index-ded8e127.css 对 .hero-section 有 display:grid!important、固定高度等，
 * 与 ai-tools-list 的纵向 Banner 叠在一起会显得挤；此处仅首页拉高层级与内边距。
 */
html:not(.aiapps-detail) .aiapps-list-root > .hero-section {
    display: block !important;
    height: auto !important;
    min-height: 560px !important;
    max-width: none !important;
    padding: 88px 24px 80px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    grid-template-columns: none !important;
    gap: 0 !important;
    align-items: unset !important;
    justify-items: unset !important;
    justify-content: unset !important;
    overflow: visible !important;
}

html:not(.aiapps-detail) .aiapps-list-root .hero-title {
    margin-bottom: 20px !important;
}

html:not(.aiapps-detail) .aiapps-list-root .hero-subtitle {
    margin-bottom: 28px !important;
}

html:not(.aiapps-detail) .aiapps-list-root .hero-menu {
    margin-top: 56px !important;
    padding-bottom: 48px !important;
}

@media (max-width: 768px) {
    html:not(.aiapps-detail) .aiapps-list-root > .hero-section {
        min-height: 480px !important;
        padding: 76px 16px 56px !important;
    }

    html:not(.aiapps-detail) .aiapps-list-root .hero-menu {
        margin-top: 40px !important;
        padding-bottom: 40px !important;
    }
}

/* --------------------------------------------------------------------------
 * 移动端顶栏：完全复刻主站 index-ded8e127.css 中 @media (max-width: 768px) 的两行结构。
 * 关键证据：主站规则把 .header 改为 flex-direction:column；.header-left order:1、
 * .header-right order:2、.nav order:10 + flex-basis:100% + overflow-x:auto，
 * 形成「logo行 + 第二行横向滚动导航」。
 * 必须覆盖 aiapps/static/css/style.css 中 1024px 段的 .nav{display:none;position:absolute;
 * flex-direction:column}、.nav-link{width:100%}、.nav-item-wrapper{width:100%}。
 * -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    header.header.header-home,
    header.header {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: rgba(255, 255, 255, 0.4) !important;
        border-bottom: none !important;
        box-shadow: 0 0 10px rgba(46, 72, 107, 0.2) !important;
        z-index: 1000 !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
        display: flex !important;
        flex-direction: column !important;
    }

    header.header .header-container {
        padding: 0 !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        overflow: visible !important;
        justify-content: space-between !important;
        gap: 0 !important;
        min-height: 56px !important;
        max-width: none !important;
        margin: 0 !important;
        width: 100% !important;
    }

    header.header .header-left {
        display: flex !important;
        align-items: center !important;
        flex: 0 0 auto !important;
        width: auto !important;
        overflow: visible !important;
        min-width: 0 !important;
        order: 1 !important;
        padding: 0 !important;
    }

    header.header .logo {
        flex-shrink: 0 !important;
    }

    header.header.header-home .logo .logo-img { height: 32px !important; }

    header.header .nav-desktop-measure { display: none !important; }
    header.header .search-box { display: none !important; }
    header.header .mobile-menu-btn { display: none !important; }
    #kq-mobile-nav { display: none !important; }

    header.header .header-right {
        flex: 0 0 auto !important;
        justify-content: flex-end !important;
        gap: 8px !important;
        min-width: 0 !important;
        order: 2 !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
    }

    header.header .header-actions { gap: 8px !important; }

    header.header .user-avatar {
        width: 38px !important;
        height: 38px !important;
    }

    header.header .user-nickname,
    header.header .dropdown-arrow {
        display: none !important;
    }

    header.header .header-search-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 8px !important;
        border: 1px solid #668aaf !important;
        border-radius: 50% !important;
        width: 36px !important;
        height: 36px !important;
        flex-shrink: 0 !important;
        margin: 0 !important;
        background: transparent !important;
    }

    header.header .header-search-icon {
        width: 18px !important;
        height: 18px !important;
    }

    header.header #kq-header-auth .header-login-btn,
    header.header #kq-header-auth .header-trial-btn {
        padding: 0 12px !important;
        font-size: 13px !important;
        height: 36px !important;
        border-radius: 18px !important;
        white-space: nowrap !important;
    }

    /* 移动端改为独立 mobile-nav；原 nav 隐藏 */
    header.header .nav {
        display: none !important;
    }

    header.header .mobile-nav {
        display: flex !important;
        align-items: center !important;
        width: 100% !important;
        flex-basis: 100% !important;
        order: 10 !important;
        gap: 20px !important;
        padding: 8px 16px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap !important;
        border-top: 1px solid rgba(148, 163, 184, 0.35) !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
        box-sizing: border-box !important;
    }

    header.header .mobile-nav::-webkit-scrollbar {
        display: none !important;
    }

    header.header .mobile-nav .nav-link {
        flex-shrink: 0 !important;
        width: auto !important;
        min-width: max-content !important;
        display: inline-flex !important;
        align-items: center !important;
        padding: 8px 0 !important;
        font-size: 13px !important;
        color: #666 !important;
        border-bottom: 2px solid transparent !important;
        text-decoration: none !important;
        white-space: nowrap !important;
        background: transparent !important;
        border-radius: 0 !important;
    }

    header.header .mobile-nav .nav-link.active {
        color: #1e88e5 !important;
        border-bottom-color: #1e88e5 !important;
        font-weight: 500 !important;
        background: transparent !important;
    }

    header.header .mobile-nav .nav-link:hover {
        color: #1e88e5 !important;
        background: transparent !important;
    }

    /* 第二行导航出现后，hero 顶部留白要相应增大，避免标题被遮 */
    html:not(.aiapps-detail) .aiapps-list-root > .hero-section {
        padding-top: 130px !important;
    }
}

.ai-tool-detail-page {
    width: 100%;
}

.aiapps-tool-layout {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 0 12px 24px;
    gap: 12px;
    align-items: flex-start;
    box-sizing: border-box;
}

/*
 * 工具目录侧栏：主站 bundle（如 index-ded8e127.css）对通用 .sidebar 常设白底、padding:20px 0、右边框等，
 * 套在 aside 上会在 .sidebar-menu 渐变块上方露出一条「白块」。此处仅作外壳：透明、无内边距，视觉交给 .sidebar-menu。
 * 另：原型 ai-tool-detail.css 在 max-width:1200px 时对 .sidebar { display:none }，会误藏本目录；用专用类提高优先级恢复显示。
 */
.aiapps-tool-layout > aside.sidebar.aiapps-catalog-sidebar {
    width: 260px !important;
    min-width: 260px !important;
    flex-shrink: 0 !important;
    box-sizing: border-box;
    background: transparent !important;
    background-color: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-right: none !important;
    box-shadow: none !important;
    display: block !important;
    height: auto !important;
}

@media (max-width: 1200px) {
    .aiapps-tool-layout > aside.sidebar.aiapps-catalog-sidebar {
        display: block !important;
    }
}

.aiapps-tool-layout .sidebar-menu {
    box-sizing: border-box;
}

.aiapps-tool-layout .menu-title .menu-icon {
    flex-shrink: 0;
}

.aiapps-tool-layout .menu-title .menu-icon svg {
    display: block;
}

.aiapps-tool-layout .content-area.aiapps-tool-slot {
    flex: 1;
    min-width: 0;
    width: 100%;
    align-self: stretch;
    align-items: stretch;
}

.aiapps-mobile-catalog {
    display: none;
}

@media (max-width: 768px) {
    /* 详情页小屏改为单列，避免目录侧栏挤压主内容 */
    .ai-tool-detail-page .aiapps-tool-layout {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 0 8px 16px;
    }

    .ai-tool-detail-page .aiapps-tool-layout > aside.sidebar.aiapps-catalog-sidebar {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        position: static !important;
    }

    .ai-tool-detail-page .aiapps-tool-layout .sidebar-menu {
        max-height: none !important;
        position: static !important;
        top: auto !important;
        padding: 12px;
    }

    .ai-tool-detail-page .aiapps-tool-layout .sidebar-menu {
        display: none !important;
    }

    .ai-tool-detail-page .aiapps-mobile-catalog {
        display: block;
        width: 100%;
        margin-top: 10px;
        background: rgba(255, 255, 255, 0.92);
        border-radius: 12px;
        padding: 10px 12px;
        box-shadow: 0 2px 12px rgba(59, 130, 246, 0.12);
    }

    .ai-tool-detail-page .aiapps-mobile-catalog-label {
        display: block;
        font-size: 13px;
        color: #64748b;
        margin-bottom: 6px;
    }

    .ai-tool-detail-page .aiapps-mobile-catalog-select {
        width: 100%;
        height: 40px;
        border: 1px solid #bfdbfe;
        border-radius: 10px;
        padding: 0 12px;
        font-size: 14px;
        color: #1e293b;
        background: #ffffff;
        outline: none;
    }

    .ai-tool-detail-page .aiapps-tool-layout .content-area.aiapps-tool-slot {
        width: 100% !important;
        min-width: 0 !important;
    }

    .ai-tool-detail-page .tool-header {
        padding: 16px;
    }

    .ai-tool-detail-page .tool-title {
        font-size: 22px;
    }

    .ai-tool-detail-page .tool-content {
        flex-direction: column;
        gap: 12px;
    }
}

/*
 * 各工具页 extra_css 常在 @media (min-width: 769px) 下写 .furry-container { max-width: 1200px; margin: 0 auto }，
 * 嵌入壳层后会在「目录侧栏 + 右侧槽」布局里把整块工具区水平居中，侧栏与主内容之间出现大块空白。
 * 用 !important 保证在壳内始终贴左、占满槽宽（仍晚于 extra_css 加载）。
 */
.aiapps-tool-slot .furry-container,
.aiapps-tool-slot .chat-container,
.aiapps-tool-slot .wechat-container,
.aiapps-tool-slot .tool-container {
    max-width: none !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box;
}

@media (min-width: 769px) {
    .aiapps-tool-slot .furry-container {
        max-width: none !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* -------------------------------------------------------------------------- */
/* 列表首页：抵消 style.css 中 .main-content .page-container > .hero-section { background:none } */
/* 注意：不得再写 background-image:none，否则会抹掉 linear-gradient 的图像层 */
/* -------------------------------------------------------------------------- */
.main-content .page-container.aiapps-list-root {
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
    background: transparent;
}

.main-content .page-container.aiapps-list-root > .hero-section {
    height: auto !important;
    min-height: 0 !important;
    position: static !important;
    display: block !important;
    grid-template-columns: none !important;
    background: linear-gradient(135deg, #f5f3ff 0%, #e0f2fe 50%, #f5f3ff 100%) !important;
}

.main-content .page-container.aiapps-list-root > .hero-section::before {
    content: none !important;
    display: none !important;
}

/* 首页主标题：用设计稿主蓝实色字，不用 style.css 里渐变 clip 字 */
.main-content .page-container.aiapps-list-root > .hero-title {
    background: none !important;
    -webkit-background-clip: border-box !important;
    background-clip: border-box !important;
    -webkit-text-fill-color: #2563eb !important;
    color: #2563eb !important;
}

/* 副标题：浅蓝胶囊条（设计稿） */
.main-content .page-container.aiapps-list-root .hero-subtitle {
    display: inline-block;
    margin: 0 auto 24px;
    padding: 10px 28px;
    background: #e0f2fe;
    border-radius: 999px;
    color: #64748b;
}

/* 分类 Tab：当前分区高亮 */
.hero-menu-item.is-active {
    border-color: rgba(59, 130, 246, 0.95) !important;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.22);
}

/* --------------------------------------------------------------------------
 * 图片全屏预览 #imageModal：主站 www.kunqiongai.com/assets/index-*.css 含
 * `.image-modal{display:flex!important;...}`，与工具页「默认隐藏、仅 .show 显示」冲突，
 * 表现为一打开页面即全屏 rgba(0,0,0,.95) 遮罩。用更高优先级还原「仅 .show 时 flex」。
 * -------------------------------------------------------------------------- */
#imageModal.image-modal:not(.show) {
    display: none !important;
}

#imageModal.image-modal.show {
    display: flex !important;
}
