/* ═══════════════════════════════════════════════════════════════
   THE ULTIMATE BEAUTY — FORM SYSTEM
   Branded form styles · 7 form types · TUB design tokens
   ═══════════════════════════════════════════════════════════════ */

/* ─── FORM CONTAINER ─────────────────────────────────────────── */
.tub-form-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--space-md);
}
.tub-form-wrap.tub-form--wide {
  max-width: 680px;
}

.tub-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ─── FORM HEADER ────────────────────────────────────────────── */
.tub-form__header {
  text-align: center;
  margin-bottom: var(--space-sm);
}
.tub-form__title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 400;
  line-height: 1.15;
  color: var(--charcoal);
  margin-bottom: 0.5rem;
}
.tub-form__subtitle {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--charcoal-60);
  line-height: 1.6;
  max-width: 440px;
  margin: 0 auto;
}

/* ─── FIELD GROUP ────────────────────────────────────────────── */
.tub-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.tub-field--row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 480px) {
  .tub-field--row { grid-template-columns: 1fr; }
}

.tub-field--hidden {
  display: none;
}

/* Conditional fields: smooth reveal */
.tub-field[data-condition] {
  display: none;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.35s ease, max-height 0.4s ease;
}
.tub-field[data-condition].tub-field--visible {
  display: flex;
  opacity: 1;
  max-height: 300px;
  overflow: visible;
}

/* ─── LABELS ─────────────────────────────────────────────────── */
.tub-label {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--charcoal);
}
.tub-label__required {
  color: var(--gold);
  margin-left: 2px;
}

/* ─── TEXT INPUTS & TEXTAREAS ────────────────────────────────── */
.tub-input,
.tub-textarea,
.tub-select {
  width: 100%;
  padding: 13px 16px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 300;
  color: var(--charcoal);
  background: var(--warm-white);
  border: 1.5px solid var(--charcoal-10);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.tub-input::placeholder,
.tub-textarea::placeholder {
  color: var(--charcoal-30);
  font-weight: 300;
}
.tub-input:focus,
.tub-textarea:focus,
.tub-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-pale);
}

/* Error state */
.tub-input--error,
.tub-textarea--error,
.tub-select--error {
  border-color: #C0392B;
  box-shadow: 0 0 0 3px rgba(192,57,43,0.08);
}

.tub-textarea {
  min-height: 100px;
  resize: vertical;
}

/* ─── SELECT / DROPDOWN ──────────────────────────────────────── */
.tub-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23B8965A' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 10px;
  padding-right: 40px;
  cursor: pointer;
}

/* ─── RADIO BUTTONS (Single Choice) ──────────────────────────── */
.tub-radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.tub-radio {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 12px 16px;
  background: var(--warm-white);
  border: 1.5px solid var(--charcoal-10);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.25s ease;
}
.tub-radio:hover {
  border-color: var(--gold-light);
  background: rgba(184,150,90,0.03);
}
.tub-radio input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--charcoal-30);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  transition: all 0.2s ease;
  cursor: pointer;
}
.tub-radio input[type="radio"]:checked {
  border-color: var(--gold);
  background: var(--gold);
  box-shadow: inset 0 0 0 3px var(--warm-white);
}
.tub-radio--active {
  border-color: var(--gold);
  background: var(--gold-pale);
}
.tub-radio__label {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--charcoal);
  line-height: 1.4;
}

/* ─── RADIO CARDS (Founding Access tiers) ────────────────────── */
.tub-card-group {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.tub-card-radio {
  display: flex;
  gap: 1rem;
  padding: 18px 20px;
  background: var(--warm-white);
  border: 1.5px solid var(--charcoal-10);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}
.tub-card-radio:hover {
  border-color: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(26,24,22,0.06);
}
.tub-card-radio input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--charcoal-30);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  transition: all 0.2s ease;
  cursor: pointer;
}
.tub-card-radio input[type="radio"]:checked {
  border-color: var(--gold);
  background: var(--gold);
  box-shadow: inset 0 0 0 3.5px var(--warm-white);
}
.tub-card-radio--active {
  border-color: var(--gold);
  background: var(--gold-pale);
  box-shadow: 0 4px 20px rgba(184,150,90,0.12);
}
.tub-card-radio__content {
  flex: 1;
}
.tub-card-radio__badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(184,150,90,0.1);
  padding: 3px 10px;
  border-radius: 100px;
  margin-bottom: 0.35rem;
}
.tub-card-radio__title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--charcoal);
  margin-bottom: 0.25rem;
}
.tub-card-radio__desc {
  font-size: 0.78rem;
  color: var(--charcoal-60);
  line-height: 1.5;
}

