/**
 * 移动端优化样式
 * 针对移动设备的体验增强
 */

/* 触摸优化 - 增大点击区域 */
button, a, input, select, .form-check {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* 按钮和可点击元素的最小尺寸 */
.btn, .btn-group > .btn, .nav-link, .dropdown-item {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 移动端优先的响应式设计 */
@media (max-width: 768px) {
    /* 容器优化 */
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* 卡片样式优化 */
    .card {
        margin-bottom: 16px;
        padding: 16px;
        border-radius: 12px;
    }

    .card-header {
        padding: 14px 16px;
        font-size: 15px;
    }

    .card-body {
        padding: 16px;
    }

    /* 表单优化 */
    .form-label {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .form-control, .form-select {
        font-size: 16px; /* 防止iOS自动缩放 */
        padding: 12px 14px;
        min-height: 48px;
    }

    .input-group-text {
        font-size: 16px;
        padding: 0 14px;
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    /* 按钮优化 */
    .btn {
        font-size: 15px;
        padding: 12px 20px;
        font-weight: 500;
    }

    .btn-sm {
        padding: 8px 14px;
        font-size: 13px;
    }

    .btn-lg {
        padding: 14px 24px;
        font-size: 16px;
    }

    /* 表格优化 - 移动端横向滚动 */
    .table-responsive {
        border-radius: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        font-size: 14px;
        white-space: nowrap;
    }

    .table thead th {
        padding: 12px 10px;
    }

    .table tbody td {
        padding: 12px 10px;
    }

    /* 分页优化 */
    .pagination {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .pagination .page-item {
        display: block;
    }

    .pagination .page-link {
        padding: 8px 12px;
        font-size: 14px;
        min-width: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* 导航优化 */
    .navbar {
        padding: 12px 16px;
    }

    .navbar-brand {
        font-size: 16px;
    }

    .navbar-nav {
        flex-direction: column;
        width: 100%;
    }

    .nav-link {
        padding: 12px 16px;
    }

    /* 侧边栏优化 */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* 移动端菜单切换按钮 */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        height: 48px;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 20px;
        cursor: pointer;
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 1060;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    /* 弹窗优化 */
    .modal-dialog {
        margin: 0;
        height: 100%;
        max-width: 100%;
    }

    .modal-content {
        height: 100%;
        border-radius: 0;
        border: none;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 16px;
    }

    /* 徽章和标签优化 */
    .badge {
        font-size: 11px;
        padding: 4px 8px;
    }

    /* 工具提示优化 */
    [data-bs-toggle="tooltip"] {
        touch-action: none;
    }

    /* 输入组优化 */
    .input-group {
        flex-direction: column;
    }

    .input-group > .form-control,
    .input-group > .form-select,
    .input-group > .input-group-text {
        border-radius: 8px !important;
        margin-bottom: 8px;
        width: 100%;
    }

    .input-group > .input-group-text {
        margin-bottom: 0;
    }

    /* 复选框和单选框优化 */
    .form-check {
        padding: 12px 14px;
        margin-bottom: 8px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .form-check:hover {
        background-color: #f8f9fa;
    }

    .form-check-input {
        width: 20px;
        height: 20px;
        margin-top: 0;
    }

    .form-check-label {
        font-size: 14px;
        margin-left: 12px;
    }

    /* 警告和提示框优化 */
    .alert {
        padding: 14px 16px;
        font-size: 14px;
        border-radius: 12px;
        margin-bottom: 16px;
    }

    /* 日期选择器优化 */
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"] {
        font-size: 16px;
        padding: 12px 14px;
    }

    /* 下拉菜单优化 */
    .dropdown-menu {
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .dropdown-item {
        padding: 12px 16px;
        font-size: 15px;
    }

    /* 进度条优化 */
    .progress {
        height: 24px;
        border-radius: 12px;
    }

    .progress-bar {
        font-size: 13px;
        line-height: 24px;
    }

    /* 分隔线优化 */
    .divider {
        height: 1px;
        background: #e9ecef;
        margin: 16px 0;
    }

    /* 统计卡片优化 */
    .stat-card {
        padding: 20px;
        border-radius: 12px;
        margin-bottom: 16px;
    }

    .stat-number {
        font-size: 28px;
        font-weight: 700;
    }

    .stat-label {
        font-size: 13px;
        opacity: 0.8;
    }

    /* 列表优化 */
    .list-group-item {
        padding: 14px 16px;
        font-size: 15px;
    }

    /* 卡片网格优化 */
    .card-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* 两列布局优化 */
    .two-column {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* 三列布局优化 */
    .three-column {
        grid-template-columns: 1fr;
        gap: 16px;
    }

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

    /* 代码块优化 */
    pre {
        padding: 14px;
        font-size: 13px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }

    /* 表单行优化 */
    .row {
        margin-left: -8px;
        margin-right: -8px;
    }

    .col,
    .col-1,
    .col-2,
    .col-3,
    .col-4,
    .col-5,
    .col-6,
    .col-7,
    .col-8,
    .col-9,
    .col-10,
    .col-11,
    .col-12 {
        padding-left: 8px;
        padding-right: 8px;
    }

    /* 文本大小优化 */
    h1 { font-size: 24px; }
    h2 { font-size: 22px; }
    h3 { font-size: 20px; }
    h4 { font-size: 18px; }
    h5 { font-size: 16px; }
    h6 { font-size: 14px; }

    p { font-size: 15px; line-height: 1.6; }
    small { font-size: 13px; }
}

/* 超小屏幕 (iPhone SE, etc.) */
@media (max-width: 375px) {
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    .card {
        padding: 14px;
        margin-bottom: 12px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .form-control,
    .form-select {
        font-size: 16px;
        padding: 10px 12px;
    }
}

/* 平板优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .container-fluid {
        padding-left: 20px;
        padding-right: 20px;
    }

    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .two-column {
        grid-template-columns: 1fr 1fr;
    }
}

/* 横屏优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .navbar {
        padding: 8px 16px;
        height: 50px;
    }

    .navbar-brand {
        font-size: 14px;
    }

    .card {
        padding: 12px;
        margin-bottom: 12px;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    }
}

/* 减少动画性能消耗（适合低端设备） */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .card {
        background: #1a1a2e;
        border-color: #2a2a4e;
        color: #e0e0e0;
    }

    .form-control,
    .form-select {
        background-color: #16213e;
        border-color: #2a2a4e;
        color: #e0e0e0;
    }

    .table {
        color: #e0e0e0;
    }

    .table thead th {
        background-color: #1a1a2e;
        border-color: #2a2a4e;
    }
}

/* 打印优化 */
@media print {
    .mobile-menu-toggle,
    .sidebar,
    .sidebar-overlay,
    .btn-no-print {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}
