/**
 * 响应式设计增强 - Responsive Design Enhancement
 * 柚果国际 www.weqoo.net
 * 针对PC/平板/移动端的优化
 */

/* ============================================
   1. 响应式断点定义
   ============================================ */

/*
断点规划：
- 移动端（Mobile）: <= 767px
- 平板（Tablet）: 768px - 1199px
- PC端（Desktop）: >= 1200px
*/

/* ============================================
   2. 移动端优先基础样式
   ============================================ */

/* 确保所有元素正确缩放 */
*, *::before, *::after {
    box-sizing: border-box;
}

/* 防止移动端字体自动放大 */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* 移动端触摸优化 */
body {
    -webkit-tap-highlight-color: rgba(146, 37, 49, 0.3);
    -webkit-touch-callout: none;
}

/* 点击区域优化 */
a, button, input[type="button"], input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   3. 导航栏响应式
   ============================================ */

/* 移动端汉堡菜单 */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    padding: 10px;
    cursor: pointer;
}

.mobile-menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--primary-color);
    margin: 5px 0;
    transition: all 0.3s ease;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* 移动端导航菜单 */
@media (max-width: 767px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .main-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background-color: #fff;
        box-shadow: -2px 0 10px rgba(0,0,0,0.1);
        transition: right 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
    }
    
    .main-nav.active {
        right: 0;
    }
    
    .main-nav ul {
        flex-direction: column;
        padding: 60px 20px 20px;
    }
    
    .main-nav li {
        width: 100%;
        margin: 0;
        border-bottom: 1px solid var(--color-gray-200);
    }
    
    .main-nav a {
        display: block;
        padding: 15px 10px;
        font-size: 16px;
    }
    
    /* 移动端遮罩层 */
    .nav-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .nav-overlay.active {
        display: block;
    }
}

/* ============================================
   4. 图片响应式
   ============================================ */

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 图片容器 */
.img-responsive {
    width: 100%;
    height: auto;
}

/* 背景图片响应式 */
.bg-cover {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* ============================================
   5. 表格响应式
   ============================================ */

@media (max-width: 767px) {
    /* 移动端表格滚动 */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    /* 或使用卡片式布局 */
    .table-card {
        display: block;
        border: 1px solid var(--color-gray-200);
        margin-bottom: 10px;
        padding: 15px;
        border-radius: var(--radius-md);
    }
    
    .table-card tr {
        display: block;
        margin-bottom: 10px;
    }
    
    .table-card td {
        display: block;
        text-align: left !important;
        padding: 5px 0;
    }
    
    .table-card td:before {
        content: attr(data-label);
        font-weight: bold;
        margin-right: 10px;
    }
}

/* ============================================
   6. 栅格系统
   ============================================ */

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -15px;
}

.col {
    padding: 0 15px;
    flex: 1;
}

