/**
 * 移动端优化样式
 * 适配手机和平板设备
 */

/* ============================================
   1. 基础移动端优化
   ============================================ */
@media (max-width: 768px) {
    /* 优化页面基础布局 */
    body {
        font-size: 14px;
    }
    
    /* 优化主容器边距 */
    .max-w-5xl,
    .max-w-6xl,
    .max-w-7xl {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* 移动端导航栏优化 */
    nav .flex.justify-between.items-center.h-16 {
        height: auto !important;
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
    
    /* 隐藏桌面端导航，显示移动端导航 */
    .desktop-nav {
        display: none !important;
    }
    
    .mobile-nav-toggle {
        display: flex !important;
    }
    
    /* 移动端菜单样式 */
    .mobile-menu {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9999;
    }
    
    .mobile-menu.open {
        display: block;
    }
    
    .mobile-menu-content {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 80%;
        max-width: 280px;
        background: white;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .mobile-menu.open .mobile-menu-content {
        transform: translateX(0);
    }
    
    /* 表格移动端适配 */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 卡片网格移动端单列 */
    .grid-cols-1.sm\:grid-cols-2.lg\:grid-cols-4,
    .grid-cols-1.sm\:grid-cols-2.lg\:grid-cols-3 {
        grid-template-columns: 1fr !important;
    }
    
    /* 表单优化 */
    form .space-y-4,
    form .space-y-6 {
        gap: 1rem !important;
    }
    
    /* 按钮优化 */
    button,
    .btn {
        padding: 0.75rem 1rem !important;
        font-size: 1rem !important;
    }
    
    /* 输入框优化 */
    input,
    select,
    textarea {
        font-size: 16px !important; /* 防止iOS缩放 */
        padding: 0.75rem !important;
    }
    
    /* 下拉菜单优化 */
    .dropdown-menu {
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        border-radius: 1rem 1rem 0 0 !important;
        box-shadow: 0 -10px 40px -10px rgba(0, 0, 0, 0.2) !important;
        transform: translateY(100%) !important;
    }
    
    .dropdown-wrapper:hover .dropdown-menu {
        transform: translateY(0) !important;
    }
}

/* ============================================
   2. 小屏幕专用优化 (小于 480px)
   ============================================ */
@media (max-width: 480px) {
    /* 更小的字体和间距 */
    body {
        font-size: 13px;
    }
    
    /* 标题字号优化 */
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.25rem !important; }
    h3 { font-size: 1.1rem !important; }
    
    /* 卡片内边距缩小 */
    .p-6 { padding: 1rem !important; }
    .p-8 { padding: 1.25rem !important; }
    
    /* 按钮更紧凑 */
    button,
    .btn {
        padding: 0.625rem 0.875rem !important;
        font-size: 0.875rem !important;
    }
    
    /* 表格单元格最小宽度 */
    td, th {
        min-width: 80px !important;
    }
}

/* ============================================
   3. 触摸友好优化
   ============================================ */
@media (hover: none) {
    /* 移除悬停效果，改用点击效果 */
    .card-hover:hover {
        transform: none !important;
        box-shadow: none !important;
    }
    
    .card-hover:active {
        transform: scale(0.98) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* 增加触摸目标大小 */
    a,
    button,
    input[type="checkbox"],
    input[type="radio"] {
        min-height: 44px !important;
        min-width: 44px !important;
    }
    
    /* 下拉菜单改用点击触发 */
    .dropdown-wrapper:hover .dropdown-menu {
        opacity: 0 !important;
        visibility: hidden !important;
        transform: translateY(-10px) !important;
    }
    
    .dropdown-wrapper.active .dropdown-menu {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(0) !important;
    }
}

/* ============================================
   4. 横屏模式优化
   ============================================ */
@media (max-width: 768px) and (orientation: landscape) {
    /* 横屏时减小顶部导航高度 */
    nav .flex.justify-between.items-center.h-16 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    /* 横屏时使用两列布局 */
    .grid-cols-1.sm\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}
