/* 移动端优化样式表 */
/* 为所有页面提供统一的移动端体验优化 */

/* 基础移动端优化 */
@media screen and (max-width: 768px) {

    /* 防止iOS Safari中的缩放 */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px !important;
    }

    /* 优化触摸目标大小 */
    button,
    .btn,
    .action-btn,
    .fab {
        min-height: 44px;
        min-width: 44px;
    }

    /* 优化链接触摸区域 */
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* 防止文本选择 */
    * {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }

    /* 允许输入框文本选择 */
    input,
    textarea {
        -webkit-user-select: text;
        -khtml-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }

    /* 优化滚动性能 */
    * {
        -webkit-overflow-scrolling: touch;
    }

    /* 防止双击缩放 */
    * {
        touch-action: manipulation;
    }

    /* 优化图片显示 */
    img {
        max-width: 100%;
        height: auto;
    }

    /* 优化表格显示 */
    table {
        font-size: 14px;
    }

    /* 优化模态框 */
    .modal {
        padding: 10px;
    }

    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }

    /* 优化侧边栏 */
    .sidebar {
        -webkit-overflow-scrolling: touch;
    }

    /* 优化搜索框 */
    .search-container {
        position: relative;
    }

    /* 优化卡片阴影 */
    .laser-card,
    .item-card,
    .project-card,
    .tutorial-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    /* 优化按钮状态 */
    .btn:active,
    .action-btn:active,
    .fab:active {
        transform: scale(0.95);
    }

    /* 优化表单元素 */
    .form-group {
        margin-bottom: 20px;
    }

    .form-group label {
        display: block;
        margin-bottom: 8px;
        font-weight: 500;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
        padding: 12px;
        border: 1px solid #ddd;
        border-radius: 8px;
        font-size: 16px;
    }

    .form-group input:focus,
    .form-group select:focus,
    .form-group textarea:focus {
        outline: none;
        border-color: #2980b9;
        box-shadow: 0 0 0 2px rgba(41, 128, 185, 0.2);
    }
}

/* 小屏幕手机优化 */
@media screen and (max-width: 480px) {

    /* 进一步减小字体和间距 */
    body {
        font-size: 14px;
    }

    h1 {
        font-size: 20px;
    }

    h2 {
        font-size: 18px;
    }

    h3 {
        font-size: 16px;
    }

    /* 优化按钮大小 */
    .btn,
    .action-btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .fab {
        width: 56px;
        height: 56px;
        font-size: 20px;
    }

    /* 优化模态框 */
    .modal {
        padding: 5px;
    }

    .modal-content {
        padding: 15px;
    }

    /* 优化表单 */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 10px;
        font-size: 16px;
    }
}

/* 横屏模式优化 */
@media screen and (max-width: 768px) and (orientation: landscape) {

    /* 减少顶部间距 */
    .top-header {
        height: 45px;
    }

    .main-container,
    .manage-container {
        margin-top: 55px;
    }

    /* 优化卡片布局 */
    .laser-grid,
    .items-grid,
    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 10px;
    }

    /* 优化图片高度 */
    .laser-image,
    .item-image,
    .project-image {
        height: 80px;
    }

    .tutorial-image {
        height: 100px;
    }
}

/* 大屏幕手机优化 */
@media screen and (min-width: 481px) and (max-width: 768px) {

    /* 优化网格布局 */
    .laser-grid,
    .items-grid,
    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 20px;
    }

    .tutorial-grid {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
        gap: 20px;
    }

    /* 优化卡片最大宽度 */
    .laser-card,
    .item-card,
    .project-card,
    .tutorial-card {
        max-width: 400px;
        margin: 0 auto;
    }
}

/* 触摸设备特定优化 */
@media (hover: none) and (pointer: coarse) {

    /* 移除悬停效果 */
    .laser-card:hover,
    .item-card:hover,
    .project-card:hover,
    .tutorial-card:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .btn:hover,
    .action-btn:hover,
    .fab:hover {
        transform: none;
    }

    /* 添加触摸反馈 */
    .laser-card:active,
    .item-card:active,
    .project-card:active,
    .tutorial-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }

    .btn:active,
    .action-btn:active,
    .fab:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    /* 优化边框和阴影 */
    .laser-card,
    .item-card,
    .project-card,
    .tutorial-card {
        border: 0.5px solid #e0e0e0;
    }

    /* 优化按钮边框 */
    .btn,
    .action-btn {
        border: 0.5px solid #ddd;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    /* 这里可以添加深色模式的样式 */
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 搜索建议样式 */
.search-suggestions {
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.suggestion-item:hover,
.suggestion-item:active {
    background-color: #f8f9fa;
}

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

/* 下拉刷新指示器样式 */
.pull-refresh-indicator {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* 加载状态优化 */
.loader-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2980b9;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* 错误状态样式 */
.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
    border-left: 4px solid #c62828;
}

/* 成功状态样式 */
.success-message {
    background: #e8f5e8;
    color: #2e7d32;
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
    border-left: 4px solid #2e7d32;
}

/* 警告状态样式 */
.warning-message {
    background: #fff3e0;
    color: #ef6c00;
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
    border-left: 4px solid #ef6c00;
}

/* 无障碍优化 */
@media (prefers-reduced-motion: reduce) {
    .loader-spinner {
        animation: none;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {

    .btn,
    .action-btn {
        border: 2px solid currentColor;
    }

    .modal-content {
        border: 2px solid currentColor;
    }
}