/* =========================================
   EthereumBliss – Guarantor Contract (UI)
   Step-based process, locked/greyed steps
   + Repayment calculator + wallet select logo
   ========================================= */

:root {
  color-scheme: dark;

  --eb-bg: #020617;
  --eb-surface: rgba(15, 23, 42, 0.96);
  --eb-surface-soft: rgba(15, 23, 42, 0.9);

  --eb-border-subtle: rgba(148, 163, 184, 0.35);
  --eb-border-strong: rgba(148, 163, 184, 0.55);

  --eb-text-main: #e5e7eb;
  --eb-text-muted: #9ca3af;
  --eb-accent1: #4f46e5;
  --eb-accent2: #06b6d4;

  --eb-radius-xl: 1.25rem;
  --eb-radius-lg: 0.9rem;
  --eb-radius-pill: 999px;
}

/* Base reset */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 0% 0%, #0f172a 0, #020617 45%, #000 100%);
  color: var(--eb-text-main);
  min-height: 100vh;
}

/* Layout shell */
.page-shell {
  max-width: 1120px;
  margin: 1.5rem auto 2.5rem;
  padding: 0 1rem;
}

/* ================= HEADER ================= */

.eb-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding: 1.25rem;
  border-radius: var(--eb-radius-xl);
  background:
    radial-gradient(circle at top left, rgba(79, 70, 229, 0.24), transparent 60%),
    radial-gradient(circle at bottom right, rgba(6, 182, 212, 0.18), transparent 65%),
    var(--eb-surface);
  border: 1px solid var(--eb-border-subtle);
  box-shadow: 0 22px 45px rgba(15, 23, 42, 0.95);
  margin-bottom: 1.25rem;
}

.eb-header-left {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  min-width: 0;
  flex: 2 1 320px;
}

.eb-logo-image {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  object-fit: cover;
  box-shadow:
    0 0 0 1px rgba(148, 163, 184, 0.6),
    0 0 24px rgba(56, 189, 248, 0.4);
}

.eb-header-text h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
}

.eb-header-text p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--eb-text-muted);
}

.eb-header-text a {
  color: #7dd3fc;
  text-decoration: none;
}

.eb-header-text a:hover { text-decoration: underline; }

.eb-header-right {
  flex: 1 1 260px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.eb-header-badge {
  align-self: flex-start;
  padding: 0.4rem 0.8rem;
  border-radius: var(--eb-radius-pill);
  border: 1px dashed rgba(94, 234, 212, 0.7);
  background: radial-gradient(circle at top left, rgba(94, 234, 212, 0.16), transparent 70%);
  font-size: 0.75rem;
  color: #a5f3fc;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.eb-header-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--eb-text-muted);
}

/* ================= PROCESS STEPPER ================= */

.process-stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.process-step-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--eb-radius-pill);
  border: 1px solid var(--eb-border-subtle);
  background: rgba(15, 23, 42, 0.9);
  font-size: 0.78rem;
  color: var(--eb-text-muted);
}

.step-number {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.85);
}

.step-label { white-space: nowrap; }

.process-step-indicator--active {
  border-color: rgba(129, 140, 248, 0.9);
  color: #e5e7eb;
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.5);
}

.process-step-indicator--active .step-number {
  background: linear-gradient(135deg, var(--eb-accent1), var(--eb-accent2));
  border-color: transparent;
  color: #ffffff;
}

.process-step-indicator--complete {
  border-color: rgba(45, 212, 191, 0.9);
  color: #a5f3fc;
}

.process-step-indicator--complete .step-number {
  background: rgba(45, 212, 191, 0.18);
  border-color: rgba(45, 212, 191, 0.9);
}

.process-step-indicator--locked { opacity: 0.55; }

/* ================= MAIN & CARDS ================= */

.eb-main { display: flex; flex-direction: column; gap: 1.25rem; }

.card {
  background: var(--eb-surface);
  border-radius: var(--eb-radius-xl);
  border: 1px solid var(--eb-border-subtle);
  padding: 1.35rem 1.25rem 1.4rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
}

.card-title { margin: 0 0 0.3rem; font-size: 1.1rem; }

.card-subtitle { margin: 0 0 1rem; font-size: 0.88rem; color: var(--eb-text-muted); }

/* ================= PROCESS STEP LOCKING ================= */

.process-step { position: relative; }

