/**
 * 统一打印样式优化
 * 适用于所有系统页面，确保打印效果一致性和专业性
 */

/* 基础打印设置 */
@media print {
  /* 页面设置 */
  @page {
    margin: 1cm;
    size: A4;
  }

  /* 全局样式重置 */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body {
    background: white !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
  }

  /* 隐藏所有非打印元素 */
  .no-print,
  .no-print *,
  nav,
  header,
  footer,
  .tabs,
  .buttons,
  .actions,
  .modal-overlay,
  .modal-content,
  .toast,
  .notification,
  .dropdown-menu,
  .context-menu {
    display: none !important;
  }

  /* 隐藏装饰性元素 */
  body::before,
  body::after,
  #app::before,
  #app::after,
  *::before,
  *::after {
    display: none !important;
  }

  /* 卡片和容器优化 */
  .tech-card,
  .card,
  .quote-card,
  .table-container,
  .table-container-full-height {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    background: white !important;
    backdrop-filter: none !important;
    page-break-inside: avoid;
  }

  /* 表格优化 */
  table {
    width: 100% !important;
    border-collapse: collapse !important;
    background-color: white !important;
    page-break-inside: avoid;
  }

  th, td {
    border: 1px solid #000 !important;
    padding: 8px 12px !important;
    text-align: left !important;
    vertical-align: middle !important;
  }

  th {
    background-color: #f0f0f0 !important;
    color: #000 !important;
    font-weight: bold !important;
    page-break-inside: avoid;
  }

  td {
    background-color: white !important;
    color: #000 !important;
  }

  /* 标题优化 */
  h1, h2, h3, h4, h5, h6 {
    color: #000 !important;
    page-break-after: avoid;
    margin: 10px 0 !important;
  }

  h1 { font-size: 18pt; }
  h2 { font-size: 16pt; }
  h3 { font-size: 14pt; }
  h4 { font-size: 13pt; }
  h5 { font-size: 12pt; }
  h6 { font-size: 11pt; }

  /* 防止内容分页断裂 */
  p, li, dt, dd {
    orphans: 3;
    widows: 3;
  }

  /* 链接处理 */
  a {
    color: #000 !important;
    text-decoration: none !important;
  }

  /* 图片优化 */
  img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }

  /* 输入框和选择框显示值 */
  input, select, textarea {
    border: none !important;
    background: transparent !important;
    appearance: none !important;
  }
}

/* 特定系统打印优化 */

/* 报价系统 */
@media print {
  .quote-card {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 15px !important;
    border: 2px solid #3b82f6 !important;
    page-break-inside: avoid;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
  }

  .quote-table {
    font-size: 9pt !important;
    table-layout: fixed !important;
    width: 100% !important;
    margin-top: 8px !important;
  }

  /* 隐藏最后一列（竖排文字列） */
  .quote-table colgroup col:nth-child(4),
  .quote-table th:nth-child(4),
  .quote-table td:nth-child(4) {
    display: none !important;
  }

  /* 表头优化 */
  .quote-table th {
    background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%) !important;
    color: #1e40af !important;
    font-weight: 800 !important;
    font-size: 9pt !important;
    border: 1.5px solid #3b82f6 !important;
    padding: 8px 6px !important;
    text-align: center !important;
  }

  .quote-table td {
    font-size: 9pt !important;
    padding: 6px 8px !important;
    border: 1px solid #93c5fd !important;
    line-height: 1.4 !important;
    vertical-align: middle !important;
  }

  /* 单数行背景 */
  .strip-0 {
    background: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 100%) !important;
  }

  /* 双数行背景 */
  .strip-1 {
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%) !important;
  }

  .quote-table td:first-child {
    font-weight: 700 !important;
    background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%) !important;
    text-align: center !important;
    border: 1.5px solid #3b82f6 !important;
    color: #1e40af !important;
  }

  .tech-title,
  .tech-title span {
    color: #3b82f6 !important;
    font-size: 18pt !important;
    font-weight: 800 !important;
  }

  .tech-title span {
    font-size: 16pt !important;
    font-weight: 600 !important;
  }

  /* 总价行优化 */
  .quote-table tr:last-child {
    background: linear-gradient(180deg, #fef2f2 0%, #fee2e2 100%) !important;
  }

  .quote-table tr:last-child td:first-child {
    font-weight: 800 !important;
    font-size: 12pt !important;
    color: #dc2626 !important;
    background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%) !important;
    border: 1.5px solid #dc2626 !important;
  }

  .quote-table tr:last-child td:nth-child(2) {
    font-weight: 700 !important;
    font-size: 10pt !important;
    color: #dc2626 !important;
  }

  .quote-table tr:last-child td:nth-child(3) {
    font-weight: 800 !important;
    font-size: 14pt !important;
    color: #dc2626 !important;
    font-family: 'Arial', sans-serif !important;
  }

  .quote-cell-overlay,
  .quote-cell-paste-flash,
  .autocomplete-list {
    display: none !important;
  }
}

/* 财务系统 */
@media print {
  .finance-table {
    font-size: 10pt !important;
  }

  .kpi-grid {
    display: none !important;
  }

  .finance-tabs {
    display: none !important;
  }
}

/* 产品与库存系统 */
@media print {
  .out-of-stock-print-area {
    position: static !important;
    width: 100% !important;
  }

  .out-of-stock-print-area,
  .out-of-stock-print-area * {
    visibility: visible !important;
  }

  .out-of-stock-model {
    max-width: none !important;
    white-space: normal !important;
  }
}

/* 成交系统 */
@media print {
  .orders-table {
    font-size: 10pt !important;
  }

  .orders-tabs {
    display: none !important;
  }

  .order-detail-summary-table {
    font-size: 9pt !important;
  }
}

/* 售后系统 */
@media print {
  .admin-table {
    font-size: 10pt !important;
  }

  .top-nav {
    display: none !important;
  }

  .records-ops-bar {
    display: none !important;
  }
}

/* 移动端打印优化 */
@media print and (max-width: 768px) {
  body {
    font-size: 10pt;
  }

  table {
    font-size: 9pt !important;
  }

  th, td {
    padding: 6px 8px !important;
  }
}

/* 宽表格打印优化 */
@media print {
  .table-responsive {
    overflow: visible !important;
    width: 100% !important;
  }
}

/* 打印页眉页脚（可选） */
@page {
  margin-top: 1.5cm;
  margin-bottom: 1.5cm;
}

/* 打印进度条隐藏 */
@media print {
  .progress-bar,
  .loading,
  .spinner {
    display: none !important;
  }
}

/* 确保内容不被截断 */
@media print {
  .content,
  .main-content,
  .page-content {
    overflow: visible !important;
  }
}
