/* RightTenantry — Public Application Form Styles
   Self-contained stylesheet for the SSR form at /apply/:code.
   Uses CSS custom properties matching the Tailwind design tokens. */

/* ── Design tokens ─────────────────────────────────────────────────────── */

:root {
  --navy: #1B2A4A;
  --amber: #D4942A;
  --off-white: #FAFAF7;
  --charcoal: #2D2D2D;
  --slate: #64748B;
  --teal: #2D8A7E;
  --red: #B04048;
  --white: #FFFFFF;
  --border: #E2E8F0;
  --border-error: #B04048;
  --shadow-diffusion: 0 20px 40px -15px rgba(0,0,0,0.05);
  --radius: 0.75rem;
  --font-headline: 'Satoshi', 'DM Sans', sans-serif;
  --font-body: 'Geist', sans-serif;
  --font-mono: 'Geist Mono', monospace;
}

/* ── Reset & base ──────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--off-white);
  color: var(--charcoal);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ── Focus styles (WCAG 2.4.7) ─────────────────────────────────────────── */

*:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 0;
  box-shadow: 0 0 0 3px rgba(212, 148, 42, 0.2);
}

/* ── Header ────────────────────────────────────────────────────────────── */

.form-header {
  background-color: var(--navy);
  color: var(--white);
  padding: 1.25rem 1.5rem;
  text-align: center;
}

.header-brand {
  margin-bottom: 1rem;
}

.brand-logo {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.brand-right {
  color: var(--amber);
}

.brand-tenantry {
  color: var(--white);
}

.header-info h1 {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--white);
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.header-address {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.header-invite {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8125rem;
}

.trust-signals {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.trust-item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
}

.trust-item svg {
  opacity: 0.7;
}


/* ── Form container ────────────────────────────────────────────────────── */

.form-container {
  max-width: 48rem; /* 768px — comfortable desktop width */
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ── Form sections ─────────────────────────────────────────────────────── */

.form-section {
  background-color: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-diffusion);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.section-title {
  float: left;
  width: 100%;
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--navy);
  margin-bottom: 1rem;
  letter-spacing: -0.025em;
  padding: 0;
}

.section-hint {
  font-size: 0.8125rem;
  color: var(--slate);
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* ── Fields ────────────────────────────────────────────────────────────── */

.form-field {
  margin-bottom: 1rem;
}

.form-field:last-child {
  margin-bottom: 0;
}

.form-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--charcoal);
  margin-bottom: 0.375rem;
}

.required-marker {
  color: var(--red);
  font-weight: 600;
}

.optional-suffix {
  color: var(--slate);
  font-weight: 400;
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field select,
.form-field textarea {
  width: 100%;
  height: 3rem; /* 48px — h-12 */
  padding: 0.625rem 0.875rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--charcoal);
  background-color: var(--white);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Remove default appearance on selects only — date inputs need their native picker on iOS */
.form-field select {
  appearance: none;
  -webkit-appearance: none;
}

.form-field textarea {
  height: auto;
  min-height: 5rem;
  resize: vertical;
  line-height: 1.5;
}

.form-field select {
  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='%2364748B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

.form-field input:hover,
.form-field select:hover,
.form-field textarea:hover {
  border-color: #CBD5E1;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(212, 148, 42, 0.2);
  outline: none;
}

/* ── Field rows (side-by-side on desktop) ──────────────────────────────── */

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

@media (min-width: 640px) {
  .field-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
}

/* ── Error states ──────────────────────────────────────────────────────── */

.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--border-error);
}

.has-error input:focus,
.has-error select:focus,
.has-error textarea:focus {
  border-color: var(--border-error);
  box-shadow: 0 0 0 3px rgba(176, 64, 72, 0.2);
}

.field-error {
  display: none;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  color: var(--red);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.field-error::before {
  content: "";
  display: inline-block;
  width: 0.875rem;
  height: 0.875rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23B04048' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M15 9l-6 6M9 9l6 6'/%3E%3C/svg%3E");
  background-size: contain;
  flex-shrink: 0;
}

.form-error-banner {
  background-color: #FEF2F2;
  border: 1px solid rgba(176, 64, 72, 0.3);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 0.875rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  text-align: left;
}

.form-error-banner:focus {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.form-error-banner-headline {
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}

.form-error-banner-list {
  margin: 0;
  padding-left: 1.25rem;
  list-style: disc;
}

.form-error-banner-list li {
  margin: 0.25rem 0;
}

.form-error-banner-list a {
  color: var(--red);
  text-decoration: underline;
}

.form-error-banner-list a:hover,
.form-error-banner-list a:focus {
  text-decoration-thickness: 2px;
}

/* ── Radio groups ──────────────────────────────────────────────────────── */

.radio-group {
  margin-bottom: 1rem;
}

.radio-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--charcoal);
  margin-bottom: 0.5rem;
}

.radio-options {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.radio-option {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.9375rem;
  color: var(--charcoal);
  cursor: pointer;
  padding: 0.375rem 0;
  min-height: 2.75rem; /* 44px touch target */
}

.radio-option input[type="radio"] {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--amber);
  cursor: pointer;
}

/* ── Checkbox field ────────────────────────────────────────────────────── */

.checkbox-field {
  margin-bottom: 1rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  color: var(--charcoal);
  cursor: pointer;
  padding: 0.375rem 0;
  min-height: 2.75rem;
}

.checkbox-label input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--amber);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Field helper ──────────────────────────────────────────────────────── */

