/* ========================================
   移动端响应式优化样式
   适配手机、平板等小屏幕设备
   ======================================== */

/* ========================================
   1. 基础优化
   ======================================== */
@media (max-width: 768px) {
    /* 容器优化 */
    .container {
        padding: 0;
    }
    
    /* 字体大小优化 */
    body {
        font-size: 14px;
        background: #f5f5f5 !important;
    }
    
    h1 {
        font-size: 1.75rem !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
    }
    
    /* 主内容区域 */
    main {
        background: #f5f5f5 !important;
    }
}

/* ========================================
   2. 导航栏移动端优化
   ======================================== */
@media (max-width: 768px) {
    .navbar {
        position: sticky;
        top: 0;
        z-index: 999;
        background: white !important;
        box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    }
    
    .navbar .container {
        flex-wrap: nowrap;
        height: 48px;
        padding: 0 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
    }
    
    .navbar-brand {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
    }
    
    .navbar-brand img,
    .logo {
        width: 28px;
        height: 28px;
    }
    
    .brand-name {
        font-size: 14px;
        white-space: nowrap;
        font-weight: 600;
    }
    
    /* 导航菜单紧凑显示 */
    .navbar-menu {
        display: flex;
        gap: 4px;
        flex: 1;
        justify-content: center;
        padding: 0;
    }
    
    .navbar-menu a {
        white-space: nowrap;
        font-size: 13px;
        padding: 5px 10px;
        border-radius: 14px;
    }
    
    /* 隐藏导航栏的搜索框 */
    .navbar-end .search-bar {
        display: none !important;
    }
    
    /* 右侧操作区 */
    .navbar-end {
        gap: 6px;
        flex-shrink: 0;
    }
    
    /* 登录按钮优化 */
    .btn-outline {
        font-size: 12px;
        padding: 5px 10px;
        white-space: nowrap;
        border-radius: 14px;
    }
    
    /* 用户下拉菜单 */
    .nav-menu {
        gap: 6px;
    }
    
    .nav-avatar-dropdown {
        right: 0;
        left: auto;
        width: 280px;
        max-width: calc(100vw - 32px);
    }
}

/* ========================================
   3. Hero区域移动端优化
   ======================================== */
@media (max-width: 768px) {
    .hero,
    .page-header {
        padding: 40px 20px 30px !important;
        text-align: center;
        background: #000000 !important;
        color: white !important;
        margin-bottom: 0 !important;
        border-radius: 0 0 20px 20px !important;
        position: relative;
    }
    
    /* HANK HANDBOOK 标题 */
    .hero::before {
        content: 'HANK HANDBOOK';
        display: block;
        font-size: 12px;
        letter-spacing: 2px;
        color: #ef4444;
        font-weight: 600;
        margin-bottom: 16px;
    }
    
    .hero h1 {
        font-size: 22px !important;
        line-height: 1.5;
        margin-bottom: 24px;
        color: white !important;
        font-weight: 600;
        white-space: normal;
        letter-spacing: 1px;
    }
    
    .hero p {
        display: none !important;
    }
    
    .hero-stats {
        display: flex;
        gap: 12px;
        justify-content: center;
        padding: 0;
        margin-top: 0;
    }
    
    .hero-stat-card {
        min-width: 100px;
        padding: 16px 12px;
        background: rgba(255, 255, 255, 0.1) !important;
        backdrop-filter: blur(10px);
        box-shadow: none !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 12px !important;
        text-align: center;
        flex: 1;
    }
    
    .hero-stat-card .stat-value {
        font-size: 1.75rem;
        font-weight: 700;
        color: #ef4444 !important;
        margin-bottom: 6px;
    }
    
    .hero-stat-card .stat-value::after {
        content: '+';
    }
    
    .hero-stat-card .stat-label {
        font-size: 12px;
        color: rgba(255,255,255,0.8) !important;
    }
    
    /* 搜索框容器 - 放在Hero下方 */
    .search-container {
        background: white;
        padding: 12px 16px;
        margin: 0 !important;
        border-bottom: 1px solid #f0f0f0;
    }
}

/* ========================================
   4. 分类导航移动端优化
   ======================================== */
