/* ============================================
 * RDG CHECKLIST - GENERIC FORM FIELD STYLING  (Phase A2)
 * Cleans up the look of builder-created checklist forms: text inputs, the
 * store dropdown (select), comment boxes (textarea), labels, section headers
 * and validation messages.
 *
 * SCOPED to `.rdg-checklist-page` (added by rdg_checklists_body_class) so it
 * only affects builder checklist fill pages - legacy Divi checklist pages and
 * the rest of the site are untouched. Radio "yes-no-toggle" buttons keep their
 * own styling from rdg-radio-button-styling.css.
 * Palette matches the existing checklist look (grays #d1d5db/#374151, blues
 * #2563eb/#3b82f6/#1e3a8a).
 * ============================================ */

/* ---- Center & constrain the whole form ----
 * The RDG Analytics page template is full-width, so on its own the Gravity Form
 * hugs the left edge and the multi-step tab bar sprawls across the page. Pull the
 * form into a centered column so it sits nicely in the middle of the page. */
.rdg-checklist-page .gform_wrapper,
.rdg-checklist-page .gform_confirmation_wrapper,
.rdg-checklist-page .gform_heading {
  /* max-width: 900px; */
  max-width: 1300px;
  margin-left: auto !important;
  margin-right: auto !important;
  float: none !important;
}
.rdg-checklist-page .gform_wrapper {
  padding: 0 20px 70px;   /* bottom padding so the nav buttons clear the site footer */
  box-sizing: border-box;
}
/* After submit, Gravity Forms replaces the form with a short confirmation message.
 * Because it is short, the site footer rides up and touches it. Give the confirmation
 * area a minimum height + generous bottom padding so the footer is pushed down. */
.rdg-checklist-page .gform_confirmation_wrapper {
  min-height: 45vh;
  padding: 30px 20px 120px;
  box-sizing: border-box;
  text-align: center;
}
/* Keep the multi-page tab/step bar and progress bar within the centered column. */
.rdg-checklist-page .gform_wrapper .gf_page_steps,
.rdg-checklist-page .gform_wrapper .gf_step,
.rdg-checklist-page .gform_wrapper .gf_progressbar_wrapper,
.rdg-checklist-page .gform_wrapper .gform_page {
  max-width: 100%;
}

/* ---- Multi-step tab bar: ONE row, one clean line per tab, ellipsis, hover = full name ----
 * The form can have many steps (e.g. 10). Keep them all on a single row by letting the
 * tabs share the width equally and shrink; long category names truncate with an ellipsis.
 * Each .rdg-tab already carries a `title` attribute (the full category name), so hovering
 * shows the full text automatically. */
.rdg-checklist-page .rdg-custom-tabs {
  flex-wrap: nowrap;      /* was wrap -> forced a 2nd row */
  overflow-x: auto;       /* safety net only if the row is genuinely too small */
}
.rdg-checklist-page .rdg-custom-tabs .rdg-tab {
  flex: 1 1 0;            /* all tabs share the row equally */
  min-width: 0;           /* allow shrinking below content width */
  max-width: none;        /* override the base 180px cap */
  padding-left: 8px;
  padding-right: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-wrap: normal;
}

/* ---- Centered form header (checklist title + user name/email) above the tabs ---- */
.rdg-checklist-page .rdg-checklist-form-title,
.rdg-checklist-page .rdg-user-details {
  text-align: center;
}
.rdg-checklist-page .rdg-checklist-form-title {
  margin: 40px 0 6px;   /* top breathing room above the title */
  font-weight: 700;
}
.rdg-checklist-page .rdg-checklist-form-title i,
.rdg-checklist-page .rdg-checklist-form-title .text-danger {
  color: #dc2626; /* red icon, even without Bootstrap on the page */
}
.rdg-checklist-page .rdg-user-details {
  margin: 0 auto 36px; /* gap between user block and the tab bar */
}
.rdg-checklist-page .rdg-user-details h4,
.rdg-checklist-page .rdg-user-details h6 {
  margin: 2px 0;
}

/* ---- Progress bar: force the blue fill ----
 * On this theme (gravity-theme / --no-framework) GF renders the bar with an empty
 * colour class (gf_progressbar_ / percentbar_), so only the width animates and there
 * is no colour. Force the blue fill (and a light track) here so it always shows. */
.rdg-checklist-page .gf_progressbar {
  background-color: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}
