/* Global form styling for Google-Form–like experience */

:root {
  /* Google Material blue 500 */
  --primary-color: #4285f4;
  --primary-color-dark: #3367d6;
  --card-bg: #fff;
  --card-radius: 8px;
  --card-shadow: rgba(0, 0, 0, 0.1);
}

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

.htmx-settling {
    opacity: 0;
}

.hidden {
    display: none;
}

body {
  font-family: 'Roboto', Arial, sans-serif;
  background: #f5f5f5;
  margin: 0;
  padding: 0;
  color: #212121;
}

.form-container {
  max-width: 600px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.question-card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: 0 3px 6px var(--card-shadow);
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
}

.question-card legend,
.question-card label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #333;
}

/* Remove default fieldset border for cleaner Material look */
.question-card fieldset {
  border: none;
  margin: 0;
  padding: 0;
  min-inline-size: auto; /* prevent huge min-width in Safari */
}

/* Radio group styling */
.radio-group {
  display: flex;
  width: 100%;
  margin-top: 0.5rem;
}

.radio-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  padding: 0 2px;
}

.radio-number {
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  color: #666;
  font-weight: bold;
}

.radio-group span {
    font-size: 1.15em;
}

.radio-group input[type="radio"] {
  margin: 0;
  transform: scale(1.2);
}
/* input and textarea focus states */
input:focus,
textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-color);
}

/* Use primary color for native form controls where supported */
input[type="checkbox"],
input[type="range"],
input[type="radio"] {
  accent-color: var(--primary-color);
}

input[type="checkbox"] {
  /* Enlarge the checkbox itself so it feels balanced
     against the larger text-input controls further down */
  transform: scale(1.3);
  margin-right: 0.4rem;
}

/* Make the interest checkbox larger since it has special prominence */
input[type="checkbox"][name="interest_foundry"] {
  transform: scale(1.6);
}

/* Enlarge radio buttons to match the new checkbox size */
input[type="radio"] {
  transform: scale(1.3);
  margin-right: 0.4rem;
}

/* Make option labels slightly larger for better readability */
.question-card fieldset label {
  font-size: 1.05em;
}

/* Suggestions box fixed to the top of the viewport */
#suggestions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  z-index: 1000;
  box-shadow: 0 -2px 4px var(--card-shadow);
  padding: 0.5rem 1rem;
  height: 150px;
  overflow: scroll;

  /* Hide the container entirely when empty so it doesn't take space */
  display: none; /* default hidden, shown via JS with content or use :not(:empty) */
}

#suggestions:has(tbody > tr)#suggestions:not(:has(tbody > tr > td.dt-empty)) {
  display: block;
}

#suggestions .suggestions-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center; /* center align horizontally */
  gap: 0.75rem;
}

#suggestions .suggestion-entry {
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

#suggestions .suggestion-entry div {
  margin: 2px 0;
}

.suggestions-spacer {
  height: 150px; /* matches or slightly exceeds the #suggestions height */
  width: 100%;
  display: block;
}

/* Make text inputs and textareas span full width and larger font */
.question-card input[type="text"],
.question-card input[type="email"],
.question-card input[type="tel"],
.question-card input[type="number"],
.question-card textarea {
  width: 100%;
  box-sizing: border-box;
  font-size: 1.1em;
  border: 1px solid #cfcfcf;
  border-radius: 4px;
  padding: 0.65rem 0.75rem;
  background: #fafafa;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Elevate input on focus */
.question-card input[type="text"]:focus,
.question-card input[type="email"]:focus,
.question-card input[type="tel"]:focus,
.question-card textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.25);
}

/* Darken placeholders slightly for better contrast */
.question-card input::placeholder,
.question-card textarea::placeholder {
  color: #888;
}

/* Center align the main heading in the form container */
.form-container h1 {
  text-align: center;
  margin-bottom: 1.5rem;
}

/* Center align top-level page headings (e.g., the form title, confirmation
   and statistics pages).  This keeps the original rule that targets
   headings inside .form-container but also covers headings that sit
   outside that container. */
h1 {
  text-align: center;
}

/* Align standalone checkbox/radio labels so wrapped text lines up under first line */
.question-card > label {
  display: flex;
  align-items: center; /* vertically center checkbox with first line of text */
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}
.question-card > label input[type="checkbox"],
.question-card > label input[type="radio"] {
  margin-top: 0; /* reset */
}

