/**
 * 移动端响应式优化样式
 * 增强触摸体验和移动端布局
 */

/* ==========================================
   汉堡菜单按钮
   ========================================== */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.mobile-menu-toggle span {
    width: 100%;
    height: 3px;
    background-color: #fff;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.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: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        max-width: 300px;
        height: 100vh;
        background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        padding: 80px 30px 30px;
        gap: 0;
        transition: right 0.3s ease;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.3);
        z-index: 1000;
        overflow-y: auto;
    }

    .nav-links.active {
        right: 0;
    }

    .nav-item {
        width: 100%;
        padding: 15px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 16px;
    }

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

    .nav-logo span {
        font-size: 16px;
    }

    .navbar {
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    .nav-links {
        width: 80%;
    }

    .nav-logo img {
        height: 35px;
    }

    .nav-logo span {
        font-size: 14px;
    }
}

/* ==========================================
   移动端遮罩层
   ========================================== */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* ==========================================
   触摸友好的按钮和表单
   ========================================== */
@media (max-width: 768px) {
    /* 增大按钮触摸区域 */
    button,
    .btn,
    a.btn,
    input[type="button"],
    input[type="submit"] {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 16px;
    }

    /* 增大表单输入框触摸区域 */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    select,
    textarea {
        min-height: 44px;
        padding: 12px;
        font-size: 16px;
    }

    /* 文件上传按钮 */
    input[type="file"] {
        padding: 10px;
    }
}

/* ==========================================
   移动端排版优化
   ========================================== */
@media (max-width: 768px) {
    body {
        font-size: 16px;
        line-height: 1.6;
    }

    h1 {
        font-size: 28px;
        line-height: 1.3;
    }

    h2 {
        font-size: 24px;
        line-height: 1.3;
    }

    h3 {
        font-size: 20px;
        line-height: 1.4;
    }

    h4 {
        font-size: 18px;
    }

    p {
        font-size: 16px;
        line-height: 1.6;
    }

    /* 避免横向滚动 */
    * {
        max-width: 100%;
    }

    img {
        height: auto;
    }
}

/* ==========================================
   移动端检测页面优化
   ========================================== */
@media (max-width: 768px) {
    .detection-container {
        margin: 80px auto 30px;
        padding: 0 15px;
    }

    .detection-title {
        font-size: 24px;
    }

    .detection-subtitle {
        font-size: 14px;
    }

    .results-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .result-card {
        padding: 15px;
    }

    .result-value {
        font-size: 24px;
    }

    /* 图片预览优化 */
    .preview-image {
        max-height: 250px;
    }

    /* 上传区域优化 */
    .upload-zone {
        padding: 30px 15px;
    }

    .upload-icon {
        font-size: 2rem;
    }

    /* 检测结果图片容器 */
    .lesion-image-container,
    .chart-container {
        height: 250px;
    }

    /* 测试图片网格 */
    .test-images-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .test-image-card {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .detection-title {
        font-size: 20px;
    }

    .test-images-grid {
        grid-template-columns: 1fr;
    }

    .result-value {
        font-size: 20px;
    }

    .detection-container {
        margin: 70px auto 20px;
        padding: 0 10px;
    }

    .preview-image {
        max-height: 200px;
    }

    .upload-zone {
        padding: 20px 10px;
    }

    /* 按钮优化 */
    .btn-primary,
    .btn-secondary {
        font-size: 14px;
        padding: 10px 20px;
    }

    /* 卡片标题 */
    .card-title,
    .section-title {
        font-size: 18px;
    }

    /* 结果卡片 */
    .result-card {
        padding: 12px;
    }

    .result-label {
        font-size: 12px;
    }

    .result-value {
        font-size: 18px;
    }
}

/* ==========================================
   移动端表格优化
   ========================================== */
@media (max-width: 768px) {
    table {
        font-size: 14px;
    }

    th, td {
        padding: 8px 5px;
    }

    /* 让表格可以横向滚动 */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 病理报告表格优化 */
    .pathology-report-section table {
        font-size: 12px;
    }

    .pathology-report-section th,
    .pathology-report-section td {
        padding: 6px 4px;
    }

    /* 病变类型显示优化 */
    #reportDiseaseTypes {
        font-size: 13px !important;
    }

    #reportDiseaseTypes p {
        padding: 8px !important;
        margin: 8px 0 !important;
        font-size: 13px !important;
        word-break: break-word;
    }

    #reportDiseaseTypes strong {
        font-size: 14px !important;
    }

    .report-section {
        padding: 10px !important;
        margin-bottom: 15px !important;
    }

    .report-section h3 {
        font-size: 16px !important;
        margin-bottom: 10px !important;
    }

    .report-section h4 {
        font-size: 14px !important;
        margin-bottom: 8px !important;
    }
}

