/* Jade Auth — Login/Signup UI */

/* ── Magic SDK iframe fix ──
   The SDK creates an iframe with display:none/opacity:0/z-index:-1
   and should toggle it visible when the OTP modal appears, but doesn't
   in our context. The JS MutationObserver handles the active toggle,
   and this CSS provides a safety net via body class. */
body.magic-login-active iframe.magic-iframe {
  display: flex !important;
  opacity: 1 !important;
  z-index: 99999 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  background: rgba(0,0,0,0.5) !important;
}

/* ── Sidebar button (compact icon) ── */
.auth-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.auth-btn svg {
  width: 22px;
  height: 22px;
}

.auth-btn--disconnected {
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary, rgba(255,255,255,0.5));
}

.auth-btn--disconnected:hover {
  background: rgba(0,255,135,0.1);
  color: var(--green-bright, #00FF87);
  transform: translateY(-1px);
}

.auth-btn--connected {
  background: rgba(0,255,135,0.1);
  color: var(--green-bright, #00FF87);
  border: 1px solid rgba(0,255,135,0.2);
}

.auth-btn--connected:hover {
  background: rgba(0,255,135,0.15);
}

/* ── Dropdown panel (position:fixed to escape stacking context) ── */
.auth-dropdown {
  position: fixed;
  width: 320px;
  background: var(--bg-card, #141414);
  border: 1px solid var(--border-default, rgba(255,255,255,0.1));
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
  z-index: 10000;
  display: none;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.auth-dropdown.auth-dropdown--visible {
  display: block;
  opacity: 1;
  transform: translateX(0);
}

.auth-dropdown::before {
  content: '';
  position: absolute;
  left: -8px;
  bottom: 18px;
  width: 8px;
  height: 8px;
  background: var(--bg-card, #141414);
  border-left: 1px solid var(--border-default, rgba(255,255,255,0.1));
  border-bottom: 1px solid var(--border-default, rgba(255,255,255,0.1));
  transform: rotate(45deg);
}

/* ── Login form inside dropdown ── */
[data-jade-auth] {
  font-family: 'Inter', -apple-system, sans-serif;
}

.jade-auth-login {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.jade-auth-login .jade-auth-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #fff);
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.jade-auth-login .jade-auth-subtitle {
  font-size: 12px;
  color: var(--text-muted, rgba(255,255,255,0.4));
  margin: 0 0 8px;
}

.jade-auth-email-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.jade-email-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-default, rgba(255,255,255,0.1));
  background: var(--bg-base, #0d0d0d);
  color: var(--text-primary, #fff);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.jade-email-input:focus {
  border-color: var(--green-bright, #00FF87);
}

.jade-email-input::placeholder {
  color: var(--text-muted, rgba(255,255,255,0.3));
}

.jade-auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  width: 100%;
}

.jade-auth-btn--email {
  background: var(--green-bright, #00FF87);
  color: #000;
}

.jade-auth-btn--email:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.jade-auth-btn--metamask {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary, #fff);
  border: 1px solid var(--border-default, rgba(255,255,255,0.1));
}

.jade-auth-btn--metamask:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  transform: translateY(-1px);
}

.jade-auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted, rgba(255,255,255,0.3));
  font-size: 12px;
  margin: 4px 0;
}

.jade-auth-divider::before,
.jade-auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-default, rgba(255,255,255,0.08));
}

/* ── Logged in state (inside dropdown) ── */
.jade-auth-logged-in {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.jade-auth-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(0,255,135,0.06);
  border: 1px solid rgba(0,255,135,0.15);
  border-radius: 10px;
}

.jade-auth-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(0,255,135,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--green-bright, #00FF87);
}

.jade-auth-user-info {
  flex: 1;
  min-width: 0;
}

.jade-auth-email {
  font-size: 13px;
  font-weight: 600;
  color: var(--green-bright, #00FF87);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jade-auth-address {
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  color: var(--text-muted, rgba(255,255,255,0.4));
  display: block;
}

/* ── Action buttons row ── */
.jade-auth-actions {
  display: flex;
  gap: 6px;
}

.jade-auth-copy-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-default, rgba(255,255,255,0.1));
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary, rgba(255,255,255,0.6));
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.jade-auth-copy-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary, #fff);
}

.jade-auth-btn--key {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(251,191,36,0.2);
  background: rgba(251,191,36,0.08);
  color: #fbbf24;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.jade-auth-btn--key:hover {
  background: rgba(251,191,36,0.15);
  border-color: rgba(251,191,36,0.35);
}

.jade-auth-logout {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary, rgba(255,255,255,0.6));
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  text-align: center;
}

.jade-auth-logout:hover {
  background: rgba(239,68,68,0.15);
  color: #ef4444;
}

