/* ===================================================================
 * oasis/forms.css  —  Form controls, chips, buttons, record-paper
 *
 * Loaded by layouts/main.html AFTER theme.css. Do NOT introduce new
 * colors here — pull from the design tokens in theme.css.
 *
 * Reference: oasis-docs/01_customer-supplied/OASIS/oasis_signup_v05.html
 *            § FORM / TOGGLE GROUP / SELECTABLE CHIPS / FOOTER
 *            § oasis_form_view_v07.html § record paper / form-page
 * =================================================================== */

/* ---------------------------------------------------------------
 * Page header — fixed top bar with OASIS logo + step indicator
 * ------------------------------------------------------------- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--hdr-bg);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}
.header-main {
  display: flex; align-items: center; justify-content: center;
  padding: 0 24px; height: 56px;
}
.logo-area { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.logo-mark {
  width: 30px; height: 30px; background: var(--hdr-accent); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem; color: var(--hdr-bg);
}
.logo-text { display: flex; flex-direction: column; line-height: 1; }
.logo-text .main { color: #FFF; font-size: 1.15rem; font-weight: 700; letter-spacing: 0.06em; }
.logo-text .sub  { color: var(--hdr-text); font-size: 0.72rem; opacity: 0.7; margin-top: 2px; }

/* ---------------------------------------------------------------
 * Step indicator — fixed directly under the header
 * ------------------------------------------------------------- */
.step-bar {
  position: fixed; top: 56px; left: 0; right: 0; z-index: 99;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 16px; flex-wrap: wrap;
}
.step-item { display: flex; align-items: center; gap: 7px; font-size: 0.76rem; color: var(--text-muted); }
.step-item .num {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--border-light); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
}
.step-item.active { color: var(--accent); font-weight: 600; }
.step-item.active .num { background: var(--accent); color: #FFF; }
.step-arrow { color: var(--border); font-size: 0.8rem; }

/* ---------------------------------------------------------------
 * Page-level typography
 * ------------------------------------------------------------- */
.page-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 4px; }
.page-desc  { font-size: 0.82rem; color: var(--text-sec); margin-bottom: 24px; line-height: 1.6; }

/* ---------------------------------------------------------------
 * Section card — numbered block used throughout the screens
 * ------------------------------------------------------------- */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  overflow: visible;
}
.section-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border-light);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.section-head .sec-num {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--accent); color: #FFF;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; flex-shrink: 0;
}
.section-head .sec-num.gray { background: var(--text-muted); }
.section-head .sec-num svg { width: 14px; height: 14px; stroke: #FFF; }
.section-head h2 { font-size: 0.98rem; font-weight: 700; }
.section-head .sec-hint { font-size: 0.72rem; color: var(--text-muted); margin-left: auto; }
.section-body { padding: 18px; }

/* ---------------------------------------------------------------
 * Form rows + groups
 * ------------------------------------------------------------- */
.field-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.field-row:last-child { margin-bottom: 0; }
.form-group { flex: 1; min-width: 180px; }
.form-group.full { flex-basis: 100%; }

.form-group label {
  display: block; font-size: 0.78rem; font-weight: 600;
  color: var(--text-sec); margin-bottom: 6px;
}
.form-group label .req {
  color: var(--danger); font-size: 0.66rem; margin-left: 5px;
  background: #FDECEE; padding: 1px 6px; border-radius: 4px; font-weight: 700;
}
.form-group label .opt {
  color: var(--text-muted); font-size: 0.66rem; margin-left: 5px;
  background: var(--surface-alt); padding: 1px 6px; border-radius: 4px; font-weight: 600;
}
/* Synonym for .req — must render identically (red pill, see mockup
   oasis_signup_v05.html § .form-group label .req). */
.form-group label .required {
  color: var(--danger); font-size: 0.66rem; margin-left: 5px;
  background: #FDECEE; padding: 1px 6px; border-radius: 4px; font-weight: 700;
}

.form-input,
.form-select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 0.86rem;
  color: var(--text); background: var(--field-bg);
  transition: all var(--transition); outline: none;
}
.form-input::placeholder { color: var(--text-muted); font-size: 0.8rem; }
.form-input:focus,
.form-select:focus {
  border-color: var(--hdr-bg); background: #FFF;
  box-shadow: 0 0 0 3px rgba(1, 173, 110, 0.12);
}
.form-input.error,
.form-select.error {
  border-color: var(--danger); background: #FFF6F7;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.10);
}
.form-input:disabled {
  background: var(--surface-alt); color: var(--text-sec);
  -webkit-text-fill-color: var(--text-sec); opacity: 1; cursor: not-allowed;
}

