/* ================================
   SoftHub Theme - Mobile Responsive
   ================================ */

/* Base Reset for Mobile */
* {
    -webkit-tap-highlight-color: transparent;
}

body {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

img,
video,
iframe {
    max-width: 100%;
    height: auto;
}

/* Container */
.container {
    padding-left: 16px;
    padding-right: 16px;
}

/* Global Mobile Overrides */
@media (max-width: 768px) {
    html,
    body {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 0 !important;
        overflow-x: hidden;
    }

    body {
        font-size: 14px;
        line-height: 1.6;
    }

    .container,
    .w1200,
    .contains {
        max-width: 100% !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    table {
        width: 100% !important;
    }
}

/* Header Mobile */
@media (max-width: 768px) {
    .sticky-header {
        top: 0;
    }
    
    .logo-box {
        width: 36px;
        height: 36px;
    }
    
    .logo-box i {
        font-size: 18px;
    }
    
    /* Hide desktop nav */
    .header-nav {
        display: none !important;
    }
    
    /* Mobile search full width */
    .header-search-mobile {
        display: block !important;
        width: 100%;
        flex: 1;
        margin: 0 12px;
    }
    
    .header-search-desktop {
        display: none !important;
    }
    
    /* Menu button */
    .header-menu-btn {
        display: block !important;
        margin-left: auto;
    }
}

/* Hero Section Mobile */
@media (max-width: 768px) {
    .hero-section {
        padding: 32px 0 !important;
    }
    
    .hero-section h2 {
        font-size: 24px !important;
        margin-bottom: 12px !important;
    }
    
    .hero-section p {
        font-size: 14px !important;
        margin-bottom: 24px !important;
    }
    
    .hero-stat-card {
        padding: 12px !important;
        min-width: 120px;
    }
    
    .hero-stat-card h3 {
        font-size: 14px !important;
        margin-bottom: 4px !important;
    }
    
    .hero-stat-card p {
        font-size: 11px !important;
    }
    
    .hero-floating-icon {
        display: none !important;
    }
}

/* Category Section Mobile */
@media (max-width: 768px) {
    #categoriesSection {
        padding: 20px 0 !important;
    }
    
    #categoriesSection h3 {
        font-size: 18px !important;
        margin-bottom: 16px !important;
    }
    
    #categoriesSection .grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }
    
    .category-card {
        padding: 8px !important;
    }
    
    .category-card i {
        font-size: 20px !important;
    }
    
    .category-card h4 {
        font-size: 12px !important;
    }
}

/* About Page Mobile */
@media (max-width: 768px) {
    .about_tabs {
        width: 100% !important;
        float: none !important;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-start;
        padding: 12px 0;
        margin-bottom: 12px;
    }

    .about_tabs li {
        flex: 0 0 auto;
        padding: 6px 12px;
        border-radius: 9999px;
        background-color: #f3f4f6;
        font-size: 13px;
        line-height: 20px;
    }

    .about_tabs li.on {
        background-color: #ff6f06;
        color: #fff;
    }

    .about_sheet {
        margin-left: 0 !important;
        min-height: auto !important;
    }

    .about_sheet h1 {
        font-size: 18px !important;
    }

    .about_sheet p {
        font-size: 14px !important;
        line-height: 1.8 !important;
    }

    .about_sheet strong {
        font-size: 15px !important;
    }

    .about_sheet .links li {
        width: 50% !important;
    }

    .about_sheet form > div {
        grid-template-columns: 1fr !important;
    }

    .about_sheet form button {
        width: 100% !important;
    }
}

