:root {
  --primary: #fdbb30;
  --primary-dark: #f89c1c;
  --border: #d0d0d0;
  --text: #222;
  --muted: #777;
  --error: #b00020;
  --bg: #fafafa;
  --section-bg: #ffffff;
}

/* ------------------------------
   Base layout
--------------------------------*/

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
  background: #fff;
}

header h1 {
  font-size: 1.6rem;
  margin-bottom: 1rem;
  border-left: 6px solid var(--primary);
  padding-left: 0.75rem;
}

/* ------------------------------
   Sections
--------------------------------*/

.form-section {
  background: var(--section-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.form-section h2 {
  margin-top: 0;
  font-size: 1.2rem;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.25rem;
}

.form-section h3 {
  margin-top: 1rem;
  font-size: 1rem;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

/* ------------------------------
   Form fields
--------------------------------*/

.field-group {
  margin-bottom: 0.9rem;
}

.field-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.field-group input[type="text"],
.field-group input[type="email"],
.field-group input[type="tel"],
.field-group input[type="url"],
.field-group input[type="date"],
.field-group textarea {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}

textarea {
  resize: none; /* autosize handled by JS */
  overflow: hidden;
}

fieldset.field-group {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem 0.9rem;
}

fieldset.field-group legend {
  padding: 0 0.25rem;
  font-weight: 600;
}

fieldset.field-group label {
  display: block;
  font-weight: 400;
  margin-bottom: 0.25rem;
}

.required {
  color: var(--error);
  margin-left: 0.15rem;
}

.error-message {
  color: var(--error);
  font-size: 0.8rem;
  min-height: 0.9rem;
}

/* ------------------------------
   Social media fields
--------------------------------*/

.sm-field {
  margin-top: 0.4rem;
  opacity: 0.4;
  pointer-events: none;
}

.sm-field.enabled {
  opacity: 1;
  pointer-events: auto;
}

/* ------------------------------
   Collapsible sections
--------------------------------*/

.collapsible {
  opacity: 1;
  transition: opacity 0.25s ease;
}

.collapse-toggle {
  width: 100%;
  text-align: left;
  background: #f5f5f5;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.collapse-toggle::after {
  content: "▾";
  font-size: 0.9rem;
}

.collapse-toggle.collapsed::after {
  content: "▸";
}

.collapsible-body {
  margin-top: 0.75rem;
}

.section-disabled {
  opacity: 0.4;
}

.section-disabled input,
.section-disabled textarea,
.section-disabled select,
.section-disabled button,
.section-disabled fieldset {
  pointer-events: none;
}

/* ------------------------------
   Buttons
--------------------------------*/

button {
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.form-actions button {
  padding: 0.6rem 1.1rem;
  border-radius: 4px;
  border: none;
  font-size: 0.95rem;
}

#printPdfButton {
  background: var(--primary);
  color: #000;
  font-weight: 600;
}

#printPdfButton:hover {
  background: var(--primary-dark);
}

.secondary-button {
  background: #e0e0e0;
  color: #222;
}

.secondary-button:hover {
  background: #d0d0d0;
}

.info-button {
  margin-left: 0.5rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  background: var(--primary);
  border: none;
  border-radius: 3px;
}

/* ------------------------------
   Signature canvas
--------------------------------*/

.signature-pad-wrapper {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  overflow: hidden;
}

#signatureCanvas {
  width: 100%;
  height: 150px;
  display: block;
}

/* ------------------------------
   Modal
--------------------------------*/

.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.55);
}

.modal-content {
  background: #fff;
  margin: 10% auto;
  padding: 1.5rem;
  border-radius: 6px;
  width: 90%;
  max-width: 600px;
  position: relative;
}

.modal-close {
  position: absolute;
  right: 1rem;
  top: 0.8rem;
  font-size: 1.4rem;
  cursor: pointer;
}

/* ------------------------------
   Footer
--------------------------------*/

.footer-note {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ------------------------------
   Print styles
--------------------------------*/

@media print {
  body {
    background: #fff;
  }

  .container {
    max-width: none;
    margin: 0;
    padding: 0.5in;
  }

  .no-print {
    display: none !important;
  }

  header h1 {
    border-left-color: #000;
  }

  hr {
    page-break-after: avoid;
  }

  .form-section {
    page-break-inside: avoid;
  }

  .modal {
    display: none !important;
  }
  
    .page-break {
    page-break-before: always;
    break-before: page;
  }


}

/* ------------------------------
   Responsive
--------------------------------*/

@media (max-width: 600px) {
  .container {
    padding: 1rem;
  }

  header h1 {
    font-size: 1.3rem;
  }
}