/* 基础样式 - H5自适应优化 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    font-size: 16px;
}

.container {
    min-height: 100vh;
    max-width: 100%;
    overflow-x: hidden;
}

/* 页面切换 */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* 登录页面样式 - 移动端优化 */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 2rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* 移动端登录表单优化 */
.login-container input[type="text"],
.login-container input[type="password"] {
    font-size: 16px; /* 防止iOS缩放 */
}

.login-container h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: #2c3e50;
}

/* 主系统页面样式 - 移动端优化 */
#main-page header {
    background: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* 导航栏样式 - 移动端优化 */
nav {
    background: #34495e;
    padding: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

/* 导航按钮移动端优化 */
.nav-btn {
    background: transparent;
    border: 1px solid #4a6278;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    text-align: center;
    min-width: 80px;
    flex: 1;
    max-width: 120px;
}

.nav-btn {
    background: transparent;
    border: 1px solid #4a6278;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.nav-btn:hover, .nav-btn.active {
    background: #4a6278;
}

/* 主内容区域 - 移动端优化 */
main {
    padding: 1rem;
    background: white;
    min-height: calc(100vh - 140px);
}

/* 操作栏样式 */
.action-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: center;
}

.action-bar select, .action-bar input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}
/* 材料网格布局 - 移动端优先 */
.materials-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin: 1rem 0;
}

@media (min-width: 480px) {
    .materials-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (min-width: 768px) {
    .materials-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 1.5rem;
    }
}

/* 材料卡片样式 - 移动端优化 */
.material-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.75rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

.material-card:active {
    transform: scale(0.98);
    box-shadow: none;
}

.material-card h3 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

@media (min-width: 768px) {
    .material-card h3 {
        font-size: 1.1rem;
    }
}

.material-price {
    font-size: 1.1rem;
    font-weight: bold;
    color: #e74c3c;
    margin: 0.5rem 0;
}

