/* =====================================================
   KRIPTO CLASSICAL — Modern Professional UI
   ===================================================== */

/* ---------- Google Font ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

/* ---------- CSS Variables ---------- */
:root {
  --font-base: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Light palette */
  --clr-bg:         #f0f4ff;
  --clr-surface:    #ffffff;
  --clr-surface2:   #f8faff;
  --clr-border:     rgba(99,102,241,.15);
  --clr-border2:    rgba(99,102,241,.08);
  --clr-text:       #1e1b4b;
  --clr-muted:      #6b7280;
  --clr-primary:    #4f46e5;
  --clr-primary-h:  #4338ca;
  --clr-accent:     #7c3aed;
  --clr-success:    #059669;
  --clr-danger:     #dc2626;
  --clr-grad1:      linear-gradient(135deg, #4f46e5, #7c3aed);
  --clr-hero-bg:    linear-gradient(135deg, rgba(79,70,229,.08) 0%, rgba(124,58,237,.08) 100%);
  --clr-glow:       rgba(79,70,229,.25);

  --radius-sm:  .5rem;
  --radius-md:  1rem;
  --radius-lg:  1.5rem;
  --radius-xl:  2rem;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(79,70,229,.10), 0 1px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 8px 32px rgba(79,70,229,.15), 0 2px 8px rgba(0,0,0,.08);
  --shadow-glow:0 0 0 3px rgba(79,70,229,.18);

  --transition: all .25s cubic-bezier(.4,0,.2,1);
  --transition-slow: all .4s cubic-bezier(.4,0,.2,1);
}

[data-bs-theme="dark"] {
  --clr-bg:         #0d0f1a;
  --clr-surface:    #13162a;
  --clr-surface2:   #181b2e;
  --clr-border:     rgba(139,92,246,.18);
  --clr-border2:    rgba(139,92,246,.09);
  --clr-text:       #e2e8ff;
  --clr-muted:      #9ca3af;
  --clr-primary:    #818cf8;
  --clr-primary-h:  #a78bfa;
  --clr-accent:     #a78bfa;
  --clr-grad1:      linear-gradient(135deg, #818cf8, #a78bfa);
  --clr-hero-bg:    linear-gradient(135deg, rgba(129,140,248,.12) 0%, rgba(167,139,250,.12) 100%);
  --clr-glow:       rgba(129,140,248,.3);
  --shadow-md:      0 4px 16px rgba(0,0,0,.4), 0 1px 4px rgba(0,0,0,.2);
  --shadow-lg:      0 8px 32px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.3);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-base);
  background: var(--clr-bg);
  color: var(--clr-text);
  min-height: 100vh;
  transition: background .35s, color .35s;
  line-height: 1.65;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--clr-primary); border-radius: 99px; }

/* ---------- Selection ---------- */
::selection { background: rgba(79,70,229,.2); color: var(--clr-primary); }

/* =====================================================
   NAVBAR
   ===================================================== */
.navbar {
  background: rgba(255,255,255,.72) !important;
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--clr-border) !important;
  padding: .85rem 0;
  transition: var(--transition);
}
[data-bs-theme="dark"] .navbar {
  background: rgba(13,15,26,.78) !important;
}
.navbar-brand {
  font-weight: 800;
  font-size: 1.25rem;
  background: var(--clr-grad1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -.3px;
}
.navbar-brand .brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--clr-grad1);
  margin-right: .5rem;
  font-size: .9rem;
  -webkit-text-fill-color: white;
}

/* ---------- Theme Toggle ---------- */
#themeToggle {
  border-radius: 99px;
  font-size: .82rem;
  padding: .35rem .9rem;
  border-color: var(--clr-border);
  color: var(--clr-muted);
  transition: var(--transition);
  gap: .4rem;
  display: flex;
  align-items: center;
}
#themeToggle:hover {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* =====================================================
   HERO SECTION
   ===================================================== */
