/**
 * DIP Engine — Stylesheet
 * ========================
 * Standalone styles for the Decision in Principle Engine.
 * Depends on CSS custom properties from the main site stylesheet:
 *   --primary, --primary-light, --secondary, --secondary-light,
 *   --accent, --dark, --text, --text-light, --light, --white, --border
 *
 * Also reuses base classes from the site: .btn, .btn-primary, .btn-outline,
 * .apply-field, .apply-form-grid, .calc-slider-*, .calc-result-*
 */


/* ── Card Container ────────────────────────────────────────────── */

.dip-card {
  background: var(--white);
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow:
    0 4px 12px rgba(0,0,0,0.05),
    0 20px 50px rgba(0,0,0,0.1),
    0 40px 100px rgba(0,0,0,0.08);
  overflow: hidden;
  max-width: 900px;
  margin: 0 auto;
}


/* ── Progress Bar ──────────────────────────────────────────────── */

.dip-progress {
  background: var(--primary);
  padding: 1.5rem 2.25rem 1.25rem;
}

.dip-progress-track {
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.dip-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--secondary-light));
  border-radius: 4px;
  width: 0%;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.dip-steps {
  display: flex;
  gap: 0.25rem;
}

.dip-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  color: rgba(255,255,255,0.35);
  background: none;
  border: none;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.dip-step:hover { color: rgba(255,255,255,0.6); }
.dip-step.active { color: var(--white); background: rgba(255,255,255,0.08); }
.dip-step.completed { color: var(--accent); }

.dip-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.25s ease;
}

.dip-step.active .dip-step-num { background: var(--accent); color: var(--primary); }
.dip-step.completed .dip-step-num { background: rgba(94,234,212,0.2); color: var(--accent); }


/* ── Step Panels ───────────────────────────────────────────────── */

.dip-panel {
  display: none;
  padding: 2.5rem;
  animation: fadeUp 0.35s ease-out;
}

.dip-panel.active { display: block; }

.dip-panel-header { margin-bottom: 2rem; }
.dip-panel-header h2 { margin-bottom: 0.4rem; }
.dip-panel-header p { font-size: 0.92rem; }


/* ── Borrower Type Radio Cards ─────────────────────────────────── */

.dip-borrower-type {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.dip-radio-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border: 2px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.dip-radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.dip-radio-card:hover { border-color: #cbd5e1; background: var(--light); }

.dip-radio-card.active {
  border-color: var(--secondary);
  background: rgba(13,148,136,0.04);
  box-shadow: 0 0 0 4px rgba(13,148,136,0.08);
}

.dip-radio-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--light);
  color: var(--text-light);
  flex-shrink: 0;
  transition: all 0.25s ease;
}

.dip-radio-card.active .dip-radio-icon {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-light));
  color: var(--white);
}

.dip-radio-icon svg { width: 22px; height: 22px; }

.dip-radio-text { display: flex; flex-direction: column; gap: 0.15rem; }
.dip-radio-text strong { font-size: 0.95rem; color: var(--text); }
.dip-radio-text span { font-size: 0.78rem; color: var(--text-light); }

.dip-radio-check {
  margin-left: auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.dip-radio-check svg { width: 14px; height: 14px; }

.dip-radio-card.active .dip-radio-check {
  border-color: var(--secondary);
  background: var(--secondary);
  color: var(--white);
}


/* ── Companies House Search ────────────────────────────────────── */

.dip-field-search {
  position: relative;
  margin-bottom: 1.5rem;
}

.dip-field-search > label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.45rem;
}

.dip-search-wrap { position: relative; }

.dip-search-wrap input {
  width: 100%;
  padding: 0.85rem 1.1rem;
  padding-right: 3rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--light);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.dip-search-wrap input::placeholder { color: var(--text-light); opacity: 0.6; }

.dip-search-wrap input:focus {
  outline: none;
  border-color: var(--secondary);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(13,148,136,0.1);
}

.dip-search-spinner {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--secondary);
}

.dip-search-spinner svg { width: 20px; height: 20px; animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Search results dropdown */
.dip-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  z-index: 50;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  max-height: 220px;
  overflow-y: auto;
}

.dip-search-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
  padding: 0.85rem 1.1rem;
  border: none;
  background: none;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.dip-search-item:last-child { border-bottom: none; }
.dip-search-item:hover { background: var(--light); }

.dip-search-item-main { display: flex; align-items: baseline; gap: 0.75rem; }
.dip-search-item-main strong { font-size: 0.88rem; color: var(--text); }
.dip-search-item-num { font-size: 0.75rem; color: var(--text-light); font-family: monospace; }

.dip-search-item-meta { display: flex; align-items: center; gap: 0.75rem; font-size: 0.75rem; color: var(--text-light); }

.dip-search-item-status {
  text-transform: capitalize;
  font-weight: 600;
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: #d1fae5;
  color: #065f46;
}

