/* =============================================================
   TIA Cohort Manager — form.css
   Covers: progress nav, step layout, all field types,
   conditional hide/show, review step, success state,
   magic-link resend, responsive.
   ============================================================= */

/* ── Theme reset — must come first ───────────────────────── */
.tia-steps {
    list-style: none !important;
    padding-left: 0 !important;
    margin-left: 0 !important;
    counter-reset: none !important;
  }
  
  .tia-steps li {
    list-style: none !important;
    list-style-type: none !important;
  }
  
  .tia-steps li::before,
  .tia-steps li::after {
    content: none !important;
    display: none !important;
  }
  
  .tia-step {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
  }
  
  .tia-fields-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 1.25rem 1.5rem !important;
  }
  
  .tia-field--full  { grid-column: 1 / -1 !important; }
  .tia-field--half  { grid-column: span 1 !important; }
  
  /* ── Reset / base ─────────────────────────────────────────── */
  .tia-form-wrap *,
  .tia-form-wrap *::before,
  .tia-form-wrap *::after {
    box-sizing: border-box;
  }
  
  .tia-form-wrap {
    max-width: 720px;
    margin: 2rem auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #1a1a1a;
  }
  
  /* ── Progress navigation ──────────────────────────────────── */
  .tia-progress-nav {
    margin-bottom: 2.5rem;
  }
  
  .tia-steps {
    list-style: none !important;
    padding-left: 0 !important;
    margin-left: 0 !important;
    margin: 0;
    display: flex;
    align-items: flex-start;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .tia-step {
    flex: 1;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    position: relative;
    font-size: 0.75rem;
    color: #888;
    padding: 0 4px;
    text-align: center;
    min-width: 60px;
    list-style: none !important;
    list-style-type: none !important;
  }
  
  /* Hide the theme-injected counter entirely */
  .tia-step::before,
  .tia-step::after {
    content: none !important;
    display: none !important;
  }
  
  /* Connector line between steps */
  .tia-step + .tia-step::before {
    content: '';
    position: absolute;
    top: 14px;
    left: calc(-50% + 14px);
    right: calc(50% + 14px);
    height: 2px;
    background: #ddd;
    z-index: 0;
  }
  
  .tia-step--done + .tia-step::before,
  .tia-step--active + .tia-step::before {
    background: #1a73e8;
  }
  
  .tia-step__num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #ccc;
    background: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    color: #888;
    margin-bottom: 0.4rem;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
  }
  
  .tia-step__label {
    font-size: 0.7rem;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  
  .tia-step--active {
    color: #1a73e8;
    font-weight: 600;
  }
  .tia-step--active .tia-step__num {
    border-color: #1a73e8;
    background: #1a73e8;
    color: #fff;
  }
  
  .tia-step--done {
    color: #188038;
  }
  .tia-step--done .tia-step__num {
    border-color: #188038;
    background: #188038;
    color: #fff;
    font-size: 0.9rem; /* ✓ checkmark */
  }
  
  /* ── Step header ──────────────────────────────────────────── */
  .tia-step-header {
    margin-bottom: 1.75rem;
  }
  
  .tia-step-header h2 {
    margin: 0 0 0.35rem;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
  }
  
  .tia-step-desc {
    margin: 0;
    color: #555;
    font-size: 0.92rem;
  }
  
  /* ── Fields grid ──────────────────────────────────────────── */
  .tia-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem 1.5rem;
  }
  
  .tia-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
  }
  
  .tia-field--full  { grid-column: 1 / -1; }
  .tia-field--half  { grid-column: span 1; }
  
  /* Conditional: hidden fields collapse cleanly */
  .tia-field--hidden {
    display: none !important;
  }
  
  /* ── Labels ───────────────────────────────────────────────── */
  .tia-field > label,
  .tia-field > .tia-field-label {
    font-weight: 500;
    font-size: 0.88rem;
    color: #222;
  }
  
  .tia-required {
    color: #c0392b;
    margin-left: 2px;
  }
  
  .tia-field-help {
    font-size: 0.8rem;
    color: #666;
    line-height: 1.45;
  }
  
  /* ── Inputs ───────────────────────────────────────────────── */
  .tia-field input[type="text"],
  .tia-field input[type="email"],
  .tia-field input[type="tel"],
  .tia-field input[type="url"],
  .tia-field input[type="number"],
  .tia-field select,
  .tia-field textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1.5px solid #ccc;
    border-radius: 6px;
    font-size: 0.96rem;
    font-family: inherit;
    background: #fff;
    color: #1a1a1a;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
  }
  
  .tia-field input:focus,
  .tia-field select:focus,
  .tia-field textarea:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.14);
    outline: none;
  }
  
  .tia-field input[aria-invalid="true"],
  .tia-field select[aria-invalid="true"],
  .tia-field textarea[aria-invalid="true"],
  .tia-field fieldset[aria-invalid="true"] {
    border-color: #c0392b;
  }
  
  .tia-field textarea {
    resize: vertical;
    min-height: 90px;
  }
  
  .tia-field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23555'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.2rem;
  }
  
  /* Locked (email after step 1 saved) */
  .tia-field--locked {
    background: #f4f4f4;
    color: #555;
    cursor: not-allowed;
  }
  
  /* ── Radio / checkbox groups ──────────────────────────────── */
  .tia-radio-group,
  .tia-checkbox-group {
    border: none;
    margin: 0;
    padding: 0;
  }
  
  .tia-radio-group legend,
  .tia-checkbox-group legend {
    font-weight: 500;
    font-size: 0.88rem;
    color: #222;
    margin-bottom: 0.5rem;
    padding: 0;
  }
  
  .tia-radio-label,
  .tia-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.92rem;
    cursor: pointer;
    padding: 0.3rem 0;
    color: #333;
  }
  
  .tia-radio-label input,
  .tia-checkbox-label input {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: #1a73e8;
    cursor: pointer;
    margin: 0;
  }
  
  /* ── Field errors ─────────────────────────────────────────── */
  .tia-field-error {
    display: block;
    color: #c0392b;
    font-size: 0.8rem;
    margin-top: 0.2rem;
    font-weight: 500;
  }
  
  /* ── Section headers (within field grid) ─────────────────── */
  .tia-section-header {
    font-size: 1rem;
    font-weight: 600;
    color: #1a73e8;
    border-bottom: 1.5px solid #e8f0fe;
    padding-bottom: 0.4rem;
    margin: 0.5rem 0 0;
    grid-column: 1 / -1;
  }
  
  /* ── Form actions ─────────────────────────────────────────── */
  .tia-form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1.5px solid #eee;
    flex-wrap: wrap;
  }
  
  /* ── Buttons ──────────────────────────────────────────────── */
  .tia-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    font-size: 0.94rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, opacity 0.15s, transform 0.1s;
    line-height: 1.4;
  }
  
  .tia-btn:active { transform: scale(0.98); }
  .tia-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
  
  .tia-btn--primary {
    background: #1a73e8;
    color: #fff;
  }
  .tia-btn--primary:hover:not(:disabled) { background: #1558b0; }
  
  .tia-btn--secondary {
    background: #f1f3f4;
    color: #333;
    border: 1.5px solid #ddd;
  }
  .tia-btn--secondary:hover:not(:disabled) { background: #e5e7ea; }
  
  .tia-btn--submit {
    background: #188038;
    color: #fff;
  }
  .tia-btn--submit:hover:not(:disabled) { background: #0f5c28; }
  
  .tia-btn--text {
    background: none;
    color: #1a73e8;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid #d0e2fc;
    border-radius: 4px;
  }
  .tia-btn--text:hover { background: #e8f0fe; }
  
  /* ── Save status ──────────────────────────────────────────── */
  .tia-save-status {
    font-size: 0.83rem;
    margin-left: auto;
    transition: color 0.2s;
  }
  .tia-save-status--ok    { color: #188038; }
  .tia-save-status--error { color: #c0392b; }
  
  /* ── Magic-link resend widget ─────────────────────────────── */
  .tia-resume-link {
    margin-top: 2rem;
    padding: 1.25rem 1.5rem;
    background: #f8faff;
    border: 1.5px solid #d0e2fc;
    border-radius: 8px;
  }
  
  .tia-resume-link__label {
    font-size: 0.88rem;
    font-weight: 500;
    color: #555;
    margin: 0 0 0.6rem;
  }
  
  .tia-resume-link__controls {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
  }
  
  .tia-resume-link__controls input[type="email"] {
    flex: 1;
    min-width: 200px;
    padding: 0.55rem 0.75rem;
    border: 1.5px solid #ccc;
    border-radius: 6px;
    font-size: 0.92rem;
    font-family: inherit;
  }
  
  .tia-resume-link__controls input[type="email"]:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26,115,232,0.14);
    outline: none;
  }
  
  /* ── Review step ──────────────────────────────────────────── */
  .tia-review-wrap h2 {
    font-size: 1.45rem;
    margin: 0 0 0.4rem;
  }
  
  .tia-review-wrap > .tia-step-desc {
    margin-bottom: 1.75rem;
  }
  
  .tia-review-section {
    border: 1.5px solid #e4e4e4;
    border-radius: 10px;
    padding: 1.1rem 1.4rem;
    margin-bottom: 1rem;
    background: #fafafa;
  }
  
  .tia-review-section__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    gap: 1rem;
  }
  
  .tia-review-section__head h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a1a1a;
  }
  
  .tia-review-dl {
    display: grid;
    grid-template-columns: minmax(160px, 35%) 1fr;
    gap: 0.3rem 1rem;
    margin: 0;
    font-size: 0.88rem;
  }
  
  .tia-review-dl dt {
    font-weight: 500;
    color: #555;
    text-transform: none;
  }
  
  .tia-review-dl dd {
    margin: 0;
    color: #222;
    word-break: break-word;
  }
  
  /* ── Success state ────────────────────────────────────────── */
  .tia-success {
    text-align: center;
    padding: 3rem 2rem;
    background: #f0fdf4;
    border-radius: 12px;
    border: 1.5px solid #bbf7d0;
  }
  
  .tia-success__icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: #188038;
    position: relative;
  }
  
  .tia-success__icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-47%, -58%) rotate(45deg);
    width: 10px;
    height: 18px;
    border-right: 3px solid #fff;
    border-bottom: 3px solid #fff;
  }
  
  .tia-success h2 {
    font-size: 1.4rem;
    color: #14532d;
    margin: 0 0 0.5rem;
  }
  
  .tia-success p {
    color: #166534;
    margin: 0.35rem 0 0;
  }
  
  /* ── Notice banners ───────────────────────────────────────── */
  .tia-notice {
    padding: 0.9rem 1.2rem;
    border-radius: 8px;
    border: 1.5px solid transparent;
    font-size: 0.92rem;
    line-height: 1.55;
    margin: 1rem 0;
  }
  .tia-notice p { margin: 0; }
  .tia-notice--info    { background: #e8f0fe; border-color: #c5d6fc; color: #1a56c4; }
  .tia-notice--warning { background: #fef3cd; border-color: #fde68a; color: #854d0e; }
  .tia-notice--success { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
  
  /* ── Badges (used in admin + dashboard) ───────────────────── */
  .tia-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }
  .tia-badge--gray   { background: #f1f3f4; color: #555; }
  .tia-badge--blue   { background: #e8f0fe; color: #1a56c4; }
  .tia-badge--amber  { background: #fef3cd; color: #854d0e; }
  .tia-badge--green  { background: #e6f9ed; color: #155724; }
  .tia-badge--red    { background: #fce8e6; color: #922b21; }
  .tia-badge--purple { background: #f3e8fd; color: #5b21b6; }
  
  /* ── Honeypot (must be invisible to humans, not screen readers) ─ */
  .tia-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }
  
  /* ── Cloudflare Turnstile ─────────────────────────────────── */
  .tia-turnstile {
    margin: 1rem 0 0;
  }
  
  /* ── Responsive ───────────────────────────────────────────── */
  @media ( max-width: 600px ) {
    .tia-fields-grid {
      grid-template-columns: 1fr;
    }
    .tia-field--half {
      grid-column: 1 / -1;
    }
    .tia-step__label {
      display: none; /* show only dots on very small screens */
    }
    .tia-review-dl {
      grid-template-columns: 1fr;
      gap: 0.15rem;
    }
    .tia-review-dl dt {
      padding-top: 0.5rem;
      border-top: 1px solid #eee;
    }
    .tia-review-dl dt:first-child {
      border-top: none;
    }
    .tia-form-actions {
      flex-direction: column;
      align-items: stretch;
    }
    .tia-btn {
      width: 100%;
      justify-content: center;
    }
    .tia-save-status {
      margin-left: 0;
      text-align: center;
    }
  }
  
  @media ( max-width: 400px ) {
    .tia-step {
      min-width: 40px;
    }
  }