/* ============================================================================
   Wise & IRR Rate Check — Modern Wise Glassmorphism Design
   ========================================================================== */

:root {
  --green: #9fe870;
  --green-deep: #163300;
  --mint: #e2f6d5;
  --pastel: #cdffad;
  --mint-hover: rgba(211, 242, 192, 0.4);

  --ink: #0e0f0c;
  --ink-2: #383a38;
  --gray: #656763;
  --surface: #ffffff;
  --surface-2: #f7f8f5;
  --surface-3: #edf0eb;
  --line: rgba(14, 15, 12, 0.12);

  --ok: #054d28;
  --ok-soft: #e2f6d5;
  --warn: #8a5a00;
  --warn-soft: #fdf3d9;
  --error: #d03238;
  --error-soft: #fdecec;

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --shadow-card: 0 4px 20px -2px rgba(14, 15, 12, 0.05), 0 0 0 1px var(--line);
  --shadow-pop: 0 0 0 1px var(--line), 0 12px 32px -12px rgba(14, 15, 12, 0.22);

  --font: "Vazirmatn", "Inter", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--surface-2);
  color: var(--ink);
  font: 400 15px/1.6 var(--font);
  font-feature-settings: "calt" 1;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--pastel); color: var(--green-deep); }

/* ------------------------------------------------------------ Header */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  transition: transform 0.14s ease;
}

.brand:hover { transform: scale(1.01); }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--ink);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }

header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.74rem;
  color: var(--gray);
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 9999px;
  background: var(--mint);
  color: var(--green-deep);
  font-size: 0.75rem;
  font-weight: 700;
}

#status-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#status-pill.idle { background: var(--surface-3); color: var(--ink-2); }
#status-pill.busy { background: var(--warn-soft); color: var(--warn); }

/* ------------------------------------------------------------ Main */

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-card);
  min-width: 0;
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: 0 6px 24px -4px rgba(14, 15, 12, 0.08), 0 0 0 1px var(--line);
}

.card-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--green-deep);
}

.glow-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #25bb35;
  display: inline-block;
  box-shadow: 0 0 8px #25bb35;
}

.latency-tag, .calc-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ok);
  background: var(--ok-soft);
  padding: 3px 10px;
  border-radius: 6px;
}

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

/* ------------------------------------------------------------ Form Grid */

.main-form-card {
  background: linear-gradient(180deg, #ffffff 0%, #f7fbf4 100%);
  border-color: rgba(159, 232, 112, 0.45);
}

.ai-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

#ai-query-input {
  flex: 1;
  font-size: 0.95rem;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid rgba(159, 232, 112, 0.6);
  background: #ffffff;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
}

#ai-query-input:focus {
  outline: none;
  border-color: var(--green-deep);
  box-shadow: 0 0 0 3px var(--pastel);
}

.ai-btn {
  white-space: nowrap;
  padding: 0 20px;
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: var(--radius-md);
}

.quick-pairs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.quick-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-2);
}

.chip {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font: 700 0.78rem/1 var(--font);
  padding: 8px 14px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  background: var(--pastel);
  border-color: var(--green);
  color: var(--green-deep);
  transform: translateY(-1px);
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ink-2);
}

.field-group input {
  width: 100%;
  background: var(--surface);
  border: 1px solid rgba(14, 15, 12, 0.18);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font: 700 0.95rem/1 var(--font);
  transition: all 0.15s ease;
}

.field-group input:focus {
  outline: none;
  border-color: var(--green-deep);
  box-shadow: 0 0 0 2px var(--mint);
}

#from, #to { font-family: var(--mono); text-transform: uppercase; }

.action-row {
  margin-top: 8px;
}

button.primary {
  width: 100%;
  padding: 14px 20px;
  background: var(--green);
  color: var(--green-deep);
  border: 0;
  border-radius: 9999px;
  font: 800 1rem/1 var(--font);
  cursor: pointer;
  transition: transform 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
  box-shadow: 0 3px 12px rgba(159, 232, 112, 0.35);
}

