/* 移动端适配样式 */

/* 防止所有元素超出屏幕 */
* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

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

/* 基础响应式设置 */
@media screen and (max-width: 1200px) {
    .container {
        padding: 0 20px;
        max-width: 100%;
        width: 100% !important;
    }
    
    /* 防止容器超出 */
    .section,
    .content-section {
        padding-left: 20px;
        padding-right: 20px;
    }
    
    /* 表格响应式 */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* 平板适配 */
@media screen and (max-width: 992px) {
    .header-container {
        flex-wrap: wrap;
    }
    
    .header-actions .lang-text {
        display: none;
    }
    
    .header-actions .login-btn,
    .header-actions .appointment-btn {
        font-size: 14px;
        padding: 8px 16px;
    }
    
    /* 两列布局改为单列 */
    .two-column-layout,
    .content-with-sidebar {
        flex-direction: column;
    }
    
    /* 卡片网格改为两列 */
    .card-grid,
    .department-grid,
    .hospital-grid,
    .doctor-grid,
    .doctors-grid,
    .package-grid,
    .news-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px;
    }
    
    /* Hospital Detail Two Column Layout */
    .container[style*="grid-template-columns: 2fr 1fr"],
    .doctor-details-wrapper {
        grid-template-columns: 1fr !important;
    }
    
    aside[style*="position: sticky"] {
        position: static !important;
    }
}

