/* 移动端适配样式 */

/* 基础响应式设置 */
@media (max-width: 768px) {
    /* 侧边栏移动端适配 */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
        overflow-y: auto;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    /* 移动端导航栏 */
    .mobile-navbar {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        padding: 0.75rem 1rem;
        position: sticky;
        top: 0;
        z-index: 1040;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .mobile-navbar .navbar-brand {
        color: white;
        font-weight: bold;
        text-decoration: none;
        font-size: 1.1rem;
    }
    
    .mobile-menu-toggle {
        background: none;
        border: none;
        color: white;
        font-size: 1.2rem;
        padding: 0.5rem;
    }
    
    /* 主内容区移动端适配 */
    .main-content {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
    
    /* 页面标题区域 */
    .page-header {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
        margin-bottom: 0;
    }
    
    .btn-toolbar {
        width: 100%;
        justify-content: flex-start;
    }
    
    /* 卡片适配 */
    .card {
        margin: 0.5rem;
        border-radius: 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* 表格移动端适配 */
    .table-responsive {
        border: none;
        margin: -1rem;
        padding: 1rem;
    }
    
    .table {
        font-size: 0.85rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
    }
    
    /* 隐藏部分列在移动端 */
    .table .d-none-mobile {
        display: none !important;
    }
    
    /* 操作按钮组适配 */
    .btn-group-sm .btn {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
    }
    
    /* 表单适配 */
    .row.g-3 {
        margin: 0;
    }
    
    .row.g-3 > [class*="col-"] {
        padding: 0.25rem;
        margin-bottom: 0.75rem;
    }
    
    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }
    
    .form-control,
    .form-select {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }
    
    /* 按钮适配 */
    .btn {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }
    
    .btn-sm {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    
    /* 模态框适配 */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-lg {
        max-width: calc(100% - 1rem);
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-body .row {
        margin: 0;
    }
    
    .modal-body .col-md-6 {
        padding: 0.5rem 0;
    }
    
    /* 统计卡片适配 */
    .col-xl-3.col-md-6 {
        margin-bottom: 1rem;
    }
    
    .card.border-left-primary,
    .card.border-left-success,
    .card.border-left-info,
    .card.border-left-warning {
        border-left: 4px solid;
    }
    
    /* 搜索筛选区域适配 */
    .search-filters .row > [class*="col-"] {
        margin-bottom: 0.75rem;
    }
    
    /* 徽章适配 */
    .badge {
        font-size: 0.7rem;
        padding: 0.35em 0.5em;
    }
    
    /* 提示消息适配 */
    .alert {
        margin: 0.5rem;
        font-size: 0.9rem;
    }
    
    /* 分页适配 */
    .pagination {
        justify-content: center;
        margin: 1rem 0;
    }
    
    .page-link {
        padding: 0.375rem 0.75rem;
        font-size: 0.85rem;
    }
}

/* 超小屏幕适配 (小于576px) */
@media (max-width: 576px) {
    .mobile-navbar {
        padding: 0.5rem;
    }
    
    .mobile-navbar .navbar-brand {
        font-size: 1rem;
    }
    
    .page-header h1 {
        font-size: 1.25rem;
    }
    
    .card {
        margin: 0.25rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .table {
        font-size: 0.8rem;
    }
    
    .table th,
    .table td {
        padding: 0.375rem 0.2rem;
        max-width: 100px;
    }
    
    .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .btn-sm {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }
    
    .form-control,
    .form-select {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
    }
    
    .modal-dialog {
        margin: 0.25rem;
        max-width: calc(100% - 0.5rem);
    }
}

/* 移动端侧边栏遮罩 */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1049;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

/* 移动端表格卡片视图 */
@media (max-width: 768px) {
    .table-card-view {
        display: none;
    }
    
    .table-card-view.active {
        display: block;
    }
    
    .table-responsive.d-none {
        display: none !important;
    }
    
    .table-card {
        background: white;
        border-radius: 0.5rem;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        border: 1px solid #e3e6f0;
    }
    
    .table-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid #e3e6f0;
    }
    
    .table-card-title {
        font-weight: bold;
        color: #5a5c69;
        margin: 0;
    }
    
    .table-card-body {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }
    
    .table-card-field {
        display: flex;
        flex-direction: column;
    }
    
    .table-card-label {
        font-size: 0.75rem;
        color: #858796;
        margin-bottom: 0.25rem;
        font-weight: 600;
    }
    
    .table-card-value {
        font-size: 0.85rem;
        color: #5a5c69;
        word-break: break-word;
    }
    
    .table-card-actions {
        display: flex;
        gap: 0.5rem;
        justify-content: flex-end;
        padding-top: 0.5rem;
        border-top: 1px solid #e3e6f0;
    }
}

/* 视图切换按钮 */
.view-toggle {
    display: none;
}

@media (max-width: 768px) {
    .view-toggle {
        display: flex;
        gap: 0.5rem;
        margin-bottom: 1rem;
        padding: 0 1rem;
    }
    
    .view-toggle .btn {
        flex: 1;
        font-size: 0.8rem;
    }
}

/* 移动端优化的输入组 */
@media (max-width: 768px) {
    .input-group {
        margin-bottom: 0.75rem;
    }
    
    .input-group-text {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
}

/* 移动端导航激活状态 */
@media (max-width: 768px) {
    .sidebar .nav-link.active {
        background: rgba(255,255,255,0.25);
        color: white;
    }
    
    .sidebar .nav-link {
        padding: 0.75rem 1rem;
        margin: 0.125rem 0;
    }
}

/* 移动端表单按钮组 */
@media (max-width: 768px) {
    .form-button-group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .form-button-group .btn {
        width: 100%;
    }
}

/* 移动端数据表格优化 */
@media (max-width: 768px) {
    .dataTables_wrapper {
        font-size: 0.85rem;
    }
    
    .dataTables_filter {
        margin-bottom: 1rem;
    }
    
    .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
    }
    
    .dataTables_length {
        margin-bottom: 1rem;
    }
    
    .dataTables_info {
        font-size: 0.8rem;
        margin-top: 1rem;
    }
    
    .dataTables_paginate {
        margin-top: 1rem;
    }
}

/* 移动端加载状态优化 */
@media (max-width: 768px) {
    .spinner-border {
        width: 2rem;
        height: 2rem;
    }
    
    .loading-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(255, 255, 255, 0.9);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 9999;
    }
}

/* 移动端滚动优化 */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }
    
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    
    .sidebar {
        -webkit-overflow-scrolling: touch;
    }
}