/**
 * Gangwan Zhunong - Mobile Styles
 * 港湾助农平台移动端适配样式
 */

/* ============================================
   桌面端：移动端菜单元素默认完全隐藏
   ============================================ */
.gw-mobile-menu-toggle,
.gw-mobile-menu,
.gw-mobile-menu-overlay {
    display: none;
}

/* ============================================
   响应式断点
   ============================================ */

/* 大屏幕 */
@media (min-width: 1200px) {
    .gw-desktop-only { display: block; }
    .gw-mobile-only { display: none; }
}

/* 平板 */
@media (min-width: 768px) and (max-width: 1199px) {
    .gw-desktop-only { display: none; }
    .gw-mobile-only { display: none; }
}

/* 移动端 */
@media (max-width: 767px) {
    .gw-desktop-only { display: none !important; }
    .gw-mobile-only { display: block !important; }
    
    /* 隐藏桌面端菜单 */
    .gw-desktop-nav { display: none !important; }
    
    /* 移动端菜单按钮 */
    .gw-mobile-menu-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: space-between;
        width: 30px;
        height: 24px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
        margin-right: 15px;
    }
    
    .gw-mobile-menu-toggle span {
        display: block;
        width: 100%;
        height: 3px;
        background: #faf9f6;
        border-radius: 2px;
        transition: transform 0.3s, opacity 0.3s;
    }
    
    /* 汉堡菜单动画 */
    .gw-mobile-menu-toggle.active span:nth-child(1) {
        transform: translateY(10px) rotate(45deg);
    }
    
    .gw-mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .gw-mobile-menu-toggle.active span:nth-child(3) {
        transform: translateY(-10px) rotate(-45deg);
    }
    
    /* 移动端菜单面板 */
    .gw-mobile-menu {
        display: block;
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        background: #1b4332;
        z-index: 10000;
        padding: 80px 30px 30px;
        transition: right 0.3s ease-in-out;
        box-shadow: -5px 0 20px rgba(0,0,0,0.3);
        overflow-y: auto;
    }
    
    .gw-mobile-menu.active {
        right: 0;
    }
    
    /* 菜单关闭按钮 */
    .gw-mobile-menu-close {
        position: absolute;
        top: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        background: none;
        border: none;
        color: #faf9f6;
        font-size: 2rem;
        cursor: pointer;
    }
    
    /* 移动端菜单项 */
    .gw-mobile-menu ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    
    .gw-mobile-menu li {
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .gw-mobile-menu a {
        display: block;
        color: #faf9f6;
        padding: 15px 0;
        font-size: 1.1rem;
        text-decoration: none;
        transition: color 0.2s;
    }
    
    .gw-mobile-menu a:hover {
        color: #c99738;
    }
    
    /* 移动端菜单遮罩 */
    .gw-mobile-menu-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 9999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s;
    }
    
    .gw-mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

/* ============================================
   移动端头部
   ============================================ */

@media (max-width: 767px) {
    .gw-header {
        position: sticky;
        top: 0;
        z-index: 9998;
        padding: 12px 15px !important;
    }
    
    .gw-header-inner {
        justify-content: space-between !important;
    }
    
    .gw-logo {
        font-size: 1.3rem !important;
    }
    
    .gw-header-contact {
        display: none;
    }
}

/* ============================================
   移动端首页
   ============================================ */

