/**
 * 移动端优化样式
 * 专门为手机和平板设备优化的CSS
 */

/* ==================== 移动端基础优化 ==================== */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

/* 移动端视口设置 */
@viewport {
    width: device-width;
    zoom: 1.0;
}

/* ==================== 触摸优化 ==================== */
.btn, .button, .clickable, 
button, input[type="button"], input[type="submit"] {
    min-height: 44px; /* iOS推荐最小触摸尺寸 */
    min-width: 44px;
    touch-action: manipulation; /* 防止双击缩放 */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* 触摸反馈 */
.btn:active, .button:active, .clickable:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* ==================== 响应式断点 ==================== */
/* 超小屏幕（手机，小于768px） */
@media (max-width: 767.98px) {
    /* 容器优化 */
    .container, .container-fluid {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* 字体大小调整 */
    body {
        font-size: 16px; /* 防止iOS自动缩放 */
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.9rem; }
    
    /* 按钮优化 */
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        border-radius: 8px;
    }
    
    .btn-lg {
        padding: 16px 24px;
        font-size: 18px;
    }
    
    .btn-sm {
        padding: 8px 16px;
        font-size: 14px;
        min-height: 36px;
    }
}

/* 小屏幕（平板，768px到991.98px） */
@media (min-width: 768px) and (max-width: 991.98px) {
    .container {
        max-width: 720px;
    }
}

/* 中等屏幕（小桌面，992px到1199.98px） */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .container {
        max-width: 960px;
    }
}

/* ==================== 学生学习界面移动端优化 ==================== */
@media (max-width: 767.98px) {
    /* 3D卡片优化 */
    .card-3d {
        width: 100%;
        max-width: 350px;
        height: 200px;
        margin: 10px auto;
    }
    
    .card-content {
        padding: 15px;
        font-size: 16px;
    }
    
    .word-text {
        font-size: 24px;
        margin-bottom: 10px;
    }
    
    .phonetic {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .meaning {
        font-size: 16px;
        line-height: 1.4;
    }
    
    /* 控制按钮优化 */
    .controls {
        flex-wrap: wrap;
        gap: 10px;
        padding: 15px;
    }
    
    .control-btn {
        flex: 1;
        min-width: 120px;
        padding: 12px;
        font-size: 16px;
    }
    
    /* 语音控制面板 */
    .voice-controls {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e0e0e0;
        padding: 15px;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    
    .voice-control-item {
        margin-bottom: 15px;
    }
    
    .voice-control-item:last-child {
        margin-bottom: 0;
    }
    
    /* 进度条优化 */
    .progress-bar {
        height: 6px;
        border-radius: 3px;
    }
    
    /* 导航优化 */
    .navigation {
        position: fixed;
        bottom: 80px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        gap: 15px;
        z-index: 1000;
    }
    
    .nav-btn {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--gradient-primary);
        color: white;
        border: none;
        box-shadow: 0 4px 15px rgba(0,0,0,0.2);
        font-size: 20px;
    }
}

/* ==================== 教师管理界面移动端优化 ==================== */
@media (max-width: 767.98px) {
    /* 表格优化 */
    .table-responsive {
        border: none;
    }
    
    .table {
        font-size: 14px;
    }
    
    .table th,
    .table td {
        padding: 8px 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
    }
    
    /* 卡片布局优化 */
    .card {
        margin-bottom: 15px;
        border-radius: 12px;
    }
    
    .card-header {
        padding: 12px 15px;
        font-size: 16px;
        font-weight: 600;
    }
    
    .card-body {
        padding: 15px;
    }
    
    /* 表单优化 */
    .form-group {
        margin-bottom: 20px;
    }
    
    .form-control {
        padding: 12px 15px;
        font-size: 16px;
        border-radius: 8px;
        border: 2px solid #e0e0e0;
    }
    
    .form-control:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    }
    
    /* 模态框优化 */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-content {
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-footer {
        padding: 15px 20px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .modal-footer .btn {
        flex: 1;
    }
}

/* ==================== 平板优化 ==================== */
@media (min-width: 768px) and (max-width: 1024px) {
    /* 3D卡片适配平板 */
    .card-3d {
        width: 400px;
        height: 250px;
    }
    
    .word-text {
        font-size: 32px;
    }
    
    .meaning {
        font-size: 18px;
    }
    
    /* 控制面板适配 */
    .controls {
        justify-content: center;
        gap: 20px;
    }
    
    .control-btn {
        min-width: 140px;
        padding: 15px 20px;
        font-size: 16px;
    }
}

/* ==================== 横屏优化 ==================== */
@media screen and (orientation: landscape) and (max-height: 500px) {
    /* 横屏时优化布局 */
    .card-3d {
        height: 180px;
        margin: 5px auto;
    }
    
    .controls {
        padding: 10px;
    }
    
    .voice-controls {
        max-height: 40vh;
        overflow-y: auto;
    }
    
    .navigation {
        bottom: 60px;
    }
}

/* ==================== 深色模式支持 ==================== */
@media (prefers-color-scheme: dark) {
    .voice-controls {
        background: #2d3748;
        border-top-color: #4a5568;
        color: white;
    }
    
    .form-control {
        background-color: #2d3748;
        border-color: #4a5568;
        color: white;
    }
    
    .form-control:focus {
        background-color: #2d3748;
        border-color: var(--primary-color);
    }
    
    .modal-content {
        background-color: #2d3748;
        color: white;
    }
}

/* ==================== 高对比度支持 ==================== */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .form-control {
        border-width: 2px;
    }
    
    .card {
        border-width: 2px;
    }
}

/* ==================== 减少动画支持 ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .card-3d {
        transform: none !important;
    }
    
    .btn:active {
        transform: none !important;
    }
}

/* ==================== 打印样式 ==================== */
@media print {
    .voice-controls,
    .navigation,
    .controls,
    .btn {
        display: none !important;
    }
    
    .card-3d {
        transform: none !important;
        box-shadow: none !important;
        border: 1px solid #000;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}
