/* Purchase modal: staking contract & trading bot — desktop + phones */

/* One tap: staking modal opens from tier cards — hide footer CTA (JS also sets inline display for WebView caches) */
#staking-cabinet.staking-cabinet--tap-to-purchase .staking-footer-cta,
#staking-cabinet.staking-cabinet--tap-to-purchase #staking-footer-cta {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  max-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
  border: none !important;
}

.modal.modal-purchase-detail {
  max-width: 560px;
  width: min(100%, calc(100dvw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 1.25rem));
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 1rem);
  display: flex;
  flex-direction: column;
  margin: auto;
  overflow: hidden;
}

.modal-overlay.modal-overlay-purchase-detail {
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 103620;
  pointer-events: auto;
}

.modal-overlay.modal-overlay-purchase-detail .modal {
  pointer-events: auto;
}

.modal.modal-purchase-detail .modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.9rem 1rem 1rem;
}

.modal.modal-purchase-detail .modal-header {
  flex-shrink: 0;
  padding: 0.85rem 1rem;
}

.modal.modal-purchase-detail .modal-title {
  font-size: 1.05rem;
  line-height: 1.3;
  padding-right: 0.5rem;
}

.modal.modal-purchase-detail .modal-footer {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: stretch;
  padding: 0.75rem 0.9rem 0.9rem;
  border-top: 1px solid var(--glass-border, var(--border-subtle));
}

.modal.modal-purchase-detail .modal-footer .btn {
  flex: 1 1 auto;
  min-height: 48px;
  font-size: 0.95rem;
  padding: 0.65rem 1rem;
}

.purchase-modal-inner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.purchase-modal-summary,
.purchase-modal-calc {
  padding: 0.9rem 0.95rem;
  border-radius: var(--radius-lg, 12px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(24, 12, 22, 0.9);
}

.purchase-modal-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.4rem 0;
  font-size: 0.86rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.purchase-modal-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.purchase-modal-row span {
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
}

.purchase-modal-row strong {
  color: var(--text-primary);
  text-align: right;
  white-space: nowrap;
}

.purchase-modal-calc-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--accent-pink);
}

.purchase-modal-calc-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 0.45rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.purchase-modal-calc-highlight {
  padding-top: 0.35rem;
  margin-top: 0.35rem;
  border-top: 1px dashed var(--glass-border, rgba(255, 255, 255, 0.12));
}

.purchase-modal-calc-value {
  color: var(--accent-pink);
  font-size: 1rem;
}

.purchase-modal-calc-hint {
  margin: 0.5rem 0 0;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.purchase-modal-notes {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.8rem;
  color: rgba(240, 230, 232, 0.86);
  line-height: 1.5;
}

.purchase-modal-notes li {
  margin-bottom: 0.4rem;
}

.purchase-modal-bot-desc {
  margin: 0;
  font-size: 0.84rem;
  color: rgba(240, 230, 232, 0.9);
  line-height: 1.55;
}

@media (max-height: 820px) {
  .modal.modal-purchase-detail {
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 0.5rem);
  }

  .modal.modal-purchase-detail .modal-body {
    padding: 0.75rem 0.85rem 0.85rem;
  }

  .purchase-modal-inner {
    gap: 0.75rem;
  }

  .purchase-modal-summary,
  .purchase-modal-calc {
    padding: 0.75rem 0.8rem;
  }

  .purchase-modal-row {
    font-size: 0.82rem;
    padding: 0.34rem 0;
  }
}

/* Phones: purchase detail — центр экрана; иначе #modal-root .modal-overlay из mobile.css даёт flex-end и модалку не видно */
@media (max-width: 768px) {
  #modal-root .modal-overlay.modal-overlay-purchase-detail {
    align-items: center !important;
    justify-content: center !important;
  }
}

/* Phones: модалка целиком в зоне видимости, при необходимости скролл внутри тела */
@media (max-width: 768px) {
  .modal-overlay {
    align-items: flex-end;
    justify-content: center;
    padding:
      max(0.75rem, env(safe-area-inset-top, 0px))
      max(0.65rem, env(safe-area-inset-right, 0px))
      calc(96px + env(safe-area-inset-bottom, 0px) + 0.75rem)
      max(0.65rem, env(safe-area-inset-left, 0px));
  }

  .modal.modal-purchase-detail {
    width: calc(100vw - 1.25rem);
    max-width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 96px - env(safe-area-inset-bottom, 0px) - 1.5rem);
    margin: 0 auto;
    border-radius: 24px 24px 20px 20px;
  }

  .modal.modal-purchase-detail .modal-footer {
    flex-direction: column;
  }

  .modal.modal-purchase-detail .modal-footer .btn {
    width: 100%;
  }

  .purchase-modal-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }

  .purchase-modal-row strong {
    text-align: left;
  }

  .purchase-modal-calc-line {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Safe area iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .modal.modal-purchase-detail .modal-footer {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}

/* Staking — early withdrawal confirmation */
.modal.modal-staking-early .modal-body {
  max-width: 26rem;
}

.staking-early-modal-inner {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  text-align: left;
}

.staking-early-modal-lead {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.staking-early-modal-phase {
  margin: 0;
  font-size: 0.9rem;
  color: var(--accent-pink);
  font-weight: 600;
}

.staking-early-modal-payout {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
  margin: 0.15rem 0 0.85rem;
  padding: 1rem 1rem 1.05rem;
  border-radius: 14px;
  background: linear-gradient(165deg, rgba(46, 213, 115, 0.14), rgba(18, 10, 22, 0.92));
  border: 1px solid rgba(46, 213, 115, 0.45);
  box-shadow:
    0 0 0 1px rgba(46, 213, 115, 0.12),
    0 8px 28px rgba(0, 0, 0, 0.35);
}

.staking-early-modal-payout-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(167, 243, 200, 0.9);
}

.staking-early-modal-payout-value {
  font-size: 1.85rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: #ecfdf5;
  text-shadow: 0 0 20px rgba(52, 211, 153, 0.35);
  line-height: 1.15;
}

.staking-early-modal-payout-note {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-secondary);
  max-width: 22rem;
}

.staking-early-modal-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.staking-early-modal-list li + li {
  margin-top: 0.45rem;
}

.staking-early-modal-check {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-top: 0.25rem;
  cursor: pointer;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-primary);
}

.staking-early-modal-checkbox {
  margin-top: 0.2rem;
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  accent-color: var(--accent-crimson);
  cursor: pointer;
}

.modal.modal-staking-early .modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
  padding-top: 1rem;
}

.modal.modal-staking-early .modal-footer .staking-early-modal-confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

@media (max-width: 480px) {
  .staking-early-modal-payout {
    padding: 0.85rem 0.75rem;
  }

  .staking-early-modal-payout-value {
    font-size: 1.45rem;
  }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .modal.modal-staking-early .modal-footer {
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  }
}
