/* ==========================================================================
   StalingScan — Design System (Dark Cyber-Fintech & Glassmorphism)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg-dark: #0a0e17;
  --bg-card: rgba(16, 24, 39, 0.75);
  --bg-card-hover: rgba(23, 33, 53, 0.85);
  --bg-surface: #111827;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(56, 189, 248, 0.5);

  /* Couleurs de statut */
  --status-active: #10b981;     /* 🟢 Vert */
  --status-active-glow: rgba(16, 185, 129, 0.3);
  --status-pending: #f59e0b;    /* 🟠 Orange / Cooldown */
  --status-pending-glow: rgba(245, 158, 11, 0.3);
  --status-completed: #3b82f6;  /* 🔵 Bleu / Terminé */
  --status-completed-glow: rgba(59, 130, 246, 0.35);
  --status-error: #ef4444;      /* 🔴 Rouge */
  --status-error-glow: rgba(239, 68, 68, 0.3);

  /* Accents */
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-blue: #3b82f6;
  --gradient-primary: linear-gradient(135deg, #06b6d4 0%, #3b82f6 50%, #8b5cf6 100%);
  --gradient-glow: linear-gradient(135deg, rgba(6, 182, 212, 0.2) 0%, rgba(59, 130, 246, 0.2) 100%);

  /* Typographie */
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(6, 182, 212, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(139, 92, 246, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Scrollbar moderne */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 60px 24px;
}

/* Top Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.35);
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 11px;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  border: 1px solid var(--border-color);
}

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-main);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  user-select: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* Cartes Glassmorphism */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* Zone d'entrée de Wallet */
.search-hero {
  text-align: center;
  padding: 40px 20px 30px;
}

.search-hero h2 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.search-hero p {
  color: var(--text-muted);
  font-size: 16px;
  max-width: 600px;
  margin: 0 auto 30px;
}

.input-box-wrapper {
  position: relative;
  max-width: 780px;
  margin: 0 auto;
}

.input-row {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 8px 10px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
  transition: all 0.25s;
}

.input-row:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 25px rgba(6, 182, 212, 0.25);
}

.wallet-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 12px 16px;
  outline: none;
}

.wallet-input::placeholder {
  color: var(--text-dim);
  font-family: var(--font-main);
}

.chain-badge-auto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  margin-right: 8px;
  white-space: nowrap;
}

/* Statuts & Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* Statut 🟠 En Staking / Cooldown */
.status-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.status-pending .status-dot {
  background: #f59e0b;
  box-shadow: 0 0 10px #f59e0b;
  animation: pulse-dot 1.8s infinite;
}

/* Statut 🟢 Actif / Déverrouillage proche */
.status-active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.status-active .status-dot {
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: pulse-dot 1.5s infinite;
}

/* Statut 🔵 Terminé / Transférable */
.status-completed {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}
.status-completed .status-dot {
  background: #3b82f6;
  box-shadow: 0 0 12px #3b82f6;
}

/* Statut 🔴 Erreur */
.status-error {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.status-error .status-dot {
  background: #ef4444;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Résumé Global Wallet */
.wallet-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}

.metric-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.metric-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Cartes de Tokens en Staking */
.tokens-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.tokens-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.token-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 16px;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}

.token-card.unlocked {
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 0 25px rgba(59, 130, 246, 0.15);
  background: rgba(15, 23, 42, 0.85);
}

.token-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.token-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.token-symbol-badge {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: var(--accent-cyan);
}

.token-name-group h4 {
  font-size: 18px;
  font-weight: 700;
}

.token-name-group .protocol-tag {
  font-size: 12px;
  color: var(--text-muted);
}

.token-amounts {
  text-align: right;
}

.token-amount-crypto {
  font-size: 20px;
  font-weight: 800;
  font-family: var(--font-mono);
}

.token-amount-usd {
  font-size: 14px;
  color: var(--accent-cyan);
  font-weight: 600;
}

/* --- BANDEAU GÉANT DE FIN DE STAKING (BIEN VISIBLE !) --- */
.countdown-banner {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.countdown-banner.completed {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.35);
}

.countdown-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.countdown-icon {
  font-size: 28px;
}

.countdown-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.countdown-timer-digits {
  font-size: 26px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: #fbbf24;
  letter-spacing: 1px;
}

.countdown-banner.completed .countdown-timer-digits {
  color: #60a5fa;
}

.countdown-date-box {
  text-align: right;
}

.countdown-date-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.countdown-date-exact {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 999px;
  transition: width 0.5s ease-out;
}

/* Tableau Historique */
.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.history-table th {
  padding: 12px 16px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
}

.history-table td {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.history-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.wallet-badge-mono {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-main);
}

/* Formulaires Admin */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--accent-cyan);
}

.form-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 5px;
}

/* Switch Toggle */
.switch-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-blue);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Console de Logs */
.log-terminal {
  background: #030712;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  height: 280px;
  overflow-y: auto;
  line-height: 1.6;
}

.log-entry {
  display: flex;
  gap: 10px;
  padding: 2px 0;
}

.log-time { color: var(--text-dim); }
.log-level { font-weight: 700; width: 60px; }
.log-level.INFO { color: var(--accent-cyan); }
.log-level.WARN { color: var(--status-pending); }
.log-level.ERROR { color: var(--status-error); }
.log-level.TELEGRAM { color: #38bdf8; }
.log-msg { color: var(--text-main); word-break: break-all; }

/* Alert Box */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* Animations */
@keyframes flash-celebrate {
  0% { box-shadow: 0 0 0 rgba(59, 130, 246, 0); }
  50% { box-shadow: 0 0 40px rgba(59, 130, 246, 0.8); }
  100% { box-shadow: 0 0 10px rgba(59, 130, 246, 0.3); }
}

.flash-active {
  animation: flash-celebrate 1.5s ease-out;
}


/* ==========================================================================
   Modale Dérivation Sécurisée (Noble Secp256k1 & BIP39)
   ========================================================================== */
#deriveDialog {
  width: min(960px, 94vw);
  height: 90vh;
  max-height: 90vh;
  margin: auto;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: #0f1218;
  color: #dde4ee;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 1px 1px rgba(255, 255, 255, 0.08);
}

#deriveDialog::backdrop {
  background: rgba(5, 8, 15, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.derive-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: #141a24;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
}

.derive-head strong {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
}

.derive-framebox {
  width: 100%;
  height: calc(90vh - 51px);
  background: #0f1218;
  position: relative;
}

.derive-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0f1218;
}

@media (max-width: 640px) {
  #deriveDialog {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  .derive-framebox {
    height: calc(100vh - 51px);
  }
}
