/**
 * 移动端适配样式
 * 响应式设计，优化移动端用户体验
 */

/* 汉堡菜单按钮样式 */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.mobile-menu-toggle span {
    width: 100%;
    height: 2px;
    background: #2c3e50;
    border-radius: 1px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* 侧边栏样式 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-content {
    position: relative;
    z-index: 1000;
}

.sidebar-header {
    display: none;
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    color: #2c3e50;
}

.sidebar-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #374151;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.menu-item:hover {
    background: #f3f4f6;
}

.menu-item.active {
    border-left-color: #007bff;
    background: #eef2ff;
    color: #007bff;
}

.menu-icon {
    margin-right: 12px;
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.menu-text {
    font-size: 14px;
    font-weight: 500;
}

/* 移动端基础样式 */
@media (max-width: 768px) {
    /* 基础布局调整 */
    html, body {
        overflow-x: hidden;
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    /* 页面布局 */
    .page {
        min-height: 100vh;
    }
    
    /* 头部优化 */
    .header {
        height: 56px;
        padding: 0 16px;
        position: relative;
        z-index: 1000;
    }
    
    .header-left {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .header-center {
        flex: 1;
        display: flex;
        justify-content: center;
    }
    
    .header-right {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .header .brand {
        font-size: 16px;
        font-weight: 600;
    }
    
    .header-title {
        font-size: 14px;
        font-weight: 500;
    }
    
    .header .btn {
        padding: 8px 12px;
        font-size: 12px;
        min-height: 36px;
    }
    
    /* 主内容区域 */
    .main {
        flex-direction: column;
    }
    
    /* 侧边栏移动端样式 */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        background: #fff;
        border-right: 1px solid #e5e7eb;
        transition: left 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .sidebar-overlay {
        display: block;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .sidebar.open + .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }
    
    .sidebar-header {
        display: flex;
    }
    
    .menu {
        padding: 0;
    }
    
    .menu-item {
        padding: 16px 20px;
        border-left: none;
        border-bottom: 1px solid #f3f4f6;
        animation: none;
    }
    
    .menu-item.active {
        border-left: none;
        background: #eef2ff;
        color: #007bff;
    }
    
    .menu-icon {
        font-size: 18px;
        width: 24px;
    }
    
    .menu-text {
        font-size: 15px;
    }
    
    .content-wrap {
        flex: 1;
        overflow-x: hidden;
    }
    
    .content {
        padding: 16px;
    }
    
    /* 卡片样式优化 */
    .card {
        margin-bottom: 16px;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        border: 1px solid #f0f0f0;
        animation: none;
    }
    
    .card-header {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        background: #fafafa;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .card-title {
        font-size: 16px;
        margin: 0;
        font-weight: 600;
        color: #2c3e50;
    }
    
    .card-body {
        padding: 16px;
    }
    
    /* 统计卡片网格优化 */
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .stat-card {
        text-align: center;
        padding: 20px 16px;
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        border: 1px solid #f0f0f0;
        animation: none;
    }
    
    .stat-number {
        font-size: 24px;
        font-weight: bold;
        margin-bottom: 8px;
        line-height: 1;
    }
    
    .stat-label {
        font-size: 12px;
        color: #666;
        margin: 0;
    }
    
    /* 网格布局优化 */
    .grid-2 {
        display: grid;
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    /* 表格移动端优化 */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        border: 1px solid #e5e7eb;
    }
    
    .table {
        min-width: 600px;
        font-size: 13px;
        margin: 0;
    }
    
    .table th,
    .table td {
        padding: 12px 8px;
        white-space: nowrap;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .table th {
        background: #f8f9fa;
        font-weight: 600;
        color: #495057;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .table tbody tr:hover {
        background: #f8f9fa;
    }
    
    /* 状态徽章优化 */
    .status-badge {
        display: inline-block;
        padding: 4px 8px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .status-active {
        background: #d4edda;
        color: #155724;
    }
    
    .status-warning {
        background: #fff3cd;
        color: #856404;
    }
    
    .status-danger {
        background: #f8d7da;
        color: #721c24;
    }
    
    .status-info {
        background: #d1ecf1;
        color: #0c5460;
    }
    
    /* 表单优化 */
    .form-group {
        margin-bottom: 16px;
    }
    
    .form-label {
        font-size: 14px;
        margin-bottom: 6px;
        display: block;
    }
    
    .form-control {
        width: 100%;
        padding: 10px 12px;
        font-size: 16px; /* 防止iOS缩放 */
        border-radius: 6px;
        border: 1px solid #ddd;
        box-sizing: border-box;
    }
    
    .form-control:focus {
        border-color: #007bff;
        outline: none;
        box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    }
    
    /* 按钮优化 */
    .btn {
        padding: 10px 16px;
        font-size: 14px;
        border-radius: 6px;
        min-height: 44px; /* 触摸友好的最小高度 */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        border: none;
        cursor: pointer;
        transition: all 0.2s ease;
        animation: none;
    }
    
    .btn-sm {
        padding: 6px 12px;
        font-size: 12px;
        min-height: 36px;
    }
    
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    /* 标签页优化 */
    .tabs {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-bottom: 1px solid #e5e7eb;
        margin-bottom: 16px;
    }
    
    .tab {
        flex-shrink: 0;
        padding: 12px 16px;
        font-size: 14px;
        white-space: nowrap;
        border-bottom: 2px solid transparent;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .tab.active {
        border-bottom-color: #007bff;
        color: #007bff;
    }
    
    /* 统计卡片 */
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .stat-card {
        text-align: center;
        padding: 16px;
        background: white;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    .stat-number {
        font-size: 24px;
        font-weight: bold;
        margin-bottom: 4px;
    }
    
    .stat-label {
        font-size: 12px;
        color: #666;
    }
    
    /* 模态框优化 */
    .modal {
        padding: 16px;
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 8px;
    }
    
    .modal-header {
        padding: 16px;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .modal-body {
        padding: 16px;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 16px;
        border-top: 1px solid #e5e7eb;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    /* 消息提示优化 */
    .message-box {
        position: fixed;
        top: 20px;
        left: 12px;
        right: 12px;
        z-index: 10000;
        padding: 12px 16px;
        border-radius: 6px;
        font-size: 14px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        animation: slideInDown 0.3s ease-out;
    }
    
    /* 加载状态优化 */
    .loading {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }
    
    .loading::after {
        content: '';
        width: 20px;
        height: 20px;
        border: 2px solid #f3f3f3;
        border-top: 2px solid #007bff;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }
    
    /* 工具提示 */
    .tooltip {
        position: relative;
    }
    
    .tooltip:hover .tooltip-text {
        display: block;
    }
    
    .tooltip-text {
        display: none;
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        background: #333;
        color: white;
        padding: 6px 8px;
        border-radius: 4px;
        font-size: 12px;
        white-space: nowrap;
        z-index: 1000;
        margin-bottom: 4px;
    }
    
    /* 响应式网格 */
    .grid {
        display: grid;
        gap: 16px;
    }
    
    .grid-1 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    
    /* 隐藏桌面端元素 */
    .desktop-only {
        display: none !important;
    }
    
    /* 显示移动端元素 */
    .mobile-only {
        display: block !important;
    }
    
    /* 文本优化 */
    .text-center-mobile {
        text-align: center;
    }
    
    .text-small-mobile {
        font-size: 12px;
    }
    
    /* 间距优化 */
    .mb-mobile {
        margin-bottom: 16px;
    }
    
    .p-mobile {
        padding: 12px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    .header {
        height: 48px;
        padding: 0 12px;
    }
    
    .header .brand {
        font-size: 14px;
    }
    
    .header-title {
        font-size: 13px;
    }
    
    .content {
        padding: 12px;
    }
    
    .card-body {
        padding: 12px;
    }
    
    .card-header {
        padding: 12px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .stat-card {
        padding: 16px 12px;
    }
    
    .stat-number {
        font-size: 20px;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    .status-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .menu-item {
        padding: 14px 16px;
    }
    
    .menu-text {
        font-size: 14px;
    }
    
    .menu-icon {
        font-size: 16px;
        width: 20px;
    }
}


/* 动画 */
@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 触摸优化 */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
    }
    
    .btn:active {
        transform: scale(0.98);
    }
    
    .tab:hover {
        background: none;
    }
    
    .tab:active {
        background: rgba(0, 123, 255, 0.1);
    }
}