/* ==========================================
   移动端图片优化
   ========================================== */
@media (max-width: 768px) {
    .section-image,
    .about-image,
    .model-image {
        width: 100%;
        height: auto;
        max-width: 100%;
    }

    .image-row {
        flex-direction: column;
        gap: 15px;
    }

    .image-box {
        width: 100%;
    }

    /* 检测结果图片优化 */
    #segmentationImage,
    #recognitionImage {
        width: 100% !important;
        height: auto !important;
        max-height: 300px;
        object-fit: contain;
    }

    .result-image-container {
        width: 100% !important;
        margin-bottom: 20px;
    }

    /* 检测结果展示区域 */
    .detection-results-display {
        flex-direction: column !important;
        gap: 15px !important;
    }

    .result-image-section {
        width: 100% !important;
        flex: none !important;
    }
}

/* ==========================================
   移动端卡片优化
   ========================================== */
@media (max-width: 768px) {
    .feature-card,
    .team-card,
    .tech-card {
        padding: 20px;
    }

    .card-grid,
    .features-grid,
    .team-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* ==========================================
   移动端间距优化
   ========================================== */
@media (max-width: 768px) {
    section {
        padding: 40px 20px;
    }

    .container {
        padding: 0 20px;
    }

    /* 减少大标题的上下边距 */
    .section-title {
        margin-bottom: 30px;
    }
}

/* ==========================================
   移动端footer优化
   ========================================== */
@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .footer-section {
        width: 100%;
        margin-bottom: 30px;
    }

    .footer-social {
        justify-content: center;
    }
}

/* ==========================================
   隐藏在移动端不必要的元素
   ========================================== */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    /* 可以隐藏一些装饰性元素 */
    .decorative-bg,
    .wave-decoration {
        display: none;
    }
}

/* ==========================================
   移动端加载动画优化
   ========================================== */
@media (max-width: 768px) {
    .loading-spinner {
        width: 40px;
        height: 40px;
    }

    .processing-indicator {
        padding: 15px;
        font-size: 14px;
    }
}

/* ==========================================
   移动端滚动优化
   ========================================== */
@media (max-width: 768px) {
    /* 平滑滚动 */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    /* 滚动条优化 */
    ::-webkit-scrollbar {
        width: 5px;
        height: 5px;
    }

    ::-webkit-scrollbar-thumb {
        background: rgba(0, 102, 204, 0.5);
        border-radius: 3px;
    }
}

/* ==========================================
   横屏模式优化
   ========================================== */
@media (max-width: 768px) and (orientation: landscape) {
    .detection-container {
        margin: 60px auto 20px;
    }

    .navbar {
        height: 60px;
    }

    .hero-section {
        min-height: 100vh;
    }
}

/* ==========================================
   手机优化 (主流手机屏幕 360px-430px)
   ========================================== */
