/* 移动端适配样式 - 清北校园网球赛 */

/* ========================================
   1. 导航栏移动端优化
   ======================================== */

@media (max-width: 768px) {
    /* 固定导航栏 */
    .navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        padding: 10px 0;
        background: rgba(102, 126, 234, 0.95);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
    }

    /* 导航栏容器 */
    .nav-container {
        padding: 0 15px;
        flex-wrap: wrap;
    }

    /* Logo区域 */
    .logo {
        font-size: 1rem;
        gap: 8px;
    }

    .logo-icon {
        font-size: 1.2rem;
    }

    .logo-text {
        font-size: 0.9rem;
    }

    /* 汉堡菜单按钮 */
    .menu-toggle {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
        padding: 5px;
        z-index: 10000;
    }

    /* 移动端菜单 */
    .nav-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: rgba(102, 126, 234, 0.98);
        backdrop-filter: blur(30px);
        flex-direction: column;
        gap: 0;
        padding: 10px 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-in-out;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    }

    .nav-menu.active {
        max-height: 400px;
    }

    .nav-menu li {
        width: 100%;
        text-align: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

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

    .nav-menu a {
        display: block;
        padding: 15px 20px;
        width: 100%;
        border-radius: 0;
    }

    /* 页面内容上边距（避免被导航栏遮挡） */
    body {
        padding-top: 70px;
        padding-left: 10px;
        padding-right: 10px;
    }

    /* ========================================
       2. 英雄区域移动端优化
       ======================================== */

    .hero {
        padding: 30px 20px;
        margin-bottom: 20px;
    }

    .hero h1 {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }

    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 15px;
    }

    .hero-stats {
        flex-direction: column;
        gap: 15px;
    }

    .stat-item {
        min-width: auto;
        width: 100%;
    }

    /* ========================================
       3. 统计卡片移动端优化
       ======================================== */

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

    .stat-card {
        padding: 20px;
    }

    .stat-value {
        font-size: 2rem;
    }

    .stat-label {
        font-size: 0.9rem;
    }

    /* ========================================
       4. 查询模块移动端优化
       ======================================== */

    .query-selector {
        padding: 20px 15px;
    }

    .query-tabs {
        flex-direction: column;
        gap: 10px;
    }

    .query-tab {
        width: 100%;
        padding: 12px;
        font-size: 0.95rem;
    }

    .query-panel {
        padding: 20px 15px;
    }

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

    .form-group {
        margin-bottom: 0;
    }

    .form-group input,
    .form-group select {
        font-size: 16px; /* 防止iOS自动缩放 */
    }

    .query-button {
        width: 100%;
        padding: 14px;
        font-size: 1rem;
    }

    /* ========================================
       5. 排行榜移动端优化
       ======================================== */

    .ranking-section {
        padding: 20px 15px;
    }

    .ranking-header h2 {
        font-size: 1.5rem;
    }

    /* 排行榜表格横向滚动 */
    .ranking-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
    }

    .ranking-table {
        min-width: 800px; /* 保持表格最小宽度 */
        font-size: 0.85rem;
    }

    .ranking-table th,
    .ranking-table td {
        padding: 10px 8px;
        white-space: nowrap;
    }

    /* 排行榜筛选器 */
    .ranking-filters {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .filter-group select {
        font-size: 16px;
    }

    /* ========================================
       6. 预测页面移动端优化
       ======================================== */

    .prediction-container {
        padding: 20px 15px;
    }

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

    .predict-button {
        width: 100%;
        padding: 14px;
    }

    /* 雷达图容器 */
    .radar-container {
        height: 300px;
        margin: 20px 0;
    }

    /* 战术建议卡片 */
    .tactics-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* ========================================
       7. 冠军墙移动端优化
       ======================================== */

    .champions-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }

    .champion-card {
        padding: 15px;
    }

    .champion-photo {
        width: 100px;
        height: 100px;
    }

    .champion-name {
        font-size: 1rem;
    }

    .champion-title {
        font-size: 0.85rem;
    }

    /* ========================================
       8. 选手详情页移动端优化
       ======================================== */

    .player-profile {
        padding: 20px 15px;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .profile-photo {
        width: 120px;
        height: 120px;
    }

    .profile-info {
        align-items: center;
    }

    .profile-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    /* 比赛记录表格 */
    .matches-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
    }

    .matches-table {
        min-width: 600px;
        font-size: 0.85rem;
    }

    /* ========================================
       9. 页脚移动端优化
       ======================================== */

    footer {
        padding: 20px 15px;
        font-size: 0.85rem;
        text-align: center;
    }

    footer p {
        margin: 8px 0;
    }

    /* ========================================
       10. 通用移动端优化
       ======================================== */

    /* 容器最大宽度 */
    .container {
        max-width: 100%;
        padding: 0 15px;
    }

    /* 按钮 */
    button,
    .button {
        min-height: 44px; /* iOS推荐的最小触摸目标 */
        font-size: 16px;
    }

    /* 输入框 */
    input,
    select,
    textarea {
        font-size: 16px; /* 防止iOS自动缩放 */
        min-height: 44px;
    }

    /* 卡片 */
    .card {
        padding: 15px;
        margin-bottom: 15px;
    }

    /* 标题 */
    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.2rem;
    }

    /* 间距调整 */
    .section {
        margin-bottom: 20px;
    }

    /* 隐藏桌面端元素 */
    .desktop-only {
        display: none !important;
    }

    /* 显示移动端元素 */
    .mobile-only {
        display: block !important;
    }
}

/* ========================================
   11. 横屏模式优化（手机横屏）
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
    body {
        padding-top: 60px;
    }

    .navbar {
        padding: 8px 0;
    }

    .hero {
        padding: 20px;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .hero-stats {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .stat-item {
        width: calc(50% - 10px);
    }
}

/* ========================================
   12. 小屏手机优化（<375px）
   ======================================== */

@media (max-width: 375px) {
    .logo-text {
        font-size: 0.8rem;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .stat-value {
        font-size: 1.8rem;
    }

    .ranking-table {
        font-size: 0.75rem;
    }

    .ranking-table th,
    .ranking-table td {
        padding: 8px 6px;
    }
}

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

@media (hover: none) and (pointer: coarse) {
    /* 增大可点击区域 */
    a,
    button,
    .clickable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* 移除hover效果 */
    *:hover {
        opacity: 1 !important;
    }

    /* 添加active效果 */
    a:active,
    button:active,
    .clickable:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* ========================================
   14. 安全区域适配（iPhone刘海屏）
   ======================================== */

@supports (padding: max(0px)) {
    body {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    .navbar {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
}
