/* Gordian Form Engine — Styles v3.5 */

/* --- RESET & BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #FFFFFF; color: #1a1a1a; line-height: 1.6;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}

/* --- LAYOUT --- */
.gf-container { max-width: 900px; margin: 0 auto; padding: 2rem 1rem; }
.gf-header-card {
  background: linear-gradient(135deg, #30348C 0%, #14b8a6 100%);
  border-radius: 1.25rem; padding: 3rem 2.5rem; margin-bottom: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}
.gf-title { font-size: 2.5rem; font-weight: 700; color: #FFFFFF; margin-bottom: 0.75rem; letter-spacing: -0.02em; }
.gf-subtitle { font-size: 1.125rem; color: rgba(255,255,255,0.9); font-weight: 400; }

/* --- PROGRESS BAR --- */
.gf-progress-wrapper { margin-bottom: 1.5rem; }
.gf-progress-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.gf-progress-text, .gf-progress-percent { font-size: 0.875rem; font-weight: 600; color: #4a5568; }
.gf-progress-bar { height: 0.75rem; background: #e2e8f0; border-radius: 9999px; overflow: hidden; }
.gf-progress-fill {
  height: 100%; background: linear-gradient(90deg, #30348C 0%, #14b8a6 100%);
  border-radius: 9999px; transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- FORM CARD --- */
.gf-form-card {
  background: #FAFAFA; border: 1px solid #e2e8f0; border-radius: 1.25rem;
  padding: 3rem 2.5rem;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}

/* --- SECTIONS --- */
.gf-section { margin-bottom: 3rem; }
.gf-section:last-child { margin-bottom: 0; }
.gf-section-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 2rem; }
.gf-section-accent {
  width: 0.375rem; height: 2.5rem;
  background: linear-gradient(180deg, #30348C 0%, #14b8a6 100%);
  border-radius: 9999px; flex-shrink: 0;
}
.gf-section-title { font-size: 1.75rem; font-weight: 700; color: #1a1a1a; letter-spacing: -0.01em; }
.gf-section-content { padding-left: 1.375rem; }

/* --- FIELDS --- */
.gf-field-wrapper { margin-bottom: 1.75rem; }
.gf-field-wrapper:last-child { margin-bottom: 0; }
.gf-label {
  display: block; font-size: 0.9375rem; font-weight: 600; color: #2d3748;
  margin-bottom: 0.625rem; letter-spacing: -0.01em;
}
.gf-required { color: #E94924; margin-left: 0.25rem; font-weight: 700; }

/* --- INPUTS --- */
.gf-input, .gf-textarea, .gf-select {
  width: 100%; padding: 0.875rem 1rem; font-size: 1rem; color: #1a1a1a;
  background: #FFFFFF; border: 2px solid #cbd5e0; border-radius: 0.75rem;
  outline: none; transition: all 0.2s ease; font-family: inherit;
}
.gf-file-input { padding: 0; border: none; background: none; }
.gf-input:hover, .gf-textarea:hover, .gf-select:hover { border-color: #a0aec0; }
.gf-input:focus, .gf-textarea:focus, .gf-select:focus {
  border-color: #30348C; box-shadow: 0 0 0 3px rgba(48,52,140,0.1);
}
.gf-input::placeholder, .gf-textarea::placeholder { color: #a0aec0; }
.gf-field-error { border-color: #E94924 !important; }
.gf-field-error:focus { box-shadow: 0 0 0 3px rgba(233,73,36,0.1) !important; }
.gf-error-message {
  display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem;
  font-size: 0.875rem; font-weight: 500; color: #E94924;
}
.gf-error-message::before { content: '⚠'; font-size: 1rem; }
.gf-textarea { resize: vertical; min-height: 120px; }

/* --- FIELD GROUP (ROW LAYOUT) --- */
.gf-field-group { display: flex; gap: 1.5rem; align-items: flex-end; }
.gf-field-group > .gf-field-wrapper { flex: 1; margin-bottom: 0; }

/* --- CUSTOM DROPDOWN --- */
.gf-select-wrapper { position: relative; }
.gf-dropdown-trigger {
  width: 100%; padding: 0.875rem 1rem; padding-right: 3rem; font-size: 1rem; color: #1a1a1a;
  background: #FFFFFF; border: 2px solid #cbd5e0; border-radius: 0.75rem;
  outline: none; transition: all 0.2s ease; font-family: inherit; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  text-align: left; user-select: none;
}
.gf-dropdown-trigger:hover { border-color: #a0aec0; }
.gf-dropdown-trigger:focus,
.gf-select-wrapper.open .gf-dropdown-trigger {
  border-color: #30348C; box-shadow: 0 0 0 3px rgba(48,52,140,0.1);
}
.gf-dropdown-trigger.placeholder { color: #a0aec0; }
.gf-dropdown-icon {
  position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: #718096; transition: transform 0.2s ease;
}
.gf-select-wrapper.open .gf-dropdown-icon { transform: translateY(-50%) rotate(180deg); }
.gf-dropdown-menu {
  position: absolute; top: calc(100% + 0.25rem); left: 0; right: 0;
  background: #FFFFFF; border: 1px solid #cbd5e0; border-radius: 0.75rem;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  max-height: 300px; overflow-y: auto; z-index: 1000; opacity: 0;
  transform: translateY(-10px); pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  scrollbar-width: none; -ms-overflow-style: none;
}
.gf-dropdown-menu::-webkit-scrollbar { display: none; }
.gf-select-wrapper.open .gf-dropdown-menu { opacity: 1; transform: translateY(0); pointer-events: auto; }
.gf-dropdown-option {
  padding: 0.875rem 1rem; cursor: pointer; transition: background-color 0.15s ease;
  font-size: 1rem; color: #2d3748;
}
.gf-dropdown-option:hover { background-color: #f0f4ff; }
.gf-dropdown-option.selected { background-color: #e6edff; font-weight: 600; color: #30348C; }
.gf-dropdown-option:first-child { border-top-left-radius: 0.625rem; border-top-right-radius: 0.625rem; }
.gf-dropdown-option:last-child { border-bottom-left-radius: 0.625rem; border-bottom-right-radius: 0.625rem; }

/* --- CURRENCY & NUMBER INPUTS --- */
.gf-currency-wrapper { position: relative; }
.gf-currency-symbol {
  position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
  font-size: 1rem; font-weight: 600; color: #4a5568; pointer-events: none; z-index: 1;
}
.gf-currency-input { padding-left: 2rem; }
.gf-input[type="number"]::-webkit-inner-spin-button,
.gf-input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.gf-input[type="number"] { -moz-appearance: textfield; }
.gf-number-wrapper { position: relative; }
.gf-number-controls {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 1px;
}
.gf-number-btn {
  width: 1.25rem; height: 0.875rem; background: transparent; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #a0aec0; transition: all 0.15s ease; padding: 0;
}
.gf-number-btn:hover { color: #4a5568; }
.gf-number-btn:active { color: #2d3748; }
.gf-number-btn svg { width: 0.75rem; height: 0.75rem; }

/* --- RADIO & CHECKBOX --- */
.gf-radio-group { display: flex; flex-direction: column; gap: 0.875rem; }
.gf-radio-option {
  display: flex; align-items: center; padding: 1rem 1.25rem;
  background: #FFFFFF; border: 2px solid #cbd5e0; border-radius: 0.75rem;
  cursor: pointer; transition: all 0.2s ease;
}
.gf-radio-option:hover { border-color: #30348C; background: #f7fafc; }
.gf-radio-option:has(input:checked) { border-color: #30348C; background: #f0f4ff; }
.gf-radio-input {
  width: 1.25rem; height: 1.25rem; margin: 0; margin-right: 1rem;
  cursor: pointer; accent-color: #30348C; flex-shrink: 0;
}
.gf-radio-label { font-size: 1rem; color: #2d3748; font-weight: 500; }
.gf-checkbox-group { display: flex; flex-direction: column; gap: 0.875rem; }
.gf-checkbox-option {
  display: flex; align-items: flex-start; padding: 1rem 1.25rem;
  background: #FFFFFF; border: 2px solid #cbd5e0; border-radius: 0.75rem;
  cursor: pointer; transition: all 0.2s ease;
}
.gf-checkbox-option:hover { border-color: #30348C; background: #f7fafc; }
.gf-checkbox-option:has(input:checked) { border-color: #30348C; background: #f0f4ff; }
.gf-checkbox-input {
  width: 1.25rem; height: 1.25rem; margin: 0; margin-right: 1rem; margin-top: 0.125rem;
  cursor: pointer; accent-color: #30348C; flex-shrink: 0;
}
.gf-checkbox-label { font-size: 1rem; color: #2d3748; line-height: 1.5; }

/* --- FILE UPLOAD --- */
.gf-file-wrapper { position: relative; display: flex; align-items: center; gap: 1rem; }
.gf-file-input-hidden {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.gf-file-btn {
  padding: 0.875rem 1rem; font-weight: 600; color: #30348C;
  background: #f0f4ff; border: 2px solid #30348C; border-radius: 0.75rem;
  cursor: pointer; transition: all 0.2s ease; flex-shrink: 0;
}
.gf-file-input-hidden:hover + .gf-file-btn,
.gf-file-input-hidden:focus + .gf-file-btn {
  background: #e6edff; box-shadow: 0 0 0 3px rgba(48,52,140,0.1);
}
.gf-file-name {
  font-size: 0.9375rem; color: #4a5568;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gf-file-wrapper.has-file .gf-file-name { color: #1a1a1a; font-weight: 500; }
.gf-file-wrapper.has-error .gf-file-btn { border-color: #E94924; }

/* --- SPAM HONEYPOT --- */
.gf-honeypot { position: absolute; left: -5000px; visibility: hidden; }

/* --- REPEATER --- */
.gf-repeater-wrapper {
  border: 2px solid #e2e8f0; border-radius: 0.75rem; padding: 1.5rem; background: #FFFFFF;
}
.gf-repeater-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 2px solid #e2e8f0;
}
.gf-repeater-title { font-size: 1rem; font-weight: 600; color: #2d3748; }
.gf-repeater-instances { display: flex; flex-direction: column; gap: 1.25rem; }
.gf-repeater-instance {
  border: 2px solid #cbd5e0; border-radius: 0.75rem; padding: 1.5rem;
  background: #f8f9fa; position: relative;
}
.gf-repeater-instance .gf-field-wrapper { padding-left: 1rem; }
.gf-repeater-instance .gf-field-group > .gf-field-wrapper { padding-left: 0; }
.gf-repeater-instance .gf-field-wrapper:has(input),
.gf-repeater-instance .gf-field-wrapper:has(textarea),
.gf-repeater-instance .gf-field-wrapper:has(.gf-select-wrapper) { margin-top: 1rem; }
.gf-repeater-instance-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.25rem; padding-bottom: 0.75rem; border-bottom: 1px solid #cbd5e0;
}
.gf-repeater-instance-title { font-size: 0.9375rem; font-weight: 600; color: #4a5568; }
.gf-repeater-instance-fields { display: flex; flex-direction: column; gap: 1rem; }
.gf-repeater-instance-fields .gf-field-wrapper { margin-bottom: 0; }

/* --- BUTTONS --- */
.gf-btn-remove {
  padding: 0.5rem 1rem; background: #FFFFFF; color: #E94924; border: 2px solid #E94924;
  border-radius: 0.5rem; font-size: 0.875rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s ease; display: inline-flex; align-items: center; gap: 0.375rem;
}
.gf-btn-remove:hover { background: #fff5f5; }
.gf-btn-add {
  padding: 0.75rem 1.5rem; background: #FFFFFF; color: #30348C; border: 2px solid #30348C;
  border-radius: 0.5rem; font-size: 0.9375rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s ease; display: inline-flex; align-items: center; gap: 0.5rem;
  margin-top: 0.75rem;
}
.gf-btn-add:hover { background: #f0f4ff; }
.gf-btn-add svg { width: 1rem; height: 1rem; }

/* --- NAVIGATION --- */
.gf-navigation {
  display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2.5rem;
  padding-top: 2.5rem; border-top: 2px solid #cbd5e0;
}
.gf-submit-error {
  width: 100%; padding: 0.875rem 1rem;
  background: #fff5f5; border: 2px solid #E94924; border-radius: 0.75rem;
  color: #E94924; font-size: 0.9375rem; font-weight: 500;
}
.gf-btn {
  padding: 1rem 2rem; font-size: 1rem; font-weight: 600; border: none; border-radius: 0.75rem;
  cursor: pointer; transition: all 0.2s ease; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.gf-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.gf-btn-primary {
  flex: 1; background: linear-gradient(135deg, #30348C 0%, #14b8a6 100%);
  color: #FFFFFF; box-shadow: 0 4px 6px -1px rgba(48,52,140,0.3);
}
.gf-btn-primary:hover:not(:disabled) {
  box-shadow: 0 10px 15px -3px rgba(48,52,140,0.4); transform: translateY(-1px);
}
.gf-btn-primary:active:not(:disabled) { transform: translateY(0); }
.gf-btn-secondary {
  padding: 1rem 2rem; background: #FFFFFF; color: #4a5568; border: 2px solid #cbd5e0;
}
.gf-btn-secondary:hover:not(:disabled) { background: #f7fafc; border-color: #a0aec0; }
.gf-spinner { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* --- SUCCESS SCREEN --- */
.gf-success-card {
  background: #FAFAFA; border: 1px solid #e2e8f0; border-radius: 1.25rem;
  padding: 4rem 3rem; text-align: center; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.gf-success-icon {
  width: 5rem; height: 5rem; margin: 0 auto 1.5rem;
  background: linear-gradient(135deg, #30348C 0%, #14b8a6 100%);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.gf-success-title { font-size: 2rem; font-weight: 700; color: #1a1a1a; margin-bottom: 1rem; }
.gf-success-text {
  font-size: 1.125rem; color: #4a5568; line-height: 1.6;
  max-width: 600px; margin: 0 auto 2rem;
}

/* --- INFO BOX --- */
.gf-info-box {
  padding: 1.25rem 1.5rem; padding-left: 3.5rem;
  background-color: #f0f9ff; border: 2px solid #b3e0ff; border-radius: 0.75rem;
  color: #0056b3; font-size: 0.9375rem; line-height: 1.6; position: relative;
}
.gf-info-box::before {
  content: 'ℹ'; position: absolute; left: 1.25rem; top: 1.25rem;
  font-size: 1.5rem; font-weight: 700;
}

/* --- SUMMARY & CALCULATION --- */
.gf-summary-list {
  list-style: none; padding: 0; margin: 0;
  border: 2px solid #e2e8f0; border-radius: 0.75rem;
  background: #FFFFFF; overflow: hidden;
}
.gf-summary-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem; font-size: 1rem; border-bottom: 2px solid #e2e8f0;
}
.gf-summary-item:last-child { border-bottom: none; }
.gf-summary-label { font-weight: 600; color: #2d3748; padding-right: 1rem; }
.gf-summary-value { font-weight: 500; color: #1a1a1a; font-size: 1.05rem; white-space: nowrap; }
.gf-calculation-display {
  font-size: 1.25rem; font-weight: 700; color: #1a1a1a;
  padding: 0.875rem 1rem; padding-left: 2rem; background: #f8f9fa;
  border: 2px solid #cbd5e0; border-radius: 0.75rem; width: 100%; text-align: right;
}

/* --- REVIEW PAGE --- */
.gf-review-section {
  background: #FFFFFF; border: 2px solid #e2e8f0; border-radius: 0.75rem;
  margin-bottom: 1.5rem; overflow: hidden;
}
.gf-review-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem; background: #f8f9fa; border-bottom: 2px solid #e2e8f0;
}
.gf-review-title { font-size: 1.125rem; font-weight: 600; color: #2d3748; }
.gf-review-edit-btn {
  font-size: 0.875rem; font-weight: 600; color: #30348C;
  background: none; border: none; cursor: pointer; text-decoration: underline; padding: 0.25rem;
}
.gf-review-edit-btn:hover { color: #14b8a6; }
.gf-review-list { list-style: none; padding: 0; margin: 0; }
.gf-review-item {
  display: flex; justify-content: space-between;
  padding: 0.875rem 1.5rem; border-bottom: 1px solid #e2e8f0;
}
.gf-review-item:last-child { border-bottom: none; }
.gf-review-label { font-size: 0.9375rem; color: #4a5568; padding-right: 1rem; flex: 0 1 55%; }
.gf-review-value { font-size: 0.9375rem; color: #1a1a1a; font-weight: 500; text-align: right; word-break: break-word; flex: 1 1 45%; min-width: 0; }

/* --- SETTLEMENT TABLE --- */
.gf-settlement-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gf-settlement-table {
  width: 100%; min-width: 800px; border-collapse: collapse; margin-top: 1rem;
  background: #FFFFFF; border: 1px solid #e2e8f0; border-radius: 0.75rem; overflow: hidden;
}
.gf-settlement-table th, .gf-settlement-table td {
  padding: 0.875rem 1rem; text-align: left; border-bottom: 1px solid #e2e8f0; vertical-align: top;
}
.gf-settlement-table th {
  font-size: 0.875rem; font-weight: 600; color: #4a5568;
  background: #f8f9fa; text-transform: uppercase; letter-spacing: 0.05em;
}
.gf-settlement-table td { font-size: 0.9375rem; color: #2d3748; }
.gf-settlement-table td:nth-child(n+4) { text-align: right; font-family: monospace, monospace; }
.gf-settlement-table tbody tr:last-child td { border-bottom: none; }
.gf-settlement-table tfoot td {
  font-size: 1.125rem; font-weight: 700; color: #1a1a1a;
  background: #f8f9fa; border-top: 2px solid #cbd5e0; text-align: right;
  font-family: monospace, monospace;
}
.gf-settlement-table tfoot tr:first-child td { padding-top: 1rem; }
.gf-settlement-table tfoot tr:last-child td { padding-bottom: 1rem; border-bottom: none; }
.gf-settlement-table tfoot .gf-total-label {
  font-size: 1.25rem; color: #30348C; text-align: left;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
.gf-settlement-table tfoot .gf-total-value { font-size: 1.5rem; color: #30348C; }
.gf-settlement-table .gf-percentage { font-size: 0.9rem; font-weight: 600; color: #4a5568; }

/* --- FOOTER --- */
.gf-footer { text-align: center; margin-top: 2rem; padding-top: 1.5rem; }
.gf-footer-text { font-size: 0.8125rem; color: #a0aec0; margin-bottom: 0.5rem; }
.gf-footer-brand { font-size: 0.875rem; color: #a0aec0; }
.gf-footer-brand-name { font-weight: 600; color: #718096; }

/* --- DATE THREE-PART SELECTOR --- */
.gf-date-parts { display: flex; gap: 0.75rem; }
.gf-date-select {
  flex: 1; appearance: none; -webkit-appearance: none;
  padding: 0.875rem 2rem 0.875rem 1rem; font-size: 1rem; color: #1a1a1a;
  background: #FFFFFF url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%23718096' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
  border: 2px solid #cbd5e0; border-radius: 0.75rem; outline: none;
  cursor: pointer; transition: all 0.2s ease; font-family: inherit;
}
.gf-date-select:hover { border-color: #a0aec0; }
.gf-date-select:focus { border-color: #30348C; box-shadow: 0 0 0 3px rgba(48,52,140,0.1); }
.gf-date-select.gf-field-error { border-color: #E94924 !important; }

/* --- VALID INPUT STATE (email / phone feedback) --- */
.gf-input--valid { border-color: #059669 !important; }
.gf-input--valid:focus { box-shadow: 0 0 0 3px rgba(5,150,105,0.1) !important; }

/* --- ADDRESS COMPOSITE FIELD --- */
.gf-address-fields { display: flex; flex-direction: column; gap: 0.75rem; }
.gf-address-row { display: flex; gap: 0.75rem; }
.gf-address-row .gf-input { flex: 1; }

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .gf-field-group { flex-direction: column; gap: 1.75rem; }
  .gf-field-group > .gf-field-wrapper { margin-bottom: 0; }
  .gf-settlement-table-wrapper { width: 100%; }
  .gf-container { padding: 1rem 0.75rem; }
  .gf-header-card { padding: 2rem 1.5rem; }
  .gf-title { font-size: 2rem; }
  .gf-subtitle { font-size: 1rem; }
  .gf-form-card { padding: 2rem 1.5rem; }
  .gf-section-title { font-size: 1.5rem; }
  .gf-section-content { padding-left: 0; }
  .gf-navigation { flex-direction: column; }
  .gf-btn-secondary { order: 2; }
  .gf-btn-primary { order: 1; }
  .gf-success-card { padding: 3rem 2rem; }
  .gf-repeater-wrapper { padding: 1rem; }
  .gf-repeater-instance { padding: 1rem; }
  .gf-date-parts { flex-direction: column; }
  .gf-address-row { flex-direction: column; }
}
