/* 性能优化和移动端适配样式 */

/* 基础优化 */
* {
    box-sizing: border-box;
}

/* 移动端触摸优化 */
@media (max-width: 768px) {
    .btn {
        min-height: 44px; /* 确保触摸目标足够大 */
        padding: 0.75rem 1rem;
    }
    
    .form-control {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 0.75rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    /* 移动端导航优化 */
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    /* 移动端表格优化 */
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .table td, .table th {
        padding: 0.5rem;
    }
}

/* 卡片悬停效果 */
.category-card-hover {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.category-card-hover:hover {
    transform: translateY(-5px);
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important;
}

/* 移动端禁用悬停效果 */
@media (hover: none) {
    .category-card-hover:hover {
        transform: none;
        box-shadow: 0 .125rem .25rem rgba(0,0,0,.075)!important;
    }
}

/* 性能优化 - 减少重绘 */
.progress-bar {
    will-change: width;
    transform: translateZ(0);
}

/* 移动端进度条优化 */
@media (max-width: 768px) {
    .progress {
        height: 20px;
    }
    
    .progress-bar {
        font-size: 0.75rem;
        line-height: 20px;
    }
}

/* 移动端模态框优化 */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: 0.5rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
}

/* 移动端表单优化 */
@media (max-width: 768px) {
    .form-check {
        margin-bottom: 0.75rem;
    }
    
    .form-check-input {
        margin-top: 0.2rem;
    }
    
    .form-check-label {
        padding-left: 0.5rem;
        line-height: 1.4;
    }
}

/* 移动端按钮组优化 */
@media (max-width: 768px) {
    .btn-group {
        display: flex;
        flex-direction: column;
    }
    
    .btn-group .btn {
        border-radius: 0.375rem !important;
        margin-bottom: 0.25rem;
    }
    
    .btn-group .btn:first-child {
        border-radius: 0.375rem !important;
    }
    
    .btn-group .btn:last-child {
        border-radius: 0.375rem !important;
        margin-bottom: 0;
    }
}

/* 移动端徽章优化 */
@media (max-width: 768px) {
    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

/* 移动端图标优化 */
@media (max-width: 768px) {
    .bi {
        font-size: 1.1em;
    }
}

/* 性能优化 - 图片懒加载 */
.lazy-image {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.lazy-image.loaded {
    opacity: 1;
}

/* 移动端文本优化 */
@media (max-width: 768px) {
    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; }
    
    .display-1 { font-size: 2.5rem; }
    .display-2 { font-size: 2rem; }
    .display-3 { font-size: 1.75rem; }
    .display-4 { font-size: 1.5rem; }
    .display-5 { font-size: 1.25rem; }
    .display-6 { font-size: 1.1rem; }
}

/* 移动端间距优化 */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .row {
        margin-left: -0.375rem;
        margin-right: -0.375rem;
    }
    
    .col, [class*="col-"] {
        padding-left: 0.375rem;
        padding-right: 0.375rem;
    }
}

/* 移动端警告框优化 */
@media (max-width: 768px) {
    .alert {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .alert p {
        margin-bottom: 0.5rem;
    }
    
    .alert p:last-child {
        margin-bottom: 0;
    }
}

/* 性能优化 - 减少动画在低端设备上的使用 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .category-card-hover:hover {
        transform: none;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .card {
        background-color: #2d3748;
        border-color: #4a5568;
    }
    
    .card-header {
        background-color: #4a5568;
        border-bottom-color: #718096;
    }
    
    .table {
        color: #e2e8f0;
    }
    
    .table-striped > tbody > tr:nth-of-type(odd) {
        background-color: rgba(255, 255, 255, 0.05);
    }
}

/* 打印样式优化 */
@media print {
    .navbar,
    .btn,
    .modal,
    .alert {
        display: none !important;
    }
    
    .card {
        border: 1px solid #000;
        box-shadow: none;
    }
    
    .table {
        border: 1px solid #000;
    }
    
    .table td,
    .table th {
        border: 1px solid #000;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .btn {
        border-width: 2px;
    }
    
    .form-control {
        border-width: 2px;
    }
    
    .card {
        border-width: 2px;
    }
}

/* 移动端加载状态优化 */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

/* 移动端焦点优化 */
@media (max-width: 768px) {
    .form-control:focus,
    .btn:focus {
        outline: 2px solid #007bff;
        outline-offset: 2px;
    }
}
