/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  line-height: 1.5;
  color: #1a1a1a;
  background: #f5f5f5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0.75rem;
}

/* ── Header ── */
header {
  text-align: center;
  padding: 1rem 0 0.6rem;
}

header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1a365d;
}

.subtitle {
  font-size: 0.85rem;
  color: #555;
  margin-top: 0.2rem;
}

/* ── Sections ── */
.section {
  background: #fff;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.65rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.section h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1a365d;
  margin-bottom: 0.35rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid #e2e8f0;
}

.section-desc {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.55rem;
}

/* ── Fields ── */
.field {
  margin-bottom: 0.55rem;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.req { color: #c53030; }

input[type="text"],
input[type="email"],
input[type="tel"],
textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

input:focus, textarea:focus {
  outline: none;
  border-color: #3182ce;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.15);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.field-row {
  display: flex;
  gap: 0.75rem;
}

.field-row .field { flex: 1; }
.field-row .field-small { flex: 0 0 80px; }

/* ── Lookup Row ── */
.lookup-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.lookup-row .field {
  flex: 1;
  margin-bottom: 0;
}

.lookup-row .btn {
  height: 2.35rem;
  padding: 0 1.25rem;
}

/* Input with prefixed label (e.g. "P-") */
.input-prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-prefix:focus-within {
  border-color: #3182ce;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.15);
}

.input-prefix-label {
  padding: 0 0.7rem;
  background: #edf2f7;
  color: #2d3748;
  font-weight: 600;
  border-right: 1px solid #cbd5e0;
  display: flex;
  align-items: center;
  font-size: 0.95rem;
  user-select: none;
}

.input-prefix input {
  border: none;
  border-radius: 0;
  flex: 1;
  min-width: 0;
  background: transparent;
}

.input-prefix input:focus {
  outline: none;
  box-shadow: none;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  font-family: inherit;
}

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

.btn-primary {
  background: #2b6cb0;
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: #2c5282; }

.btn-secondary {
  background: #e2e8f0;
  color: #2d3748;
}

.btn-secondary:hover:not(:disabled) { background: #cbd5e0; }

.btn-small {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  background: #e2e8f0;
  color: #2d3748;
}

.btn-small:hover { background: #cbd5e0; }

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  padding: 1rem 0;
}

/* ── Michigan county map ── */
.map-wrapper {
  position: relative;
  margin-bottom: 1rem;
}

/* Desktop: tuck the hint into the empty area west of the Lower Peninsula
   (below the UP, over the Lake Michigan whitespace inside the SVG viewBox).
   pointer-events:none so mouse-over still reaches the county paths beneath. */
.map-hover {
  position: absolute;
  left: 3%;
  top: 34%;
  width: 26%;
  padding: 0.6rem 0.5rem;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.25;
  color: #c53030;
  background: rgba(255, 245, 245, 0.75);
  border: 1px solid #feb2b2;
  border-radius: 6px;
  z-index: 2;
  pointer-events: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.map-hover.active {
  color: #1a365d;
  background: rgba(235, 244, 255, 0.88);
  border-color: #90cdf4;
  font-weight: 600;
}

/* Small screens: stack hint above the map instead of overlaying. */
@media (max-width: 640px) {
  .map-hover {
    position: static;
    width: auto;
    padding: 0.5rem;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
  }
}

.michigan-map {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  line-height: 0;
}

.michigan-map svg {
  width: 100%;
  height: auto;
  display: block;
}

.county-path {
  fill: #edf2f7;
  stroke: #718096;
  stroke-width: 0.75;
  cursor: pointer;
  transition: fill 0.1s;
}

.county-path:hover,
.county-path:focus {
  fill: #cbd5e0;
  outline: none;
}

.county-path.selected {
  fill: #48bb78;
  stroke: #22543d;
}

.county-path.selected:hover,
.county-path.selected:focus {
  fill: #38a169;
}

.map-fallback {
  font-size: 0.85rem;
  color: #666;
  font-style: italic;
  text-align: center;
  padding: 1rem;
}

/* ── Found callout & verify notice ── */
.found-callout {
  background: #fff5f5;
  border: 2px solid #c53030;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  margin-bottom: 0.65rem;
  color: #c53030;
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.25;
}

.verify-notice {
  color: #c53030;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* ── Practice Area Grid (column-major: reads top-to-bottom, then right) ── */
.practice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(4, auto);
  grid-auto-flow: column;
  gap: 0.25rem 1rem;
}

.practice-grid .inline-other {
  grid-column: 1 / -1;
  grid-row: 4;
}

.checkbox-grid .inline-other {
  grid-column: 1 / -1;
}

@media (max-width: 479px) {
  .practice-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-auto-flow: row;
  }
  .practice-grid .inline-other {
    grid-column: auto;
    grid-row: auto;
  }
}

/* ── Checkbox & Radio Grids ── */
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.2rem;
}

.checkbox-label, .radio-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
}

.checkbox-label:hover, .radio-label:hover { background: #f7fafc; }

/* Inline "Other: ___" layout — checkbox + label + fill-in on one line */
.inline-other {
  gap: 0.4rem;
}

.inline-text-input {
  flex: 1;
  min-width: 100px;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  border: 1px solid #cbd5e0;
  border-radius: 4px;
}

.inline-text-input:disabled {
  background: #f1f5f9;
  color: #a0aec0;
  cursor: not-allowed;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.radio-group-stacked {
  flex-direction: column;
}

.radio-group-row {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

@media (min-width: 480px) {
  .field-full { grid-column: 1 / -1; }
}

/* ── Speaking row (horizontal Yes / No / Other-with-input) ── */
.speaking-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
}

.speaking-row .radio-label {
  padding: 0.35rem 0.5rem;
}

.speaking-row .speaking-other {
  flex: 1;
  min-width: 240px;
  gap: 0.5rem;
}

.speaking-other-input {
  flex: 1;
  min-width: 120px;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

.speaking-other-input:disabled {
  background: #f1f5f9;
  color: #a0aec0;
  cursor: not-allowed;
}

/* ── County Checklist ── */
.county-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

.county-filter {
  flex: 1;
  min-width: 180px;
  padding: 0.35rem 0.6rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 0.85rem;
}

.county-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  min-height: 0;
}

.county-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  background: #ebf4ff;
  color: #2b6cb0;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.county-chip .remove {
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  color: #4a5568;
}

.county-chip .remove:hover { color: #c53030; }

.counties-checklist {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.5rem;
}

.county-group-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.5rem;
  margin-bottom: 0.15rem;
  padding-left: 0.25rem;
}

.county-group-label:first-child { margin-top: 0; }

.counties-checklist .checkbox-label {
  font-size: 0.8rem;
  padding: 0.2rem 0.35rem;
}

/* ── Status Messages ── */
.status-msg {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.status-msg.info { background: #ebf8ff; color: #2b6cb0; }
.status-msg.success { background: #f0fff4; color: #276749; }
.status-msg.error { background: #fff5f5; color: #c53030; }
.status-msg.loading { background: #fefcbf; color: #744210; }

.error-list {
  background: #fff5f5;
  border: 1px solid #feb2b2;
  border-radius: 6px;
  padding: 0.75rem;
  margin-top: 0.5rem;
}

.error-list ul {
  list-style: none;
  padding: 0;
}

.error-list li {
  font-size: 0.85rem;
  color: #c53030;
  padding: 0.15rem 0;
}

/* ── Review Summary ── */
#review-summary {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

.review-section:last-child { margin-bottom: 0; }

.review-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1a365d;
  margin-bottom: 0.35rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #e2e8f0;
}

.review-section .review-value {
  font-size: 0.85rem;
  color: #333;
  padding: 0.15rem 0;
}

.review-section .review-value.empty {
  color: #a0aec0;
  font-style: italic;
}

.note {
  font-size: 0.8rem;
  color: #718096;
  text-align: center;
  margin: 0.75rem 0;
}

/* ── Confirmation ── */
.confirmation {
  text-align: center;
  padding: 3rem 1rem;
}

.confirmation h2 {
  color: #276749;
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

.confirmation p {
  color: #555;
  margin-bottom: 0.5rem;
}

/* ── Responsive ── */
@media (min-width: 480px) {
  .field-grid {
    grid-template-columns: 1fr 1fr;
  }

  .checkbox-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 640px) {
  .container { padding: 1rem; }

  header h1 { font-size: 1.45rem; }

  .section { padding: 1rem 1.25rem; }

  .counties-checklist {
    columns: 2;
    column-gap: 1rem;
    max-height: 400px;
  }
}