@media (max-width: 430px) {
    /* 全局字体优化 */
    body {
        font-size: 14px;
        line-height: 1.6;
    }

    /* 主页英雄区 */
    .hero-section {
        padding: 60px 20px 40px;
        min-height: 85vh;
    }

    .hero-title {
        font-size: 28px !important;
        line-height: 1.3;
        margin-bottom: 15px;
    }

    .hero-subtitle {
        font-size: 15px !important;
        margin-bottom: 25px;
    }

    /* 按钮优化 - 确保触摸目标足够大 */
    .btn-primary,
    .btn-secondary,
    .cta-button {
        min-height: 44px;
        padding: 12px 24px;
        font-size: 15px;
        margin: 8px 0;
    }

    /* 导航栏 */
    .navbar {
        padding: 12px 16px;
        height: auto;
    }

    .nav-logo {
        font-size: 16px;
    }

    .nav-logo img {
        height: 32px;
    }

    /* 卡片和容器 */
    .feature-card,
    .team-card,
    .tech-card,
    .card {
        padding: 20px 16px;
        margin-bottom: 16px;
    }

    .card-title,
    .section-title {
        font-size: 20px;
        margin-bottom: 12px;
    }

    .card-description,
    .section-description {
        font-size: 14px;
        line-height: 1.6;
    }

    /* 检测页面优化 */
    .detection-container {
        padding: 0 16px;
        margin: 70px auto 30px;
    }

    .detection-title {
        font-size: 24px;
        margin-bottom: 12px;
    }

    .detection-subtitle {
        font-size: 14px;
    }

    /* 上传区域 */
    .upload-zone {
        padding: 24px 16px;
        min-height: 180px;
    }

    .upload-icon {
        font-size: 2.5rem;
        margin-bottom: 12px;
    }

    /* 测试图片网格 */
    .test-images-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .test-image-card {
        padding: 10px;
    }

    .test-image-card img {
        border-radius: 6px;
    }

    /* 预览图片 */
    .preview-image {
        max-height: 250px;
        width: 100%;
        object-fit: contain;
    }

    /* 结果区域 */
    .results-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .result-card {
        padding: 16px;
    }

    .result-label {
        font-size: 13px;
    }

    .result-value {
        font-size: 22px;
    }

    /* 病理报告 */
    .report-section {
        padding: 12px !important;
        margin-bottom: 16px !important;
    }

    .report-section h3 {
        font-size: 18px !important;
    }

    .report-section table {
        font-size: 13px;
    }

    .report-section td,
    .report-section th {
        padding: 8px 6px;
    }

    /* 检测结果图片 */
    #segmentationImage,
    #recognitionImage {
        max-height: 280px;
        border-radius: 8px;
    }

    /* 系统介绍页面优化 */
    .about-title,
    .model-title {
        font-size: 26px;
    }

    .about-text,
    .model-description {
        font-size: 14px;
        line-height: 1.7;
    }

    .model-feature {
        font-size: 13px;
        padding: 10px 0;
    }

    /* 页脚优化 */
    .footer-section {
        padding: 40px 20px;
    }

    .footer-title {
        font-size: 24px;
    }

    .footer-nav-item {
        font-size: 14px;
        padding: 10px 0;
    }

    /* 控制面板优化 */
    .control-panel {
        padding: 20px 16px !important;
        margin: 20px 0 !important;
    }

    .control-title {
        font-size: 18px !important;
        margin-bottom: 16px;
    }

    .control-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .control-item {
        padding: 12px;
    }

    .control-label {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .control-value,
    select.control-value {
        font-size: 14px;
        padding: 10px;
        min-height: 44px;
    }

    /* 文件输入优化 */
    input[type="file"] {
        font-size: 14px;
        padding: 10px;
    }

    /* 图片展示区域优化 */
    .image-display-section {
        padding: 16px;
    }

    .image-display-section h3 {
        font-size: 18px;
        margin-bottom: 12px;
    }
}

/* ==========================================
   超小屏幕优化 (小于375px)
   ========================================== */
@media (max-width: 375px) {
    .hero-title {
        font-size: 24px !important;
    }

    .hero-subtitle {
        font-size: 14px !important;
    }

    .detection-title,
    .about-title,
    .model-title {
        font-size: 22px;
    }

    .btn-primary,
    .btn-secondary {
        font-size: 14px;
        padding: 10px 20px;
    }

    .test-images-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .navbar {
        padding: 10px 12px;
    }

    .nav-logo img {
        height: 28px;
    }
}

/* ==========================================
   设备监控页面移动端优化
   ========================================== */
@media (max-width: 768px) {
    /* 监控网格布局 */
    .monitoring-grid,
    .devices-grid,
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    /* 监控卡片 */
    .monitor-card,
    .device-card,
    .stat-card {
        padding: 15px !important;
        margin-bottom: 15px;
    }

    /* 图表容器 */
    .chart-container,
    .graph-container {
        height: 250px !important;
        margin: 15px 0;
    }

    /* 状态指示器 */
    .status-indicator {
        font-size: 12px;
    }

    /* 设备列表 */
    .device-list {
        padding: 10px;
    }

    .device-item {
        padding: 10px;
        font-size: 14px;
    }

    /* 监控标题 */
    .monitor-title,
    .device-title {
        font-size: 20px !important;
    }

    /* 数值显示 */
    .monitor-value,
    .stat-value {
        font-size: 24px !important;
    }

    /* 监控页面容器 */
    .monitoring-container {
        padding: 15px !important;
        margin-top: 70px;
    }
}

@media (max-width: 480px) {
    /* 超小屏幕设备监控优化 */
    .monitor-card,
    .device-card,
    .stat-card {
        padding: 12px !important;
    }

    .chart-container,
    .graph-container {
        height: 200px !important;
    }

    .monitor-value,
    .stat-value {
        font-size: 20px !important;
    }

    .device-item {
        padding: 8px;
        font-size: 13px;
    }
}