/* ── Close on outside click backdrop ── */
.auth-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

/* ── Responsive: mobile header dropdown ── */
@media (max-width: 640px) {
  .auth-dropdown {
    width: calc(100% - 32px);
    left: 16px;
    right: 16px;
  }

  .auth-dropdown::before {
    display: none;
  }
}


/* ── Mobile Header (≤640px) ── */
.mobile-header {
  display: none;
}

@media (max-width: 640px) {
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 25;
    height: 52px;
  }

  .mobile-header__logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--green-bright);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.02em;
    text-decoration: none;
  }

  .mobile-header__logo svg {
    width: 24px;
    height: 24px;
  }

  .mobile-header__auth {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
  }

  .mobile-header__auth svg {
    width: 20px;
    height: 20px;
  }

  .mobile-header__auth:hover {
    background: rgba(0,255,135,0.1);
    color: var(--green-bright);
  }

  .mobile-header__auth--connected {
    background: rgba(0,255,135,0.1);
    color: var(--green-bright);
    border: 1px solid rgba(0,255,135,0.2);
  }
}

/* ============================================
   Jade — Profile Setup Modal
   ============================================ */

/* ── Backdrop ── */
.jade-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: jadeModalFadeIn 0.2s ease-out;
}

@keyframes jadeModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Modal ── */
.jade-profile-modal {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 255, 135, 0.05);
  animation: jadeModalSlideIn 0.25s ease-out;
}

@keyframes jadeModalSlideIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ── */
.jade-profile-modal__header {
  padding: 24px 24px 0 24px;
}

.jade-profile-modal__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary, #fafafa);
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.jade-profile-modal__subtitle {
  font-size: 13px;
  color: var(--text-muted, #898989);
  margin: 0;
}

/* ── Body / Fields ── */
.jade-profile-modal__body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.jade-profile-modal__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #b4b4b4);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: -8px;
}

.jade-profile-modal__input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid #2a2a2a;
  background: #0d0d0d;
  color: var(--text-primary, #fafafa);
  font-size: 14px;
  font-family: 'Inter', -apple-system, sans-serif;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.jade-profile-modal__input:focus {
  border-color: #00FF87;
  box-shadow: 0 0 0 3px rgba(0, 255, 135, 0.1);
}

.jade-profile-modal__input::placeholder {
  color: var(--text-faint, #5a5a5a);
}

.jade-profile-modal__input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  background: #0d0d0d;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.jade-profile-modal__input-wrap:focus-within {
  border-color: #00FF87;
  box-shadow: 0 0 0 3px rgba(0, 255, 135, 0.1);
}

.jade-profile-modal__input-prefix {
  padding: 0 0 0 14px;
  font-size: 14px;
  color: var(--text-muted, #898989);
  font-weight: 600;
  user-select: none;
  flex-shrink: 0;
}

.jade-profile-modal__input--prefixed {
  border: none;
  background: transparent;
  border-radius: 0;
  padding-left: 4px;
}

.jade-profile-modal__input--prefixed:focus {
  border: none;
  box-shadow: none;
}

.jade-profile-modal__textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid #2a2a2a;
  background: #0d0d0d;
  color: var(--text-primary, #fafafa);
  font-size: 14px;
  font-family: 'Inter', -apple-system, sans-serif;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  resize: vertical;
  min-height: 80px;
  max-height: 160px;
}

.jade-profile-modal__textarea:focus {
  border-color: #00FF87;
  box-shadow: 0 0 0 3px rgba(0, 255, 135, 0.1);
}

.jade-profile-modal__textarea::placeholder {
  color: var(--text-faint, #5a5a5a);
}

.jade-profile-modal__hint {
  font-size: 11px;
  color: var(--text-faint, #5a5a5a);
  margin-top: -10px;
}

.jade-profile-modal__error {
  font-size: 12px;
  color: var(--red-error, #f3727f);
  margin-top: -10px;
  min-height: 0;
}

/* ── Footer / Save Button ── */
.jade-profile-modal__footer {
  padding: 0 24px 24px 24px;
}

.jade-profile-modal__save {
  width: 100%;
  padding: 12px 20px;
  border-radius: 10px;
  border: none;
  background: #00FF87;
  color: #0a0a0a;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Inter', -apple-system, sans-serif;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: -0.01em;
}

.jade-profile-modal__save:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(0, 255, 135, 0.2);
}

.jade-profile-modal__save:active {
  transform: translateY(0);
}

/* ── Toast notification ── */
.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card, #1a1a1a);
  border: 1px solid rgba(0, 255, 135, 0.2);
  border-radius: 10px;
  color: var(--green-bright, #00FF87);
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', -apple-system, sans-serif;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--success {
  border-color: rgba(0, 255, 135, 0.25);
}

.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-bar-height, 56px) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