/* ─── CHECKBOX (GDPR, multi-select) ──────────────────────────── */
.tub-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
}
.tub-checkbox input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--charcoal-30);
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 1px;
  position: relative;
  transition: all 0.2s ease;
  cursor: pointer;
}
.tub-checkbox input[type="checkbox"]:checked {
  border-color: var(--gold);
  background: var(--gold);
}
.tub-checkbox input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.tub-checkbox__text {
  font-size: 0.76rem;
  color: var(--charcoal-60);
  line-height: 1.5;
}
.tub-checkbox__text a {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ─── MULTI CHECKBOX GROUP ───────────────────────────────────── */
.tub-multi-check {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.tub-multi-check .tub-checkbox {
  padding: 10px 14px;
  background: var(--warm-white);
  border: 1.5px solid var(--charcoal-10);
  border-radius: var(--radius-sm);
  transition: all 0.25s ease;
}
.tub-multi-check .tub-checkbox:hover {
  border-color: var(--gold-light);
}
.tub-multi-check .tub-checkbox--active {
  border-color: var(--gold);
  background: var(--gold-pale);
}

/* ─── DATE PICKER ────────────────────────────────────────────── */
.tub-input[type="date"] {
  cursor: pointer;
}
.tub-input[type="date"]::-webkit-calendar-picker-indicator {
  filter: opacity(0.5);
  cursor: pointer;
}

/* ─── NUMBER INPUT ───────────────────────────────────────────── */
.tub-input[type="number"] {
  -moz-appearance: textfield;
}
.tub-input[type="number"]::-webkit-outer-spin-button,
.tub-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ─── ERROR MESSAGE ──────────────────────────────────────────── */
.tub-error {
  font-size: 0.72rem;
  color: #C0392B;
  font-weight: 400;
  margin-top: 2px;
  display: none;
}
.tub-error--visible {
  display: block;
  animation: tub-shake 0.35s ease;
}
@keyframes tub-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ─── SUBMIT BUTTON ──────────────────────────────────────────── */
.tub-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 16px 32px;
  margin-top: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-light);
  background: var(--charcoal);
  border: none;
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.35s ease;
}
.tub-submit:hover {
  background: #2A2622;
  color: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(26,24,22,0.2);
}
.tub-submit:active {
  transform: translateY(0);
}
.tub-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Submit loading state */
.tub-submit--loading {
  pointer-events: none;
  color: transparent;
}
.tub-submit--loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(184,150,90,0.3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: tub-spin 0.7s linear infinite;
}
@keyframes tub-spin {
  to { transform: rotate(360deg); }
}

/* ─── SUCCESS STATE ──────────────────────────────────────────── */
.tub-form__success {
  display: none;
  text-align: center;
  padding: var(--space-md) var(--space-sm);
  animation: tub-fadeIn 0.5s ease;
}
.tub-form__success--visible {
  display: block;
}
@keyframes tub-fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tub-form__success-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}
.tub-form__success-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--charcoal);
  margin-bottom: 0.5rem;
}
.tub-form__success-text {
  font-size: 0.85rem;
  color: var(--charcoal-60);
  line-height: 1.6;
  max-width: 380px;
  margin: 0 auto;
}

/* ─── PHONE INPUT WITH PREFIX ────────────────────────────────── */
.tub-phone-wrap {
  display: flex;
  gap: 0.5rem;
}
.tub-phone-prefix {
  width: 80px;
  flex-shrink: 0;
  text-align: center;
}
.tub-phone-wrap .tub-input:last-child {
  flex: 1;
}

/* ─── FORM SECTION DIVIDER ───────────────────────────────────── */
.tub-form__divider {
  width: 40px;
  height: 1px;
  background: var(--gold);
  margin: 0.5rem auto;
  opacity: 0.4;
}

/* ─── FORM NOTE / HELPER TEXT ────────────────────────────────── */
.tub-note {
  font-size: 0.72rem;
  color: var(--charcoal-30);
  font-style: italic;
  margin-top: -0.3rem;
}