.process-step-overlay {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  text-align: center;
  color: var(--eb-text-muted);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(2px);
  z-index: 3;
  padding: 0.75rem;
}

.process-step--locked { opacity: 0.6; }
.process-step--locked .process-step-overlay { display: flex; }

.process-step--locked input,
.process-step--locked select,
.process-step--locked textarea,
.process-step--locked button,
.process-step--locked .checkbox-row,
.process-step--locked .radio-row,
.process-step--locked .quick-months {
  pointer-events: none;
}

/* ================= FORM ELEMENTS ================= */

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.8rem;
}

.field-full { grid-column: 1 / -1; }

label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--eb-text-muted);
}

input, select, textarea {
  border-radius: var(--eb-radius-lg);
  border: 1px solid var(--eb-border-subtle);
  background: var(--eb-surface-soft);
  color: var(--eb-text-main);
  padding: 0.55rem 0.7rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

input::placeholder, textarea::placeholder { color: #6b7280; }

input:focus, select:focus, textarea:focus {
  border-color: rgba(129, 140, 248, 0.9);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.55);
  background: rgba(15, 23, 42, 0.98);
}

textarea { resize: vertical; min-height: 72px; }

.field-hint { margin: 0.25rem 0 0; font-size: 0.78rem; color: var(--eb-text-muted); }

/* Radio rows */
.radio-row { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.2rem; }

.radio-inline {
  font-size: 0.86rem;
  color: var(--eb-text-main);
  text-transform: none;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.radio-inline input[type="radio"] { width: 1rem; height: 1rem; }

/* Checkbox rows */
.checkbox-row { margin: 0.4rem 0; font-size: 0.84rem; color: var(--eb-text-muted); }

.checkbox-row label {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.4rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--eb-text-main);
  font-size: 0.86rem;
}

.checkbox-row input[type="checkbox"] { width: 1rem; height: 1rem; margin-top: 0.1rem; }

/* Grid helpers */
.grid { display: grid; gap: 0.8rem 1rem; margin-bottom: 0.5rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .eb-header { padding: 1.1rem; }
}

/* Divider & subtitles */
.divider {
  height: 1px;
  margin: 1rem 0 0.8rem;
  background: linear-gradient(to right, transparent, rgba(148, 163, 184, 0.65), transparent);
}

.section-subtitle { margin: 0 0 0.35rem; font-size: 0.95rem; }
.section-help { margin: 0 0 0.6rem; font-size: 0.83rem; color: var(--eb-text-muted); }

/* Loan-type extra sections */
.loan-type-extra {
  margin-top: 0.75rem;
  padding: 0.8rem 0.8rem 0.85rem;
  border-radius: 1rem;
  border: 1px dashed var(--eb-border-subtle);
  background: rgba(15, 23, 42, 0.85);
}

.loan-extra-title { margin: 0 0 0.5rem; font-size: 0.95rem; }

/* ================= WALLET SELECT + LOGO ================= */

.wallet-select-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.wallet-logo-preview {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(2, 6, 23, 0.35);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.75);
}

/* ================= QUICK MONTHS ================= */

.quick-months {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.chip {
  border: 1px solid var(--eb-border-strong);
  background: rgba(15, 23, 42, 0.6);
  color: var(--eb-text-main);
  border-radius: var(--eb-radius-pill);
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.08s ease, background 0.12s ease;
}

.chip:hover { transform: translateY(-1px); filter: brightness(1.04); }
.chip:active { transform: translateY(0); }
.chip.is-active {
  border-color: rgba(129, 140, 248, 0.9);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.45);
  background: rgba(79, 70, 229, 0.18);
}

/* ================= REPAYMENT PREVIEW CARD ================= */

.repay-card {
  margin-top: 0.85rem;
  border-radius: 1rem;
  border: 1px solid rgba(129, 140, 248, 0.35);
  background:
    radial-gradient(circle at top left, rgba(79, 70, 229, 0.20), transparent 60%),
    rgba(2, 6, 23, 0.35);
  padding: 0.9rem;
}

.repay-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  margin-bottom: 0.7rem;
}

.repay-title { font-weight: 700; font-size: 0.95rem; }
.repay-sub { margin-top: 0.2rem; font-size: 0.82rem; color: var(--eb-text-muted); }

.repay-pill {
  padding: 0.35rem 0.75rem;
  border-radius: var(--eb-radius-pill);
  border: 1px dashed rgba(94, 234, 212, 0.55);
  color: #a5f3fc;
  font-size: 0.78rem;
  white-space: nowrap;
  background: rgba(6, 182, 212, 0.08);
}

