/* ==========================================
   Dossier Form — AgrementHub
   ========================================== */

/* --- Layout --- */
.form-page {
  min-height: calc(100vh - 200px);
  padding: 3rem 2rem 5rem;
  background: var(--cream);
}

.form-container {
  max-width: 760px;
  margin: 0 auto;
}

/* --- Form Header --- */
.form-header {
  margin-bottom: 2.5rem;
}

.form-header h1 {
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  color: var(--text);
  margin-bottom: 0.875rem;
}

.form-subtitle {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.65;
}

/* --- Progress Bar --- */
.progress-bar {
  height: 4px;
  background: rgba(45, 80, 22, 0.12);
  border-radius: 2px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--forest);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  font-weight: 500;
}

/* --- Sections --- */
.form-section {
  background: var(--white);
  border: 1.5px solid rgba(45, 80, 22, 0.1);
  border-radius: 1rem;
  padding: 2rem 2.25rem;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  font-family: 'DM Sans', sans-serif;
}

.section-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--forest);
  color: var(--white);
  border-radius: 50%;
  font-size: 0.8125rem;
  font-weight: 600;
  flex-shrink: 0;
}

.section-description {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

/* --- Fields --- */
.field-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
}

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

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.required {
  color: #C04040;
}

input[type="text"],
input[type="number"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 0.6875rem 1rem;
  border: 1.5px solid rgba(45, 80, 22, 0.2);
  border-radius: 0.625rem;
  background: var(--cream);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9375rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(45, 80, 22, 0.08);
  background: var(--white);
}

input.input-error,
select.input-error,
textarea.input-error {
  border-color: #C04040;
  background: #FFF8F8;
}

input.input-error:focus,
select.input-error:focus,
textarea.input-error:focus {
  box-shadow: 0 0 0 3px rgba(192, 64, 64, 0.08);
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235C5C5C' d='M6 8.5L1.5 4h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

textarea {
  resize: vertical;
  min-height: 110px;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

/* --- Field hints & errors --- */
.field-hint {
  font-size: 0.78125rem;
  color: var(--text-light);
  margin-top: 0.3rem;
}

.field-error {
  font-size: 0.78125rem;
  color: #C04040;
  margin-top: 0.3rem;
  min-height: 1.2em;
  font-weight: 500;
}

/* --- Financial table --- */
.year-anchors {
  margin-bottom: 1.5rem;
}

.financial-table-wrapper {
  border: 1px solid rgba(45, 80, 22, 0.1);
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  background: rgba(248, 244, 239, 0.5);
}

.financial-year-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--amber-dark);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
  font-family: 'DM Sans', sans-serif;
}

.financial-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* --- Salary ratio --- */
.ratio-info {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: rgba(45, 80, 22, 0.05);
  border-radius: 0.625rem;
}

.ratio-bar {
  height: 6px;
  background: var(--forest);
  border-radius: 3px;
  margin-bottom: 0.625rem;
  transition: width 0.4s ease, background 0.3s ease;
  max-width: 100%;
}

#ratioVerdict {
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* --- Validation summary --- */
.validation-summary {
  background: #FFF5F5;
  border: 1.5px solid #C04040;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
  color: #C04040;
  font-size: 0.875rem;
  font-weight: 500;
}

/* --- Submit button --- */
.form-actions {
  margin-top: 2rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--forest);
  color: var(--white);
  border: none;
  border-radius: 0.75rem;
  padding: 0.875rem 2rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
  background: var(--forest-dark);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* --- JSON output --- */
#jsonOutput {
  margin-top: 2.5rem;
  background: var(--white);
  border: 1.5px solid rgba(45, 80, 22, 0.15);
  border-radius: 1rem;
  padding: 2rem;
}

#jsonOutput h2 {
  font-size: 1.25rem;
  color: var(--text);
  margin-bottom: 1rem;
}

#jsonPayload {
  background: var(--cream-dark);
  border-radius: 0.625rem;
  padding: 1.25rem;
  font-size: 0.8125rem;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
  line-height: 1.65;
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  max-height: 400px;
  overflow-y: auto;
}

.output-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  color: var(--forest);
  border: 1.5px solid var(--forest);
  border-radius: 0.625rem;
  padding: 0.5rem 1.25rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-secondary:hover {
  background: var(--forest);
  color: var(--white);
}

/* --- Tooltips --- */
.label-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.4rem;
}

.label-row label {
  margin-bottom: 0;
}

.label-row .required {
  color: #C04040;
  margin-left: 0.1rem;
}

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(45, 80, 22, 0.15);
  color: var(--forest);
  font-size: 0.6875rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
  font-family: 'DM Sans', sans-serif;
  line-height: 1;
  padding-bottom: 1px;
  user-select: none;
}

.info-btn:hover {
  background: rgba(45, 80, 22, 0.3);
}

.tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tooltip-wrap .info-btn {
  margin-left: 0.35rem;
  margin-top: 0.2rem;
}

.tooltip-content {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1C2B1A;
  color: #F4F9F2;
  border-radius: 0.625rem;
  padding: 0.75rem 1rem;
  width: 260px;
  font-size: 0.78125rem;
  line-height: 1.55;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 100;
  pointer-events: none;
  white-space: normal;
}

.tooltip-content::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1C2B1A;
}

.tooltip-content::before {
  content: attr(data-ref);
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: rgba(244, 249, 242, 0.55);
  margin-top: 0.4rem;
  letter-spacing: 0.02em;
}

/* --- Salary ratio calculator --- */
.ratio-calc-wrapper {
  margin-bottom: 1.25rem;
}

.ratio-calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.ratio-calc-grid .field-group label {
  font-size: 0.8125rem;
}

.ratio-calc-grid input {
  font-size: 0.9375rem;
}

.ratio-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}

.ratio-divider::before,
.ratio-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(45, 80, 22, 0.12);
}

.ratio-divider span {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.ratio-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.125rem;
  border-radius: 0.625rem;
  transition: background 0.3s, border-color 0.3s;
}

.ratio-result.ok {
  background: rgba(45, 80, 22, 0.08);
  border: 1.5px solid rgba(45, 80, 22, 0.25);
}

.ratio-result.fail {
  background: rgba(192, 64, 64, 0.08);
  border: 1.5px solid rgba(192, 64, 64, 0.3);
}

.ratio-result-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

.ratio-result-value {
  font-size: 1.0625rem;
  font-weight: 700;
  font-family: 'Fraunces', serif;
}

.ratio-result.ok .ratio-result-value {
  color: var(--forest);
}

.ratio-result.fail .ratio-result-value {
  color: #C04040;
}

.ratio-result-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.ratio-bar-fill {
  height: 6px;
  border-radius: 3px;
  background: var(--forest);
  transition: width 0.4s ease;
}

.ratio-result.ok .ratio-bar-fill {
  background: var(--forest);
}

.ratio-result.fail .ratio-bar-fill {
  background: #C04040;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .form-page {
    padding: 2rem 1rem 4rem;
  }

  .form-section {
    padding: 1.5rem 1.25rem;
  }

  .financial-row,
  .ratio-calc-grid {
    grid-template-columns: 1fr;
  }

  .tooltip-content {
    width: 220px;
    left: auto;
    right: 0;
    transform: none;
  }

  .tooltip-content::after {
    left: auto;
    right: 16px;
    transform: none;
  }
}