@media (max-width: 768px) {
    /* 一级分类导航 */
    .category-tabs,
    .primary-categories,
    .category-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .category-tabs::-webkit-scrollbar,
    .primary-categories::-webkit-scrollbar,
    .category-scroll::-webkit-scrollbar {
        display: none;
    }
    
    .category-tabs {
        gap: 8px;
        padding: 10px 12px;
        border-bottom: 1px solid #f0f0f0;
        background: white;
    }
    
    .category-tab {
        white-space: nowrap;
        font-size: 13px;
        padding: 6px 14px;
        flex-shrink: 0;
        border-radius: 16px;
        background: white;
        color: #666;
        border: 1px solid #e5e5e5;
    }
    
    .category-tab.active {
        background: #ef4444 !important;
        color: white !important;
        border-color: #ef4444 !important;
    }
    
    /* 二级标签导航 */
    .tags-container,
    .secondary-categories {
        padding: 8px 12px;
        background: white;
        border-bottom: 1px solid #f5f5f5;
    }
    
    .tag-item {
        font-size: 12px;
        padding: 5px 12px;
        white-space: nowrap;
        border-radius: 14px;
        background: #f5f5f5;
        color: #666;
        border: none;
    }
    
    .tag-item.active {
        background: #fff1f0 !important;
        color: #ef4444 !important;
    }
    
    /* 左右布局改为上下布局 */
    .resources-layout,
    .main-layout {
        flex-direction: column !important;
        gap: 16px;
    }
    
    .category-sidebar {
        width: 100% !important;
        position: static !important;
        order: -1;
    }
    
    .category-sidebar > div {
        position: static !important;
    }
    
    /* 侧边栏分类改为横向滚动 */
    .category-sidebar .category-item {
        display: inline-block;
        margin-right: 8px;
        margin-bottom: 8px;
    }
}

/* ========================================
   5. 资源卡片移动端优化
   ======================================== */