.repay-grid {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 680px) {
  .repay-grid { grid-template-columns: minmax(0, 1fr); }
}

.repay-metric {
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 0.9rem;
  padding: 0.65rem 0.75rem;
  background: rgba(15, 23, 42, 0.55);
}

.repay-k { font-size: 0.78rem; color: var(--eb-text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.repay-v { margin-top: 0.25rem; font-size: 1rem; font-weight: 650; }

.repay-note {
  margin: 0.75rem 0 0;
  color: var(--eb-text-muted);
  font-size: 0.78rem;
}

/* ================= BUTTONS ================= */

.btn-primary,
.btn-secondary {
  border-radius: var(--eb-radius-pill);
  border: none;
  padding: 0.6rem 1.4rem;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease, background 0.12s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--eb-accent1), var(--eb-accent2));
  color: white;
  box-shadow: 0 10px 24px rgba(56, 189, 248, 0.4);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(56, 189, 248, 0.55);
  filter: brightness(1.03);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(56, 189, 248, 0.45);
}

.btn-secondary {
  background: transparent;
  color: var(--eb-text-main);
  border: 1px solid var(--eb-border-strong);
}

.btn-secondary:hover { background: rgba(15, 23, 42, 0.9); }

.btn-secondary--small {
  align-self: flex-start;
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
}

/* Export row */
.export-row {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

/* ================= STATUS BANNERS ================= */

.status-banner {
  margin-top: 0.75rem;
  border-radius: 0.75rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.83rem;
  border: 1px dashed var(--eb-border-subtle);
}

.status-banner--idle { background: rgba(15, 23, 42, 0.8); }

.status-banner--error {
  background: rgba(127, 29, 29, 0.25);
  border-color: rgba(248, 113, 113, 0.88);
  color: #fecaca;
}

.status-banner--ok {
  background: rgba(6, 95, 70, 0.32);
  border-color: rgba(45, 212, 191, 0.9);
  color: #a5f3fc;
}

/* ================= GUARANTOR CARD ================= */

.guarantor-card {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.9rem 0.8rem;
  border-radius: 1rem;
  border: 1px solid var(--eb-border-subtle);
  background: radial-gradient(circle at top left, rgba(79, 70, 229, 0.25), transparent 70%);
}

.guarantor-meta { flex: 1 1 260px; }

.gm-row {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
  font-size: 0.88rem;
}

.gm-label { color: var(--eb-text-muted); }
.gm-value { color: var(--eb-text-main); }
.gm-value-strong { font-weight: 600; }

.gm-description {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
  color: var(--eb-text-muted);
}

/* ================= SIGNATURES ================= */

.guarantor-signature { flex: 1 1 260px; }

.signature-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--eb-text-muted);
  margin-bottom: 0.2rem;
}

.signature-box {
  min-height: 42px;
  padding: 0.35rem 0.7rem;
  border-radius: 0.75rem;
  border: 1px dashed rgba(209, 213, 219, 0.8);
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.9);
}

.signature-box--shaggy {
  font-family: "Brush Script MT", "Segoe Script", "Lucida Handwriting", cursive;
  font-style: italic;
  font-size: 1.25rem;
  letter-spacing: 0.06em;
}

.signature-box--draw { padding: 0; overflow: hidden; }

#borrowerSignaturePad {
  width: 100%;
  height: 160px;
  display: block;
  background: rgba(15, 23, 42, 0.95);
  cursor: crosshair;
}

.signature-hint { margin: 0.25rem 0 0.4rem; font-size: 0.78rem; color: var(--eb-text-muted); }

/* Form wrapper */
.contract-form { display: flex; flex-direction: column; gap: 1.25rem; }

.signature-field { max-width: 520px; }

/* Final submission note */
.submission-note {
  margin-top: 0.9rem;
  font-size: 0.85rem;
  color: #a5f3fc;
  background: rgba(6, 95, 70, 0.32);
  border-radius: 0.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(45, 212, 191, 0.85);
}

/* Small screens tweaks */
@media (max-width: 640px) {
  .page-shell { margin-top: 1rem; }
  .card { padding: 1.1rem 1rem 1.2rem; }
  .eb-header-text h1 { font-size: 1.15rem; }
  .process-stepper { gap: 0.4rem; }
  .step-label { font-size: 0.72rem; }
}
