/* ============================================================
   MRP资源库 - 全局统一样式
   主色调：#2563EB
   ============================================================ */

/* ============================================================
   1. 基础重置
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fb;
    color: #1f2937;
    line-height: 1.5;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ============================================================
   2. 标题栏
   ============================================================ */

.app-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 50;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 16px;
}

.header-left,
.header-right {
    width: 40px;
    flex-shrink: 0;
}

.header-title {
    font-size: 17px;
    font-weight: 700;
    color: #2563EB;
    margin: 0;
    text-align: center;
    flex: 1;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: #2563EB;
    font-size: 18px;
    border-radius: 50%;
    transition: background 0.15s;
}
.back-btn:active {
    background: #f3f4f6;
}

/* ============================================================
   3. 主内容区
   ============================================================ */

.app-main {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.page-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 16px;
}

.app-view,
.detail-view,
.resources-view,
.post-detail,
.rank-view,
.list-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 16px;
}

.app-main .app-view,
.app-main .page-content,
.app-main .detail-view,
.app-main .resources-view,
.app-main .rank-view,
.app-main .list-view,
.app-main .post-detail {
    padding-top: 12px;
}

.has-nav .page-content,
.has-nav .app-view {
    padding-bottom: 60px;
}

.detail-view,
.resources-view,
.post-detail,
.rank-view,
.list-view {
    padding-bottom: 0;
}

/* ============================================================
   4. 底部导航
   ============================================================ */

.bottom-nav {
    flex-shrink: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid #e5e7eb;
    z-index: 100;
}

.bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100%;
    padding: 0 8px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 0;
    border-radius: 30px;
    color: #9ca3af;
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    flex: 1;
    text-align: center;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-item i {
    font-size: 20px;
}

.nav-item.active {
    color: #2563EB;
}

/* ============================================================
   5. 统一状态组件
   ============================================================ */

.state-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 32px 24px;
    text-align: center;
    min-height: 200px;
    width: 100%;
}

.state-icon {
    font-size: 40px;
    line-height: 1;
    margin-bottom: 12px;
    color: #cbd5e1;
}

.state-title {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 6px;
}

.state-desc {
    font-size: 13px;
    color: #9ca3af;
    margin-bottom: 16px;
    max-width: 300px;
}

.state-btn {
    display: inline-block;
    padding: 8px 28px;
    background: #2563EB;
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.state-btn:active {
    transform: scale(0.96);
}

.loading-state .loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: #2563EB;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-bottom: 14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state .state-icon {
    color: #cbd5e1;
}

.error-state .state-icon {
    color: #f59e0b;
}

/* ============================================================
   6. 全局加载遮罩
   ============================================================ */

.global-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.global-loading .loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: #2563EB;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ============================================================
   7. 通用容器
   ============================================================ */

.container {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #1f2937;
}

.card-link {
    font-size: 12px;
    color: #2563EB;
    text-decoration: none;
    font-weight: 500;
}

/* ============================================================
   8. 列表容器
   ============================================================ */

.home-grid,
.forum-list,
.rank-list,
.comments-list,
.downloads-list,
.favorites-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 16px;
}

/* ============================================================
   9. 搜索框
   ============================================================ */

.search-bar {
    background: white;
    border-radius: 24px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    border: 1px solid #f0f0f0;
    transition: all 0.2s ease;
}

.search-bar:focus-within {
    border-color: #2563EB;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.10);
}

.search-bar i {
    color: #9ca3af;
    font-size: 15px;
    transition: color 0.2s;
}

.search-bar:focus-within i {
    color: #2563EB;
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    background: transparent;
    color: #1f2937;
}

.search-bar input::placeholder {
    color: #c0c0c6;
}

/* ============================================================
   10. 分类标签栏（基础样式）
   ============================================================ */

.filter-bar {
    background: white;
    border-radius: 40px;
    padding: 4px;
    margin-bottom: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.category-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
}

.category-tab {
    flex: 1;
    text-align: center;
    padding: 6px 0;
    background: transparent;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
}

