/* =================================================================
 * common.css —— 全站公共样式 & 完整响应式基础
 * 与 style.css 并行，后加载
 * ================================================================= */

/* ============ 公共组件（骨架页使用） ============ */
* { box-sizing: border-box; }

.app-topbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: 56px; background: rgba(255,255,255,.98);
    backdrop-filter: blur(8px); border-bottom: 1px solid #eee;
    z-index: 1000; display: flex; align-items: center; padding: 0 24px;
}
.app-topbar .tb-left { display: flex; align-items: center; gap: 16px; }
.app-topbar .tb-logo { font-size: 20px; font-weight: 700; color: #111;
    text-decoration: none; display: flex; align-items: center; gap: 8px; }
.app-topbar .tb-logo img { height: 32px; width: auto; }
.app-topbar .tb-nav { display: flex; gap: 24px; margin-left: 40px; }
.app-topbar .tb-nav a { color: #555; text-decoration: none; font-size: 14px;
    padding: 6px 0; border-bottom: 2px solid transparent;
    transition: color .2s, border-color .2s; }
.app-topbar .tb-nav a:hover, .app-topbar .tb-nav a.active {
    color: #0d6efd; border-color: #0d6efd; }
.app-topbar .tb-right { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.app-topbar .tb-btn { padding: 6px 16px; border-radius: 6px; font-size: 13px;
    text-decoration: none; cursor: pointer; border: 1px solid transparent; }
.app-topbar .tb-btn-outline { border-color: #ddd; color: #333; background: #fff; }
.app-topbar .tb-btn-primary { background: #0d6efd; color: #fff; }
.app-topbar .tb-btn-primary:hover { background: #0b5ed7; }
.app-with-topbar { padding-top: 56px; }

.app-footer {
    background: #f8f9fa; border-top: 1px solid #eee;
    padding: 40px 24px 24px; margin-top: 48px; font-size: 13px; color: #666;
}
.app-footer .footer-inner { max-width: 1200px; margin: 0 auto;
    display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
.app-footer .footer-inner h4 { margin: 0 0 12px; font-size: 14px; color: #222; font-weight: 600; }
.app-footer .footer-inner a { color: #666; text-decoration: none; display: block; padding: 3px 0; }
.app-footer .footer-inner a:hover { color: #0d6efd; }
.app-footer .footer-bottom { max-width: 1200px; margin: 32px auto 0; padding-top: 16px;
    border-top: 1px solid #e9ecef; text-align: center; color: #999; font-size: 12px; }

/* 骨架页通用 */
.page-shell { max-width: 1200px; margin: 40px auto; padding: 0 24px; }
.page-shell h1 { font-size: 28px; font-weight: 700; color: #111; margin-bottom: 8px; }
.page-shell .page-subtitle { color: #666; font-size: 14px; margin-bottom: 32px; }
.page-card { background: #fff; border: 1px solid #eee; border-radius: 12px; padding: 24px; margin-bottom: 16px; }

/* ============ 修复原首页 style.css 的响应式缺口 ============ */

/* 全局防溢出（关键！否则任何固定宽度组件都会让整个页面水平滚动） */
body { overflow-x: hidden; }

/* 平板断点：768px – 1199px ============ */
@media (min-width: 768px) and (max-width: 1199px) {
    .container { max-width: 960px; padding: 0 16px; }

    /* 首页结果网格缩小间隙 */
    .result-content { gap: 12px; }
    .result-thumbnail { width: 140px; height: 105px; }
    .resource-content { gap: 18px; }
    .resource-thumbnail { width: 160px; }
    .resource-thumbnail img { width: 160px; height: 120px; }

    /* 分类间距 */
    .categories { gap: 20px; }

    /* 骨架页 */
    .app-footer .footer-inner { grid-template-columns: 1fr 1fr; }
    .page-shell { max-width: 960px; }
    .app-topbar { padding: 0 16px; }
    .app-topbar .tb-nav { gap: 16px; margin-left: 24px; }
}

/* 手机断点：< 768px ============ */
@media (max-width: 767px) {
    body { overflow-x: hidden; }

    /* ============ 原首页 style.css 组件 ============ */
    .container { padding: 0 12px; }

    /* header 三栏挤压 */
    .header { padding: 12px 0; }
    .header .container {
        flex-direction: column; gap: 10px; padding: 0 12px;
    }
    .channels { gap: 8px; order: 2; }
    .channel-btn { padding: 4px 10px; font-size: 13px; }
    .logo { order: 1; flex: none; }
    .logo .site-logo { height: 40px; }
    .login-area { order: 3; }
    .login-btn { padding: 6px 14px; font-size: 13px; }

    /* 搜索框 */
    .search-box { flex-direction: column; gap: 8px; padding: 0 12px; }
    #search-input { width: 100%; max-width: 100%; }
    #search-btn { width: 100%; }

    /* 分类 */
    .categories { flex-direction: column; align-items: stretch; gap: 12px; padding: 0 12px; }
    .categories-nav { padding: 0 12px; }
    .categories-nav h4 { text-align: center; }

    /* 结果项 —— 关键！result-content 必须竖排，否则 160px 固定缩略图会撑爆 */
    .result-item { padding: 0 12px; }
    .result-content {
        flex-direction: column; gap: 10px;
        align-items: center; text-align: center;
    }
    .result-thumbnail { width: 100%; max-width: 240px; height: auto; }
    .result-info { width: 100%; }
    .result-title { font-size: 16px; }
    .result-meta { gap: 6px; font-size: 12px; justify-content: center; }
    .result-time-info { justify-content: center; gap: 4px; }
    .result-actions { justify-content: center; flex-wrap: wrap; }

    /* 资源卡片 */
    .resource-card { border-width: 1px; padding: 12px; min-height: 0; }
    .resource-content {
        flex-direction: column; gap: 12px; align-items: stretch;
    }
    .resource-thumbnail {
        width: 100%; height: auto; flex-shrink: initial;
    }
    .resource-thumbnail img { width: 100%; height: auto; max-height: 200px; object-fit: contain; }
    .resource-title { font-size: 16px; }
    .one-click-download-btn { width: 100%; max-width: none; padding: 10px; font-size: 16px; }

    /* 推荐区域（那个绿框） */
    .recommended-area { padding: 12px; min-height: 0; border-width: 1px; }
    .recommended-area h3 { font-size: 16px; }

    /* 搜索结果网格 —— style.css 里 results-grid 已经在媒体查询里设了 auto-fill，但没 display: grid！补一个 */
    .results-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }

    /* 排序控制 */
    .sorting-controls { flex-direction: column; gap: 10px; padding: 10px; }
    .sort-buttons { flex-wrap: wrap; justify-content: center; }

    /* 文件类型选择 */
    .file-type-buttons { gap: 12px; }
    .file-type-group .category-box { width: 100px; height: 70px; font-size: 14px; }

    /* 页脚波浪区 */
    .wave-footer { padding: 40px 0 24px; margin-top: 30px; background-size: cover; }
    .footer-links { gap: 10px; }
    .footer-links a { font-size: 13px; }
    .footer-logo { display: none; } /* 绝对定位在右下方，手机上可能溢出 */
    .footer-info { font-size: 11px; line-height: 1.6; padding: 0 12px; }

    /* 模态框 */
    .modal-content { width: 92%; margin: 8% auto; padding: 16px; }
    .close { right: 12px; top: 8px; }
    .preview-title { font-size: 18px; }
    .preview-meta { font-size: 12px; }

    /* 热门素材网格 */
    .hot-materials-list { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }

    /* 合规提示 */
    .compliance-notice { margin: 0 12px 16px; font-size: 12px; padding: 8px; }

    /* 空结果 */
    .empty-results { padding: 40px 12px; }
    .no-results-content { padding: 0 12px; }
}

/* ============ 骨架页组件的手机适配 ============ */
@media (max-width: 767px) {
    .app-topbar { padding: 0 12px; height: 50px; }
    .app-topbar .tb-nav { display: none; }
    .app-topbar .tb-logo { font-size: 16px; }
    .app-topbar .tb-logo img { height: 26px; }
    .app-topbar .tb-btn { padding: 5px 10px; font-size: 12px; }

    .app-footer { padding: 24px 16px 16px; }
    .app-footer .footer-inner { grid-template-columns: 1fr; gap: 20px; }
    .app-footer .footer-bottom { font-size: 11px; line-height: 1.6; }

    .page-shell { margin: 24px auto; padding: 0 16px; }
    .page-shell h1 { font-size: 22px; }
    .page-card { padding: 16px; }
}

/* 骨架屏占位 */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%; animation: skeleton-anim 1.5s infinite; border-radius: 4px;
}
@keyframes skeleton-anim {
    0% { background-position: 200% 0; } 100% { background-position: -200% 0; }
}
