/* ====================================
   移动端响应式样式
   适用于订货管理系统所有页面
   ==================================== */

/* ========== 平板和手机通用样式（宽度 ≤ 1024px）========== */
@media screen and (max-width: 1024px) {
  /* 统计卡片网格调整 */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  
  /* 图表网格调整 */
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  /* 内容卡片内边距减小 */
  .content-card {
    padding: 20px;
  }
}

/* ========== 手机样式（宽度 ≤ 768px）========== */
@media screen and (max-width: 768px) {
  /* ----- 基础布局调整 ----- */
  body {
    font-size: 14px;
  }
  
  .main-layout {
    flex-direction: column;
  }
  
  /* ----- 侧边栏改为顶部导航 ----- */
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #e8e8e8;
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  }
  
  .sidebar-header {
    height: 50px;
    padding: 0 12px;
  }
  
  .sidebar-header h1 {
    font-size: 16px;
  }
  
  /* 菜单项横向滑动 */
  .sidebar .menu-items {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
    scrollbar-width: none; /* Firefox */
  }
  
  .sidebar .menu-items::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }
  
  .sidebar .menu-item {
    padding: 10px 16px;
    white-space: nowrap;
    font-size: 14px;
    border-left: none;
    border-bottom: 3px solid transparent;
    flex-shrink: 0;
  }
  
  .sidebar .menu-item.active {
    border-left: none;
    border-bottom-color: #1890ff;
    background: #e6f7ff;
  }
  
  /* ----- 顶部导航栏 ----- */
  .top-header {
    height: 50px;
    padding: 0 12px;
    font-size: 14px;
  }
  
  .top-header .el-button {
    padding: 6px 12px;
    font-size: 13px;
    height: 32px;
  }
  
  /* ----- 内容区域调整 ----- */
  .content-body {
    padding: 12px;
  }
  
  .container {
    padding: 12px;
  }
  
  /* ----- 统计卡片单列显示 ----- */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .stat-card {
    padding: 16px;
  }
  
  .stat-value {
    font-size: 28px;
  }
  
  .stat-icon {
    font-size: 24px;
  }
  
  .trend-up,
  .trend-down {
    font-size: 12px;
  }
  
  /* ----- 内容卡片调整 ----- */
  .content-card {
    padding: 16px;
    margin-bottom: 12px;
  }
  
  .card-header {
    font-size: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
  }
  
  .section-title {
    font-size: 15px;
    margin: 16px 0 12px;
  }
  
  /* ----- 筛选栏调整 ----- */
  .filter-bar {
    flex-direction: column;
    gap: 10px;
  }
  
  .filter-bar > * {
    width: 100% !important;
  }
  
  .filter-bar .el-button {
    width: 100%;
  }
  
  /* ----- 表格调整 ----- */
  .el-table {
    font-size: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .el-table th {
    padding: 10px 0;
    font-size: 12px;
    white-space: nowrap;
  }
  
  .el-table td {
    padding: 10px 0;
    font-size: 12px;
  }
  
  /* 表格按钮调整 */
  .el-table .el-button {
    padding: 5px 8px;
    font-size: 12px;
    min-width: 60px !important;
    height: 32px !important;
    margin: 2px;
  }
  
  /* 表格操作列固定 */
  .el-table .el-table__fixed-right {
    width: 140px !important;
  }
  
  /* ----- 表单调整 ----- */
  .el-form-item {
    margin-bottom: 16px;
  }
  
  .el-form-item__label {
    font-size: 14px;
    margin-bottom: 4px;
    line-height: 1.5;
  }
  
  /* 输入框和选择器调整 */
  .el-input__inner,
  .el-textarea__inner,
  .el-select__input {
    font-size: 14px;
    height: 40px;
  }
  
  .el-textarea__inner {
    min-height: 80px;
  }
  
  /* 日期选择器调整 */
  .el-date-editor {
    width: 100% !important;
  }
  
  .el-date-editor--daterange {
    width: 100% !important;
  }
  
  .el-date-editor--daterange.el-input__inner {
    width: 100% !important;
  }
  
  /* ----- 对话框调整 ----- */
  .el-dialog {
    width: 90% !important;
    max-width: 90% !important;
    margin-top: 50px !important;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
  }
  
  .el-dialog__header {
    padding: 12px 16px;
    border-bottom: 1px solid #e8e8e8;
  }
  
  .el-dialog__title {
    font-size: 16px;
    font-weight: 600;
  }
  
  .el-dialog__body {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .el-dialog__footer {
    padding: 8px 16px 16px;
    border-top: 1px solid #e8e8e8;
  }
  
  .el-dialog__footer .el-button {
    padding: 8px 16px;
    font-size: 14px;
    min-width: 80px;
  }
  
  /* ----- 按钮调整 ----- */
  .el-button {
    padding: 8px 16px;
    font-size: 14px;
    height: 40px;
  }
  
  .el-button--small {
    padding: 6px 12px;
    font-size: 13px;
    height: 32px;
  }
  
  /* ----- 分页调整 ----- */
  .el-pagination {
    justify-content: center;
    flex-wrap: wrap;
    padding: 12px 0;
  }
  
  .el-pagination .el-pager li {
    min-width: 30px;
    height: 30px;
    line-height: 30px;
    font-size: 13px;
  }
  
  .el-pagination button {
    min-width: 30px;
    height: 30px;
    font-size: 13px;
  }
  
  .el-pagination__total {
    font-size: 12px;
    margin-bottom: 8px;
  }
  
  .el-pagination__sizes {
    margin: 0 0 8px 0;
  }
  
  /* ----- 登录页面调整 ----- */
  .login-wrapper {
    padding: 20px;
  }
  
  .login-box {
    width: 85%;
    padding: 30px 20px;
  }
  
  .login-header .logo {
    font-size: 40px;
  }
  
  .login-header h1 {
    font-size: 20px;
  }
  
  /* ----- 角色标签调整 ----- */
  .role-badge {
    padding: 2px 6px;
    font-size: 11px;
  }
  
  /* ----- 商品表格图片 ----- */
  .product-image {
    width: 40px;
    height: 40px;
  }
  
  /* ----- 总计框调整 ----- */
  .total-box {
    padding: 12px;
    margin-top: 12px;
  }
  
  .total-amount {
    font-size: 20px;
  }
  
  .total-qty {
    font-size: 14px;
  }
  
  /* ----- 操作按钮组 ----- */
  .form-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .form-actions .el-button {
    width: 100%;
  }
}

/* ========== 小屏手机（宽度 ≤ 375px）========== */
@media screen and (max-width: 375px) {
  .stat-value {
    font-size: 24px;
  }
  
  .stat-label {
    font-size: 12px;
  }
  
  .card-header {
    font-size: 15px;
  }
  
  .el-table {
    font-size: 11px;
  }
  
  .el-button {
    font-size: 13px;
    padding: 6px 12px;
  }
  
  .el-input__inner {
    font-size: 13px;
  }
}

/* ========== 隐藏/显示控制 ========== */
@media screen and (max-width: 768px) {
  .hide-on-mobile {
    display: none !important;
  }
}

.show-on-mobile {
  display: none;
}

@media screen and (max-width: 768px) {
  .show-on-mobile {
    display: block;
  }
}

/* ========== 触摸优化 ========== */
@media screen and (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: transparent;
  }
  
  .menu-item,
  .el-button,
  .stat-card,
  .el-checkbox,
  .el-radio {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  
  /* 增加点击区域 */
  .menu-item {
    min-height: 44px;
  }
  
  .el-button {
    min-height: 40px;
  }
}

/* ========== 滚动条优化 ========== */
@media screen and (max-width: 768px) {
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }
  
  ::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
  }
  
  ::-webkit-scrollbar-track {
    background: #f1f1f1;
  }
}

