/**
 * Renewal checker. Uses the site's own tokens (Nunito headings, Roboto body,
 * #0B63E5 primary) rather than the placeholder palette from the mockup.
 *
 * The dropdown and the detail step are white cards with their own colours,
 * so they read the same on a light section and on a dark one.
 */

.lei-renewal-checker {
  --rc-primary: #0B63E5;
  --rc-primary-dark: #0951bd;
  --rc-cta: #2c64ae;      /* the application form's modern button */
  --rc-cta-dark: #224f8c;
  --rc-text: #111827;
  --rc-muted: #818487;
  --rc-line: #DDDDDD;
  --rc-soft: #F5F9FF;
  --rc-radius: 9px;
  max-width: 720px;
  margin: 0 auto;
  font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: left;
}

.lei-renewal-checker * { box-sizing: border-box; }

/* Both steps sit in the same grid cell, so the widget is as tall as the
   taller of the two from the first paint and never grows when switching.
   The idle step is hidden with opacity, not visibility: themes put
   "transition: all" on inputs and buttons, and an inherited visibility
   would then fade - the form lingering over the detail for 0.3s, and the
   field refusing focus on the way back. The script makes it inert too. */
.lei-rc-stage { display: grid; }
.lei-rc-stage > .lei-rc-form,
.lei-rc-stage > .lei-rc-detail { grid-area: 1 / 1; min-width: 0; transition: none; }

.lei-renewal-checker.is-detail .lei-rc-form,
.lei-renewal-checker:not(.is-detail) .lei-rc-detail { opacity: 0; pointer-events: none; }

.lei-rc-label {
  display: block;
  margin: 0 0 8px;
  color: var(--rc-text);
  font-family: Nunito, sans-serif;
  font-size: 16px;
  font-weight: 600;
}

.lei-rc-strip { position: relative; display: flex; gap: 8px; }