button.primary:hover {
  background: var(--pastel);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(159, 232, 112, 0.45);
}

button.primary:active { transform: scale(0.98); }

.hint {
  margin: 16px 0 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--gray);
}

/* --------------------------------------------------- Calculation Result Card */

.calculation-card {
  background: #ffffff;
  border: 2px solid var(--green);
  box-shadow: 0 8px 30px -4px rgba(159, 232, 112, 0.25);
}

.nok-result-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--ink);
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  border: 1px solid var(--line);
}

/* ------------------------------------------------------------- AI Verdict */

.verdict-tag {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 9999px;
}

.verdict-tag.optimal { background: var(--ok-soft); color: var(--ok); }
.verdict-tag.caution { background: var(--warn-soft); color: var(--warn); }

.ai-verdict-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  border-right: 4px solid var(--green);
}

.ai-verdict-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.ai-verdict-title {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--ink);
}

.ai-fee-rating {
  font-size: 0.76rem;
  font-weight: 700;
  background: #ffffff;
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--green-deep);
}

.ai-verdict-summary {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink-2);
}

/* ---------------------------------------------------------------- Results */

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--line);
}

.stat-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--gray);
  margin-bottom: 4px;
}

.stat-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--ink);
  font-feature-settings: "calt" 1, "tnum" 1;
}

.screens {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}

.screen-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0e0f0c;
}

.screen-header {
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  background: #1e201b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.screen-card img {
  width: 100%;
  display: block;
  object-fit: cover;
  background: #0e0f0c;
}

/* ------------------------------------------------------------------ Chart */

#chart {
  margin-bottom: 20px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--line);
}

.chart-title {
  font-size: 0.85rem;
  font-weight: 800;
  margin-bottom: 10px;
}

svg .chart-line {
  fill: none;
  stroke: var(--green-deep);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

svg circle {
  fill: var(--green);
  stroke: var(--green-deep);
  stroke-width: 2;
  cursor: pointer;
  transition: r 0.15s ease;
}

svg circle:hover { r: 6; }

svg .grid { stroke: rgba(14, 15, 12, 0.08); stroke-dasharray: 4; }
svg .axis { font-size: 9px; fill: var(--gray); font-family: var(--mono); }

/* ----------------------------------------------------------------- Table */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

th, td { text-align: right; padding: 11px 14px; border-bottom: 1px solid var(--line); }

thead th {
  color: var(--ink-2);
  font-weight: 700;
  font-size: 0.72rem;
  background: var(--surface-2);
}

tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--mint-hover); }
tbody tr:last-child td { border-bottom: 0; }

.history-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}

button.secondary {
  padding: 8px 16px;
  border: 0;
  border-radius: 9999px;
  background: rgba(22, 51, 0, 0.08);
  color: var(--green-deep);
  font: 700 0.82rem var(--font);
  cursor: pointer;
  transition: all 0.14s ease;
}

button.secondary:hover { background: rgba(22, 51, 0, 0.14); transform: translateY(-1px); }

/* ---------------------------------------------------------------- Footer */

footer {
  text-align: center;
  padding: 20px 16px 40px;
  font-size: 0.78rem;
  color: var(--gray);
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ----------------------------------------------------------------- Toast */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90vw, 560px);
  padding: 13px 20px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 999;
}

.toast.warn { border-color: rgba(138, 90, 0, 0.35); color: var(--warn); background: var(--warn-soft); }
.toast.error { border-color: rgba(208, 50, 56, 0.35); color: var(--error); background: var(--error-soft); }

.hidden { display: none !important; }
.dim { color: var(--gray); }

@media (max-width: 768px) {
  header { padding: 12px 16px; }
  .screens { grid-template-columns: 1fr; }
  .ai-input-row { flex-direction: column; }
  .ai-btn { padding: 12px 20px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}
