/* ==========================================
   Mobile H5 优化
   普慧康泰 - 移动端H5专项优化
   ========================================== */

/* 防止iOS Safari自动缩放文本 */
body {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* 防止双击缩放 */
* {
    touch-action: manipulation;
}

/* 优化触摸滚动 */
.main,
.article-content,
.news-list,
.nav-menu {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* 移动端优化的输入框 */
input,
textarea,
select {
    font-size: 16px !important;
    /* 防止iOS自动缩放 */
}

/* 移动端按钮触摸优化 */
.btn,
button,
a {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    outline: none;
}

.btn:active,
button:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* 移动端卡片点击效果 */
.card,
.product-card,
.solution-card,
.news-card,
.honor-card {
    -webkit-tap-highlight-color: transparent;
}

/* 移动端图片优化 */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 移动端视频优化 */
video,
iframe {
    max-width: 100%;
}

/* 移动端表格优化 */
table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

/* 移动端长文本优化 */
.article-content {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* 移动端链接优化 */
a {
    text-decoration: none;
    color: inherit;
}

/* ==========================================
   移动端安全区域适配（刘海屏等）
   ========================================== */
@supports (padding: max(0px)) {
    .header {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }

    .footer {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .nav-menu {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* ==========================================
   移动端导航菜单优化
   ========================================== */
@media (max-width: 991px) {
    /* 汉堡菜单按钮 - 小尺寸 */
    .nav-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        width: 24px;
        height: 20px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        margin-left: 0.75rem;
    }

    .nav-toggle span {
        display: block;
        width: 20px;
        height: 2px;
        background: var(--color-gray-900);
        margin: 2px 0;
        transition: all 0.3s ease;
        border-radius: 2px;
    }

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

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

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

    /* 导航菜单容器 */
    .nav-menu {
        position: fixed;
        top: var(--header-height, 70px);
        left: -100%;
        width: 100%;
        height: calc(100vh - var(--header-height, 70px));
        background: var(--color-white);
        flex-direction: column;
        padding: var(--spacing-6);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        transition: left 0.3s ease;
        z-index: 999;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .nav-menu.active {
        left: 0;
    }

    /* 导航列表 */
    .nav-list {
        flex-direction: column;
        width: 100%;
        padding: 0;
    }

    /* 导航项 */
    .nav-item {
        width: 100%;
        border-bottom: 1px solid var(--color-gray-100);
    }

    /* 导航链接 */
    .nav-link {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1rem;
        font-size: 1rem;
        min-height: 52px;
        color: var(--color-gray-900);
    }

    .nav-link:active {
        background: var(--color-gray-50);
    }

    /* 下拉图标 */
    .nav-dropdown-icon {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
        transition: transform 0.3s ease;
    }

    .nav-dropdown.expanded .nav-dropdown-icon {
        transform: rotate(180deg);
    }

    /* 移动端下拉内容 */
    .nav-dropdown-content {
        display: none;
        background: var(--color-gray-50);
        animation: slideDown 0.3s ease;
    }

    .nav-dropdown.expanded .nav-dropdown-content {
        display: block;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* 移动端分区标题 */
    .nav-mobile-section-title {
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--color-gray-500);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        padding: 0.75rem 1rem 0.5rem;
        margin: 0;
    }

    /* 移动端链接项 */
    .nav-mobile-item {
        display: block;
        padding: 0.875rem 1rem;
        color: var(--color-gray-700);
        text-decoration: none;
        font-size: 0.9375rem;
        border-bottom: 1px solid var(--color-gray-100);
        transition: background 0.2s ease, color 0.2s ease;
    }

    .nav-mobile-item:last-child {
        border-bottom: none;
    }

    .nav-mobile-item:active {
        background: var(--color-gray-100);
        color: var(--color-primary);
    }

}

/* ==========================================
   移动端横屏优化
   ========================================== */
@media (orientation: landscape) and (max-height: 600px) {
    .hero {
        min-height: 100vh;
        padding: 1rem 0;
    }

    .hero-content {
        padding-top: 2rem;
    }

    .header {
        padding: 0.5rem 1rem;
    }

    .logo-img {
        height: 30px;
    }

    .nav-toggle {
        height: 20px;
        width: 24px;
    }

    .nav-toggle span {
        width: 20px;
    }

    .nav-menu {
        top: 60px;
        height: calc(100vh - 60px);
    }
}

/* ==========================================
   移动端暗黑模式适配
   ========================================== */
@media (prefers-color-scheme: dark) {
    /* 可选：添加暗黑模式支持 */
    body {
        background-color: #000;
        color: #fff;
    }

    .header {
        background: rgba(0, 0, 0, 0.98);
    }

    .card {
        background: #1c1c1e;
    }

    .nav-menu {
        background: #000;
    }

    .nav-link {
        color: #fff;
    }

    .nav-dropdown-content {
        background: #1c1c1e;
    }
}

/* ==========================================
   移动端减少动画（性能优化）
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================
   移动端轮播图优化
   ========================================== */
@media (max-width: 767px) {
    .hero-carousel-nav {
        bottom: 1rem;
    }

    .carousel-dot {
        width: 8px;
        height: 8px;
    }

    .carousel-arrow {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .carousel-arrow.prev {
        left: 0.5rem;
    }

    .carousel-arrow.next {
        right: 0.5rem;
    }
}

/* ==========================================
   移动端表单优化
   ========================================== */
@media (max-width: 767px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px;
        padding: 0.75rem 1rem;
    }

    .btn {
        width: 100%;
        text-align: center;
        min-height: 48px;
    }
}

/* ==========================================
   移动端新闻列表优化
   ========================================== */
@media (max-width: 767px) {
    .news-list {
        max-height: 300px;
    }

    .news-item {
        padding: 0.75rem 0;
    }

    .news-item-title {
        font-size: 0.9375rem;
        line-height: 1.5;
    }

    .news-item-meta {
        font-size: 0.8125rem;
    }
}

/* ==========================================
   移动端产品卡片优化
   ========================================== */
@media (max-width: 767px) {
    .product-card,
    .service-card,
    .solution-card {
        margin-bottom: 1rem;
        border-radius: var(--border-radius-sm);
    }

    .product-image {
        height: 200px;
    }

    .product-content {
        padding: 1rem;
    }

    .product-title {
        font-size: 1.125rem;
    }

    .product-description {
        font-size: 0.875rem;
        line-height: 1.6;
    }

    .service-icon {
        height: 180px;
    }

    .service-card {
        padding: 1.25rem;
    }
}

/* ==========================================
   移动端荣誉墙优化
   ========================================== */
@media (max-width: 767px) {
    .honors-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .honor-card {
        padding: 1rem;
        text-align: center;
    }

    .honor-title {
        font-size: 0.9375rem;
    }
}

/* ==========================================
   移动端专利墙优化
   ========================================== */
@media (max-width: 767px) {
    .patents-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .patent-category {
        margin-bottom: 1rem;
    }

    .patent-category-title {
        font-size: 1rem;
    }

    .patent-item {
        font-size: 0.875rem;
        padding: 0.5rem 0;
    }
}

/* ==========================================
   移动端图库优化
   ========================================== */
@media (max-width: 767px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .gallery-item {
        border-radius: var(--border-radius-sm);
        overflow: hidden;
    }

    .gallery-overlay {
        font-size: 0.75rem;
        padding: 0.5rem;
    }
}

/* ==========================================
   移动端联系页面优化
   ========================================== */
@media (max-width: 767px) {
    .contact-tabs {
        display: flex;
        overflow-x: auto;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .contact-tab {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .contact-info-item {
        padding: 1rem;
        border-left: 3px solid var(--color-primary);
    }

    .contact-icon {
        display: none;
    }

    .contact-form {
        padding: 1.25rem;
    }
}

/* ==========================================
   移动端页脚优化
   ========================================== */
@media (max-width: 767px) {
    .footer {
        padding: var(--spacing-8) 0 var(--spacing-6);
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-6);
        text-align: center;
    }

    .footer-column {
        text-align: center;
    }

    .footer-title {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    .footer-links li {
        margin-bottom: 0.5rem;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding-top: var(--spacing-6);
    }

    .footer-copyright {
        font-size: 0.75rem;
        line-height: 1.6;
    }
}

/* ==========================================
   移动端文章页面优化
   ========================================== */
@media (max-width: 767px) {
    .article-container {
        padding: 2rem 1rem;
    }

    .article-title {
        font-size: 1.5rem;
        line-height: 1.3;
    }

    .article-cover {
        height: 200px;
    }

    .article-content {
        font-size: 0.9375rem;
        line-height: 1.8;
    }

    .article-content p {
        margin-bottom: 1rem;
        text-align: justify;
    }

    .back-nav {
        padding: 0.75rem 0;
    }

    .back-link {
        width: 100%;
        text-align: center;
        justify-content: center;
        font-size: 0.9375rem;
    }
}

/* ==========================================
   移动端加载动画优化
   ========================================== */
@media (max-width: 767px) {
    .fade-in {
        opacity: 0;
        transform: translateY(20px);
    }

    .fade-in.visible {
        opacity: 1;
        transform: translateY(0);
        transition: opacity 0.4s ease, transform 0.4s ease;
    }
}

/* ==========================================
   移动端滚动条优化
   ========================================== */
@media (max-width: 767px) {
    .news-list::-webkit-scrollbar,
    .nav-menu::-webkit-scrollbar,
    .contact-tabs::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }

    .news-list::-webkit-scrollbar-thumb,
    .nav-menu::-webkit-scrollbar-thumb,
    .contact-tabs::-webkit-scrollbar-thumb {
        background: var(--color-gray-300);
        border-radius: 2px;
    }

    .news-list::-webkit-scrollbar-track,
    .nav-menu::-webkit-scrollbar-track,
    .contact-tabs::-webkit-scrollbar-track {
        background: transparent;
    }
}

/* ==========================================
   移动端弹出层优化
   ========================================== */
@media (max-width: 767px) {
    .modal,
    .dialog {
        width: 90vw;
        max-width: 90vw;
        margin: 1rem;
        padding: 1.5rem;
    }
}

/* ==========================================
   移动端打印优化
   ========================================== */
@media print and (max-width: 767px) {
    .header,
    .footer,
    .nav-toggle {
        display: none !important;
    }

    .main {
        padding-top: 0;
    }
}

/* ==========================================
   iOS Safari 特定优化
   ========================================== */
@supports (-webkit-touch-callout: none) {
    body {
        cursor: pointer;
    }

    .btn,
    a {
        -webkit-touch-callout: none;
    }

    input,
    textarea,
    select {
        -webkit-appearance: none;
        border-radius: 8px;
    }

    .nav-toggle {
        -webkit-touch-callout: none;
        width: 28px;
        height: 24px;
    }
}

/* ==========================================
   Android Chrome 特定优化
   ========================================== */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    select {
        background-image: none;
    }
}

/* ==========================================
   移动端按钮触摸优化补充
   ========================================== */
@media (max-width: 767px) {
    .btn,
    .btn-primary,
    .btn-outline,
    .btn-secondary {
        min-height: 48px;
        min-width: 48px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0.75rem 1.5rem;
        font-size: 0.9375rem;
    }
}

/* ==========================================
   移动端CTA区域优化
   ========================================== */
@media (max-width: 767px) {
    .hero-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }

    .hero-buttons .btn {
        width: 100%;
    }

    .section-header {
        text-align: center;
    }

    .section-subtitle {
        max-width: 100%;
        font-size: 0.9375rem;
    }
}