/* Override width for small inline fill-in inputs following checkboxes */
.question-card label input[type="text"] {
  width: 100%;              /* span entire card width */
  display: block;           /* place on its own line */
  font-size: 1.1em;         /* match other large text inputs */
  padding: 0.65rem 0.75rem; /* same padding as default inputs */
  margin: 0.5rem 0 0;       /* small space above, no left indent */
  box-sizing: border-box;
  border: 1px solid #cfcfcf;
  border-radius: 4px;
  background: #fafafa;
}

/* Style <select> controls to match text inputs */
.question-card select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-size: 1.1em;
  line-height: 1.4;
  min-height: 2.75rem;
  border: 1px solid #cfcfcf;
  border-radius: 4px;
  padding: 0.65rem 0.75rem;
  background: #fafafa;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Elevate select on focus for consistency */
.question-card select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.25);
}

.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header styles */
.site-header {
  background: #333; /* dark gray background */
  color: #fff;
  padding: 0.75rem 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-header a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  padding: 0 0.25rem;
  transition: color 0.15s ease;
}

.site-header a:hover,
.site-header a:focus {
  color: #ffd866; /* highlight color for hover, adjust to brand if needed */
  text-decoration: underline;
}

/* left-side nav spacing and divider */
.nav-left {
  display: flex;
  align-items: center;
}

/* Even link spacing with a subtle divider */
.nav-left a {
  padding: 0 0.75rem;
  border-right: 1px solid rgba(255, 255, 255, 0.3);
}

.nav-left a:first-child {
  padding-left: 0;
}

.nav-left a:last-child {
  border-right: none;
  padding-right: 0;
}

.site-header a:hover,
.site-header a:focus {
  text-decoration: underline;
}

.auth-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-login {
    display: none;
}

@media screen and (min-width: 992px) {
  .auth-links .nav-login {
    display: block;
  }
}

/* Full-width submit button to match question cards */
.form-container button {
  display: block;
  width: 100%;
  margin-top: 1rem;
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.75rem 1rem;
  font-weight: 500;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

/* Styled button that matches form-container button but is not full-width */
.styled-button {
  display: inline-block;
  margin-top: 1rem;
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.75rem 1rem;
  font-weight: 500;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.styled-button:hover {
  background: var(--primary-color-dark);
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
}

.styled-button:active {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) inset;
}

.form-container button:hover {
  background: var(--primary-color-dark);
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
}

.form-container button:active {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) inset;
}

.form-container button.cancel {
  background: #757575;
}
.form-container button:hover.cancel {
  background: #616161;
}

/* Meta info for small, gray text (replaces Tailwind text-xs text-gray-500) */
.meta-info {
  font-size: 0.85em;
  color: #6b7280;
  margin-bottom: 8px;
}

table tbody tr {
  cursor: pointer;
}

/* Edit window sidebar styles */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 500px;
  max-width: 90vw;
  background: #fff;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 1200;
  overflow-y: auto;
}

.sidebar.show-start {
  transform: translateX(-100%);
  opacity: 0;
}

.sidebar.show {
  transition: transform 0.3s ease-in-out,opacity 0.3s ease-in-out;
}

.sidebar.show-end {
  transform: translateX(0%);
  opacity: 1;
}
.sidebar.hide {
  transform: translateX(-100%);
  transition: transform 0.3s ease-in-out,opacity 0.3s ease-in-out;
}

/* Refresh dialog styles */
.refresh-dialog {
  border: none;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  padding: 0;
  width: 90%;
  max-width: 500px;
  backdrop-filter: blur(4px);
  background: white;
}

.refresh-dialog-header {
  padding: 20px 20px 10px;
  border-bottom: 1px solid #eee;
}

.refresh-dialog-header h2 {
  margin: 0;
  color: #333;
  font-size: 1.5rem;
}

.refresh-dialog-body {
  padding: 20px;
}

.refresh-dialog-body p {
  margin: 0;
  color: #666;
  font-size: 1rem;
  line-height: 1.5;
}

.refresh-dialog-footer {
  padding: 20px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.refresh-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background-color 0.2s;
}

.btn-primary {
  background-color: #007bff;
  color: white;
}

.btn-primary:hover {
  background-color: #0069d9;
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background-color: #5a6268;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.875rem;
}

.btn-outline-secondary {
  background-color: transparent !important;
  color: #6c757d !important;
  border: 1px solid #6c757d !important;
}

.btn-outline-secondary:hover {
  background-color: #6c757d !important;
  color: white !important;
}


/* ===== Index mobile styles (scoped to index only) ===== */
#index-mobile-scope {
  font-size: clamp(1rem, 2.2vw + 0.5rem, 1.125rem);
  line-height: 1.6;
  padding-inline: 0.75rem;
  overflow-wrap: anywhere;
}

