/* Bilan AI — Dual Mode Engine (Form + Interview/Wizard)
   Inspired by TurboTax's proven UX pattern:
   Ctrl+1 = Form Mode (power users)
   Ctrl+2 = Interview Mode (guided, one question at a time) */

/* ── Mode toggle bar ── */
#pb-mode-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 18px;
  width: fit-content;
}
.pb-mode-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border: none;
  border-radius: 7px;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.pb-mode-btn.active {
  background: #fff;
  color: #1a56db;
  box-shadow: 0 1px 6px rgba(0,0,0,.1);
}
.pb-mode-btn:hover:not(.active) { color: #1a56db; }
.pb-mode-shortcut {
  font-size: 10px;
  background: #e0e7ff;
  color: #3730a3;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
}
.pb-mode-btn.active .pb-mode-shortcut {
  background: #1a56db;
  color: #fff;
}

/* ── Interview overlay (hides existing form, shows wizard) ── */
#pb-interview-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #f0f4ff;
  z-index: 8000;
  overflow-y: auto;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 16px 60px;
}
#pb-interview-overlay.active { display: flex; }

/* ── Interview card ── */
#pb-interview-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 48px rgba(26,86,219,.12);
  width: 100%;
  max-width: 680px;
  overflow: hidden;
  animation: pbCardIn .35s cubic-bezier(.25,.8,.25,1);
}
@keyframes pbCardIn {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Card header ── */
#pb-iv-header {
  background: linear-gradient(135deg, #1e3a5f, #1a56db);
  padding: 22px 28px 18px;
  color: #fff;
}
#pb-iv-module { font-size: 12px; opacity: .7; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
#pb-iv-title  { font-size: 20px; font-weight: 700; margin: 0; }
#pb-iv-progress-wrap { margin-top: 14px; }
#pb-iv-progress-track {
  height: 4px;
  background: rgba(255,255,255,.25);
  border-radius: 2px;
  overflow: hidden;
}
#pb-iv-progress-fill {
  height: 4px;
  background: #fff;
  border-radius: 2px;
  transition: width .4s ease;
}
#pb-iv-step-label {
  font-size: 11px;
  opacity: .75;
  margin-top: 5px;
  display: flex;
  justify-content: space-between;
}

/* ── Card body ── */
#pb-iv-body { padding: 32px 36px 24px; min-height: 280px; }
#pb-iv-question {
  font-size: 22px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.3;
  margin-bottom: 8px;
}
#pb-iv-subtext {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 22px;
  line-height: 1.5;
}

/* ── Field container — centers one field at a time ── */
#pb-iv-field-wrap {
  margin-bottom: 20px;
}
#pb-iv-field-wrap input,
#pb-iv-field-wrap select,
#pb-iv-field-wrap textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  background: #fff;
  color: #1e293b;
}
#pb-iv-field-wrap input:focus,
#pb-iv-field-wrap select:focus,
#pb-iv-field-wrap textarea:focus {
  border-color: #1a56db;
  box-shadow: 0 0 0 4px rgba(26,86,219,.1);
}
#pb-iv-field-wrap label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
}
/* Line items in interview mode */
#pb-iv-lineitems {
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}
.pb-iv-line-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0;
  border-bottom: 1px solid #f1f5f9;
}
.pb-iv-line-row:last-child { border-bottom: none; }
.pb-iv-line-cell {
  padding: 8px 10px;
  border-right: 1px solid #f1f5f9;
}
.pb-iv-line-cell:last-child { border-right: none; }
.pb-iv-line-cell input, .pb-iv-line-cell select {
  border: none !important;
  box-shadow: none !important;
  padding: 4px 6px !important;
  font-size: 13px !important;
}
.pb-iv-line-hdr {
  background: #f8fafc;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.pb-iv-add-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #1a56db;
  border: none;
  background: none;
  cursor: pointer;
  padding: 10px 14px;
  width: 100%;
  border-top: 1px dashed #e2e8f0;
}
/* Summary step */
#pb-iv-summary {
  display: grid;
  gap: 10px;
}
.pb-iv-summary-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 8px;
  border-left: 3px solid #1a56db;
}
.pb-iv-summary-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  min-width: 120px;
  flex-shrink: 0;
}
.pb-iv-summary-value { font-size: 13.5px; color: #1e293b; font-weight: 500; }

/* ── "Why we need this" accordion ── */
#pb-iv-why-wrap { margin-bottom: 18px; }
#pb-iv-why-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #1a56db;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-weight: 500;
}
#pb-iv-why-toggle .arrow { transition: transform .2s; font-size: 10px; }
#pb-iv-why-toggle.open .arrow { transform: rotate(90deg); }
#pb-iv-why-content {
  display: none;
  background: #f0f7ff;
  border-left: 3px solid #1a56db;
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  font-size: 12.5px;
  color: #1e3a5f;
  line-height: 1.55;
  margin-top: 8px;
}
#pb-iv-why-content.open { display: block; }

/* ── Validation error in interview mode ── */
.pb-iv-field-error {
  font-size: 12px;
  color: #dc3545;
  font-weight: 600;
  margin-top: 6px;
  display: none;
}
.pb-iv-field-error.show { display: block; }