.category-tab.active {
    background: #2563EB;
    color: white;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

/* ============================================================
   11. Banner
   ============================================================ */

.banner {
    background: linear-gradient(135deg, #2563EB, #3B82F6);
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 16px;
    color: white;
    position: relative;
    overflow: hidden;
}

.banner::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -20%;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.banner h2 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 4px;
}

.banner p {
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 10px;
}

.banner-btn {
    background: white;
    color: #2563EB;
    border: none;
    padding: 5px 16px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

/* ============================================================
   12. 分类图标区
   ============================================================ */

.category-grid {
    display: flex;
    justify-content: space-around;
    background: white;
    border-radius: 12px;
    padding: 10px 8px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.category-item {
    text-align: center;
    cursor: pointer;
    flex: 1;
}

.category-icon {
    width: 44px;
    height: 44px;
    background: #f3f4f6;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 5px;
    font-size: 18px;
    color: #2563EB;
}

.category-item span {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

/* ============================================================
   13. Toast 消息
   ============================================================ */

.toast-message {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    color: white;
    animation: toastIn 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.toast-message.success {
    background: #10b981;
}
.toast-message.error {
    background: #ef4444;
}
.toast-message.warning {
    background: #f59e0b;
}
.toast-message.info {
    background: #2563EB;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ============================================================
   14. 悬浮发帖按钮
   ============================================================ */

.fab-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.30);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    z-index: 90;
    transition: all 0.2s ease;
}

.fab-btn:active {
    transform: scale(0.92);
}

/* ============================================================
   15. 模态框
   ============================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #9ca3af;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
}

.modal-btn {
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
}

.modal-btn.cancel {
    background: #f3f4f6;
    color: #1f2937;
}
.modal-btn.submit {
    background: #2563EB;
    color: white;
}

/* ============================================================
   16. 确认对话框
   ============================================================ */

.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.confirm-overlay.show {
    display: flex;
}
.confirm-box {
    background: white;
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    padding: 24px;
    animation: scaleIn 0.2s ease-out;
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.confirm-box h3 {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
}
.confirm-box p {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 20px;
}
.confirm-box .btn-group {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.confirm-box .btn-group button {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}
.confirm-box .btn-cancel {
    background: #f3f4f6;
    color: #1f2937;
}
.confirm-box .btn-cancel:hover {
    background: #e5e7eb;
}
.confirm-box .btn-confirm {
    background: #ef4444;
    color: white;
}
.confirm-box .btn-confirm:hover {
    background: #dc2626;
}

/* ============================================================
   17. 加载更多
   ============================================================ */

.loading-more {
    text-align: center;
    padding: 15px;
    color: #9ca3af;
    font-size: 12px;
}

/* ============================================================
   18. 帖子卡片
   ============================================================ */

.post-card {
    background: white;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
}
.post-card:active {
    transform: scale(0.99);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.post-author {
    display: flex;
    align-items: center;
    gap: 8px;
}

.post-author-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.post-author-name {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
}

.post-time {
    font-size: 11px;
    color: #9ca3af;
}

.post-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
}
.post-badge.sticky {
    background: #fee2e2;
    color: #ef4444;
}
.post-badge.question {
    background: #fef3c7;
    color: #f59e0b;
}
.post-badge.solved {
    background: #d1fae5;
    color: #10b981;
}

.post-title {
    font-size: 15px;
    font-weight: 700;
    color: #1f2937;
}

.post-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #9ca3af;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
    margin-top: 10px;
}
.post-stats span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ============================================================
   19. 框架级响应式
   ============================================================ */

@media (min-width: 768px) {
    .page-content,
    .app-view,
    .detail-view,
    .resources-view,
    .post-detail,
    .rank-view,
    .list-view {
        padding: 0 24px;
    }
    .category-tab {
        padding: 6px 20px;
        font-size: 13px;
    }
}

@media (min-width: 1024px) {
    .page-content,
    .app-view,
    .detail-view,
    .resources-view,
    .post-detail,
    .rank-view,
    .list-view {
        padding: 0 32px;
    }
    .category-icon {
        width: 60px;
        height: 60px;
        font-size: 26px;
    }
}

@media (max-width: 480px) {
    .page-content,
    .app-view,
    .detail-view,
    .resources-view,
    .post-detail,
    .rank-view,
    .list-view {
        padding: 0 12px;
    }
    .category-tab {
        font-size: 11px;
        padding: 5px 0;
    }
    .category-icon {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
    .search-bar {
        padding: 8px 14px;
    }
    .search-bar input {
        font-size: 13px;
    }
}

/* ============================================================
   20. 资源页 & 论坛页 - 统一吸顶方案
   ============================================================ */

/* ---------- 20.1 吸顶容器 ---------- */
.resources-filter-sticky,
.forum-filter-sticky {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #f5f7fb;
    flex-shrink: 0;
}

/* ---------- 20.2 分类标签 ---------- */
.resources-filter-sticky .filter-bar,
.forum-filter-sticky .filter-bar {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    margin: 0;
    padding: 0;
}

.resources-filter-sticky .category-tabs,
.forum-filter-sticky .category-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding: 8px 16px 6px 16px;
}
.resources-filter-sticky .category-tabs::-webkit-scrollbar,
.forum-filter-sticky .category-tabs::-webkit-scrollbar {
    display: none;
}

.resources-filter-sticky .category-tab,
.forum-filter-sticky .category-tab {
    flex: 0 0 auto;
    padding: 5px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: white;
    color: #6b7280;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    border: 1px solid transparent;
}

.resources-filter-sticky .category-tab:active,
.forum-filter-sticky .category-tab:active {
    transform: scale(0.94);
}

.resources-filter-sticky .category-tab.active,
.forum-filter-sticky .category-tab.active {
    background: #2563EB;
    color: white;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
    border-color: #2563EB;
}

/* ---------- 20.3 搜索框 ---------- */
.app-view .search-bar {
    margin: 0 16px 8px 16px;
}

/* ---------- 20.4 论坛 Tab 导航 ---------- */
.forum-filter-sticky .forum-tab-nav {
    padding: 0 16px;
    background: #f5f7fb;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}

/* ---------- 20.5 移动端适配 ---------- */
@media (max-width: 480px) {
    .resources-filter-sticky .category-tabs,
    .forum-filter-sticky .category-tabs {
        gap: 6px;
        padding: 6px 12px 4px 12px;
    }
    .resources-filter-sticky .category-tab,
    .forum-filter-sticky .category-tab {
        padding: 4px 12px;
        font-size: 12px;
        border-radius: 16px;
    }

    .app-view .search-bar {
        margin: 0 12px 6px 12px;
        padding: 8px 14px;
        border-radius: 20px;
    }

    .forum-filter-sticky .forum-tab-nav {
        padding: 0 12px;
    }
}

@media (max-width: 380px) {
    .resources-filter-sticky .category-tabs,
    .forum-filter-sticky .category-tabs {
        gap: 4px;
        padding: 4px 8px 2px 8px;
    }
    .resources-filter-sticky .category-tab,
    .forum-filter-sticky .category-tab {
        padding: 3px 10px;
        font-size: 11px;
        border-radius: 14px;
    }
}