.hero {
  background: var(--clr-hero-bg);
  border: 1px solid var(--clr-border);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%234f46e5' fill-opacity='0.03'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}
.hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
  animation: orbFloat 8s ease-in-out infinite;
}
.hero-orb-1 {
  width: 200px; height: 200px;
  background: rgba(79,70,229,.12);
  top: -50px; right: -20px;
}
.hero-orb-2 {
  width: 140px; height: 140px;
  background: rgba(124,58,237,.12);
  bottom: -30px; right: 120px;
  animation-delay: -3s;
}

.badge-pill {
  background: var(--clr-grad1);
  color: white;
  border-radius: 99px;
  padding: .3rem .9rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .3px;
  display: inline-block;
}

.info-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.info-card .algo-chip {
  display: inline-flex;
  align-items: center;
  background: rgba(79,70,229,.08);
  border: 1px solid rgba(79,70,229,.15);
  color: var(--clr-primary);
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .7rem;
  margin: .15rem;
  transition: var(--transition);
}
.info-card .algo-chip:hover {
  background: var(--clr-grad1);
  color: white;
  border-color: transparent;
  transform: translateY(-1px);
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
  background: var(--clr-surface) !important;
  border: 1px solid var(--clr-border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-md) !important;
  transition: var(--transition-slow) !important;
}
.card:hover {
  box-shadow: var(--shadow-lg) !important;
  border-color: rgba(79,70,229,.25) !important;
}
.card-body { padding: 1.75rem !important; }

/* ---------- Section titles inside cards ---------- */
.card-body h2.h4 {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -.2px;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.card-body h2.h4::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.1em;
  background: var(--clr-grad1);
  border-radius: 2px;
}

/* =====================================================
   FORM ELEMENTS
   ===================================================== */
.form-label {
  font-weight: 600;
  font-size: .85rem;
  color: var(--clr-text);
  margin-bottom: .4rem;
  letter-spacing: .1px;
}
.form-text {
  font-size: .78rem;
  color: var(--clr-muted);
}

.form-control, .form-select {
  background: var(--clr-surface2) !important;
  border: 1px solid var(--clr-border) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--clr-text) !important;
  font-family: var(--font-base);
  font-size: .9rem !important;
  padding: .6rem .9rem !important;
  transition: var(--transition) !important;
}
.form-control:focus, .form-select:focus {
  background: var(--clr-surface) !important;
  border-color: var(--clr-primary) !important;
  box-shadow: var(--shadow-glow) !important;
  outline: none !important;
}
.form-control::placeholder { color: var(--clr-muted) !important; opacity: .7; }
textarea.form-control { resize: vertical; min-height: 110px; }

/* ---------- Radio toggle group ---------- */
.btn-group .btn-outline-primary {
  border-color: var(--clr-border) !important;
  color: var(--clr-muted) !important;
  background: var(--clr-surface2) !important;
  font-size: .88rem;
  font-weight: 600;
  transition: var(--transition) !important;
}
.btn-check:checked + .btn-outline-primary {
  background: var(--clr-grad1) !important;
  border-color: var(--clr-primary) !important;
  color: white !important;
  box-shadow: 0 2px 8px rgba(79,70,229,.35) !important;
}
.btn-group .btn-outline-primary:hover:not(.active) {
  border-color: var(--clr-primary) !important;
  color: var(--clr-primary) !important;
  background: rgba(79,70,229,.06) !important;
}

/* ---------- Submit button ---------- */
#submitBtn {
  background: var(--clr-grad1);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .3px;
  padding: .75rem 1.5rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  box-shadow: 0 4px 14px rgba(79,70,229,.4);
}
#submitBtn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.15), transparent);
  opacity: 0;
  transition: opacity .2s;
}
#submitBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79,70,229,.5);
}
#submitBtn:hover::before { opacity: 1; }
#submitBtn:active { transform: translateY(0); }

/* Loading state */
#submitBtn.loading {
  pointer-events: none;
  opacity: .85;
}
.btn-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: .4rem;
}

/* =====================================================
   KEY PANELS — animated transitions
   ===================================================== */