@media (max-width: 767px) {
    .gw-hero {
        padding: 40px 15px !important;
        min-height: auto !important;
    }
    
    .gw-hero h1 {
        font-size: 1.8rem !important;
        line-height: 1.4 !important;
    }
    
    .gw-hero p {
        font-size: 1rem !important;
    }
    
    .gw-stats {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .gw-advantage-grid {
        grid-template-columns: 1fr !important;
    }
    
    .gw-product-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .gw-contact-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   移动端产品页
   ============================================ */

@media (max-width: 767px) {
    .gw-single-product .gw-product-grid {
        grid-template-columns: 1fr !important;
    }
    
    .gw-product-image {
        height: 250px !important;
    }
    
    .gw-product-info {
        padding: 20px !important;
    }
    
    .gw-product-title {
        font-size: 1.5rem !important;
    }
    
    .gw-contact-panel {
        padding: 20px !important;
    }
    
    .gw-contact-buttons {
        flex-direction: column !important;
    }
    
    .gw-contact-buttons > * {
        width: 100% !important;
        text-align: center !important;
    }
}

/* ============================================
   移动端产品归档页
   ============================================ */

@media (max-width: 767px) {
    .gw-filter-bar {
        padding: 15px !important;
    }
    
    .gw-filter-taxonomy {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .gw-filter-taxonomy a {
        padding: 5px 12px !important;
        font-size: 0.85rem !important;
    }
    
    .gw-products-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .gw-archive-header h1 {
        font-size: 1.8rem !important;
    }
}

/* ============================================
   移动端农户详情页
   ============================================ */

@media (max-width: 767px) {
    .gw-farmer-profile {
        padding: 30px 20px !important;
    }
    
    .gw-farmer-profile > div {
        flex-direction: column !important;
        text-align: center !important;
    }
    
    .gw-farmer-avatar img {
        width: 120px !important;
        height: 120px !important;
    }
    
    .gw-farmer-info h1 {
        font-size: 1.8rem !important;
    }
    
    .gw-farmer-info > div:last-child {
        justify-content: center !important;
    }
}

/* ============================================
   移动端页脚
   ============================================ */

@media (max-width: 767px) {
    .gw-footer-grid {
        grid-template-columns: 1fr !important;
        text-align: center;
    }
    
    .gw-footer h3 {
        margin-top: 20px;
    }
}

/* ============================================
   移动端表单
   ============================================ */

@media (max-width: 767px) {
    .gw-register-form {
        padding: 25px 20px !important;
    }
    
    .gw-register-form input,
    .gw-register-form textarea,
    .gw-register-form select {
        font-size: 16px !important; /* 防止 iOS 缩放 */
    }
    
    .gw-register-form > div:nth-child(3) {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   移动端辅助类
   ============================================ */

@media (max-width: 767px) {
    .gw-container {
        padding: 0 15px;
    }
    
    .gw-btn {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
    
    .gw-btn-primary {
        width: 100%;
        text-align: center;
    }
    
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.2rem; }
    
    /* 返回顶部按钮位置调整 */
    #gw-back-to-top {
        bottom: 20px !important;
        right: 20px !important;
        width: 45px !important;
        height: 45px !important;
    }
}

/* ============================================
   触摸设备优化
   ============================================ */

@media (hover: none) and (pointer: coarse) {
    /* 移除悬停效果（触摸设备无悬停） */
    .gw-product-card:hover {
        transform: none !important;
    }
    
    .gw-btn:hover {
        transform: none !important;
    }
    
    /* 增加触摸目标大小 */
    .gw-btn,
    a,
    button {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* 去除链接下划线（移动端通常不需要） */
    a:not(.gw-btn):not(.gw-cta-button) {
        text-decoration: none;
    }
}

/* ============================================
   安全区域适配（iPhone X 及以上）
   ============================================ */

@supports (padding: max(0px)) {
    .gw-header {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
    
    #gw-back-to-top {
        right: max(20px, env(safe-area-inset-right));
        bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* ============================================
   新增 Section 响应式适配
   （平台定位说明 + 采购流程 + 全局声明条）
   ============================================ */

/* 平板及以下：平台定位说明区两栏变单栏 */
@media (max-width: 900px) {
    .gw-platform-intro > div > div:first-child {
        display: block !important;
        grid-template-columns: 1fr !important;
    }
    .gw-platform-intro > div > div > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}

/* 移动端：采购流程图四列变两列 */
@media (max-width: 768px) {
    .gw-process-section > div > div[style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .gw-platform-intro > div > div {
        grid-template-columns: 1fr !important;
    }
}

/* 小屏手机：采购流程图两列变单列 */
@media (max-width: 480px) {
    .gw-process-section > div > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* 全局声明条内边距缩小 */
    .gw-global-disclaimer > div {
        flex-direction: column;
        gap: 8px !important;
    }

    /* 顶部公告栏文字缩小 */
    #gw-top-notice {
        font-size: 0.78rem !important;
        padding: 6px 30px 6px 12px !important;
    }
}

/* 桌面端显示采购流程连接线 */
@media (min-width: 769px) {
    .gw-process-line {
        display: block !important;
    }
}

/* 采购流程卡片悬停效果 */
.gw-process-section > div > div[style*="border-radius: 16px"]:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1) !important;
}