/* Legacy Template Mobile Overrides */
@media (max-width: 768px) {
    .crumb {
        padding: 10px 0;
        font-size: 12px;
    }

    .crumb .w1200 {
        padding-left: 16px;
        padding-right: 16px;
        white-space: normal;
    }

    .index_wrap,
    .detail_wrap,
    .phb_wrap,
    .contains {
        width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .fl,
    .fr,
    .fl_wrap,
    .fr_wrap {
        float: none !important;
        width: 100% !important;
    }

    .padding20 {
        padding: 16px !important;
    }

    .title_gray,
    .title_black,
    .title_yellow {
        height: auto;
    }

    .title_gray h2,
    .title_gray h3,
    .title_black h3,
    .title_yellow h3 {
        font-size: 16px !important;
        line-height: 1.4 !important;
        margin-top: 0 !important;
    }

    .title_gray .more {
        float: none !important;
        display: inline-block !important;
        width: auto !important;
        margin-top: 8px;
    }

    .index_tab_wrap .tab_menu {
        position: static !important;
        display: flex !important;
        gap: 12px;
        overflow-x: auto;
        padding: 8px 0;
        white-space: nowrap;
    }

    .index_tab_wrap .tab_menu li {
        float: none !important;
        font-size: 14px !important;
        height: auto !important;
    }

    .index_tab_wrap .tab_menu li span,
    .index_tab_wrap .tab_menu li a {
        padding: 0 12px !important;
        border-left: 0 !important;
        line-height: 1.6 !important;
    }

    .tag_type_wrap {
        display: flex !important;
        flex-wrap: wrap;
        gap: 8px;
    }

    .tag_type_wrap li {
        float: none !important;
        width: auto !important;
    }

    .type_wrap,
    .type_wrap .sub_box {
        width: 100% !important;
    }

    .type_wrap ul {
        width: 100% !important;
        float: none !important;
        border-right: 0 !important;
        margin-right: 0 !important;
    }

    .type_wrap ul li .tag,
    .type_wrap ul li .txt,
    .type_wrap ul li .time {
        width: auto !important;
        float: none !important;
    }

    .warehouse .sub_box ul,
    .game_collection .sub_box ul,
    .game_subject_ul ul,
    .game_subject_tag .cont ul,
    .game_tag .cont ul,
    .phb_type .type_box,
    .phb_type .btn_box {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .warehouse .sub_box ul li,
    .game_collection .sub_box ul li,
    .game_subject_ul ul li,
    .game_subject_tag .cont ul li,
    .game_tag .cont ul li,
    .phb_type .type_box li,
    .phb_type .btn_box li {
        width: 100% !important;
        float: none !important;
        margin: 0 !important;
        box-sizing: border-box;
    }

    .warehouse .sub_box ul li img,
    .game_collection .sub_box ul li img,
    .game_subject_ul ul li img,
    .list_wrap ul li img {
        width: 100% !important;
        height: auto !important;
    }

    .warehouse .sub_box ul li .btn,
    .game_subject_ul ul li .btn,
    .list_wrap ul li .btn {
        display: inline-block;
        padding: 6px 10px !important;
        font-size: 12px !important;
        border-radius: 6px;
    }

    .list_wrap ul {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .list_wrap ul li {
        display: flex;
        gap: 12px;
        align-items: flex-start;
    }

    .list_wrap ul li .img_box img {
        width: 88px !important;
        height: 88px !important;
        object-fit: cover;
        border-radius: 8px;
    }

    .detail_wrap {
        display: block !important;
    }

    .detail_wrap .list_wrap,
    .detail_wrap .fr_wrap {
        width: 100% !important;
    }

    .game_subject_top {
        display: flex !important;
        flex-direction: column;
        gap: 12px;
    }

    .game_subject_top img {
        width: 100% !important;
        height: auto !important;
    }

    .game_subject_top .cont h1 {
        font-size: 20px !important;
    }

    .phb_list,
    .phb_list_right,
    .phb_tuijian,
    .phb_type,
    .phb_jingdian,
    .phb_hotapp {
        width: 100% !important;
        float: none !important;
    }

    .phb_tuijian .cont li,
    .phb_list ul li,
    .phb_r_l ul li {
        display: flex;
        gap: 12px;
        align-items: center;
        flex-wrap: wrap;
    }

    .phb_list ul li {
        flex-direction: column;
        align-items: stretch;
    }

    .phb_list ul li .btn {
        width: 100% !important;
        text-align: center;
    }

    .phb_tuijian .cont li img,
    .phb_list ul li img {
        width: 48px !important;
        height: 48px !important;
    }

    .phb_jingdian .cont dl,
    .phb_hotapp .cont dl {
        width: 100% !important;
        float: none !important;
    }

    .phb_jingdian .cont dd,
    .phb_hotapp .cont dd {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .pagecode {
        text-align: center;
        margin-top: 16px;
    }

    .article-list-wrap {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .category-summary {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .summary-stats {
        width: 100%;
    }

    .article-item {
        flex-direction: column;
        gap: 12px;
    }

    .article-item img {
        width: 100% !important;
        height: 180px !important;
    }

    .article-meta {
        flex-wrap: wrap;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .warehouse .sub_box ul,
    .game_collection .sub_box ul,
    .game_subject_ul ul,
    .game_subject_tag .cont ul,
    .game_tag .cont ul,
    .list_wrap ul,
    .phb_type .type_box,
    .phb_type .btn_box {
        grid-template-columns: 1fr !important;
    }
}

/* Software Grid Mobile */
@media (max-width: 768px) {
    #cardView {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    
    .software-card {
        border-radius: 8px !important;
        overflow: hidden;
    }
    
    .software-card-image {
        height: 120px !important;
    }
    
    .software-card-body {
        padding: 12px !important;
    }
    
    .software-card-body h4 {
        font-size: 14px !important;
        margin-bottom: 6px !important;
    }
    
    .software-card-body p {
        font-size: 11px !important;
        margin-bottom: 8px !important;
    }
    
    .software-card-footer {
        padding: 10px !important;
    }
    
    .btn-primary,
    .btn-success {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
    
    /* View toggle hidden on mobile */
    .view-toggle {
        display: none !important;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    #cardView {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    .hero-section h2 {
        font-size: 32px !important;
    }
    
    .hero-section p {
        font-size: 16px !important;
    }
}

/* Detail Page Mobile */
@media (max-width: 768px) {
    .detail-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .detail-grid > div:first-child {
        grid-column: 1 !important;
    }
    
    .detail-image {
        max-width: 100% !important;
        height: 180px !important;
    }
    
    .detail-badge {
        font-size: 11px !important;
        padding: 4px 8px !important;
    }
    
    h1 {
        font-size: 22px !important;
    }
    
    .download-btn {
        padding: 10px !important;
        font-size: 14px !important;
    }
    
    .sidebar {
        margin-top: 16px;
    }
    
    .sidebar-box {
        padding: 16px !important;
    }
}

/* List Page Mobile */
@media (max-width: 768px) {
    .list-page-header {
        padding: 24px 16px !important;
        margin-bottom: 20px !important;
    }
    
    .list-page-header h1 {
        font-size: 22px !important;
    }
    
    .list-page-header p {
        font-size: 13px !important;
    }
    
    .category-filter {
        padding: 12px !important;
        gap: 8px !important;
    }
    
    .category-filter a {
        padding: 6px 12px !important;
        font-size: 13px !important;
    }
    
    .article-item {
        padding: 16px !important;
        border-radius: 8px !important;
    }
    
    .article-item img {
        width: 100% !important;
        height: 160px !important;
    }
    
    .article-content h3 {
        font-size: 16px !important;
    }
    
    .article-content p {
        font-size: 13px !important;
    }
    
    .sidebar {
        display: none !important;
    }
    
    .pagination {
        gap: 6px !important;
    }
    
    .pagination a,
    .pagination span {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }
}

/* Footer Mobile */
@media (max-width: 768px) {
    .footer-section {
        padding: 40px 0 !important;
    }
    
    .footer-logo-box {
        width: 40px !important;
        height: 40px !important;
    }
    
    .footer-section h4 {
        font-size: 18px !important;
    }
    
    .footer-section p {
        font-size: 13px !important;
        line-height: 1.6 !important;
    }
    
    .footer-social-btn {
        width: 36px !important;
        height: 36px !important;
    }
}

/* Utility Classes */
.hidden-mobile {
    display: block;
}

@media (max-width: 768px) {
    .hidden-mobile {
        display: none !important;
    }
}

.visible-mobile {
    display: none !important;
}

@media (max-width: 768px) {
    .visible-mobile {
        display: block !important;
    }
}

/* Touch-friendly buttons */
@media (max-width: 768px) {
    button,
    a.btn-primary,
    a.btn-success,
    .category-card,
    .filter-tab {
        min-height: 44px;
    }
}

/* Improve text readability on mobile */
@media (max-width: 768px) {
    body {
        font-size: 14px;
        line-height: 1.6;
    }
    
    h1 {
        font-size: 24px;
    }
    
    h2 {
        font-size: 20px;
    }
    
    h3 {
        font-size: 18px;
    }
    
    h4 {
        font-size: 16px;
    }
}
