/* pkl-print.css */
:root {
    --k-primary: #00866E;
    --k-secondary: #59B985;
    --k-gray: #6C757D;
    --k-border: #DEE2E6;
    --k-light: #f8f9fa; /* เพิ่มตัวแปรสีสำหรับพื้นหลังอ่อน */
  }
  
  /* Print Layout */
  @media print {
    @page {
      size: A5 landscape;
      margin: 0;
    }
  
    body {
      margin: 0;
      -webkit-print-color-adjust: exact;
      print-color-adjust: exact;
    }
  
    .print-container {
      width: 210mm;
      height: 148mm;
      margin: 0;
      padding: 10mm;
      box-sizing: border-box;
      page-break-after: always;
    }
  
    /* ซ่อนองค์ประกอบที่ไม่ต้องการในการพิมพ์ */
    .k-modal-overlay,
    .k-print-options,
    .k-modal-footer,
    .search-results-container,
    .bulk-actions {
      display: none !important;
    }
  }
  
  /* General Layout */
  .print-container {
    font-family: 'Sarabun', sans-serif;
    font-size: 12px;
    color: #333;
    background: white;
  }
  
  /* Header Section */
  .print-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 1rem;
  }
  
  .company-logo {
    width: 120px;
    flex-shrink: 0;
  }
  
  .company-logo img {
    width: 100%;
    height: auto;
  }
  
  .document-info {
    flex: 1;
  }
  
  .document-info h1, .document-title h1 { /* ใช้ร่วมกันสำหรับ h1 ในส่วนหัว */
    margin: 0;
    font-size: 20px;
    color: var(--k-primary);
  }
  
  .document-number {
    font-size: 14px;
    color: var(--k-gray);
    margin-top: 4px;
  }
  
  /* Customer Info Section */
  .customer-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 8px;
    background: var(--k-light);
    border-radius: 4px;
  }
  
  .info-group {
    display: flex;
    gap: 8px;
  }
  
  .info-group label {
    color: var(--k-gray);
    white-space: nowrap;
  }
  
  .info-group span {
    font-weight: 500;
  }
  
  /* Products Table */
  .products-table-container {
    margin-bottom: 1rem;
  }
  
  .products-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
  }
  
  .products-table th,
  .products-table td {
    border: 1px solid var(--k-border);
    padding: 4px 6px;
    text-align: left;
  }
  
  .products-table th {
    background: var(--k-light);
    font-weight: 500;
    white-space: nowrap;
  }
  
  .products-table tbody tr:nth-child(even) {
    background: #fafafa;
  }
  
  /* Summary Section */
  .summary-section, .total-summary { /* ใช้ class ร่วมกันสำหรับรูปแบบพื้นฐาน */
    margin-bottom: 1rem;
    background: var(--k-light);
    padding: 8px 12px;
    border-radius: 4px;
  }
  
  .summary-section h4, .total-summary h4 { /* ใช้ร่วมกันสำหรับ h4 ในส่วนสรุป */
    margin: 0 0 4px 0;
    font-size: 14px;
    color: var(--k-primary);
  }
  
  .summary-content, .total-summary p { /* ใช้ร่วมกันสำหรับเนื้อหาในส่วนสรุป */
    font-weight: 500;
    margin: 0;
    font-size: 10px;
  }
  
  /* Footer Section */
  .print-footer {
    margin-top: auto;
    border-top: 1px dashed var(--k-border);
    padding-top: 1rem;
  }
  
  .signature-section {
    display: flex;
    justify-content: center;
    gap: 4rem;
    margin-bottom: 1rem;
  }
  
  .signature-box {
    text-align: center;
  }
  
  .sign-line {
    margin-bottom: 4px;
    color: var(--k-gray);
  }
  
  .signature-box p {
    margin: 0;
    font-size: 12px;
    color: var(--k-gray);
  }
  
  .signature-box span {
    font-size: 11px;
    color: var(--k-gray);
  }
  
  .footer-info, .footer-note { /* ใช้ class ร่วมกันสำหรับข้อมูลท้ายกระดาษ */
    font-size: 10px;
    color: var(--k-gray);
  }
  
  .footer-info {
    display: flex;
    justify-content: space-between;
  }
  
  .company-details {
    text-align: left;
  }
  
  .company-details p {
    margin: 0;
  }
  
  .print-datetime {
    text-align: right;
  }
  
  /* Watermark */
  .watermark, .copy-watermark { /* ใช้ class ร่วมกันสำหรับลายน้ำ */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 60px;
    opacity: 0.1;
    pointer-events: none;
    text-transform: uppercase;
    color: var(--k-primary);
  }
  
  /* Copy Colors */
  .print-container[data-copy="2"] .watermark {
    color: #0066CC;
  }
  
  .print-container[data-copy="3"] .watermark {
    color: #CC0000;
  }
  
  /* Print Modal Styles */
  .k-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
  }
  
  .k-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  }
  
  .k-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--k-border);
  }
  
  .k-modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--k-primary);
  }
  
  .k-modal-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--k-gray);
    transition: color 0.2s;
  }
  
  .k-modal-close:hover {
    color: var(--k-primary);
  }
  
  .k-modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  
  .k-print-preview {
    flex: 1;
    padding: 1.5rem;
    overflow: hidden;
    background: var(--k-light);
  }
  
  .k-preview-container {
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    height: 100%;
    overflow: hidden;
    border-radius: 4px;
  }
  
  .k-preview-frame {
    width: 100%;
    height: 100%;
    border: none;
  }
  
  .k-print-options {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--k-border);
    display: flex;
    gap: 2rem;
  }
  
  .k-option-group {
    display: flex;
    gap: 1.5rem;
  }
  
  .k-checkbox, .so-label { /* ใช้ class ร่วมกันสำหรับ checkbox และ label */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
  }
  
  .k-checkbox-mark, .checkmark { /* ใช้ class ร่วมกันสำหรับกรอบ checkbox */
    width: 18px;
    height: 18px;
    border: 2px solid var(--k-primary);
    border-radius: 4px;
    position: relative;
    background-color: white;
  }
  
  .k-checkbox input:checked + .k-checkbox-mark::after, .so-checkbox:checked ~ .checkmark:after { /* ใช้ร่วมกันสำหรับเครื่องหมายถูก */
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    background: var(--k-primary);
    border-radius: 2px;
  }
  .so-checkbox:checked ~ .checkmark:after{
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    background: transparent;
    border: solid #4CAF50;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
  }
  
  .k-select select, .k-select { /* แก้ไขการเยื้องของ select */
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--k-border);
    border-radius: 4px;
  }
  .k-select{
      margin-left: 0.5rem;
  }
  
  .k-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--k-border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
  }
  
  .k-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
  }
  
  .k-btn-primary {
    background: var(--k-primary);
    color: white;
  }
  
  .k-btn-primary:hover {
    background: #007159;
  }
  
  .k-btn-secondary {
    background: var(--k-light);
    color: var(--k-gray);
  }
  
  .k-btn-secondary:hover {
    background: #e9ecef;
  }
  
  /* Responsive adjustments for the modal */
  @media (max-width: 768px) {
    .k-modal-content {
      width: 95%;
      height: 95vh;
    }
  
    .k-print-options {
      flex-direction: column;
      gap: 1rem;
    }
  
    .k-option-group {
      flex-direction: column;
      gap: 0.75rem;
    }
  }
  
  /* Search Results */
  .search-results-container {
    max-height: 400px;
    overflow-y: auto;
  }
  
  .search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid #eee;
  }
  
  .search-result-item:hover {
    background-color: #f8f9fa;
  }
  
  .so-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
  }
  
  .checkbox-wrapper {
    flex: 0 0 auto;
    position: relative;
    margin-right: 10px;
  }
  
  .so-info {
    flex-grow: 1;
  }
  
  .so-number {
    font-weight: bold;
    display: block;
    font-size: 14px;
  }
  
  .so-text, .customer-name {
    color: #666;
    font-size: 0.9em;
  }
  
  .customer-name{
      font-size: 13px;
  }
  
  .so-date {
    color: #999;
    font-size: 12px;
  }
  
  /* Bulk Actions */
  .bulk-actions {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 10px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .print-selected {
    background: #4CAF50;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
  }
  
  .print-selected:disabled {
    background: #ccc;
    cursor: not-allowed;
  }