.field-helper {
  font-size: 0.8125rem;
  color: var(--slate);
  margin-top: 0.375rem;
  line-height: 1.4;
}

/* ── Conditional fields ────────────────────────────────────────────────── */

.conditional-field {
  margin-top: 0.5rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border);
}

/* ── Additional income repeater ───────────────────────────────────────── */

.additional-income-block {
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

.add-source-link,
.remove-source-link {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--navy);
  cursor: pointer;
  text-decoration: underline;
}

.add-source-link:hover,
.remove-source-link:hover {
  color: var(--amber);
}

.remove-source-link {
  font-size: 0.8125rem;
  color: var(--slate);
  margin-top: 0.25rem;
}

.income-source-row {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background-color: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.income-source-row[hidden] {
  display: none;
}

/* ── Co-applicant block ───────────────────────────────────────────────── */

.co-applicant-block {
  margin-top: 1rem;
}

.co-applicant-block[hidden] {
  display: none;
}

.co-applicant-card {
  margin-top: 0.75rem;
  padding: 0.875rem 1rem;
  background-color: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.co-applicant-card[hidden],
.conditional-field[hidden] {
  display: none;
}

.co-applicant-card-title {
  font-family: var(--font-headline);
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--navy);
  margin-bottom: 0.5rem;
}

/* ── References ────────────────────────────────────────────────────────── */

.ref-group {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.ref-group:last-of-type {
  border-bottom: none;
  margin-bottom: 0.5rem;
  padding-bottom: 0;
}

.ref-group[hidden] {
  display: none;
}

.ref-heading {
  font-family: var(--font-headline);
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--navy);
  margin-bottom: 0.75rem;
  letter-spacing: -0.025em;
}

/* ── Character counter ─────────────────────────────────────────────────── */

.char-counter {
  text-align: right;
  margin-top: 0.25rem;
}

.char-counter span {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--slate);
}

/* ── Upload areas ──────────────────────────────────────────────────────── */

.upload-area {
  border: 2px dashed var(--border);
  border-radius: 0.5rem;
  padding: 1.25rem;
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  background-color: #FAFAF7;
}

.upload-area:hover {
  border-color: var(--amber);
  background-color: rgba(212, 148, 42, 0.03);
}

.upload-area input[type="file"] {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--slate);
  width: 100%;
  min-height: 2.75rem; /* 44px touch target */
  cursor: pointer;
}

.upload-area input[type="file"]::file-selector-button {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--navy);
  background-color: var(--white);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.5rem 1rem;
  margin-right: 0.75rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.upload-area input[type="file"]::file-selector-button:hover {
  background-color: #F1F5F9;
}

/* ── Consent transparency notice ───────────────────────────────────────── */

.consent-notice {
  padding: 1.25rem 1.25rem 1rem;
  background-color: var(--white);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  color: var(--slate);
  line-height: 1.55;
}

.consent-notice-heading {
  font-family: var(--font-headline);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.625rem;
}

.consent-notice p {
  margin-bottom: 0.625rem;
}

.consent-notice p:last-child {
  margin-bottom: 0;
}

.consent-notice a {
  color: var(--amber);
  text-decoration: underline;
}

.consent-notice a:hover {
  color: var(--navy);
}

.consent-rights-list {
  list-style: disc;
  padding-left: 1.25rem;
  margin-bottom: 0.625rem;
}

.consent-rights-list li {
  margin-bottom: 0.375rem;
}

.consent-rights-list li:last-child {
  margin-bottom: 0;
}

/* ── Consent block ─────────────────────────────────────────────────────── */

.consent-block {
  padding: 1rem;
  background-color: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
}

.consent-block.has-error {
  border-color: var(--border-error);
}