.rdg-checklist-page .gf_progressbar_percentage {
  background-color: #2563eb !important;
  background-image: none !important;
  border-radius: 999px;
}
.rdg-checklist-page .gf_progressbar_percentage span {
  color: #ffffff !important;
}

/* ---- Field spacing ---- */
.rdg-checklist-page .gform_wrapper .gfield {
  margin-bottom: 20px;
}

/* ---- Navigation buttons — equal size on all screen sizes ---- */
.rdg-checklist-page .gform_wrapper .gform_next_button,
.rdg-checklist-page .gform_wrapper .gform_previous_button,
.rdg-checklist-page .gform_wrapper .gform_button,
.rdg-checklist-page .rdg-btn-save-exit,
.rdg-checklist-page .rdg-btn-cancel {
  min-width: 120px;
  text-align: center;
}

/* ==== MOBILE RESPONSIVENESS ==== */
/* Phones (< 480 px) */
@media (max-width: 479px) {

  /* Form column fills the screen, tighter padding */
  .rdg-checklist-page .gform_wrapper {
    padding: 0 12px 110px;   /* extra bottom space so buttons sit above the fixed footer */
  }

  /* Header */
  .rdg-checklist-page .rdg-checklist-form-title {
    margin-top: 24px;
    font-size: 1.25rem;
  }

  /* Tabs: on very small screens allow horizontal scroll rather than squashing
     10 tabs into 320px — each tab keeps a readable minimum width */
  .rdg-checklist-page .rdg-custom-tabs .rdg-tab {
    flex: 0 0 auto;
    min-width: 80px;
    font-size: 11px;
    padding-left: 6px;
    padding-right: 6px;
  }

  /* Yes/No toggle buttons — stack vertically so they don't overflow */
  .rdg-checklist-page .gform_wrapper .yes-no-toggle .gfield_radio,
  .rdg-checklist-page .gform_wrapper .gfield_radio {
    flex-direction: column;
  }

  /* Navigation buttons — 2 per row on phones, equal size, single-line text. */
  .rdg-checklist-page .gform_wrapper .gform_next_button,
  .rdg-checklist-page .gform_wrapper .gform_previous_button,
  .rdg-checklist-page .gform_wrapper .gform_button,
  .rdg-checklist-page .rdg-btn-save-exit,
  .rdg-checklist-page .rdg-btn-cancel {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    font-size: 13px !important;
    padding: 12px 8px !important;
    letter-spacing: 1px !important;
    white-space: nowrap !important;   /* keep "Save & Exit" on one line */
  }

  /* 2-column grid:  Save & Exit | Cancel   /   Previous | Next */
  .rdg-checklist-page .gform_page_footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: stretch;   /* equal button heights per row */
    margin-bottom: 24px;    /* gap below the buttons, before the site footer */
    padding-bottom: 8px;
  }
}

/* Tablets (480 px – 768 px) */
@media (min-width: 480px) and (max-width: 768px) {

  .rdg-checklist-page .gform_wrapper {
    padding: 0 16px;
  }

  .rdg-checklist-page .rdg-custom-tabs .rdg-tab {
    flex: 0 0 auto;
    min-width: 90px;
    font-size: 12px;
  }

  .rdg-checklist-page .gform_wrapper .gform_next_button,
  .rdg-checklist-page .gform_wrapper .gform_previous_button {
    padding: 10px 18px;
  }
}

/* ---- Collapsible "Comments" fields ----
 * The textarea is hidden by JS (rdg-checklist-comments-toggle.js); a "+" button next
 * to the "Comments" label reveals it. Keep the label + button on one line. */
.rdg-checklist-page .gfield--type-textarea .gfield_label {
  display: inline-block;
  margin-bottom: 0;
  vertical-align: middle;
}
.rdg-checklist-page .rdg-comment-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: 10px;
  padding: 0 0 5px;
  box-sizing: border-box;
  font-size: 20px;
  line-height: 1;
  font-weight: 400;
  color: #ffffff;
  background: #1e7efc;
  border: none;
  border-radius: 20%;       /* perfect circle */
  cursor: pointer;
  vertical-align: middle;
  box-shadow: 0 2px 6px rgba(30,126,252,0.30);
  transition: background 0.15s, transform 0.1s;
}
.rdg-checklist-page .rdg-comment-toggle:hover {
  background: #1565d8;
  transform: scale(1.1);
}
.rdg-checklist-page .gfield--type-textarea .ginput_container_textarea {
  margin-top: 8px;
}

