/* ═══════════════════════════════════════════════════════
   Tokens
═══════════════════════════════════════════════════════ */
.idsf-wrap {
  --navy-90: oklch(14% 0.04 240);
  --navy-80: oklch(22% 0.06 240);
  --navy-60: oklch(36% 0.1  240);
  --navy-40: oklch(52% 0.12 240);
  --navy-20: oklch(72% 0.08 240);
  --navy-05: oklch(96% 0.015 240);

  --surface:  oklch(97.5% 0.004 240);
  --raised:   oklch(100%  0     0);
  --border:   oklch(88%   0.01  240);
  --muted:    oklch(52%   0.02  240);
  --body:     oklch(16%   0.02  240);

  --accent:        var(--navy-60);
  --accent-hover:  var(--navy-80);
  --accent-ring:   oklch(72% 0.1 240 / 35%);

  --error:    oklch(48% 0.22 25);
  --success:  oklch(46% 0.18 145);
  --warn-bg:  oklch(97% 0.01 80);
  --info-bg:  oklch(96% 0.015 240);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 20px;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--body);
  background: var(--surface);
}

@media (prefers-color-scheme: dark) {
  .idsf-wrap {
    --surface: oklch(12% 0.02 240);
    --raised:  oklch(17% 0.025 240);
    --border:  oklch(28% 0.03 240);
    --muted:   oklch(62% 0.025 240);
    --body:    oklch(93% 0.01 240);
    --navy-05: oklch(20% 0.03 240);
    --info-bg: oklch(19% 0.025 240);
    --warn-bg: oklch(18% 0.02 80);
    --accent:  oklch(68% 0.12 240);
    --accent-hover: oklch(76% 0.1 240);
  }
}

/* ═══════════════════════════════════════════════════════
   Agency Header
═══════════════════════════════════════════════════════ */
.idsf-agency-header {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--navy-90);
  color: #fff;
  padding: 24px 40px;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  margin-bottom: 0;
}

.idsf-agency-badge {
  font-size: 2rem;
  flex-shrink: 0;
}

.idsf-agency-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}

.idsf-agency-sub {
  margin: 0;
  font-size: 0.85rem;
  color: oklch(80% 0.05 240);
}

/* ═══════════════════════════════════════════════════════
   Privacy Banner
═══════════════════════════════════════════════════════ */
.idsf-privacy-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--info-bg);
  border: 1px solid var(--border);
  border-top: none;
  padding: 14px 40px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
}

.idsf-privacy-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }

/* ═══════════════════════════════════════════════════════
   Form Shell
═══════════════════════════════════════════════════════ */
.idsf-form,
.idsf-success {
  background: var(--raised);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════
   Sections
═══════════════════════════════════════════════════════ */
.idsf-section {
  padding: 32px 40px;
  border-bottom: 1px solid var(--border);
}

.idsf-section:last-of-type { border-bottom: none; }

.idsf-section--privacy { background: var(--navy-05); }

.idsf-section-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.idsf-section-num {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.idsf-section-head h2 {
  margin: 0 0 2px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--body);
}

.idsf-section-head p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ═══════════════════════════════════════════════════════
   Country Grid
═══════════════════════════════════════════════════════ */
.idsf-country-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.idsf-country-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 120ms ease;
  position: relative;
  user-select: none;
}

.idsf-country-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.idsf-country-card:hover {
  border-color: var(--accent);
  background: var(--navy-05);
  transform: translateY(-2px);
}

.idsf-country-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--navy-05);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.idsf-country-card:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.idsf-country-flag { font-size: 2rem; line-height: 1; }
.idsf-country-name { font-size: 0.78rem; font-weight: 600; text-align: center; color: var(--body); }

/* ═══════════════════════════════════════════════════════
   Field Grid
═══════════════════════════════════════════════════════ */
.idsf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}

.idsf-field--full { grid-column: 1 / -1; }

.idsf-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

label, .idsf-pair-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--body);
}

.idsf-req { color: var(--error); margin-left: 2px; }
.idsf-opt { font-weight: 400; color: var(--muted); font-size: 0.82rem; }

input:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
select {
  height: 42px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--body);
  font-size: 0.95rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

input:hover:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
select:hover { border-color: var(--navy-40); }

input:focus:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

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

.idsf-field-error {
  font-size: 0.8rem;
  color: var(--error);
  min-height: 1.1em;
}

.idsf-field-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ═══════════════════════════════════════════════════════
   Inline pair (height)
═══════════════════════════════════════════════════════ */
.idsf-pair { display: flex; gap: 10px; }
.idsf-pair > div { flex: 1; }