.material-stock {
    color: #666;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

/* 数量控制区域 - 移动端优化 */
.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.quantity-controls input {
    width: 100%;
    padding: 0.5rem;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    margin: 0.5rem 0;
}

@media (min-width: 480px) {
    .quantity-controls input {
        width: 60px;
        margin: 0;
    }
}

.quantity-controls button {
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    border-radius: 4px;
    border: 1px solid #ddd;
    background-color: #f5f5f5;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quantity-controls button:hover {
    background-color: #e0e0e0;
}

.quantity-controls button:active {
    background-color: #d0d0d0;
    transform: scale(0.98);
}

.quantity-controls .btn-decrease {
    background-color: #f8f9fa;
    border-color: #ddd;
}

.quantity-controls .btn-increase {
    background-color: #f8f9fa;
    border-color: #ddd;
}

.quantity-controls .btn-primary {
    flex: 1;
    min-height: 2.5rem;
    font-size: 1rem;
    background-color: #007bff;
    color: white;
    border: none;
}

.quantity-controls .btn-primary:hover {
    background-color: #0069d9;
}

.quantity-controls .btn-primary:active {
    background-color: #005cbf;
    transform: scale(0.98);
}

/* 购物车样式 */
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.cart-summary {
    margin-top: 2rem;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.cart-summary h3 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.order-total {
    font-size: 1.2rem;
    margin: 1.5rem 0;
    text-align: right;
    background: white;
    padding: 1rem;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* 订单列表样式 */
.order-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #fafafa;
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.order-status {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.status-pending { background: #fff3cd; color: #856404; }
.status-confirmed { background: #d1ecf1; color: #0c5460; }
.status-delivered { background: #d4edda; color: #155724; }
.status-completed { background: #d4edda; color: #155724; }

/* 个人中心样式 */
.profile-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.material-stock-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
}

/* 管理后台样式 */
.admin-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin-bottom: 1rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    border-bottom-color: #3498db;
    color: #3498db;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.admin-table th, .admin-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.admin-table th {
    background: #f8f9fa;
    font-weight: 600;
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* 表单操作按钮组 */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

.form-actions .btn-secondary,
.form-actions .btn-primary {
    width: auto;
    min-width: 80px;
    margin-top: 0;
}

/* 用户表单特定样式 */
#user-form-modal .modal-content {
    max-width: 500px;
}

#user-form h3 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
    text-align: center;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

/* 表单样式 */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
}

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

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* 按钮样式 */
.btn-primary {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    width: 100%;
    margin-top: 1rem;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

.btn-danger {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

.btn-warning {
    background: #f39c12;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

/* 消息提示 */
.message {
    padding: 0.75rem;
    border-radius: 4px;
    margin: 1rem 0;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* H5自适应响应式设计 - 多断点优化 */
@media (max-width: 1200px) {
    .materials-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    
    .profile-content {
        gap: 1.5rem;
    }
}

/* 平板设备优化 */
@media (max-width: 768px) {
    /* 基础布局调整 */
    body {
        font-size: 15px;
    }
    
    #main-page header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .user-info {
        justify-content: center;
    }
    
    nav {
        padding: 0.75rem;
        gap: 0.25rem;
    }
    
    .nav-btn {
        font-size: 13px;
        padding: 0.4rem 0.75rem;
        min-width: 70px;
        flex: 0 1 auto;
    }
    
    main {
        padding: 0.75rem;
    }
    
    /* 内容布局调整 */
    .profile-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .materials-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .action-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .admin-tabs {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .tab-btn {
        padding: 0.5rem 1rem;
        font-size: 14px;
    }
    
    .modal-content {
        margin: 5% auto;
        width: 95%;
        padding: 1.5rem;
    }
    
    /* 购物车优化 */
    .cart-item {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        text-align: center;
    }
    
    .cart-summary {
        padding: 1.5rem;
        margin-top: 1rem;
    }
    
    .order-total {
        margin: 1rem 0;
        padding: 0.75rem;
    }
}

/* 手机设备优化 */
@media (max-width: 480px) {
    /* 基础样式优化 */
    body {
        font-size: 14px;
    }
    
    #main-page header h1 {
        font-size: 1.5rem;
    }
    
    .user-info {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-btn {
        white-space: nowrap;
        flex: 0 0 auto;
        min-width: auto;
        padding: 0.4rem 0.6rem;
        font-size: 12px;
    }
    
    main {
        padding: 0.5rem;
    }
    
    /* 表单优化 */
    .form-group input, .form-group select, .form-group textarea {
        padding: 0.6rem;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    .btn-primary {
        padding: 0.8rem;
        font-size: 16px;
    }
    
    /* 材料卡片优化 */
    .material-card {
        padding: 0.75rem;
    }
    
    .quantity-controls {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .quantity-controls input {
        width: 100%;
    }
    
    /* 订单和表格优化 */
    .order-item {
        padding: 0.75rem;
    }
    
    .order-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .admin-table {
        font-size: 13px;
    }
    
    .admin-table th, .admin-table td {
        padding: 0.5rem;
    }
    
    .modal-content {
        margin: 2% auto;
        padding: 1rem;
        border-radius: 4px;
    }
    
    .close {
        right: 0.5rem;
        top: 0.5rem;
    }
}

/* 超小屏设备优化 */
@media (max-width: 320px) {
    .nav-btn {
        padding: 0.3rem 0.5rem;
        font-size: 11px;
    }
    
    .login-container {
        margin: 50px auto;
        padding: 1rem;
    }
    
    .action-bar select, .action-bar input {
        font-size: 14px;
    }
}

/* 移动端专属优化 */
/* 触摸按钮优化 */
.btn-primary, .btn-secondary, .btn-danger, .nav-btn, .tab-btn {
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 输入框优化，防止iOS自动缩放 */
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="tel"],
.form-group input[type="email"],
.form-group select {
    font-size: 16px;
    -webkit-appearance: none;
    border-radius: 4px;
}

/* 防止长按菜单 */
.nav-btn, .btn-primary, .btn-secondary {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* 移动端滚动优化 */
nav {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

nav::-webkit-scrollbar {
    display: none;
}

/* 移动端标题自适应 */
@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }
    
    h2, h3 {
        font-size: 1.25rem;
    }
}

/* 移动端加载状态优化 */
.loading {
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* 防止iOS橡皮筋效果 */
.container {
    position: relative;
    min-height: 100vh;
}

/* 移动端列表项触摸反馈 */
.material-card, .cart-item, .order-item {
    transition: all 0.2s ease;
}

.material-card:active, .cart-item:active, .order-item:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* 订单状态选择框移动端优化 */
.order-status-select {
    min-width: 100px;
    height: 32px;
    padding: 0.25rem;
    font-size: 13px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.order-status-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 移动端状态更新提示 */
.order-status-container {
    position: relative;
}

.order-status-updating {
    display: inline-block;
    margin-left: 8px;
    font-size: 12px;
    color: #3498db;
    font-weight: 500;
}

.order-status-success {
    color: #27ae60 !important;
}

@media (max-width: 480px) {
    .order-status-select {
        min-width: 80px;
        font-size: 12px;
        padding: 0.2rem;
    }
    
    .admin-table th:nth-child(2),
    .admin-table td:nth-child(2) {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .admin-table th:nth-child(4),
    .admin-table td:nth-child(4) {
        min-width: 90px;
    }
    
    .order-status-updating {
        font-size: 11px;
        margin-left: 4px;
    }
}

/* 加载动画 */
.loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* 库存状态 */
.low-stock {
    color: #e74c3c;
    font-weight: bold;
}

.normal-stock {
    color: #27ae60;
}