/* TopAid Healthcare Forms - Base Stylesheet */
/* Version: v20260111 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --topaid-orange: #E85A24;
  --topaid-blue: #2B4B8C;
  --border-color: #333;
  --light-gray: #f5f5f5;
  --text-color: #1a1a1a;
}

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

@page {
  size: letter;
  margin: 0.5in 0.5in 0.75in 0.5in;
}

@media print {
  html, body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
  }

  .no-print {
    display: none !important;
  }

  .page-break {
    page-break-before: always;
    break-before: page;
  }

  /* Prevent orphans and widows */
  p, h1, h2, h3, h4 {
    orphans: 3;
    widows: 3;
  }

  /* Keep elements together - avoid breaking inside */
  .form-row,
  .form-group,
  .signature-section,
  .signature-block,
  .checkbox-group,
  .radio-group,
  tr,
  .section-header,
  .section-header-light {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Keep headers with following content */
  h1, h2, h3, .section-header, .section-header-light {
    break-after: avoid;
    page-break-after: avoid;
  }

  input[type="text"],
  input[type="date"],
  input[type="tel"],
  input[type="email"],
  input[type="number"],
  input[type="time"],
  textarea,
  select {
    border: none !important;
    border-bottom: 1px solid #000 !important;
    background: transparent !important;
  }
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-color);
  background: white;
  max-width: 850px;
  margin: 0 auto;
  padding: 30px 40px;
}

@media screen {
  body {
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
  }
}

@media print {
  body {
    background: white !important;
    box-shadow: none !important;
    padding: 15px !important;
    max-width: none !important;
    margin: 0 !important;
    font-size: 11px !important;
  }

  .page-break {
    page-break-before: always;
    break-before: page;
    margin-top: 0;
    padding-top: 0;
  }

  /* Ensure form header fits on first page */
  .form-header {
    margin-bottom: 10px;
  }

  .form-title {
    margin: 10px 0;
  }
}

/* Header */
.form-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--topaid-orange);
  margin-bottom: 15px;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-section img {
  height: 85px;
  width: auto;
}

.company-info {
  text-align: right;
  font-size: 10px;
  line-height: 1.5;
}

.company-info .company-name {
  font-weight: 700;
  font-size: 12px;
  color: var(--topaid-orange);
}

.company-info .tagline {
  font-style: italic;
  color: var(--topaid-blue);
  font-size: 9px;
}

/* Form Title */
.form-title {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--topaid-blue);
  margin: 15px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Section Headers */
.section-header {
  background: var(--topaid-blue);
  color: white;
  padding: 6px 10px;
  font-weight: 600;
  font-size: 11px;
  margin: 15px 0 10px 0;
  text-transform: uppercase;
}

.section-header-light {
  background: var(--light-gray);
  color: var(--topaid-blue);
  padding: 6px 10px;
  font-weight: 600;
  font-size: 11px;
  margin: 15px 0 10px 0;
  border-left: 3px solid var(--topaid-orange);
}

/* Form Fields */
.form-row {
  display: flex;
  gap: 15px;
  margin-bottom: 10px;
}

.form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.form-group.w-25 { flex: 0 0 25%; }
.form-group.w-33 { flex: 0 0 33.33%; }
.form-group.w-50 { flex: 0 0 50%; }
.form-group.w-66 { flex: 0 0 66.66%; }
.form-group.w-75 { flex: 0 0 75%; }
.form-group.w-100 { flex: 0 0 100%; }

.form-group label {
  font-weight: 500;
  font-size: 10px;
  color: #555;
  margin-bottom: 3px;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="tel"],
.form-group input[type="email"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 11px;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--topaid-orange);
  box-shadow: 0 0 0 2px rgba(232, 90, 36, 0.1);
}

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

/* Inline Fields (label and input on same line) */
.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.inline-field label {
  font-weight: 500;
  font-size: 10px;
  white-space: nowrap;
}

.inline-field input {
  flex: 1;
  padding: 4px 6px;
  border: none;
  border-bottom: 1px solid #333;
  font-size: 11px;
}

/* Checkboxes and Radio Buttons */
.checkbox-group,
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

.checkbox-item,
.radio-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.checkbox-item input,
.radio-item input {
  width: 14px;
  height: 14px;
  accent-color: var(--topaid-orange);
}

.checkbox-item label,
.radio-item label {
  font-size: 10px;
  font-weight: 400;
}

/* Yes/No Toggle */
.yes-no {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.yes-no label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
}

/* Tables */
.form-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 10px;
}

.form-table th,
.form-table td {
  border: 1px solid #ccc;
  padding: 6px 8px;
  text-align: left;
}

.form-table th {
  background: var(--light-gray);
  font-weight: 600;
  color: var(--topaid-blue);
}

.form-table td input[type="text"] {
  width: 100%;
  border: none;
  padding: 2px;
  font-size: 10px;
}

.form-table td input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

/* Task Table (Care Plan) */
.task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

.task-table th {
  background: var(--topaid-blue);
  color: white;
  padding: 8px;
  text-align: center;
  font-weight: 600;
}

.task-table td {
  border: 1px solid #ddd;
  padding: 6px 8px;
}

.task-table .category-cell {
  background: var(--light-gray);
  font-weight: 600;
  color: var(--topaid-blue);
  width: 100px;
}

.task-table .task-cell {
  width: 200px;
}

.task-table .check-cell {
  width: 80px;
  text-align: center;
}

/* Signature Section */
.signature-section {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #ddd;
}

.signature-row {
  display: flex;
  gap: 30px;
  margin-bottom: 20px;
}

.signature-block {
  flex: 1;
}

.signature-line {
  border-bottom: 1px solid #333;
  height: 40px;
  margin-bottom: 5px;
}

.signature-label {
  font-size: 9px;
  color: #666;
}

/* Footer */
.form-footer {
  margin-top: 40px;
  padding: 15px 0;
  font-size: 8px;
  color: #999;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #eee;
}

.form-footer .version {
  font-family: monospace;
}

.form-footer .page-number::before {
  content: "";
}

@media print {
  .form-footer {
    margin-top: 30px;
  }
}

/* Text Areas with Lines */
.lined-textarea {
  background-image: repeating-linear-gradient(
    transparent,
    transparent 19px,
    #ddd 19px,
    #ddd 20px
  );
  line-height: 20px;
  padding: 0 8px;
  min-height: 100px;
}

/* ADL Grid */
.adl-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.adl-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
}

.adl-item label {
  flex: 1;
}

.adl-item .level-select {
  display: flex;
  gap: 5px;
}

.adl-item .level-select label {
  font-size: 9px;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-small { font-size: 9px; }
.text-muted { color: #666; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.border-box {
  border: 1px solid #ccc;
  padding: 10px;
  margin: 10px 0;
}

/* Print/Export Controls (hidden in print) */
.print-controls {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  gap: 8px;
}

.print-controls button {
  background: var(--topaid-orange);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s;
}

.print-controls button:hover {
  background: #c94a1a;
}

.print-controls button:last-child {
  background: #666;
}

.print-controls button:last-child:hover {
  background: #555;
}

@media print {
  .print-controls {
    display: none;
  }
}