@media (max-width: 768px) {
    .resources-grid,
    #resourcesGrid,
    #articlesList,
    .learning-courses {
        grid-template-columns: 1fr !important;
        gap: 0;
        padding: 12px 0;
        background: #f5f5f5;
    }
    
    .resource-card {
        padding: 14px 16px;
        gap: 10px;
        border-radius: 12px;
        border: none;
        margin: 0 12px 12px 12px;
        position: relative;
        min-height: 100px;
        background: white;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    }
    
    .resource-card:hover {
        box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    }
    
    .resource-card:active {
        transform: scale(0.99);
    }
    
    .resource-main {
        flex-direction: row;
        gap: 12px;
        align-items: flex-start;
        padding-right: 70px;
    }
    
    .resource-icon {
        display: none !important;
    }
    
    .resource-body {
        flex: 1;
        min-width: 0;
    }
    
    .resource-title {
        font-size: 14px;
        font-weight: 500;
        line-height: 1.5;
        margin-bottom: 6px;
        color: #333;
        /* 限制2行 */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .resource-meta-row {
        gap: 6px;
        flex-wrap: wrap;
        margin-bottom: 5px;
    }
    
    .resource-tag {
        font-size: 10px;
        padding: 2px 6px;
        border-radius: 2px;
        font-weight: 500;
    }
    
    /* PDF标签红色 */
    .resource-tag:first-child {
        background: #ef4444 !important;
        color: white !important;
    }
    
    /* 会员标签 */
    .resource-tag:nth-child(2) {
        background: #fee2e2 !important;
        color: #ef4444 !important;
    }
    
    .resource-stats-row {
        font-size: 10px;
        gap: 10px;
        flex-wrap: wrap;
        color: #999;
    }
    
    .resource-stats-row span {
        display: flex;
        align-items: center;
        gap: 3px;
    }
    
    .resource-actions {
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        flex-direction: column;
        width: auto;
        gap: 5px;
    }
    
    .resource-actions button {
        padding: 5px 10px;
        font-size: 11px;
        white-space: nowrap;
        border-radius: 3px;
        min-width: 54px;
    }
    
    /* 下载按钮样式 */
    .resource-actions button:first-child {
        background: #ef4444 !important;
        color: white !important;
        border: none;
    }
    
    /* 收藏按钮样式 */
    .resource-actions button:last-child {
        background: #fff1f0 !important;
        color: #ef4444 !important;
        border: 1px solid #ffccc7;
    }
}

/* ========================================
   6. 筛选器移动端优化
   ======================================== */
@media (max-width: 768px) {
    .filter-tabs,
    .filter-bar {
        gap: 8px;
        padding: 10px 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        background: white;
        margin-bottom: 0;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .filter-tab {
        font-size: 13px;
        padding: 6px 14px;
        white-space: nowrap;
        border-radius: 14px;
        background: #f5f5f5;
        color: #666;
        border: none;
    }
    
    .filter-tab.active {
        background: #ef4444 !important;
        color: white !important;
    }
    
    /* 搜索框 */
    .search-container {
        padding: 10px 16px;
        margin-bottom: 0 !important;
        background: white;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .main-search-form {
        width: 100%;
        position: relative;
    }
    
    .search-input-wrapper {
        width: 100%;
        background: #f5f5f5;
        border-radius: 18px;
        border: none;
        display: flex;
        align-items: center;
    }
    
    .main-search-input {
        font-size: 13px;
        padding: 8px 40px 8px 36px;
        background: #f5f5f5;
        border: none;
        border-radius: 18px;
        height: 36px;
    }
    
    .main-search-input::placeholder {
        color: #999;
    }
    
    .search-submit-btn {
        font-size: 16px;
        color: #999;
        left: 12px;
        position: absolute;
    }
}

/* ========================================
   7. 弹窗优化
   ======================================== */
@media (max-width: 768px) {
    .modal {
        padding: 16px;
        align-items: flex-end;
    }
    
    .modal-content {
        max-width: 100% !important;
        width: 100%;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
        margin: 0;
    }
    
    .modal-header {
        padding: 16px;
    }
    
    .modal-body {
        padding: 16px;
        max-height: 70vh;
    }
    
    .modal-footer {
        padding: 16px;
        gap: 12px;
    }
    
    .modal-footer button {
        flex: 1;
    }
    
    /* 登录弹窗 */
    .login-modal .modal-content,
    .payment-modal .modal-content {
        max-width: 100% !important;
        border-radius: 16px 16px 0 0;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* 防止iOS自动缩放 */
    }
}

/* ========================================
   8. 按钮优化
   ======================================== */
@media (max-width: 768px) {
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-outline {
        padding: 10px 20px;
        font-size: 14px;
        min-height: 44px; /* iOS点击目标最小尺寸 */
    }
    
    .btn-group {
        flex-direction: column;
        gap: 12px;
    }
    
    .btn-group button {
        width: 100%;
    }
}

/* ========================================
   9. 表格优化
   ======================================== */
@media (max-width: 768px) {
    .data-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
        font-size: 13px;
    }
    
    th, td {
        padding: 8px 10px;
        white-space: nowrap;
    }
}

/* ========================================
   10. 会员/课程页面优化
   ======================================== */
@media (max-width: 768px) {
    /* 学习进度卡片 */
    .learning-courses {
        grid-template-columns: 1fr !important;
    }
    
    .course-card {
        padding: 12px;
    }
    
    .course-card img {
        height: 120px;
    }
    
    /* 会员价格卡片 */
    .pricing-cards {
        flex-direction: column;
        gap: 16px;
    }
    
    .pricing-card {
        width: 100%;
    }
    
    /* 分类侧边栏 */
    .category-sidebar {
        display: none;
    }
    
    /* 显示移动端分类选择器 */
    .mobile-category-selector {
        display: block;
        padding: 12px 16px;
        background: white;
        border-bottom: 1px solid #eee;
    }
}

/* ========================================
   11. 页脚优化
   ======================================== */
@media (max-width: 768px) {
    .footer {
        padding: 24px 16px;
        text-align: center;
    }
    
    .footer p {
        font-size: 13px;
    }
}

/* ========================================
   12. 无限滚动加载优化
   ======================================== */
@media (max-width: 768px) {
    .loading-more {
        padding: 20px;
        font-size: 14px;
    }
    
    .no-more-data {
        padding: 20px;
        font-size: 13px;
    }
}

/* ========================================
   13. Toast通知优化
   ======================================== */
@media (max-width: 768px) {
    .global-toast {
        bottom: 20px;
        left: 16px;
        right: 16px;
        transform: translateX(0) translateY(20px);
        width: auto;
        font-size: 13px;
        padding: 10px 16px;
    }
    
    .global-toast.show {
        transform: translateX(0) translateY(0);
    }
}

/* ========================================
   14. 下拉菜单优化
   ======================================== */
@media (max-width: 768px) {
    .nav-dropdown-menu {
        font-size: 14px;
    }
    
    .nav-dropdown-item {
        padding: 12px 16px;
    }
    
    .nav-dropdown-item-icon {
        font-size: 18px;
    }
}

/* ========================================
   15. 文章详情页优化
   ======================================== */
@media (max-width: 768px) {
    .article-content {
        padding: 16px;
        font-size: 15px;
        line-height: 1.7;
    }
    
    .article-content img {
        max-width: 100%;
        height: auto;
    }
    
    .article-content pre {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================
   16. 特殊小屏幕优化 (iPhone SE等)
   ======================================== */
@media (max-width: 375px) {
    .container {
        padding: 0 12px;
    }
    
    .resource-card {
        padding: 10px;
    }
    
    .resource-title {
        font-size: 14px;
    }
    
    .resource-tag {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .navbar .container {
        padding: 0 8px;
    }
}

/* ========================================
   17. 横屏模式优化
   ======================================== */
@media (max-width: 768px) and (orientation: landscape) {
    .hero,
    .page-header {
        padding: 24px 16px !important;
    }
    
    .modal {
        padding: 8px;
    }
    
    .modal-content {
        max-height: 85vh;
    }
}

/* ========================================
   18. 触摸优化
   ======================================== */
@media (max-width: 768px) {
    /* 增大点击区域 */
    a, button {
        min-height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 移除hover效果，使用active */
    .resource-card:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }
    
    .resource-card:active {
        transform: scale(0.98);
        background: #f9fafb;
    }
    
    button:active {
        transform: scale(0.95);
    }
}

/* ========================================
   19. 防止缩放优化
   ======================================== */
@media (max-width: 768px) {
    /* 防止input聚焦时页面缩放 */
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* 防止双击缩放 */
    * {
        touch-action: manipulation;
    }
}

/* ========================================
   20. 性能优化
   ======================================== */
@media (max-width: 768px) {
    /* 减少阴影提升性能 */
    .resource-card {
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    }
    
    /* 简化动画 */
    * {
        transition-duration: 0.15s !important;
    }
    
    /* GPU加速 */
    .modal-content,
    .nav-avatar-dropdown {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
}

/* ========================================
   21. 悬浮按钮 - 登录/小程序
   ======================================== */
@media (max-width: 768px) {
    /* 隐藏导航栏的登录按钮 */
    .navbar-end .btn-outline {
        display: none !important;
    }
    
    /* 悬浮登录按钮 */
    .floating-login-btn {
        position: fixed;
        top: 90px;
        right: 16px;
        bottom: auto;
        width: 56px;
        height: 56px;
        background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
        border-radius: 50%;
        box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 998;
        cursor: pointer;
        transition: all 0.3s;
        color: white;
        font-size: 13px;
        font-weight: 600;
        text-align: center;
        line-height: 1.2;
        padding: 8px;
    }
    
    .floating-login-btn:active {
        transform: scale(0.95);
    }
    
    /* 小程序码弹窗 */
    .miniprogram-modal {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        z-index: 999;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }
    
    .miniprogram-modal.show {
        display: flex;
    }
    
    .miniprogram-content {
        background: white;
        border-radius: 16px;
        padding: 24px;
        text-align: center;
        max-width: 320px;
        width: 100%;
    }
    
    .miniprogram-content h3 {
        font-size: 18px;
        margin-bottom: 16px;
        color: #333;
    }
    
    .miniprogram-qrcode {
        width: 200px;
        height: 200px;
        margin: 0 auto 16px;
        background: #f5f5f5;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .miniprogram-content p {
        font-size: 13px;
        color: #666;
        margin-bottom: 16px;
    }
    
    .miniprogram-close {
        background: #ef4444;
        color: white;
        border: none;
        border-radius: 8px;
        padding: 10px 24px;
        font-size: 14px;
        cursor: pointer;
    }
}

/* ========================================
   22. 置顶悬浮按钮
   ======================================== */
@media (max-width: 768px) {
    .scroll-to-top {
        position: fixed;
        bottom: 50px;
        right: 20px;
        width: 48px;
        height: 48px;
        background: rgba(255, 255, 255, 0.95);
        border: 1px solid #e5e5e5;
        border-radius: 50%;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        display: none;
        align-items: center;
        justify-content: center;
        z-index: 997;
        cursor: pointer;
        transition: all 0.3s;
        color: #666;
        font-size: 20px;
    }
    
    .scroll-to-top.show {
        display: flex;
    }
    
    .scroll-to-top:active {
        transform: scale(0.95);
        background: #f5f5f5;
    }
    
    .scroll-to-top svg,
    .scroll-to-top i {
        width: 24px;
        height: 24px;
    }
}
@media (max-width: 768px) {
    .site-footer .footer-top {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 16px;
    }

    .site-footer .footer-left {
        text-align: center;
    }

    .site-footer .footer-center {
        align-self: center;
        text-align: center;
    }

    .site-footer .footer-right {
        display: none;
    }

    .site-footer .back-to-top {
        border: none;
        background: transparent;
        padding: 0;
        font-size: 14px;
    }

    .site-footer .footer-right .qr-row {
        flex-direction: column;
        gap: 12px;
    }

    .site-footer .footer-right .qr-block {
        align-items: center;
    }

    .site-footer .footer-right img {
        width: 120px;
        height: 120px;
    }

    .site-footer .footer-right .qr-title,
    .site-footer .footer-right .qr-caption {
        font-size: 13px;
    }

    .site-footer .footer-banner {
        height: 200px;
    }

    .site-footer .footer-banner .banner-text {
        font-size: 120px;
        letter-spacing: 4px;
    }
}
