/*
 * 首页 / 工具列表页（root/index）的样式，不依赖 Bootstrap / MDB。
 * 暗色样式统一放在 public/css/theme-dark.less（编译为 theme-dark.css），这里只写亮色。
 * 分类 / 子分类药丸、最近使用的 chip、卡片都由 root-tools.js 或服务端直出的 HTML 使用。
 */
.root-tools-search {
    position: relative;
    margin: 0 0 16px;
}
.root-tools-search .material-icons {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 22px;
    color: var(--q-primary, #1976d2);
    pointer-events: none;
}
.rt-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    height: 42px;
    padding: 0 14px 0 44px;
    font-size: 15px;
    color: inherit;
    background: transparent;
    border: 1px solid rgba(128, 128, 128, .5);
    border-radius: 8px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.rt-input:focus {
    border-color: var(--q-primary, #1976d2);
    box-shadow: 0 0 0 1px var(--q-primary, #1976d2);
}

/* 分类胶囊栏 */
.category-nav-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}
.category-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 20px;
    background: #f1f5f9;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: all 0.15s ease;
    user-select: none;
}
.category-pill .material-icons { font-size: 16px; }
.category-pill:hover, .category-pill.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}
.category-pill .badge, .sub-category-pill .badge {
    margin-left: 4px;
    font-size: 11px;
    color: #64748b;
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
}
.category-pill:hover .badge, .category-pill.active .badge,
.sub-category-pill:hover .badge, .sub-category-pill.active .badge {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.25);
}

/* 手机端分类下拉 */
.category-select-wrapper { display: none; margin: 0 0 16px; position: relative; }
.category-select-wrapper .material-icons {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    font-size: 20px; color: var(--q-primary, #1976d2); pointer-events: none;
}
.category-select-wrapper select { appearance: auto; padding-right: 10px; cursor: pointer; font-size: 14px; }

/* 二级子分类药丸 */
.sub-category-nav-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: -10px;
    margin-bottom: 20px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}
.sub-category-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 14px;
    background: #ffffff;
    color: #64748b;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: all 0.15s ease;
    user-select: none;
}
.sub-category-pill .material-icons { font-size: 15px; }
.sub-category-pill:hover, .sub-category-pill.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #0369a1;
}

/* 最近 / 常用 */
.rt-recent-title { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; font-size: 14px; font-weight: 700; }
.rt-recent-title .material-icons { font-size: 20px; }
.rt-recent-list { display: flex; flex-wrap: wrap; }
.history-tool-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: #f1f5f9;
    color: #334155;
    text-decoration: none;
    margin: 0 8px 8px 0;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    border: 1px solid rgba(0,0,0,0.06);
}
.history-tool-chip .material-icons { font-size: 18px; }
.history-tool-chip:hover {
    background: #3b82f6;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

/* 分类区块 */
.section-header-box {
    display: flex;
    align-items: baseline;
    margin: 28px 0 14px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.04);
    padding-bottom: 8px;
}
.section-header-box h4 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 20px; font-weight: 700; }
.section-header-box .rt-section-desc { margin-left: 15px; font-size: 13px; opacity: .65; }