.consent-inner {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.consent-inner input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.125rem;
  accent-color: var(--amber);
  cursor: pointer;
  flex-shrink: 0;
}

.consent-inner label {
  font-size: 0.8125rem;
  color: var(--slate);
  line-height: 1.5;
  cursor: pointer;
}

/* ── Review summary ────────────────────────────────────────────────────── */

.review-summary {
  margin-bottom: 1rem;
}

/* ── Submit button ─────────────────────────────────────────────────────── */

.form-nav {
  margin-top: 0.5rem;
}

.btn-submit {
  display: block;
  width: 100%;
  height: 3.25rem; /* 52px */
  font-family: var(--font-headline);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--white);
  background-color: var(--amber);
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
  min-height: 2.75rem; /* 44px touch target */
}

.btn-submit:hover:not(:disabled) {
  background-color: #C08425;
}

.btn-submit:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Footer ────────────────────────────────────────────────────────────── */

.form-footer {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
}

.form-footer p {
  font-size: 0.75rem;
  color: var(--slate);
}

/* ── Legal document (privacy / terms / contact / erase / dsar) ─────────── */

.legal-document {
  max-width: 40rem; /* tighter reading measure than the 48rem form container */
  margin-inline: auto;
  color: var(--charcoal);
}

.legal-document > :first-child {
  margin-top: 0;
}

.legal-lede {
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--charcoal);
}

.legal-document h2 {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
  color: var(--navy);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.legal-document p {
  line-height: 1.6;
  margin-bottom: 1rem;
}

.legal-document p:last-child {
  margin-bottom: 0;
}

.legal-document ul {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.legal-document li {
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.legal-document li:last-child {
  margin-bottom: 0;
}

.legal-document a {
  color: var(--navy);
  text-decoration: underline;
}

.legal-document a:hover,
.legal-document a:focus {
  text-decoration-thickness: 2px;
}

.legal-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1rem;
  font-size: 0.9375rem;
}

.legal-table th,
.legal-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.legal-table th {
  font-weight: 600;
  color: var(--navy);
}

/* ── Secondary pages (confirmation, closed, duplicate) ─────────────────── */

.confirmation-page,
.closed-notice,
.duplicate-notice {
  background-color: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-diffusion);
  padding: 2.5rem 1.5rem;
  text-align: center;
  margin-top: 1rem;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}

.confirmation-icon,
.closed-icon,
.duplicate-icon {
  margin-bottom: 1rem;
}

.confirmation-page h2,
.closed-notice h2,
.duplicate-notice h2 {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 1.375rem;
  color: var(--navy);
  margin-bottom: 0.75rem;
  letter-spacing: -0.025em;
}

.confirmation-property {
  font-size: 0.9375rem;
  color: var(--slate);
  margin-bottom: 0.25rem;
}

.confirmation-review-date {
  font-size: 0.875rem;
  color: var(--slate);
  margin-top: 1rem;
}

.confirmation-next-steps {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.confirmation-next-steps p {
  font-size: 0.875rem;
  color: var(--slate);
}

.closed-details,
.duplicate-details {
  font-size: 0.9375rem;
  color: var(--slate);
  line-height: 1.5;
}

.closed-date {
  font-size: 0.8125rem;
  font-family: var(--font-mono);
  color: var(--slate);
  margin-top: 0.75rem;
}

/* ── Responsive — tablet (640px+) ─────────────────────────────────────── */

@media (min-width: 640px) {
  .form-header {
    padding: 1.5rem 2rem;
  }

  .form-container {
    padding: 2rem 1.5rem;
  }

  .form-section {
    padding: 2rem;
  }

  .header-info h1 {
    font-size: 1.75rem;
  }
}

/* ── Responsive — desktop (1024px+) ──────────────────────────────────── */

@media (min-width: 1024px) {
  .form-header {
    padding: 2rem 2.5rem;
  }

  .header-info h1 {
    font-size: 2rem;
  }

  .brand-logo {
    font-size: 1.5rem;
  }

  .form-container {
    padding: 2.5rem 2rem;
  }

  .form-section {
    padding: 2.5rem;
    margin-bottom: 1.5rem;
  }

  .section-title {
    font-size: 1.25rem;
  }

  .field-row {
    gap: 1rem;
  }

  .confirmation-page,
  .closed-notice,
  .duplicate-notice {
    padding: 3rem 2.5rem;
  }

  .btn-submit {
    max-width: 20rem;
    margin-left: auto;
    margin-right: auto;
  }
}

/* ── Mobile select fix (44px touch target) ─────────────────────────────── */

@media (max-width: 640px) {
  .form-field select {
    min-height: 2.75rem;
  }
}