/* ========== 汉堡菜单和遮罩层 ========== */
.mobile-menu-btn {
  display: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  margin-right: 12px;
  color: #666;
}

.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

@media screen and (max-width: 768px) {
  .mobile-menu-btn {
    display: block;
  }
  
  .sidebar {
    position: fixed;
    left: -100%;
    top: 50px;
    height: calc(100vh - 50px);
    transition: left 0.3s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    width: 280px;
    max-width: 80%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .sidebar.open {
    left: 0;
  }
  
  .sidebar .menu-items {
    flex-direction: column;
    overflow-x: visible;
    overflow-y: visible;
    padding: 0;
  }
  
  .sidebar .menu-item {
    border-bottom: 1px solid #f0f0f0;
    border-left: 3px solid transparent;
    padding: 14px 20px;
  }
  
  .sidebar .menu-item.active {
    border-left-color: #1890ff;
    border-bottom: 1px solid #f0f0f0;
    background: #e6f7ff;
  }
  
  .overlay.show {
    display: block;
  }
}

/* ========== 打印样式 ========== */
@media print {
  .sidebar,
  .top-header,
  .filter-bar,
  .el-pagination,
  .mobile-menu-btn {
    display: none !important;
  }
  
  .main-content {
    width: 100%;
  }
  
  .content-card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