/* 工具卡片网格：卡片由 root-tools.js 构造 */
.root-tools-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 15px;
}
@media (min-width: 600px) { .root-tools-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .root-tools-row { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1440px) { .root-tools-list-wide .root-tools-row { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.rt-card {
    --rt-color: var(--q-primary, #1976d2);
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    border: 1px solid var(--rt-color);
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
    transition: box-shadow .2s, transform .2s;
}
.rt-card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .15); }
.rt-c-success { --rt-color: #1b9e55; }
.rt-c-info { --rt-color: #0e9fd0; }
.rt-c-warning { --rt-color: #e69a00; }
.rt-c-danger { --rt-color: #dc2626; }
.rt-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px 8px;
    font-weight: 700;
    color: inherit;
    text-decoration: none;
}
.rt-card-head:hover { text-decoration: none; }
.rt-card-head .rt-ico { color: var(--rt-color); font-size: 22px; }
.rt-card-head .rt-arrow { margin-left: auto; font-size: 18px; opacity: .6; }
.tool-name-text { margin-right: 8px; }
.rt-card-body { padding: 0 16px 15px; }
.tool-sub-row { margin-bottom: 8px; line-height: 1; }
.tool-sub-badge {
    display: inline-block;
    font-size: 11px;
    line-height: 1.4;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.04);
    color: #64748b;
}
.rt-card-desc { margin: 0; font-size: 14px; opacity: .7; }

@media (max-width: 1023.98px) {
    .category-nav-bar { display: none; }
    .category-select-wrapper { display: block; }
}

/*
 * 手机端工具列表很长，搜索框吸顶（仅窄屏）。top 用 --rh-nav-offset（脚本按固定顶栏高度实测），缺省 56px。
 * 吸顶包含块是主栏：侧栏广告在主栏之后的兄弟列里，滚到广告时搜索框随主栏离开，不会压住广告。
 * 不用 position:fixed，也不抬到广告浮层之上，避免遮挡广告。
 */
@media (max-width: 1023.98px) {
    .root-tools-search {
        position: sticky;
        top: var(--rh-nav-offset, 56px);
        z-index: 1020;
        margin: 0 -8px;
        padding: 8px 8px 12px;
        background: #fff;
        box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
    }
    .root-tools-search .material-icons { left: 20px; top: calc(50% - 2px); }
}

/*
 * 列表卡片由 root-tools.js 在加载时构造。构造完成前（#rootToolsList 还没有 .is-ready），
 * 按每个分类默认显示的卡片数（行上的 data-n）预留大致高度，让下面的内容（含广告位）不在卡片出现时整体下跳。
 * 列数与上面的网格一致（1 / 2 / 3 列，无侧栏广告时 ≥1440px 为 4 列）；行高是实测整数，只是估算，构造完成后以真实高度为准。
 * 只在脚本可用时预留（scripting: enabled）：没有 JS 时卡片不会出现，也就不留空白，页面显示 <noscript> 提示。
 */
@media (scripting: enabled) {
    .root-tools-list:not(.is-ready) [data-n="1"] { min-height: 150px; }
    .root-tools-list:not(.is-ready) [data-n="2"] { min-height: 300px; }
    .root-tools-list:not(.is-ready) [data-n="3"] { min-height: 450px; }
    .root-tools-list:not(.is-ready) [data-n="4"] { min-height: 600px; }
    .root-tools-list:not(.is-ready) [data-n="5"] { min-height: 750px; }
    .root-tools-list:not(.is-ready) [data-n="6"] { min-height: 900px; }
    .root-tools-list:not(.is-ready) [data-n="7"] { min-height: 1050px; }
    .root-tools-list:not(.is-ready) [data-n="8"] { min-height: 1200px; }
    .root-tools-list:not(.is-ready) [data-n="9"] { min-height: 1350px; }
    .root-tools-list:not(.is-ready) [data-n="10"] { min-height: 1500px; }
    .root-tools-list:not(.is-ready) [data-n="11"] { min-height: 1650px; }
    .root-tools-list:not(.is-ready) [data-n="12"] { min-height: 1800px; }
    .root-tools-list:not(.is-ready) [data-n="13"] { min-height: 1950px; }
    .root-tools-list:not(.is-ready) [data-n="14"] { min-height: 2100px; }
}
@media (scripting: enabled) and (min-width: 600px) {
    .root-tools-list:not(.is-ready) [data-n="1"] { min-height: 145px; }
    .root-tools-list:not(.is-ready) [data-n="2"] { min-height: 145px; }
    .root-tools-list:not(.is-ready) [data-n="3"] { min-height: 290px; }
    .root-tools-list:not(.is-ready) [data-n="4"] { min-height: 290px; }
    .root-tools-list:not(.is-ready) [data-n="5"] { min-height: 435px; }
    .root-tools-list:not(.is-ready) [data-n="6"] { min-height: 435px; }
    .root-tools-list:not(.is-ready) [data-n="7"] { min-height: 580px; }
    .root-tools-list:not(.is-ready) [data-n="8"] { min-height: 580px; }
    .root-tools-list:not(.is-ready) [data-n="9"] { min-height: 725px; }
    .root-tools-list:not(.is-ready) [data-n="10"] { min-height: 725px; }
    .root-tools-list:not(.is-ready) [data-n="11"] { min-height: 870px; }
    .root-tools-list:not(.is-ready) [data-n="12"] { min-height: 870px; }
    .root-tools-list:not(.is-ready) [data-n="13"] { min-height: 1015px; }
    .root-tools-list:not(.is-ready) [data-n="14"] { min-height: 1015px; }
}
@media (scripting: enabled) and (min-width: 1024px) {
    .root-tools-list:not(.is-ready) [data-n="1"] { min-height: 175px; }
    .root-tools-list:not(.is-ready) [data-n="2"] { min-height: 175px; }
    .root-tools-list:not(.is-ready) [data-n="3"] { min-height: 175px; }
    .root-tools-list:not(.is-ready) [data-n="4"] { min-height: 350px; }
    .root-tools-list:not(.is-ready) [data-n="5"] { min-height: 350px; }
    .root-tools-list:not(.is-ready) [data-n="6"] { min-height: 350px; }
    .root-tools-list:not(.is-ready) [data-n="7"] { min-height: 525px; }
    .root-tools-list:not(.is-ready) [data-n="8"] { min-height: 525px; }
    .root-tools-list:not(.is-ready) [data-n="9"] { min-height: 525px; }
    .root-tools-list:not(.is-ready) [data-n="10"] { min-height: 700px; }
    .root-tools-list:not(.is-ready) [data-n="11"] { min-height: 700px; }
    .root-tools-list:not(.is-ready) [data-n="12"] { min-height: 700px; }
    .root-tools-list:not(.is-ready) [data-n="13"] { min-height: 875px; }
    .root-tools-list:not(.is-ready) [data-n="14"] { min-height: 875px; }
}
@media (scripting: enabled) and (min-width: 1440px) {
    .root-tools-list-wide:not(.is-ready) [data-n="1"] { min-height: 160px; }
    .root-tools-list-wide:not(.is-ready) [data-n="2"] { min-height: 160px; }
    .root-tools-list-wide:not(.is-ready) [data-n="3"] { min-height: 160px; }
    .root-tools-list-wide:not(.is-ready) [data-n="4"] { min-height: 160px; }
    .root-tools-list-wide:not(.is-ready) [data-n="5"] { min-height: 320px; }
    .root-tools-list-wide:not(.is-ready) [data-n="6"] { min-height: 320px; }
    .root-tools-list-wide:not(.is-ready) [data-n="7"] { min-height: 320px; }
    .root-tools-list-wide:not(.is-ready) [data-n="8"] { min-height: 320px; }
    .root-tools-list-wide:not(.is-ready) [data-n="9"] { min-height: 480px; }
    .root-tools-list-wide:not(.is-ready) [data-n="10"] { min-height: 480px; }
    .root-tools-list-wide:not(.is-ready) [data-n="11"] { min-height: 480px; }
    .root-tools-list-wide:not(.is-ready) [data-n="12"] { min-height: 480px; }
    .root-tools-list-wide:not(.is-ready) [data-n="13"] { min-height: 640px; }
    .root-tools-list-wide:not(.is-ready) [data-n="14"] { min-height: 640px; }
}

.root-tools-noscript { margin: 0 0 16px; font-size: 14px; }

/* 没有 JS 时分类下面没有卡片，只剩空标题：整块收起，由 <noscript> 提示和顶部菜单代替 */
@media (scripting: none) {
    .root-tools-section { display: none; }
}
