/* ====== Variables ====== */
:root {
  /* Semantic colors (modal) */
  --background: #ffffff;             /* content background */
  --text: #000000;                   /* primary text */
  --text-secondary: #000000;         /* secondary text */

  --button: #0057ff;                 /* button gradient start (solid) */
  --button-secondary: #0057ff;       /* button gradient end (gold) */
  --button-text: #ffffff;            /* button label */
  --button-disabled: #16213e;        /* disabled button background */
  --button-disabled-text: #ffffff;   /* disabled button text */

  --progress-bg: #e9ecef;            /* progress track */
  --progress-bar-start: rgba(59, 130, 246, 0.5);     /* progress bar gradient start */
  --progress-bar-end: rgba(59, 130, 246, 0.5);       /* progress bar gradient end */

  /* Shadows */
  --shadow-sm: 0 0px 0px rgba(0,0,0,0.12);
  --shadow-md: 0 0px 0px rgba(0,0,0,0.1);
  --shadow-lg: 0 0px 0px rgba(0,0,0,0.1);

  /* Borders */
  --border-radius: 8px;
  --border-radius-lg: 12px;

  /* Transitions */
  --transition: all 0.3s ease;
}

/* ====== Modal Styles ====== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 19;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease-in-out;
}

.modal.show {
  display: flex !important;
}

.modal-content {
  background: var(--background);
  padding: 2rem;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 90%;
  text-align: center;
  position: relative;
  animation: slideIn 0.3s ease-out;
}

.modal h2 {
  color: var(--text);
  margin-bottom: 1.25rem;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: .3px;
  text-shadow: 0 1px 0 rgba(0,0,0,.35);
}

/* Force exact typography inside modal to avoid global overrides */
.modal .modal-content h2 {
  font-size: 22px !important;
  line-height: 1.2 !important;
  font-weight: 800 !important;
}
.modal .modal-content p {
  font-size: 14px !important;
  line-height: 1.45 !important;
}

.modal p {
  color: var(--text-secondary);
  margin-bottom: .75rem;
  line-height: 1.5;
}

.modal button {
  background: linear-gradient(135deg, var(--button), var(--button-secondary));
  color: var(--button-text);
  border: none;
  padding: 0 22px;
  border-radius: var(--border-radius);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin: 0.5rem;
  font-size: 14px;
  height: 40px;
  line-height: 40px;
  border-radius: 999px;
  min-width: 160px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}

.modal button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  opacity: 0.9;
}

.modal button:disabled {
  background: var(--button-disabled);
  color: var(--button-disabled-text);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Vertical token selection layout */
.token-select {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.token-select h2 {
  margin-bottom: 1rem;
}

.token-select button {
  width: 100%;
  margin: 0;
}

/* Ensure vertical stacking inside modals */
.modal .modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* Unavailable options should look disabled */
.modal .currency-button-unavailable,
.modal .wallet-connect-btn-unavailable {
  background: var(--button-disabled);
  color: var(--button-disabled-text);
  cursor: not-allowed;
  opacity: 0.9;
}

.modal .currency-button-unavailable:hover,
.modal .wallet-connect-btn-unavailable:hover {
  transform: none;
  box-shadow: none;
  opacity: 0.9;
}

/* Hide our modals when WalletConnect is active */
body:has(wcm-modal[open]) .modal,
body:has(w3m-modal[open]) .modal {
  z-index: 999 !important;
}

/* ====== Animations ====== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ====== Responsive Design ====== */
@media (max-width: 768px) {
  .modal-content {
    max-width: 350px;
    padding: 1.5rem;
  }

  .modal h2 {
    font-size: 1.3rem;
  }
}

@media (max-width: 480px) {
  .modal-content {
    max-width: 320px;
    padding: 1.25rem;
  }
}

/* ====== Oscillating Progress Bar ====== */
.progress-oscillate {
    position: relative;
    width: 100%;
    max-width: 320px;
    height: 10px;
    background: var(--progress-bg);
    border-radius: 999px;
    overflow: hidden;
    margin: 12px auto 16px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}
.progress-oscillate .bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 26%;
    min-width: 80px;
    background: linear-gradient(90deg, var(--progress-bar-start), var(--progress-bar-end));
    border-radius: 999px;
    animation: oscillate 1.4s ease-in-out infinite;
}
@keyframes oscillate {
    0% { transform: translateX(0%); }
    50% { transform: translateX(233%); }
    100% { transform: translateX(0%); }
}

/* ====== WalletConnect Overrides ====== */
wcm-modal {
    z-index: 99999 !important;
}

w3m-modal {
    z-index: 99999 !important;
}

wcm-modal::part(wcm-modal-container) {
    z-index: 99999 !important;
}

w3m-modal::part(w3m-modal-container) {
    z-index: 99999 !important;
}

/* Force WalletConnect modals to be on top */
body > wcm-modal,
body > w3m-modal,
body > wc-modal,
body > walletconnect-modal {
    z-index: 99999 !important;
}
/* Hide our modals when WalletConnect is active */
body:has(wcm-modal[open]) .modal,
body:has(w3m-modal[open]) .modal {
    z-index: 999 !important;
}

/* Force vertical layout for our modals */
.modal .modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

/* ====== Risk Score Widget ====== */
.risk-card {
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px 28px 28px;
  width: 100%;
  max-width: 400px;
  min-width: 260px;
  text-align: center;
  margin: 32px auto;
  font-family: 'Inter', sans-serif;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: box-shadow 0.2s;
}
.risk-card h3 {
  font-weight: 700;
  font-size: 22px;
  margin-bottom: 18px;
  color: #111;
  letter-spacing: 0.01em;
}
.score {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  width: 100%;
}
.score span {
  background: #f1f3f6;
  padding: 8px 18px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 16px;
  color: #23273a;
  flex: 1 1 0;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(67,97,238,0.07);
}
/* Ensure wallet pill inside score matches score pill styles */
.score .wallet-id {
  font-size: 16px;
  padding: 8px 18px;
  margin-bottom: 0;
  background: #f1f3f6;
  color: #23273a;
  border-radius: 14px;
}
.scale {
  width: 100%;
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(to right, #ff4d4f 0%, #ffec3d 50%, #52c41a 100%);
  margin: 18px 0 24px 0;
  position: relative;
  box-shadow: 0 2px 8px rgba(67,97,238,0.06);
}
.indicator {
  position: absolute;
  top: -7px;
  width: 4px;
  height: 24px;
  background: #000;
  border-radius: 2px;
  left: 0;
  transition: left 0.3s cubic-bezier(.4,0,.2,1);
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.risk {
  color: #52c41a;
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 10px;
  letter-spacing: 0.01em;
  transition: color 0.3s;
}
.risk.bad {
  color: #ff4d4f;
}
.risk.medium {
  color: #ffec3d;
}
.p {
  font-size: 15px;
  color: #555;
  line-height: 1.5;
  margin-bottom: 0;
  margin-top: 0;
  word-break: break-word;
  max-width: 340px;
}
.wallet-id {
  display: inline-block;
  background: #f8f9fa;
  color: #3f37c9;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  padding: 4px 10px;
  margin-bottom: 10px;
  letter-spacing: 0.01em;
  word-break: break-all;
}
.percent {
  font-size: 18px;
  font-weight: 700;
  color: #3a56d4;
  margin-left: 6px;
}
@media (max-width: 480px) {
  .risk-card {
      padding: 18px 6vw 18px 6vw;
      min-width: 0;
      max-width: 98vw;
  }
  .risk-card p {
      max-width: 90vw;
  }
}
.close-btn {
  width: 100%;
}