.key-panel {
  margin-top: .9rem;
  transform-origin: top;
}
.key-panel.panel-enter {
  animation: panelEnter .3s cubic-bezier(.4,0,.2,1) forwards;
}
.key-panel.panel-exit {
  animation: panelExit .2s cubic-bezier(.4,0,.2,1) forwards;
}

/* =====================================================
   RESULT SECTION
   ===================================================== */
.result-card { animation: liftIn .45s cubic-bezier(.4,0,.2,1); }

.result-box {
  background: linear-gradient(135deg, rgba(79,70,229,.06), rgba(124,58,237,.06));
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.result-box::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--clr-grad1);
  border-radius: 0 2px 2px 0;
}
.result-box .result-label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--clr-muted);
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}
.result-box .result-label span {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: rgba(99,102,241,.1);
  border-radius: 99px;
  padding: .1rem .6rem;
  border: 1px solid rgba(99,102,241,.15);
}
.result-value {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--clr-primary);
  word-break: break-all;
  letter-spacing: .5px;
}

/* Copy button */
.copy-btn {
  background: rgba(79,70,229,.08);
  border: 1px solid var(--clr-border);
  color: var(--clr-primary);
  border-radius: var(--radius-sm);
  padding: .3rem .7rem;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.copy-btn:hover {
  background: var(--clr-grad1);
  color: white;
  border-color: transparent;
}
.copy-btn.copied {
  background: #059669;
  color: white;
  border-color: transparent;
}

/* =====================================================
   MATRIX TABLES
   ===================================================== */
.matrix-table {
  border-collapse: separate;
  border-spacing: .3rem;
  animation: fadeUp .35s ease;
}
.matrix-table td {
  min-width: 2.8rem;
  height: 2.8rem;
  text-align: center;
  border-radius: var(--radius-sm);
  background: rgba(79,70,229,.09);
  border: 1px solid rgba(79,70,229,.18);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: .9rem;
  transition: var(--transition);
}
.matrix-table td:hover {
  background: rgba(79,70,229,.2);
  transform: scale(1.05);
}
.playfair-table td {
  background: rgba(5,150,105,.1);
  border-color: rgba(5,150,105,.2);
  min-width: 2.4rem;
  height: 2.4rem;
}
.playfair-table td:hover {
  background: rgba(5,150,105,.22);
}

/* =====================================================
   STEPS / CALCULATION LIST
   ===================================================== */
.steps .list-group-item {
  font-family: var(--font-mono);
  font-size: .83rem;
  background: var(--clr-surface2) !important;
  border-color: var(--clr-border2) !important;
  color: var(--clr-text);
  padding: .6rem 1rem;
  transition: var(--transition);
  counter-increment: step-counter;
  animation: stepReveal .3s ease both;
}
.steps .list-group-item:hover {
  background: rgba(79,70,229,.06) !important;
  padding-left: 1.2rem;
}
.steps .list-group-item:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important; }
.steps .list-group-item:last-child  { border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important; }

/* Staggered animation for steps */
.steps .list-group-item:nth-child(1)  { animation-delay: .05s; }
.steps .list-group-item:nth-child(2)  { animation-delay: .10s; }
.steps .list-group-item:nth-child(3)  { animation-delay: .15s; }
.steps .list-group-item:nth-child(4)  { animation-delay: .20s; }
.steps .list-group-item:nth-child(5)  { animation-delay: .25s; }
.steps .list-group-item:nth-child(n+6){ animation-delay: .30s; }

/* =====================================================
   HISTORY TABLE
   ===================================================== */
.table {
  font-size: .875rem;
  color: var(--clr-text);
}
.table thead th {
  font-weight: 700;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--clr-muted);
  border-bottom: 2px solid var(--clr-border) !important;
  padding: .65rem .75rem;
  background: transparent;
}
.table tbody tr {
  transition: var(--transition);
  animation: fadeUp .3s ease both;
}
.table tbody tr:hover { background: rgba(79,70,229,.04) !important; }
.table td {
  padding: .65rem .75rem;
  border-color: var(--clr-border2) !important;
  vertical-align: middle;
}
.table td.fw-semibold { color: var(--clr-primary); font-family: var(--font-mono); font-size: .8rem; }