/* 移动端适配 */
@media screen and (max-width: 768px) {
    /* 容器和基础布局 */
    .container {
        padding: 0 15px;
        width: 100%;
        max-width: 100%;
    }
    
    .section {
        padding: 30px 15px;
    }
    
    /* Header 移动端样式 */
    .header-container {
        padding: 10px 15px;
    }
    
    .logo img {
        max-height: 40px;
    }
    
    .nav {
        display: block !important;
        position: fixed;
        top: 0;
        right: -100%;
        left: auto;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: white;
        z-index: 9999;
        transition: right 0.3s ease;
        overflow-y: auto;
        padding: 60px 0 20px;
        box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    }
    
    .nav.active {
        right: 0;
        left: auto;
    }
    
    .nav-list {
        flex-direction: column;
        gap: 0;
    }
    
    .nav-list li {
        width: 100%;
        border-bottom: 1px solid #eee;
    }
    
    .nav-list li a {
        display: block;
        padding: 15px 20px;
        color: #333;
    }
    
    .dropdown-menu {
        position: static;
        display: none;
        background: #f8f9fa;
        box-shadow: none;
        width: 100% !important;
        min-width: 100% !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        padding: 10px 15px !important; /* 增加内边距避免靠近边缘 */
        box-sizing: border-box !important;
    }
    
    /* 移除 .active 强制 display: block，由 JS slideDown 控制 */

    /* 针对特殊布局的下拉菜单（如科室/医院列表）优化 */
    .hospital-dropdown,
    .doctor-dropdown {
        padding: 20px 15px !important;
    }

    .region-list,
    .department-list {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        width: 100% !important;
    }
    
    .dropdown-menu a {
        padding: 12px 30px;
    }
    
    /* 医院和医生下拉菜单移动端样式 */
    .hospital-dropdown,
    .doctor-dropdown {
        min-width: 100%;
        padding: 15px;
    }
    
    .region-list,
    .department-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .dropdown-search-title {
        font-size: 13px;
        margin-bottom: 10px;
    }
    
    .region-item,
    .dept-item {
        font-size: 12px;
        padding: 8px 10px;
    }
    
    .header-actions {
        gap: 10px;
    }
    
    .header-actions .lang-selector {
        display: none;
    }
    
    .header-actions .login-btn {
        display: none;
    }
    
    .header-actions .appointment-btn {
        font-size: 12px;
        padding: 8px 12px;
        white-space: nowrap;
    }
    
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: none;
        border: none;
        font-size: 24px;
        color: #333;
        cursor: pointer;
    }
    
    body.menu-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 9998;
    }

    body.menu-open .header {
        z-index: 10000;
    }
    
    /* Hero Section 移动端优化 */
    .hero-section {
        padding: 0 !important;
        margin-top: 0 !important;
        height: 530px !important; /* 根据内容高度定死，防止塌陷 */
        min-height: 530px !important;
    }
    
    .hero-slider-container {
        height: 100% !important;
    }

    .hero-slide .container.hero-slide-inner {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        padding: 30px 15px !important;
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
    }

    .slide-content {
        padding-right: 0 !important;
        text-align: center !important;
        width: 100% !important;
    }

    .slide-title {
        font-size: 24px !important;
        margin-bottom: 10px !important;
        text-align: center !important;
    }

    .slide-badge {
        margin-bottom: 10px !important;
    }

    .slide-description {
        font-size: 13px !important;
        margin-bottom: 20px !important;
        text-align: center !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .slide-metrics {
        grid-template-columns: 1fr 1fr !important;
        gap: 20px !important;
        margin-bottom: 25px !important;
        width: 100%;
    }

    .metric-value {
        font-size: 22px !important;
    }

    .metric-label {
        font-size: 11px !important;
    }

    .slide-btns {
        flex-direction: row !important; /* Keep side by side if possible, or use wrap */
        flex-wrap: wrap;
        justify-content: center !important;
        gap: 8px !important;
        width: 100%;
    }

    .slide-btns .btn {
        flex: 1;
        min-width: 140px;
        padding: 10px 15px !important;
        font-size: 13px !important;
        margin: 0 !important;
        white-space: nowrap;
    }

    .slide-visual {
        display: none !important;
    }
    
    .hero-slider-container > button {
        width: 32px !important;
        height: 32px !important;
        background: rgba(255,255,255,0.9) !important;
    }

    .hero-slider-container > button[style*="left: 30px"] {
        left: 10px !important;
    }

    .hero-slider-container > button[style*="right: 30px"] {
        right: 10px !important;
    }

    .hero-indicators {
        bottom: 15px !important;
    }

    /* 公司介绍区块移动端优化 */
    .company-intro-section {
        padding: 40px 0 !important;
    }

    .company-intro-grid {
        grid-template-columns: 1fr !important;
        gap: 40px !important;
        margin-bottom: 40px !important;
    }

    .company-info h2 {
        font-size: 28px !important;
        margin-bottom: 15px !important;
    }

    .company-info p {
        font-size: 14px !important;
        line-height: 1.6 !important;
    }

    .company-btns {
        flex-direction: column !important;
    }

    .company-btns .btn {
        width: 100% !important;
    }

    .highlight-card {
        padding: 30px 20px !important;
        border-radius: 20px !important;
    }

    .highlight-card h3 {
        font-size: 22px !important;
        margin-bottom: 20px !important;
    }

    .highlight-card .fas.fa-check {
        font-size: 16px !important;
    }
    
    .highlight-card h4 {
        font-size: 16px !important;
    }
    
    .hero-content {
        padding: 20px 15px;
        max-width: 100%;
    }
    
    .hero-title {
        font-size: 24px;
        line-height: 1.3;
    }
    
    .hero-subtitle {
        font-size: 14px;
    }
    
    .hero-search {
        padding: 15px;
    }
    
    .search-box {
        flex-direction: column;
        gap: 10px;
    }
    
    .search-input {
        width: 100%;
    }
    
    /* 搜索弹窗移动端 */
    .header-search-container {
        padding: 20px 15px;
        width: 95%;
        max-width: 95%;
    }
    
    .header-search-box {
        flex-direction: column;
        gap: 10px;
    }
    
    .header-search-input {
        width: 100%;
    }
    
    .btn-header-search {
        width: 100%;
    }
    
    .suggestion-tags {
        gap: 8px;
    }
    
    .suggestion-tags .tag {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    /* 通用移动端样式 */
    h1 {
        font-size: 28px;
        line-height: 1.3;
    }
    
    h2 {
        font-size: 24px;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 20px;
        line-height: 1.3;
    }
    
    h4 {
        font-size: 18px;
    }
    
    p {
        font-size: 14px;
        line-height: 1.6;
    }
    
    .btn {
        font-size: 14px;
        padding: 10px 20px;
        white-space: nowrap;
    }
    
    /* 卡片网格移动端 - 全部改为单列 */
    .card-grid,
    .department-grid,
    .hospital-grid,
    .doctor-grid,
    .doctors-grid,
    .package-grid,
    .news-grid,
    .service-grid,
    .feature-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    /* 卡片样式调整 */
    .card,
    .department-card,
    .hospital-card,
    .doctor-card,
    .package-card,
    .news-card {
        padding: 15px;
        margin: 0;
    }
    
    /* Hospital Card Mobile Styles */
    .hospital-header {
        flex-direction: column;
        gap: 15px;
        padding: 20px;
    }
    
    .hospital-logo {
        width: 80px;
        height: 80px;
        font-size: 32px;
    }
    
    .hospital-info h3 {
        font-size: 20px;
    }
    
    .hospital-body {
        padding: 20px;
    }
    
    .hospital-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-box {
        padding: 10px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    .region-filter-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    /* Hospital Detail Hero Mobile */
    .hero [style*="display: flex"] {
        flex-direction: column !important;
        gap: 20px !important;
        text-align: center;
    }
    
    .hero [style*="width: 120px"] {
        width: 100px !important;
        height: 100px !important;
        font-size: 40px !important;
        margin: 0 auto;
    }
    
    .hero h1 {
        font-size: 32px !important;
    }
    
    .hero p {
        font-size: 16px !important;
    }
    
    .hero [style*="font-size: 28px"] {
        font-size: 24px !important;
    }
    
    .hero [style*="display: flex; gap: 30px"] {
        justify-content: center;
        gap: 20px !important;
    }
    
    /* Hospital Detail Grid Mobile */
    .section-block [style*="grid-template-columns: repeat(2, 1fr)"] {
        grid-template-columns: 1fr !important;
    }
    
    .card-image,
    .hospital-image,
    .doctor-image,
    .package-image,
    .news-image {
        height: 200px;
        object-fit: cover;
    }
    
    /* 统计数据移动端 */
    .stats-container,
    .stats-grid {
        flex-direction: column;
        gap: 15px;
    }
    
    .stat-item {
        width: 100%;
        text-align: center;
    }
    
    /* 特色功能移动端 */
    .features-grid {
        grid-template-columns: 1fr !important;
    }
    
    .feature-item {
        padding: 20px 15px;
    }
    
    /* 表单移动端 */
    .form-container {
        padding: 20px 15px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .form-group {
        width: 100%;
        margin-bottom: 15px;
    }
    
    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        width: 100%;
        font-size: 16px; /* 防止 iOS 自动缩放 */
        padding: 12px 15px;
    }
    
    /* 表格移动端 */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 14px;
    }
    
    th, td {
        padding: 8px 10px;
        white-space: nowrap;
    }
    
    /* 筛选器移动端 */
    .filters-container,
    .search-filters {
        flex-direction: column;
        gap: 10px;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-tags {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .filter-tag {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    /* 列表布局移动端 */
    .list-item {
        flex-direction: column;
        padding: 15px;
    }
    
    .list-image {
        width: 100%;
        height: 200px;
        object-fit: cover;
    }
    
    /* 侧边栏移动端 */
    .sidebar {
        width: 100%;
        margin-top: 30px;
    }
    
    .sidebar-widget {
        padding: 15px;
    }
    
    /* 分页移动端 */
    .pagination {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .pagination .nav-links {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 8px;
    }
    
    .pagination a,
    .pagination span {
        font-size: 14px;
        min-width: 40px;
        height: 40px;
        padding: 0 12px;
    }
    
    /* 标签页移动端 */
    .tabs {
        flex-wrap: wrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab {
        font-size: 14px;
        padding: 10px 15px;
        white-space: nowrap;
    }
    
    /* 模态框移动端 */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 20px auto;
        padding: 20px 15px;
    }
    
    .modal-header h2 {
        font-size: 20px;
    }
    
    /* Breadcrumb 移动端 */
    .breadcrumb {
        font-size: 12px;
        flex-wrap: wrap;
        padding: 10px 15px;
    }
    
    /* Footer 移动端 */
    .footer {
        padding: 30px 15px;
    }
    
    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 30px;
    }
    
    .footer-section {
        text-align: center;
    }
    
    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 20px 15px;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 10px;
    }
    
    /* 按钮组移动端 */
    .button-group,
    .action-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .button-group .btn {
        width: 100%;
    }
    
    /* 图片画廊移动端 */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    /* 时间线移动端 */
    .timeline {
        padding-left: 20px;
    }
    
    .timeline-item {
        padding-left: 30px;
    }
    
    /* 引用块移动端 */
    blockquote {
        padding: 15px;
        margin: 15px 0;
        font-size: 14px;
    }
    
    /* 代码块移动端 */
    pre {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 15px;
        font-size: 12px;
    }
    
    /* 视频容器移动端 */
    .video-container,
    .embed-container {
        position: relative;
        padding-bottom: 56.25%;
        height: 0;
        overflow: hidden;
    }
    
    .video-container iframe,
    .embed-container iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
    
    /* 地图容器移动端 */
    .map-container {
        height: 300px;
        width: 100%;
    }
    
    /* 警告框移动端 */
    .alert,
    .notice,
    .warning {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    /* 徽章移动端 */
    .badge {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    /* 进度条移动端 */
    .progress {
        height: 8px;
    }
    
    /* 价格显示移动端 */
    .price-display {
        flex-direction: column;
        gap: 10px;
    }
    
    .price {
        font-size: 24px;
    }
    
    /* 评分显示移动端 */
    .rating {
        font-size: 14px;
    }
    
    /* 社交分享按钮移动端 */
    .social-share {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .social-share a {
        font-size: 14px;
        padding: 8px 12px;
    }
}

/* 小屏手机适配 */
@media screen and (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .section {
        padding: 20px 10px;
    }
    
    .header-container {
        padding: 8px 10px;
    }
    
    .header-actions .appointment-btn {
        display: none;
    }
    
    .header-actions .search-icon {
        font-size: 18px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    h2 {
        font-size: 20px;
    }
    
    h3 {
        font-size: 18px;
    }
    
    h4 {
        font-size: 16px;
    }
    
    p {
        font-size: 13px;
    }
    
    .btn {
        font-size: 13px;
        padding: 8px 16px;
    }
    
    .card,
    .department-card,
    .hospital-card,
    .doctor-card {
        padding: 12px;
    }
    
    .card-image,
    .hospital-image,
    .doctor-image {
        height: 180px;
    }
    
    /* 图片画廊单列 */
    .gallery-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* 表格字体更小 */
    table {
        font-size: 12px;
    }
    
    th, td {
        padding: 6px 8px;
    }
    
    /* 模态框全屏 */
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
        overflow-y: auto;
    }
}

/* 横屏适配 */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .nav {
        width: 50%;
    }
    
    .hero-section {
        min-height: auto;
        padding: 0 !important;
    }
    
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* 高 DPI 屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}