/* ═══════════════════════════════════════════════════════
   Upload
═══════════════════════════════════════════════════════ */
.idsf-upload-row { margin-top: 20px; }

.idsf-upload-box {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.idsf-upload-box:hover {
  border-color: var(--accent);
  background: var(--navy-05);
}

.idsf-upload-box input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

.idsf-upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.idsf-upload-icon { font-size: 2rem; }
.idsf-upload-placeholder small { font-size: 0.78rem; }

.idsf-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  min-height: 20px;
}

.idsf-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border);
}

.idsf-preview span { font-size: 0.82rem; color: var(--muted); }

/* ═══════════════════════════════════════════════════════
   Signature
═══════════════════════════════════════════════════════ */
.idsf-sig-wrap {
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--raised);
  overflow: hidden;
  margin-bottom: 8px;
}

#idsf-sig-canvas {
  display: block;
  width: 100%;
  height: 160px;
  touch-action: none;
  cursor: crosshair;
}

.idsf-sig-clear {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--muted);
  transition: background 120ms ease;
}

.idsf-sig-clear:hover { background: var(--border); color: var(--body); }
.idsf-sig-clear:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ═══════════════════════════════════════════════════════
   Privacy box
═══════════════════════════════════════════════════════ */
.idsf-privacy-box {
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 24px;
  margin-bottom: 20px;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.7;
}

.idsf-privacy-box h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--body);
}

.idsf-privacy-box p { margin: 0 0 10px; }
.idsf-privacy-box p:last-child { margin: 0; }
.idsf-privacy-box ul { margin: 8px 0; padding-left: 20px; }
.idsf-privacy-box li { margin-bottom: 4px; }

.idsf-privacy-laws { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }

.idsf-law-badge {
  background: var(--navy-05);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ═══════════════════════════════════════════════════════
   Consent checkboxes
═══════════════════════════════════════════════════════ */
.idsf-consent-row { margin-bottom: 16px; }

.idsf-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--body);
  line-height: 1.6;
}

.idsf-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════
   Submit
═══════════════════════════════════════════════════════ */
.idsf-submit-wrap {
  padding: 32px 40px;
  background: var(--navy-05);
  border-top: 1px solid var(--border);
}

.idsf-submit-error {
  color: var(--error);
  font-size: 0.875rem;
  margin-bottom: 12px;
  min-height: 1.2em;
  padding: 10px 14px;
  background: oklch(97.5% 0.01 25);
  border: 1px solid oklch(85% 0.05 25);
  border-radius: var(--r-sm);
  display: none;
}

.idsf-submit-error:not(:empty) { display: block; }

.idsf-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  background: var(--navy-80);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 140ms ease, transform 100ms ease;
}

.idsf-submit-btn:hover:not(:disabled) {
  background: var(--navy-90);
  transform: translateY(-1px);
}

.idsf-submit-btn:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 3px;
}

.idsf-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.idsf-btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid oklch(100% 0 0 / 30%);
  border-top-color: #fff;
  border-radius: 50%;
  animation: idsf-spin 0.65s linear infinite;
}

@keyframes idsf-spin { to { transform: rotate(360deg); } }

.idsf-submit-note {
  margin: 12px 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ═══════════════════════════════════════════════════════
   Success
═══════════════════════════════════════════════════════ */
.idsf-success {
  text-align: center;
  padding: 60px 40px;
  border-radius: var(--r-xl);
}

.idsf-success-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 2rem;
  display: grid;
  place-items: center;
  margin: 0 auto 24px;
}

.idsf-success h2 { margin: 0 0 10px; font-size: 1.5rem; }
.idsf-success p  { color: var(--muted); margin: 0 0 8px; }

.idsf-success-detail {
  margin-top: 24px;
  padding: 20px;
  background: var(--navy-05);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  color: var(--muted);
  text-align: left;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.idsf-success-detail p { margin: 0 0 8px; }
.idsf-success-detail p:last-child { margin: 0; }

/* ═══════════════════════════════════════════════════════
   Accessibility
═══════════════════════════════════════════════════════ */
.idsf-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ═══════════════════════════════════════════════════════
   Responsive
═══════════════════════════════════════════════════════ */
@media (max-width: 680px) {
  .idsf-agency-header { padding: 20px 20px; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .idsf-privacy-banner { padding: 12px 20px; }
  .idsf-section { padding: 24px 20px; }
  .idsf-submit-wrap { padding: 24px 20px; }
  .idsf-success { padding: 40px 20px; }
  .idsf-grid { grid-template-columns: 1fr; }
  .idsf-field--full { grid-column: unset; }
  .idsf-country-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 400px) {
  .idsf-country-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
}