.btn-outline-danger {
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 600;
  border-color: rgba(220,38,38,.3) !important;
  color: var(--clr-danger) !important;
  transition: var(--transition);
}
.btn-outline-danger:hover {
  background: var(--clr-danger) !important;
  color: white !important;
  border-color: var(--clr-danger) !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(220,38,38,.3);
}

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
  background: linear-gradient(135deg, rgba(79,70,229,.04), rgba(124,58,237,.04));
  border: 2px dashed var(--clr-border);
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
}
.empty-state .empty-icon {
  font-size: 2.8rem;
  display: block;
  margin-bottom: .75rem;
  animation: pulse 2.5s ease-in-out infinite;
}

/* =====================================================
   FLASH ALERTS
   ===================================================== */
.alert {
  border-radius: var(--radius-md) !important;
  border: 1px solid transparent !important;
  font-size: .9rem;
  animation: alertSlide .35s cubic-bezier(.4,0,.2,1);
}
.alert-danger  { background: rgba(220,38,38,.08) !important; border-color: rgba(220,38,38,.2) !important; color: #b91c1c !important; }
.alert-success { background: rgba(5,150,105,.08) !important; border-color: rgba(5,150,105,.2) !important; color: #065f46 !important; }
[data-bs-theme="dark"] .alert-danger  { color: #fca5a5 !important; }
[data-bs-theme="dark"] .alert-success { color: #6ee7b7 !important; }

/* =====================================================
   PROGRESS / LOADING OVERLAY
   ===================================================== */
#loadingOverlay {
  position: fixed;
  inset: 0;
  background: rgba(13,15,26,.45);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
#loadingOverlay.show {
  opacity: 1;
  pointer-events: all;
}
.loading-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 2rem 3rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: popIn .3s cubic-bezier(.34,1.56,.64,1);
}
.loading-ring {
  width: 52px; height: 52px;
  border: 4px solid var(--clr-border);
  border-top-color: var(--clr-primary);
  border-right-color: var(--clr-accent);
  border-radius: 50%;
  animation: spin .8s cubic-bezier(.4,0,.2,1) infinite;
  margin: 0 auto .9rem;
}
.loading-text {
  font-weight: 600;
  font-size: .92rem;
  color: var(--clr-muted);
  animation: pulse 1.5s ease-in-out infinite;
}

/* =====================================================
   SCROLL TO TOP
   ===================================================== */
#scrollTop {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--clr-grad1);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(12px);
  transition: var(--transition);
  pointer-events: none;
  z-index: 500;
}
#scrollTop.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}
#scrollTop:hover { transform: translateY(-3px) scale(1.08); box-shadow: var(--shadow-lg); }

/* =====================================================
   TOOLTIP
   ===================================================== */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(.9);
  background: var(--clr-text);
  color: var(--clr-surface);
  font-size: .74rem;
  font-weight: 500;
  padding: .3rem .7rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
  z-index: 100;
}
[data-tooltip]:hover::after { opacity: 1; transform: translateX(-50%) scale(1); }

/* =====================================================
   KEYFRAMES
   ===================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes liftIn {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes panelEnter {
  from { opacity: 0; transform: translateY(-8px) scaleY(.95); }
  to   { opacity: 1; transform: translateY(0) scaleY(1); }
}
@keyframes panelExit {
  from { opacity: 1; transform: translateY(0) scaleY(1); }
  to   { opacity: 0; transform: translateY(-6px) scaleY(.95); }
}
@keyframes stepReveal {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes alertSlide {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.85); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes orbFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50%       { transform: translateY(-18px) scale(1.05); }
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
  .card-body { padding: 1.25rem !important; }
  .result-value { font-size: 1rem; }
  .hero { padding: 1.5rem !important; }
}
