/* Disciplinary Code - Professional Document Styling */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Times New Roman', Times, serif;
  background: var(--app-bg, #f5f5f5);
  color: var(--app-text, #000);
  line-height: 1.6;
  padding: 20px;
}

.document-container {
  max-width: 900px;
  margin: 0 auto;
  background: #fff;
  padding: 60px 80px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  min-height: 100vh;
}

.document-header {
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 30px;
  border-bottom: 3px solid var(--app-button-bg, #2563eb);
}

.company-logo-doc {
  margin-bottom: 20px;
}

.company-logo-doc img {
  max-width: 180px;
  height: auto;
}

.document-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.document-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--app-button-bg, #2563eb);
  margin-top: 20px;
}

.acknowledgment-section {
  margin: 40px 0;
  padding: 30px;
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
}

.acknowledgment-section p {
  margin-bottom: 20px;
  line-height: 2;
}

.signature-fields {
  margin-top: 40px;
  display: grid;
  gap: 30px;
}

.signature-field {
  display: flex;
  flex-direction: column;
}

.signature-field label {
  font-weight: 600;
  margin-bottom: 8px;
  color: #374151;
}

.signature-field input,
.signature-field .signature-line {
  border: none;
  border-bottom: 2px solid #000;
  padding: 8px 4px;
  font-size: 1rem;
  background: transparent;
}

/* Inline input for name capture in acknowledgment sentence */
input.signature-input {
  border: none;
  border-bottom: 2px solid #000;
  padding: 4px 6px;
  font-size: 1rem;
  background: transparent;
  outline: none;
}

/* Utility: screen-reader only label */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.signature-line {
  min-height: 40px;
  display: block;
}

/* Signature pad UI */
.signature-pad-wrap {
  border: 2px dashed #9ca3af;
  padding: 10px;
  border-radius: 8px;
  background: #fafafa;
}
.signature-pad {
  width: 100%;
  max-width: 100%;
  height: 200px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  touch-action: none; /* smoother pointer events on touch */
}
.signature-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}
.signature-hint {
  color: #6b7280;
  font-size: 0.9rem;
}
.signature-proof {
  display: flex;
  gap: 20px;
  margin-top: 8px;
  color: #374151;
  font-size: 0.95rem;
}

.code-section {
  margin: 40px 0;
}

.code-section h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1f2937;
  margin: 30px 0 15px 0;
  text-transform: uppercase;
}

.code-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #374151;
  margin: 20px 0 10px 0;
}

.code-section p,
.code-section li {
  margin-bottom: 10px;
  text-align: justify;
}

.code-section ol,
.code-section ul {
  margin-left: 40px;
  margin-bottom: 20px;
}

.code-section ol li {
  margin-bottom: 8px;
}

.note-box {
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
  padding: 15px 20px;
  margin: 20px 0;
  font-weight: 500;
}

.important-box {
  background: #fee2e2;
  border-left: 4px solid #dc2626;
  padding: 15px 20px;
  margin: 20px 0;
  font-weight: 500;
}

.button-group {
  display: flex;
  gap: 15px;
  margin: 40px 0;
  justify-content: center;
}

.btn {
  padding: 12px 30px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-primary {
  background: var(--app-button-bg, #2563eb);
  color: var(--app-button-text, #fff);
}

.btn-primary:hover {
  background: var(--app-button-bg-alt, #1d4ed8);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background: #6b7280;
  color: #fff;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-success {
  background: #10b981;
  color: #fff;
}

.btn-success:hover {
  background: #059669;
}

@media print {
  body {
    background: white;
  }
  
  .document-container {
    padding: 80px 40px 100px 40px; /* Add space for header and footer */
    box-shadow: none;
  }
  
  .button-group {
    display: none;
  }
  .signature-actions .btn { display: none; }
  
  .no-print {
    display: none;
  }
  
  /* Print page setup with headers and footers */
  @page {
    margin: 0.75in 0.5in;
    
    @top-center {
      content: "Agile Automate - Disciplinary Code & Procedures";
      font-family: 'Times New Roman', serif;
      font-size: 10pt;
      color: #333;
      border-bottom: 1px solid #ddd;
      padding-bottom: 5px;
    }
    
    @bottom-left {
      content: "Confidential Document";
      font-family: 'Times New Roman', serif;
      font-size: 9pt;
      color: #666;
    }
    
    @bottom-center {
      content: "Page " counter(page) " of " counter(pages);
      font-family: 'Times New Roman', serif;
      font-size: 9pt;
      color: #666;
    }
    
    @bottom-right {
      content: "Effective Date: October 2025";
      font-family: 'Times New Roman', serif;
      font-size: 9pt;
      color: #666;
    }
  }
  
  /* Force final acknowledgment section to start on a new page */
  .final-acknowledgment {
    page-break-before: always !important;
    margin-top: 0 !important;
    padding-top: 200px; /* Move down approximately 10 rows */
  }
  
  /* Prevent page breaks inside acknowledgment sections */
  .acknowledgment-section {
    page-break-inside: avoid;
  }
  
  /* Keep signature fields together */
  .signature-fields {
    page-break-inside: avoid;
  }
  
  /* Avoid orphan lines at page breaks */
  .code-section h2 {
    page-break-before: auto;
    page-break-after: avoid;
    margin-top: 30px;
  }
  
  .code-section h3,
  .code-section h4 {
    page-break-after: avoid;
    page-break-inside: avoid;
  }
  
  .code-section p,
  .code-section ol,
  .code-section ul {
    orphans: 3;
    widows: 3;
    page-break-inside: avoid;
  }
  
  /* Keep list items together when possible */
  .code-section li {
    page-break-inside: avoid;
  }
  
  /* Remove colored borders from note/important boxes in print */
  .note-box {
    border-left: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
    margin: 15px 0;
  }
  
  .important-box {
    border-left: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
    margin: 15px 0;
  }
  
  /* Better handling for document header on first page only */
  .document-header {
    page-break-after: avoid;
  }
  
  /* Ensure tables don't break awkwardly */
  table {
    page-break-inside: avoid;
  }
}

@media (max-width: 768px) {
  .document-container {
    padding: 30px 20px;
  }
  
  .document-header h1 {
    font-size: 1.5rem;
  }
  
  .document-header h2 {
    font-size: 1.2rem;
  }
  
  .code-section ol,
  .code-section ul {
    margin-left: 20px;
  }
}