.dip-status-dissolved,
.dip-status-liquidation { background: #fee2e2; color: #991b1b; }

.dip-search-empty { padding: 1.25rem; text-align: center; color: var(--text-light); font-size: 0.88rem; }


/* ── Company Info Card ─────────────────────────────────────────── */

.dip-company-info {
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.dip-info-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #065f46;
  background: #d1fae5;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  margin-bottom: 1.25rem;
}

.dip-info-badge svg { width: 14px; height: 14px; }

.dip-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.dip-info-full { grid-column: 1 / -1; }
.dip-info-item { display: flex; flex-direction: column; gap: 0.2rem; }

.dip-info-label {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
}

.dip-info-value { font-size: 0.9rem; font-weight: 600; color: var(--text); text-transform: capitalize; }

.dip-change-btn {
  margin-top: 1.25rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--secondary);
  background: none;
  border: 1px solid var(--secondary);
  border-radius: 8px;
  padding: 0.4rem 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.dip-change-btn:hover { background: rgba(13,148,136,0.06); }


/* ── Contact Section ───────────────────────────────────────────── */

.dip-contact-section { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.dip-contact-section h3 { font-size: 1rem; font-weight: 700; color: var(--primary); margin-bottom: 1.25rem; }


/* ── Calculator Grid ───────────────────────────────────────────── */

.dip-calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.dip-calc-sliders { padding: 2rem; display: flex; flex-direction: column; gap: 2rem; }
.dip-calc-results { background: var(--primary); padding: 2rem; display: flex; flex-direction: column; justify-content: center; }


/* ── Editable Amount Input ─────────────────────────────────────── */

.dip-amount-editable-wrap { display: flex; align-items: center; gap: 0.4rem; }
.dip-editable-value { cursor: pointer; transition: all 0.2s ease; }
.dip-editable-value:hover { color: var(--secondary); }

.dip-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1.5px solid var(--secondary);
  background: rgba(13,148,136,0.06);
  color: var(--secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.dip-edit-btn svg { width: 14px; height: 14px; }
.dip-edit-btn:hover { background: var(--secondary); color: var(--white); }

.dip-exact-input {
  width: 100%;
  padding: 0.45rem 0.8rem;
  border: 2px solid var(--secondary);
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--primary);
  background: var(--white);
  outline: none;
  box-shadow: 0 0 0 4px rgba(13,148,136,0.1);
}

.dip-exact-input::placeholder { font-size: 0.82rem; font-weight: 500; color: var(--text-light); opacity: 0.7; }


/* ── Navigation Buttons ────────────────────────────────────────── */

.dip-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.dip-nav-final { gap: 1rem; }
.dip-next-btn svg, .dip-back-btn svg { width: 16px; height: 16px; }


/* ── Result Banner (Approved / Flagged) ────────────────────────── */

.dip-result-banner {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  border-radius: 14px;
  margin-bottom: 2rem;
}

.dip-result-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #065f46;
  color: #a7f3d0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dip-result-icon svg { width: 22px; height: 22px; }
.dip-result-text { display: flex; flex-direction: column; gap: 0.25rem; }
.dip-result-text strong { font-size: 1rem; color: #065f46; }
.dip-result-text span { font-size: 0.82rem; color: #047857; line-height: 1.5; }

/* Flagged state (orange) */
.dip-result-flagged { background: #fff7ed !important; border-color: #fed7aa !important; }
.dip-result-flagged .dip-result-icon { background: #9a3412 !important; color: #fed7aa !important; }
.dip-result-flagged .dip-result-text strong { color: #9a3412 !important; }
.dip-result-flagged .dip-result-text span { color: #c2410c !important; }


/* ── Review Summary Tables ─────────────────────────────────────── */

.dip-summary { display: flex; flex-direction: column; gap: 1.5rem; margin-bottom: 2rem; }

.dip-summary-section { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }

.dip-summary-section h3 {
  padding: 0.85rem 1.25rem;
  background: var(--light);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  margin: 0;
}

.dip-summary-grid { padding: 0; }

.dip-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.dip-summary-row:last-child { border-bottom: none; }
.dip-summary-label { font-size: 0.82rem; color: var(--text-light); }

.dip-summary-value {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  max-width: 60%;
}


/* ── LTV Bar ───────────────────────────────────────────────────── */

.dip-ltv-bar {
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}

.dip-ltv-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.75rem; }
.dip-ltv-header span { font-size: 0.82rem; color: var(--text-light); font-weight: 500; }
.dip-ltv-header strong { font-size: 1.1rem; color: var(--primary); }

.dip-ltv-track { height: 10px; background: var(--border); border-radius: 6px; overflow: hidden; position: relative; }

.dip-ltv-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary), var(--secondary-light));
  border-radius: 6px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.dip-ltv-fill.dip-ltv-over { background: linear-gradient(90deg, #f59e0b, #ef4444); }

.dip-ltv-labels { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--text-light); margin-top: 0.4rem; }
.dip-ltv-threshold { color: var(--secondary); font-weight: 600; }


/* ── Download Button ───────────────────────────────────────────── */

.dip-download-btn { gap: 0.6rem; }
.dip-download-btn svg { width: 18px; height: 18px; }


/* ── Responsive ────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .dip-card { border-radius: 14px; }
  .dip-panel { padding: 1.5rem; }
  .dip-progress { padding: 1.25rem 1.5rem 1rem; }
  .dip-steps { flex-wrap: wrap; gap: 0.35rem; }
  .dip-step { font-size: 0.7rem; padding: 0.4rem 0.5rem; }
  .dip-borrower-type { grid-template-columns: 1fr; }
  .dip-calc-grid { grid-template-columns: 1fr; }
  .dip-calc-sliders { padding: 1.5rem; }
  .dip-calc-results { padding: 1.5rem; }
  .dip-info-grid { grid-template-columns: 1fr; }
  .dip-nav { flex-direction: column; gap: 0.75rem; }
  .dip-nav .btn { width: 100%; justify-content: center; }
  .dip-nav-final { flex-direction: column-reverse; }
  .dip-result-banner { flex-direction: column; text-align: center; align-items: center; }
  .dip-summary-value { max-width: 55%; }
}
