/* ==========================================================
   global.css – Boligbanken skjemaer
   Felles CSS for alle skjemaer under /assets/global.css
   Skjemaspesifikke regler legges i <style>-tag i index.html
   ========================================================== */

/* ==========================================================
   DESIGN TOKENS
   ========================================================== */
:root {
  --bg: #fafafa;
  --card: #fff;
  --text: #222;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #5b7cff;
  --accent-strong: #3b5bff;
  --danger: #b00020;
  --danger-bg: #fef2f2;
  --signer-bg: #fcfcfd;
  --radius: 14px;
  --shadow: 0 6px 18px rgba(0, 0, 0, .06);
}

/* ==========================================================
   RESET
   ========================================================== */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.45;
}

/* ==========================================================
   SKJEMA-WRAPPER
   ========================================================== */
.skjema-form {
  max-width: 860px;
  margin: 32px auto 80px;
  padding: 0 16px;
  line-height: 1.45;
}

/* ==========================================================
   CARDS
   ========================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  margin: 24px 0;
  box-shadow: var(--shadow);
  overflow: visible;
}

.card h1 {
  margin: 0 0 12px;
  font-size: 1.6rem;
  font-weight: 700;
}

.card h2 {
  margin: 0 0 18px;
  font-size: 1.25rem;
  font-weight: 650;
}

/* ==========================================================
   TEKST-HJELPERE
   ========================================================== */
.help     { color: var(--muted); font-size: .92rem; }
.note     { color: var(--muted); font-size: .95rem; margin-top: 8px; }
.status   { display: block; margin-top: 6px; font-size: .92rem; color: var(--muted); }
.field-hint { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.label-note { color: var(--muted); font-weight: normal; font-size: .9rem; }

/* ==========================================================
   LAYOUT HJELPERE
   ========================================================== */
.row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.row.compact { margin-bottom: 8px; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

@media (max-width: 760px) {
  .two-col { grid-template-columns: 1fr; }
}

.inline {
  display: flex;
  gap: 12px;
  align-items: center;
}

.inline input  { flex: 1 1 240px; }
.inline button { white-space: nowrap; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.subsection-title {
  font-weight: 650;
  color: var(--text);
}

/* ==========================================================
   LABELS
   ========================================================== */
label {
  font-weight: 600;
  font-size: .98rem;
}

/* ==========================================================
   INPUTS
   ========================================================== */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
  appearance: none;
  width: 100%;
  min-height: 48px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 1rem;
  transition: border .15s, box-shadow .15s;
  margin-bottom: 6px;
}

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

input[readonly],
textarea[readonly] {
  background: #f5f7fb;
  color: #374151;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 124, 255, .15);
}

input:invalid,
select:invalid,
textarea:invalid {
  box-shadow: none !important;
  outline: none !important;
}

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

input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
  text-align: left;
}

.readonly-multiline {
  width: 100%;
  min-height: 44px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f5f7fb;
  color: #374151;
  font-size: 1rem;
  line-height: 1.4;
  overflow: hidden;
  resize: none;
  box-sizing: border-box;
}

/* ==========================================================
   RADIO / CHECKBOX GRUPPER
   ========================================================== */
.radio-group,
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.radio-row label { font-weight: 500; }
.radio-row input { margin-right: 6px; }

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: .9rem;
  color: var(--text);
  white-space: nowrap;
}

.check-inline input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
}

.form-check-row {
  display: flex !important;
  align-items: center !important;
  gap: 12px;
  padding: 3px 0;
}

.form-check-row input[type="radio"] {
  width: 18px !important;
  height: 18px !important;
  margin: 0 !important;
  flex-shrink: 0;
  position: relative !important;
  bottom: -2.5px !important;
}

.form-check-row label {
  display: inline-block !important;
  line-height: 1.2 !important;
  font-weight: 600 !important;
  font-size: .98rem;
  cursor: pointer;
}

/* ==========================================================
   KNAPPER
   ========================================================== */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .04s;
}

button:hover    { background: var(--accent-strong); }
button:active   { transform: translateY(1px); }
button:disabled { opacity: .6; cursor: not-allowed; }
button:focus    { outline: none; box-shadow: none; }

.btn-outline {
  background: #fff;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: rgba(91, 124, 255, .08); }

.btn-inline {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  padding: 0;
  margin: 0;
  font-size: .95rem;
  cursor: pointer;
}
.btn-inline:hover { text-decoration: underline; }

.btn-mini {
  appearance: none;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  font-size: .85rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  line-height: 1;
  display: inline-block;
  transition: background .15s, color .15s, border-color .15s;
}

.btn-mini:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-mini:active { transform: translateY(1px); }

/* ==========================================================
   FEIL & VALIDERING
   ========================================================== */
.section-error {
  color: var(--danger);
  font-size: .95rem;
  margin-top: 2px;
  display: none;
}
.section-error.show { display: block; }

.error-text {
  color: var(--danger);
  font-size: .9rem;
  margin-top: 4px;
  display: none;
}

.field-error {
  display: none;
  font-size: .85rem;
  color: var(--danger);
  margin-top: 2px;
}

.error-text:not(:empty),
.field-error:not(:empty) {
  display: block;
}

input.input-error,
input.input-error:invalid,
select.input-error,
select.input-error:invalid,
textarea.input-error,
textarea.input-error:invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(176, 0, 32, .12) !important;
}

/* ==========================================================
   INFO-IKON & BOBLE
   ========================================================== */