/* ─── FORM IN MODAL / POPUP ──────────────────────────────────── */
.tub-form-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.tub-form-modal--active {
  display: flex;
}
.tub-form-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(26,24,22,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}
.tub-form-modal__box {
  position: relative;
  z-index: 1;
  background: var(--ivory);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(26,24,22,0.2);
  animation: tub-modalIn 0.4s ease;
}
@keyframes tub-modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.tub-form-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--charcoal-60);
  background: rgba(26,24,22,0.05);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 2;
}
.tub-form-modal__close:hover {
  background: rgba(26,24,22,0.1);
  color: var(--charcoal);
}

/* ─── INLINE FORM (embedded in page section) ─────────────────── */
.tub-form-inline {
  background: var(--cream);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border: 1px solid var(--charcoal-10);
}

/* ─── FORM IN DARK SECTIONS ──────────────────────────────────── */
/* Auto-detect: any [data-tub-form] inside a dark-bg section gets a card */
.contact-shell [data-tub-form],
.jotform-container [data-tub-form],
[style*="background:#1A"] [data-tub-form],
[style*="background:var(--charcoal)"] [data-tub-form] {
  background: var(--ivory);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border: 1px solid rgba(184,150,90,0.15);
  box-shadow: 0 8px 32px rgba(26,24,22,0.15);
}

/* ─── COMPACT FORM (newsletter / footer) ─────────────────────── */
.tub-form--compact {
  max-width: 400px;
}
.tub-form--compact .tub-form {
  flex-direction: row;
  gap: 0.5rem;
}
.tub-form--compact .tub-input {
  flex: 1;
  padding: 12px 14px;
  font-size: 0.82rem;
}
.tub-form--compact .tub-submit {
  width: auto;
  padding: 12px 24px;
  margin-top: 0;
  white-space: nowrap;
}
@media (max-width: 480px) {
  .tub-form--compact .tub-form {
    flex-direction: column;
  }
  .tub-form--compact .tub-submit {
    width: 100%;
  }
}

/* ─── CHARACTER COUNTER ──────────────────────────────────────── */
.tub-char-count {
  font-size: 0.65rem;
  color: var(--charcoal-30);
  text-align: right;
  margin-top: -0.2rem;
}
.tub-char-count--warn {
  color: #E67E22;
}
.tub-char-count--max {
  color: #C0392B;
}

/* ─── FORM SECTION (step indicator for multi-step) ───────────── */
.tub-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: var(--space-sm);
}
.tub-step {
  width: 32px;
  height: 3px;
  background: var(--charcoal-10);
  border-radius: 2px;
  transition: all 0.3s ease;
}
.tub-step--active {
  background: var(--gold);
  width: 48px;
}
.tub-step--done {
  background: var(--gold-light);
}

/* ─── NEWSLETTER IN DARK FOOTER ──────────────────────────────── */
.footer-newsletter .tub-form-wrap {
  padding: 0;
}
.footer-newsletter .tub-form {
  flex-direction: row;
  gap: 0.5rem;
  max-width: 440px;
  margin: 1rem auto 0;
}
.footer-newsletter .tub-input {
  flex: 1;
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
  color: var(--ivory);
  padding: 13px 16px;
}
.footer-newsletter .tub-input::placeholder {
  color: rgba(255,255,255,0.35);
}
.footer-newsletter .tub-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184,150,90,0.2);
}
.footer-newsletter .tub-submit {
  width: auto;
  padding: 13px 24px;
  margin-top: 0;
  white-space: nowrap;
  background: var(--gold);
  color: #fff;
}
.footer-newsletter .tub-submit:hover {
  background: var(--gold-light);
}
.footer-newsletter .tub-form__success-title {
  color: var(--ivory);
}
.footer-newsletter .tub-form__success-text {
  color: rgba(255,255,255,0.6);
}
@media (max-width: 480px) {
  .footer-newsletter .tub-form {
    flex-direction: column;
  }
  .footer-newsletter .tub-submit {
    width: 100%;
  }
}

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .tub-form-wrap { padding: var(--space-sm); }
  .tub-form__title { font-size: 1.4rem; }
  .tub-card-radio { padding: 14px 16px; }
  .tub-form-modal__box { max-height: 85vh; border-radius: var(--radius-sm); }
}