/* 移动端全宽 */
@media (max-width: 767px) {
    .col {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* 平板端 */
@media (min-width: 768px) and (max-width: 1199px) {
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
}

/* PC端 */
@media (min-width: 1200px) {
    .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
    .col-lg-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
}

/* ============================================
   7. 内容区域响应式
   ============================================ */

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

@media (max-width: 767px) {
    .container {
        padding: 0 10px;
    }
    
    /* 移动端内边距调整 */
    .section {
        padding: 30px 0;
    }
    
    .card {
        padding: 15px;
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .container {
        max-width: 960px;
    }
}

/* ============================================
   8. 字体响应式
   ============================================ */

@media (max-width: 767px) {
    h1 { font-size: 24px; }
    h2 { font-size: 20px; }
    h3 { font-size: 18px; }
    h4 { font-size: 16px; }
    h5 { font-size: 14px; }
    h6 { font-size: 13px; }
    
    body { font-size: 14px; }
}

@media (min-width: 768px) and (max-width: 1199px) {
    h1 { font-size: 28px; }
    h2 { font-size: 24px; }
    h3 { font-size: 20px; }
    h4 { font-size: 18px; }
}

/* ============================================
   9. 按钮响应式
   ============================================ */

@media (max-width: 767px) {
    .btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 16px;
    }
    
    .btn-group .btn {
        width: auto;
        margin: 5px;
    }
}

/* ============================================
   10. 表单响应式
   ============================================ */

@media (max-width: 767px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    textarea,
    select {
        width: 100%;
        font-size: 16px; /* 防止iOS自动缩放 */
        padding: 12px;
    }
    
    .form-inline {
        flex-direction: column;
    }
    
    .form-inline input,
    .form-inline button {
        width: 100%;
        margin-bottom: 10px;
    }
}

/* ============================================
   11. 卡片布局响应式
   ============================================ */

.card-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

@media (max-width: 767px) {
    .card-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   12. 语言切换按钮响应式
   ============================================ */

.lang-switch {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    padding: 8px 16px;
    font-size: 14px;
}

@media (max-width: 767px) {
    .lang-switch {
        top: 10px;
        right: 10px;
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* ============================================
   13. 工具类 - 显示/隐藏
   ============================================ */

/* 移动端隐藏 */
@media (max-width: 767px) {
    .hide-mobile { display: none !important; }
}

/* 平板隐藏 */
@media (min-width: 768px) and (max-width: 1199px) {
    .hide-tablet { display: none !important; }
}

/* PC端隐藏 */
@media (min-width: 1200px) {
    .hide-desktop { display: none !important; }
}

/* 只在移动端显示 */
.show-mobile {
    display: none !important;
}

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

/* ============================================
   14. 性能优化
   ============================================ */

/* 硬件加速 */
.accelerate {
    transform: translateZ(0);
    will-change: transform;
}

/* 平滑滚动 */
html {
    /* 修复（2026-09-17）：去除全局 scroll-behavior: smooth，
       与 css/design-system.css 同步处理，避免任何“吸回”的视觉错觉 */
    scroll-behavior: auto;
}

/* 减少移动端动画 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   15. 触摸优化
   ============================================ */

/* 移动端链接点击区域 */
@media (max-width: 767px) {
    a {
        padding: 5px;
        margin: -5px;
    }
    
    button {
        padding: 12px 20px;
    }
}

/* 滚动优化 */
.scroll-container {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* ============================================
   16. 横向滚动（移动端）
   ============================================ */

@media (max-width: 767px) {
    .horizontal-scroll {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: 15px;
        padding-bottom: 10px;
    }
    
    .horizontal-scroll > * {
        flex: 0 0 80%;
        scroll-snap-align: start;
    }
    
    /* 隐藏滚动条但保持功能 */
    .horizontal-scroll::-webkit-scrollbar {
        display: none;
    }
}

/* ============================================
   17. 招聘列表响应式优化
   ============================================ */

@media (max-width: 767px) {
    .job-list li {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .job-list .job-title {
        font-size: 16px;
        margin-bottom: 5px;
    }
    
    .job-list .job-meta {
        font-size: 13px;
        color: var(--color-gray-600);
    }
}

/* ============================================
   18. 新闻列表响应式
   ============================================ */

@media (max-width: 767px) {
    .news-item {
        flex-direction: column;
    }
    
    .news-item img {
        width: 100%;
        margin-bottom: 15px;
    }
    
    .news-content {
        width: 100%;
    }
}

/* ============================================
   19. 产品列表响应式
   ============================================ */

.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

@media (max-width: 767px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
}

/* ============================================
   20. 页脚响应式
   ============================================ */

@media (max-width: 767px) {
    .footer {
        text-align: center;
    }
    
    .footer-columns {
        flex-direction: column;
    }
    
    .footer-column {
        width: 100%;
        margin-bottom: 30px;
    }
}

/* ============================================
   21. 性能监控标记
   ============================================ */

/* 用于性能测试的视觉标记 */
.perf-marker {
    position: fixed;
    bottom: 10px;
    left: 10px;
    background: rgba(146, 37, 49, 0.8);
    color: white;
    padding: 5px 10px;
    font-size: 11px;
    border-radius: 3px;
    z-index: 9999;
    display: none;
}

@media (max-width: 767px) {
    .perf-marker {
        display: block;
    }
    .perf-marker::after {
        content: " Mobile";
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .perf-marker::after {
        content: " Tablet";
    }
}

@media (min-width: 1200px) {
    .perf-marker::after {
        content: " Desktop";
    }
}