/* ── Navigation footer ── */
#pb-iv-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 36px 24px;
  border-top: 1px solid #f1f5f9;
}
#pb-iv-dots {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
}
.pb-iv-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e2e8f0;
  cursor: pointer;
  transition: all .2s;
}
.pb-iv-dot.done  { background: #16a34a; }
.pb-iv-dot.active{ background: #1a56db; width: 22px; border-radius: 4px; }
#pb-iv-back {
  background: none;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all .2s;
  min-width: 100px;
}
#pb-iv-back:hover { background: #f8fafc; color: #1a56db; border-color: #bfdbfe; }
#pb-iv-back:disabled { opacity: .4; cursor: default; }
#pb-iv-continue {
  background: #1a56db;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  min-width: 140px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#pb-iv-continue:hover { background: #1646b8; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(26,86,219,.35); }
#pb-iv-continue.save-btn { background: #16a34a; }
#pb-iv-continue.save-btn:hover { background: #15803d; }

/* ── GAAP chip at bottom of card ── */
#pb-iv-gaap {
  background: #f0fdf4;
  border-top: 1px solid #e2e8f0;
  padding: 8px 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #14532d;
}
#pb-iv-gaap-badge {
  background: #16a34a;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* ── Exit button ── */
#pb-iv-exit {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 8001;
  background: rgba(255,255,255,.9);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12.5px;
  color: #64748b;
  cursor: pointer;
  backdrop-filter: blur(4px);
  display: none;
}
#pb-iv-exit.visible { display: block; }
#pb-iv-exit:hover { color: #1a56db; border-color: #bfdbfe; }

/* ── Keyboard hint ── */
#pb-iv-kbd-hint {
  position: fixed;
  bottom: 14px;
  right: 18px;
  z-index: 8001;
  font-size: 11px;
  color: rgba(255,255,255,.6);
  display: none;
  gap: 12px;
}
#pb-iv-kbd-hint.visible { display: flex; }
.pb-kbd { background: rgba(255,255,255,.15); padding: 2px 7px; border-radius: 4px; font-weight: 600; }

/* ── Form mode: field order hint ── */
.pb-form-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e0e7ff;
  color: #3730a3;
  font-size: 10px;
  font-weight: 700;
  margin-right: 5px;
  flex-shrink: 0;
}

/* ── Smooth form fade ── */
.pb-form-visible { opacity: 1; transition: opacity .2s; }
.pb-form-hidden  { opacity: 0; pointer-events: none; height: 0; overflow: hidden; }

@media (max-width: 640px) {
  #pb-iv-body { padding: 24px 20px 16px; }
  #pb-iv-footer { padding: 14px 20px 20px; }
  #pb-iv-gaap { padding: 8px 20px; }
  #pb-iv-question { font-size: 18px; }
  #pb-iv-header { padding: 18px 20px 14px; }
}

/* ════════════════════════════════════════════════════════════════
   INLINE ENTITY CREATION PANEL
   Slides in below any select field when user needs to create a
   prerequisite record without leaving the interview mode.
════════════════════════════════════════════════════════════════ */

/* "+ Add new [Entity]" button below selects */
.pb-add-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
  color: #1a56db;
  background: none;
  border: 1.5px dashed #bfdbfe;
  border-radius: 8px;
  padding: 7px 16px;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: all .2s;
  font-weight: 500;
}
.pb-add-new-btn:hover {
  background: #eff6ff;
  border-color: #1a56db;
}
.pb-add-new-btn .pb-plus {
  width: 20px;
  height: 20px;
  background: #1a56db;
  color: #fff;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Inline panel itself */
#pb-inline-panel {
  display: none;
  border: 2px solid #1a56db;
  border-radius: 12px;
  margin-top: 12px;
  overflow: hidden;
  animation: pbInlineSlide .25s ease-out;
}
#pb-inline-panel.open { display: block; }
@keyframes pbInlineSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
#pb-inline-header {
  background: #1a56db;
  color: #fff;
  padding: 11px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
}
#pb-inline-header .pb-ih-badge {
  background: rgba(255,255,255,.25);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: .4px;
}
#pb-inline-header .pb-ih-close {
  margin-left: auto;
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#pb-inline-body {
  padding: 16px;
  background: #f8faff;
}
#pb-inline-why {
  font-size: 12px;
  color: #4b6584;
  background: #eff6ff;
  border-left: 3px solid #1a56db;
  border-radius: 0 6px 6px 0;
  padding: 8px 12px;
  margin-bottom: 14px;
  line-height: 1.45;
}
.pb-inline-field {
  margin-bottom: 12px;
}
.pb-inline-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}
.pb-inline-field input,
.pb-inline-field select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s;
  background: #fff;
}
.pb-inline-field input:focus,
.pb-inline-field select:focus {
  border-color: #1a56db;
  box-shadow: 0 0 0 3px rgba(26,86,219,.08);
}
.pb-inline-field .pb-inline-hint {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 3px;
}
#pb-inline-footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
}
#pb-inline-cancel {
  flex: 1;
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 9px;
  font-size: 13px;
  cursor: pointer;
  color: #64748b;
}
#pb-inline-cancel:hover { background: #f8fafc; }
#pb-inline-save {
  flex: 2;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all .2s;
}
#pb-inline-save:hover { background: #15803d; }
#pb-inline-save.loading { opacity: .65; pointer-events: none; }
#pb-inline-error {
  font-size: 12px;
  color: #dc3545;
  padding: 6px 16px 0;
  display: none;
}
#pb-inline-error.show { display: block; }

/* Success flash after inline creation */
.pb-inline-success {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: #065f46;
  font-weight: 500;
  margin-top: 8px;
  animation: pbInlineSlide .2s ease-out;
}