/* Typography */
#index-mobile-scope h1 {
  font-size: clamp(1.35rem, 4vw + 0.5rem, 1.75rem);
  line-height: 1.25;
  margin: 1rem 0 1.25rem;
}

#index-mobile-scope .question-card legend {
  font-size: clamp(1.125rem, 2.8vw + 0.6rem, 1.375rem);
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

#index-mobile-scope .question-card label {
  font-size: clamp(1rem, 2.2vw + 0.5rem, 1.25rem);
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  min-height: 44px; /* comfortable tap target */
}

/* Controls and inputs */
#index-mobile-scope input[type="checkbox"] {
  /* keep consistent with global but ensure spacing for tap */
  margin-right: 0.3rem; /* 50% reduced spacing before label text */
}

#index-mobile-scope .question-card input[type="text"],
#index-mobile-scope .question-card input[type="email"],
#index-mobile-scope .question-card input[type="tel"],
#index-mobile-scope .question-card input[type="number"],
#index-mobile-scope .question-card textarea,
#index-mobile-scope .question-card select {
  font-size: 1.1rem;
  padding: 0.9rem 1rem;
  min-height: 48px;
}

/* Invalid input highlighting */
input.invalid {
  border-color:#d93025 !important;
  box-shadow:0 0 0 2px rgba(217,48,37,.2) !important;
}

/* Field-level error message styling */
.field-error {
  color: #d93025;
  font-size: 0.95rem;
  margin-top: 6px;
  display: none;
}

.field-error.show { display: block; }

/* Progressive enhancements */
@media (min-width: 600px) {
  #index-mobile-scope .form-container {
    max-width: 640px;
  }
  #index-mobile-scope .question-card label {
    padding: 0.4rem 0;
  }
}


/* Layout */
#index-mobile-scope .question-card {
  overflow-wrap: anywhere;
}

#index-mobile-scope .form-container {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

/* Buttons */
#index-mobile-scope .form-container button {
  font-size: 1.1rem;
  padding: 0.9rem 1rem;
  min-height: 48px;
}

/* Progressive enhancements */
@media (min-width: 600px) {
  #index-mobile-scope .form-container {
    max-width: 640px;
  }
  #index-mobile-scope .question-card label {
    padding: 0.4rem 0;
  }
}

@media (min-width: 768px) {
  #index-mobile-scope .form-container {
    max-width: 680px;
  }
}

@media (min-width: 992px) {
  #index-mobile-scope .form-container {
    max-width: 720px;
  }
}

/* === Custom layout for first two checkbox questions === */
/* Make first two fieldsets (priorities and beliefs) a wrapping flex row */
#index-mobile-scope .form-container form > .question-card:nth-of-type(-n+2) fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.25rem; /* 50% reduced spacing between items */
}

/* Default mobile layout - left aligned checkboxes */
#index-mobile-scope .form-container form > .question-card:nth-of-type(-n+2) fieldset > label {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* left align checkbox + text within the label */
  text-align: left;            /* left align the label text */
  margin: 0;
  padding: 0.25rem 0;         /* 50% reduced vertical padding */
  min-height: 22px;           /* 50% reduced min height from 44px */
  flex: 0 1 calc((100% - 1rem) / 3); /* max 3 per row (0.5rem gaps) */
  max-width: calc((100% - 1rem) / 3);
  min-width: 220px; /* give a little more room to avoid wrapping */
  padding-left: 0.5rem;
}

/* Force the "Other" option to its own full line */
#index-mobile-scope .form-container form > .question-card:nth-of-type(1) fieldset > label:has(input[name="priority_other"]),
#index-mobile-scope .form-container form > .question-card:nth-of-type(2) fieldset > label:has(input[name="spiritual_beliefs_other"]) {
  display: block;
  flex: 0 0 100%;
  width: 100%;
  max-width: 100%;
  text-align: left; /* do not center-align the 'Other' label */
}

/* Ensure the Other text field shows on its own line and fills width */
#index-mobile-scope .form-container form > .question-card:nth-of-type(1) fieldset > label:has(input[name="priority_other"]) input[type="text"],
#index-mobile-scope .form-container form > .question-card:nth-of-type(2) fieldset > label:has(input[name="spiritual_beliefs_other"]) input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
}

/* Desktop layout - centered checkboxes */
@media (min-width: 768px) {
  #index-mobile-scope .form-container form > .question-card:nth-of-type(-n+2) fieldset {
    justify-content: center;
  }
  #index-mobile-scope .form-container form > .question-card:nth-of-type(-n+2) fieldset > label {
    justify-content: center;
    text-align: center;
    padding-left: 0;
  }
}