.field-note { font-size: 0.7rem; color: var(--text-muted); margin-top: 5px; line-height: 1.5; }
.field-err  { font-size: 0.7rem; color: var(--danger);  margin-top: 4px; display: none; }
.field-err.show { display: block; }

/* ---------------------------------------------------------------
 * Postal code + telephone split inputs
 * ------------------------------------------------------------- */
.postal-wrap { display: flex; align-items: center; gap: 6px; }
.postal-wrap .form-input { width: 64px; text-align: center; flex: none; }
.postal-wrap .sep { color: var(--text-muted); }

.tel-wrap { display: flex; align-items: center; gap: 6px; }
.tel-wrap .form-input { flex: 1; text-align: center; min-width: 0; }
.tel-wrap .sep { color: var(--text-muted); }

.pc-search-btn {
  padding: 9px 12px; border: 1.5px solid var(--accent);
  background: #F0F7F3; color: var(--accent);
  border-radius: var(--radius);
  font-family: inherit; font-size: 0.76rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: all var(--transition);
  display: flex; align-items: center; gap: 4px;
  flex: 0 0 auto;            /* don't shrink inside .postal-wrap — English "Search address" clips otherwise */
}
.pc-search-btn:hover { background: #E3F0E9; }
.pc-search-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pc-search-btn svg { width: 13px; height: 13px; }

/* ---------------------------------------------------------------
 * Postal-candidate dropdown (zipcloud lookup result)
 * ------------------------------------------------------------- */
.addr-group { position: relative; }
.pc-candidates {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
  background: #FFF; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  margin-top: 4px; max-height: 220px; overflow-y: auto;
}
.pc-item {
  padding: 10px 12px; font-size: 0.82rem; cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.pc-item:last-child { border-bottom: none; }
.pc-item:hover { background: #F0F7F3; }
.pc-loading,
.pc-empty { padding: 10px 12px; font-size: 0.78rem; color: var(--text-muted); }

/* ---------------------------------------------------------------
 * Toggle group — two buttons acting like radio
 * ------------------------------------------------------------- */
.toggle-group { display: flex; gap: 8px; }
.toggle-btn {
  flex: 1; padding: 10px; border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
  font-family: inherit; font-size: 0.82rem; font-weight: 600;
  color: var(--text-sec); cursor: pointer;
  transition: all var(--transition);
}
.toggle-btn:hover:not(.active) { border-color: var(--accent); }
.toggle-btn.active { background: var(--accent); border-color: var(--accent); color: #FFF; }
.toggle-group.error .toggle-btn { border-color: var(--danger); }

/* ---------------------------------------------------------------
 * Selectable chips — single (radio) and multi (checkboxes)
 * ------------------------------------------------------------- */
.chip-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: flex; align-items: center; gap: 7px; padding: 9px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all var(--transition);
  font-size: 0.8rem; user-select: none;
}
.chip:hover { border-color: var(--accent); }
.chip.checked { background: #E8F5E9; border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip .cbox {
  width: 16px; height: 16px; border: 2px solid var(--border); border-radius: 3px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.chip.radio .cbox { border-radius: 50%; }
.chip.checked .cbox { background: var(--accent); border-color: var(--accent); }
.chip .cbox svg { width: 10px; height: 10px; stroke: #FFF; opacity: 0; }
.chip.checked .cbox svg { opacity: 1; }
.chip.radio.checked .cbox { background: var(--accent); }
.chip.radio.checked .cbox::after {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: #FFF;
}
.chip.radio .cbox svg { display: none; }

/* ---------------------------------------------------------------
 * Buttons
 * ------------------------------------------------------------- */
.btn {
  padding: 12px 24px; border: none; border-radius: var(--radius);
  font-family: inherit; font-size: 0.9rem; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all var(--transition);
}
.btn svg { width: 17px; height: 17px; }

.btn-back    { background: transparent; color: var(--text-sec); border: 1.5px solid var(--border); }
.btn-back:hover { background: var(--surface-alt); }
.btn-submit {
  background: var(--orange); color: #FFF;
  box-shadow: 0 4px 14px rgba(255, 153, 0, 0.32);
}
.btn-submit:hover {
  background: var(--orange-hover);
  box-shadow: 0 6px 20px rgba(255, 153, 0, 0.42);
  transform: translateY(-1px);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ---------------------------------------------------------------
 * Footer — fixed bottom action bar (back + submit)
 * ------------------------------------------------------------- */
.app-footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
  padding: 12px 20px;
}
.footer-inner {
  max-width: 720px; width: 100%; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

/* ---------------------------------------------------------------
 * Toast — top-centered transient notification
 * ------------------------------------------------------------- */
.toast {
  position: fixed; top: 110px; left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: var(--hdr-bg); color: #FFF;
  padding: 11px 22px; border-radius: 8px;
  font-size: 0.82rem; font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none;
  transition: all 0.3s; z-index: 500;
  max-width: 90%; text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* Explicit error variant — red (var(--danger)). Passed by the login
   badCredentials SSR toast so the colour is not coupled to the base rule. */
.toast.error { background: var(--danger); }

/* ---------------------------------------------------------------
 * Confirm dialog — overlay + centered dialog box
 * ------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(28, 31, 26, 0.42);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.dialog {
  background: var(--surface); border-radius: 14px;
  box-shadow: var(--shadow-lg);
  max-width: 460px; width: 100%;
  padding: 30px 30px 24px;
  transform: scale(0.94);
  transition: transform 0.2s;
  max-height: 90vh; overflow-y: auto;
}
.overlay.show .dialog { transform: scale(1); }
.dialog .ok-icon {
  width: 56px; height: 56px; background: #E8F5E9; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.dialog .ok-icon svg { width: 30px; height: 30px; stroke: var(--good); }
.dialog h3 { font-size: 1.1rem; font-weight: 700; text-align: center; margin-bottom: 10px; }
.dialog .lead {
  font-size: 0.84rem; color: var(--text-sec);
  line-height: 1.7; text-align: center; margin-bottom: 18px;
}
.next-steps {
  background: var(--surface-alt);
  border: 1px solid var(--border-light); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 20px;
}
.next-steps h4 { font-size: 0.78rem; font-weight: 700; color: var(--text-sec); margin-bottom: 10px; }
.next-step-item {
  display: flex; gap: 10px; font-size: 0.78rem;
  color: var(--text-sec); line-height: 1.5; margin-bottom: 9px;
}
.next-step-item:last-child { margin-bottom: 0; }
.next-step-item .sn {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: #FFF;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.66rem; font-weight: 700; flex-shrink: 0;
}
.pdf-note {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.74rem; color: var(--info-blue);
  background: #E7F1FB;
  padding: 9px 12px; border-radius: var(--radius); margin-bottom: 18px;
}
.pdf-note svg { width: 16px; height: 16px; flex-shrink: 0; }
.dialog .dialog-btn {
  width: 100%; padding: 12px; border: none; border-radius: var(--radius);
  background: var(--accent); color: #FFF;
  font-family: inherit; font-size: 0.88rem; font-weight: 700;
  cursor: pointer; transition: all 0.12s;
}
.dialog .dialog-btn:hover { background: var(--accent-hover); }

/* ---------------------------------------------------------------
 * Site (factory) card — multi-factory block in signup screen
 * ------------------------------------------------------------- */
.site-card { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: visible; }
.site-card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: #EAF4EF;
  border-bottom: 1px solid var(--border-light);
  border-radius: var(--radius) var(--radius) 0 0;
  flex-wrap: wrap;
}
.site-card-head .site-no { font-weight: 700; font-size: 0.84rem; color: var(--accent); }
.site-card-body { padding: 14px; }

.rep-toggle {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; font-size: 0.74rem;
  color: var(--text-sec); user-select: none; margin-left: 4px;
}
.rep-toggle .radio {
  width: 16px; height: 16px; border: 2px solid var(--border);
  border-radius: 50%; flex-shrink: 0; position: relative;
  transition: all var(--transition);
}
.rep-toggle.selected { color: var(--orange); font-weight: 700; }
.rep-toggle.selected .radio { border-color: var(--orange); }
.rep-toggle.selected .radio::after {
  content: ''; position: absolute; inset: 3px;
  border-radius: 50%; background: var(--orange);
}
.rep-badge {
  font-size: 0.66rem; font-weight: 700;
  color: #B36B00; background: #FFF3DC;
  padding: 2px 8px; border-radius: 4px;
}
.site-remove {
  margin-left: auto; background: none; border: none;
  cursor: pointer; color: var(--text-muted);
  padding: 4px 6px; border-radius: 4px;
  font-size: 0.74rem;
  display: flex; align-items: center; gap: 3px;
  transition: all var(--transition);
}
.site-remove:hover { color: var(--danger); background: #FDECEE; }
.site-remove svg { width: 13px; height: 13px; }

.add-site-btn {
  width: 100%; padding: 12px;
  border: 1.5px dashed var(--accent); border-radius: var(--radius);
  background: #F0F7F3; color: var(--accent);
  font-family: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all var(--transition);
}
.add-site-btn:hover { background: #E3F0E9; }
.add-site-btn svg { width: 16px; height: 16px; }
.add-site-btn.disabled {
  border-color: var(--border); border-style: solid;
  background: var(--surface-alt); color: var(--text-muted);
  cursor: not-allowed;
}
.add-site-btn.disabled:hover { background: var(--surface-alt); }

/* ---------------------------------------------------------------
 * "Same as company" copy toggle (per site)
 * ------------------------------------------------------------- */
.same-company-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 13px; margin-bottom: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border-light); border-radius: var(--radius);
  cursor: pointer; font-size: 0.78rem; font-weight: 600;
  color: var(--text-sec); user-select: none;
  transition: all var(--transition);
}
.same-company-toggle:hover { border-color: var(--accent); }
.same-company-toggle .cbox {
  width: 18px; height: 18px; border: 2px solid var(--border); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.same-company-toggle .cbox svg { width: 11px; height: 11px; stroke: #FFF; opacity: 0; }
.same-company-toggle.checked { background: #E8F5E9; border-color: var(--accent); color: var(--accent); }
.same-company-toggle.checked .cbox { background: var(--accent); border-color: var(--accent); }
.same-company-toggle.checked .cbox svg { opacity: 1; }

/* ---------------------------------------------------------------
 * Agreement box (terms-of-service checkbox)
 * ------------------------------------------------------------- */
.agree-box {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border-light); border-radius: var(--radius);
  cursor: pointer;
}
.agree-box .cbox {
  width: 20px; height: 20px; border: 2px solid var(--border); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
  transition: all var(--transition);
}
.agree-box.checked .cbox { background: var(--accent); border-color: var(--accent); }
.agree-box .cbox svg { width: 13px; height: 13px; stroke: #FFF; opacity: 0; }
.agree-box.checked .cbox svg { opacity: 1; }
.agree-box .agree-text {
  font-size: 0.8rem; color: var(--text-sec);
  line-height: 1.6;
}
.agree-box .agree-text a { color: var(--info-blue); text-decoration: underline; }

/* ---------------------------------------------------------------
 * Responsive — collapse footer + step label on narrow screens
 * ------------------------------------------------------------- */
@media (max-width: 560px) {
  .footer-inner .btn { padding: 11px 16px; font-size: 0.84rem; }
  .step-item span.lbl { display: none; }
}