.lei-rc-input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  color: var(--rc-text);
  background: #fff;
  border: 1px solid var(--rc-line);
  border-radius: var(--rc-radius);
  font-family: inherit;
  font-size: 16px;
}
.lei-rc-input::placeholder { color: #9CA3AF; }
.lei-rc-input:focus { outline: 2px solid var(--rc-primary); outline-offset: 1px; border-color: var(--rc-primary); }

.lei-rc-btn {
  height: 52px;
  padding: 0 26px;
  color: #fff;
  background: var(--rc-primary);
  border: 2px solid var(--rc-primary);
  border-radius: var(--rc-radius);
  font-family: Nunito, sans-serif;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.lei-rc-btn:hover { background: #fff; color: var(--rc-primary); }
.lei-rc-btn[disabled] { opacity: .65; cursor: default; }

.lei-rc-hint { margin: 10px 0 0; color: var(--rc-muted); font-size: 13px; }
.lei-rc-hint.is-error { color: #991B1B; }

.lei-rc-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .02em; }

.lei-rc-pill {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.lei-rc-pill:empty { display: none; }
.lei-rc-pill.is-issued { color: #166534; background: #DCFCE7; }
.lei-rc-pill.is-lapsed { color: #991B1B; background: #FEE2E2; }

.lei-rc-cta {
  display: block;
  padding: 15px 20px;
  color: #ffffff!important;
  background: var(--rc-primary);
  border: 2px solid var(--rc-primary);
  border-radius: var(--rc-radius);
  font-family: Nunito, sans-serif;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: background .2s ease, color .2s ease;
}
.lei-rc-cta:hover { background: #fff; color: var(--rc-primary)!important; }

/* ---------------------------------------------------------------
   Several matches: a dropdown over the content below, three rows
   visible (height set by the script), the rest scroll.
   --------------------------------------------------------------- */

.lei-rc-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--rc-line);
  border-radius: var(--rc-radius);
  box-shadow: 0 14px 34px rgba(15, 23, 42, .22);
  text-align: left;
}
.lei-rc-dropdown[hidden] { display: none; }

.lei-rc-choose {
  margin: 0;
  padding: 10px 16px 9px;
  color: var(--rc-muted);
  border-bottom: 1px solid var(--rc-line);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

/* "Not found" and errors use the same dropdown, with the message alone. */
.lei-rc-dropdown.is-message .lei-rc-choose {
  padding: 12px 16px;
  color: #991B1B;
  border-bottom: 0;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
}

.lei-rc-list {
  position: relative; /* rows measure their offsetTop from here */
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.lei-rc-list li { margin: 0; padding: 0; }
.lei-rc-list li + li { border-top: 1px solid var(--rc-line); }

.lei-rc-option {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 11px 16px;
  color: var(--rc-text);
  background: #fff;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.lei-rc-option:hover,
.lei-rc-option:focus-visible { background: var(--rc-soft); }
.lei-rc-option:focus-visible { outline: 2px solid var(--rc-primary); outline-offset: -2px; }

.lei-rc-option.is-selected {
  background: var(--rc-soft);
  border-left-color: var(--rc-primary);
}

.lei-rc-option-name {
  color: var(--rc-text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.lei-rc-option-meta {
  color: var(--rc-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: .02em;
}

/* ---------------------------------------------------------------
   Detail step: replaces the form in the same space. Kept compact
   (one line per field, long names cut with an ellipsis) so it is
   no taller than the form it replaces.
   --------------------------------------------------------------- */

.lei-rc-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-self: start;
  gap: 10px;
  padding: 14px 12px;
  color: var(--rc-text);
  background: #fff;
  border: 1px solid var(--rc-line);
  border-radius: var(--rc-radius);
  text-align: left;
}
.lei-rc-detail:focus { outline: none; }

/* A low basis: the button only drops to its own row on a really narrow
   card. Dropping it on a normal card made the step taller than the form,
   and the shared grid cell then made the form taller too. */
.lei-rc-detail-main { flex: 1 1 150px; min-width: 0; }

.lei-rc-detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
}

.lei-rc-name {
  min-width: 0;
  overflow: hidden;
  color: var(--rc-text);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lei-rc-detail .lei-rc-pill {
  flex: none;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
}

/* When space runs out the label gives way, never the LEI or the date. */
.lei-rc-detail-row {
  display: flex;
  gap: 6px;
  margin: 0;
  color: var(--rc-text);
  font-size: 13px;
  line-height: 1.5;
  white-space: nowrap;
}

.lei-rc-detail-label {
  min-width: 0;
  overflow: hidden;
  color: var(--rc-muted);
  font-size: 11px;
  text-overflow: ellipsis;
}

.lei-rc-lei,
.lei-rc-renewal { flex: none; }

.lei-rc-detail-actions {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

/* Same button as the application form's modern layout ("Continue to
   details"): colour, font, radius and the arrow on the right. */
.lei-rc-detail .lei-rc-cta {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  color: #fff!important;
  background: var(--rc-cta);
  border: 1px solid transparent;
  border-radius: 6px;
  font-family: "Plus Jakarta Sans", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  transition: background .18s, transform .18s;
}
.lei-rc-detail .lei-rc-cta:hover,
.lei-rc-detail .lei-rc-cta:focus {
  color: #fff!important;
  background: var(--rc-cta-dark);
  border-color: transparent;
}
.lei-rc-detail .lei-rc-cta:hover { transform: translateY(-1px); }
.lei-rc-detail .lei-rc-cta span { font-size: 19px; line-height: 1; }

.lei-rc-back {
  padding: 3px 6px;
  color: var(--rc-cta);
  background: none;
  border: 0;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  text-decoration: underline;
  cursor: pointer;
}
.lei-rc-back:hover { color: var(--rc-cta-dark); background: none; }

@media (max-width: 600px) {
  .lei-rc-strip { flex-direction: column; }
  .lei-rc-btn { width: 100%; }
  .lei-rc-detail-actions { flex-basis: 100%; flex-direction: row; align-items: center; }
  .lei-rc-detail .lei-rc-cta { flex: 1; }
}