/* ---- Subtle separator between checklist items ----
 * Each item's question (radio / number / text / read-only html field) gets a faint
 * divider line above it, so items are clearly separated. The first item directly under
 * a section heading has no line (it already sits below the section title). */
.rdg-checklist-page .gform_wrapper .gfield--type-radio,
.rdg-checklist-page .gform_wrapper .gfield--type-number,
.rdg-checklist-page .gform_wrapper .gfield--type-text,
.rdg-checklist-page .gform_wrapper .gfield--type-html {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 22px;
  margin-top: 22px;
}
.rdg-checklist-page .gform_wrapper .gsection + .gfield {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

/* ---- Labels ---- */
.rdg-checklist-page .gform_wrapper .gfield_label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
  line-height: 1.4;
}

.rdg-checklist-page .gform_wrapper .gfield_required {
  color: #dc2626;
  margin-left: 3px;
}

/* Field description / "How to check" helper text */
.rdg-checklist-page .gform_wrapper .gfield_description {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.45;
  margin-top: 4px;
  padding: 0;
}

/* ---- Text-like inputs, selects and textareas ---- */
.rdg-checklist-page .gform_wrapper input[type="text"],
.rdg-checklist-page .gform_wrapper input[type="number"],
.rdg-checklist-page .gform_wrapper input[type="email"],
.rdg-checklist-page .gform_wrapper input[type="tel"],
.rdg-checklist-page .gform_wrapper input[type="url"],
.rdg-checklist-page .gform_wrapper input[type="password"],
.rdg-checklist-page .gform_wrapper select,
.rdg-checklist-page .gform_wrapper textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px;
  font-size: 15px;
  line-height: 1.4;
  color: #374151;
  background-color: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

/* Placeholder */
.rdg-checklist-page .gform_wrapper input::placeholder,
.rdg-checklist-page .gform_wrapper textarea::placeholder {
  color: #9ca3af;
}

/* Focus state */
.rdg-checklist-page .gform_wrapper input[type="text"]:focus,
.rdg-checklist-page .gform_wrapper input[type="number"]:focus,
.rdg-checklist-page .gform_wrapper input[type="email"]:focus,
.rdg-checklist-page .gform_wrapper input[type="tel"]:focus,
.rdg-checklist-page .gform_wrapper input[type="url"]:focus,
.rdg-checklist-page .gform_wrapper input[type="password"]:focus,
.rdg-checklist-page .gform_wrapper select:focus,
.rdg-checklist-page .gform_wrapper textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  outline: none;
}

/* ---- Select: custom dropdown arrow ---- */
.rdg-checklist-page .gform_wrapper select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

/* ---- Comment boxes ---- */
.rdg-checklist-page .gform_wrapper textarea {
  min-height: 110px;
  line-height: 1.5;
  resize: vertical;
}

/* ---- Section headers (checklist categories) ---- */
.rdg-checklist-page .gform_wrapper .gsection {
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 10px;
  margin: 28px 0 20px;
}

.rdg-checklist-page .gform_wrapper .gsection_title,
.rdg-checklist-page .gform_wrapper .gsection .gfield_label {
  font-size: 19px;
  font-weight: 700;
  color: #1e3a8a;
  margin: 0;
}

/* ---- Read-only (None type) HTML rows ---- */
.rdg-checklist-page .gform_wrapper .gfield_html {
  color: #374151;
  font-size: 15px;
  line-height: 1.5;
}

/* ---- Validation messages ---- */
.rdg-checklist-page .gform_wrapper .gfield_error input[type="text"],
.rdg-checklist-page .gform_wrapper .gfield_error input[type="number"],
.rdg-checklist-page .gform_wrapper .gfield_error select,
.rdg-checklist-page .gform_wrapper .gfield_error textarea {
  border-color: #dc2626;
}

.rdg-checklist-page .gform_wrapper .validation_message,
.rdg-checklist-page .gform_wrapper .gfield_validation_message {
  color: #dc2626;
  font-size: 13px;
  font-weight: 500;
  margin-top: 6px;
}

/* ---- Disabled state ---- */
.rdg-checklist-page .gform_wrapper input:disabled,
.rdg-checklist-page .gform_wrapper select:disabled,
.rdg-checklist-page .gform_wrapper textarea:disabled {
  background-color: #f9fafb;
  color: #9ca3af;
  cursor: not-allowed;
}