.label-with-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.info-icon {
  all: unset;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  line-height: 1;
  text-align: center;
  flex-shrink: 0;
}

.info-bubble {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  max-width: 360px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
  font-size: .9rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity .12s ease, transform .12s ease;
  z-index: 100;
}

.info-bubble p { margin: 4px 0; }

.info-icon:hover + .info-bubble,
.info-icon:focus + .info-bubble {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ==========================================================
   ADRESSE-AUTOCOMPLETE (Kartverket)
   ========================================================== */
.addr-row { position: relative; }

.addr-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.addr-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.addr-autocomplete { position: relative; }

.addr-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow: auto;
  z-index: 99999;
}

.addr-suggest-item {
  padding: 10px 12px;
  cursor: pointer;
  font-size: .95rem;
}

.addr-suggest-item:hover,
.addr-suggest-item.active {
  background: rgba(91, 124, 255, .08);
}

.addr-row.is-open .addr-help { display: none; }

.addr-override-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.addr-override-wrap .help {
  text-align: center;
  font-size: .85rem;
}

/* ==========================================================
   CONDITIONAL BLOKKER
   ========================================================== */
.conditional-block {
  margin-top: 16px;
  padding: 16px;
  border-radius: 10px;
  background: #f5f7fb;
  border: 1px solid var(--border);
}

.cond-box {
  margin-top: 16px;
  padding: 18px 20px;
  border-radius: 12px;
  background: #f5f7fb;
  border: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .04);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cond-box h4 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 600;
}

.cond-box .row { margin-bottom: 8px; }

.cond-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 760px) {
  .cond-row-2 { grid-template-columns: 1fr; }
}

.field-full { width: 100%; }

.field-half-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.field-half {
  display: flex;
  flex-direction: column;
}

@media (max-width: 760px) {
  .field-half-wrapper { grid-template-columns: 1fr; }
}

/* ==========================================================
   RRH & PEP KORT
   ========================================================== */
.rrh-card,
.pep-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-top: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

.rrh-card .row,
.pep-card .row { margin-bottom: 16px; }

.rrh-head,
.pep-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.rrh-head strong,
.pep-head strong {
  font-size: .95rem;
  font-weight: 600;
}

/* ==========================================================
   PERCENT INPUT
   ========================================================== */
.percent-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.percent-wrapper input {
  width: 80px;
  text-align: right;
}

/* ==========================================================
   BRREG-RADER
   ========================================================== */
.brreg-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  background: #fff;
  overflow: hidden;
}

.brreg-row + .brreg-row { margin-top: 12px; }

.brreg-content {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
  gap: 16px;
}

.member-name {
  flex: 1 1 auto;
  min-width: 0;
  background: #f5f7fb;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  color: #374151;
  font-size: 1rem;
  margin: 0;
}

.contact-inline { margin-top: 16px; }

@media (max-width: 560px) {
  .brreg-content { flex-wrap: wrap; }
  .check-inline  { margin-left: 0; }
}

/* ==========================================================
   MANUELLE KORT
   ========================================================== */
.manual-card {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 16px;
  background: #fcfcff;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.manual-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.manual-check {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 8px;
}

.manual-check label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: .9rem;
  color: var(--text);
}

.manual-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.manual-card .row {
  margin-left: 0 !important;
  margin-right: 0 !important;
}
.manual-card .row > * {
  padding-left: 0 !important;
  padding-right: 0 !important;
}
.manual-card input[type="text"],
.manual-card input[type="email"],
.manual-card input[type="tel"],
.manual-card textarea {
  padding: 12px 14px !important;
  box-sizing: border-box;
}

/* ==========================================================
   SIGNATAR-KORT
   ========================================================== */
.signer-card {
  background: var(--signer-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
}

.signer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.signer-head strong {
  font-size: .95rem;
  font-weight: 600;
}

.signer-card .row { margin-bottom: 16px; }

#signerList {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

@media (max-width: 760px) {
  .signer-card { padding: 18px; }
}

/* ==========================================================
   SUCCESS BANNER
   ========================================================== */
.success-banner {
  background: #e6f7ee;
  border: 1px solid #b7ebc6;
  color: #1e7f4f;
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-weight: 500;
  font-size: .95rem;
}

/* ==========================================================
   KONTO-BLOKKER
   ========================================================== */
.konto-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.konto-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.konto-check input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.konto-navn-wrap { margin-left: 26px; }

.konto-navn-label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 4px;
  display: block;
}

.konto-close-question {
  margin-left: 26px;
  margin-top: 10px;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
}

.konto-close-details {
  margin-left: 26px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bank-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 350px;
}

.bank-field label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--muted);
}

.konto-navn-input,
.bank-field input {
  width: 350px !important;
  max-width: 350px !important;
  min-height: 34px !important;
  padding: 8px 10px !important;
  border-radius: 6px !important;
  font-size: .9rem !important;
  border: 1px solid var(--border);
  background: #fff;
  box-sizing: border-box;
}

/* ==========================================================
   POPUP
   ========================================================== */
.popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.popup-box {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 520px;
  width: 90%;
  box-shadow: var(--shadow);
  text-align: center;
}

.popup-box h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.2rem;
}

.popup-box p {
  margin-bottom: 10px;
  font-size: .95rem;
  color: #374151;
}

.popup-box button { margin-top: 12px; }

/* ==========================================================
   UTILS
   ========================================================== */
.hidden { display: none !important; }