/* ═══════════════════════════════════════════════════════════════════════════
   hop.decker.im — Components Stylesheet
   Modals, dropdowns, toasts, token lists, transaction status
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Modal Overlay ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.15s ease-out;
}

.modal-overlay.hidden { display: none !important; }

.modal {
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-modal);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: scaleIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
}

/* ── Search Input ─────────────────────────────────────────────────────────── */
.search-wrapper {
  position: relative;
  margin-bottom: var(--space-3);
}

.search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: var(--space-3) var(--space-3) var(--space-3) calc(var(--space-3) * 2 + 16px);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.search-input:focus {
  border-color: var(--border-primary);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.08);
}

.search-input::placeholder { color: var(--text-tertiary); }

/* ── Chain Grid ───────────────────────────────────────────────────────────── */
.chain-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.chain-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  cursor: pointer;
  transition: all var(--transition-fast);
  aspect-ratio: 1;
  overflow: hidden;
}

.chain-btn:hover {
  border-color: var(--border-primary);
  background: rgba(124, 92, 252, 0.08);
  transform: translateY(-1px);
}

.chain-btn.active {
  border-color: var(--color-primary);
  background: rgba(124, 92, 252, 0.15);
  box-shadow: 0 0 12px rgba(124, 92, 252, 0.2);
}

.chain-btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.chain-btn-more {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary-light);
  letter-spacing: 0.3px;
}

/* Expanded network selector: search + named list instead of the icon grid */
.chain-grid-expanded {
  display: flex;
  flex-direction: column;
}

.chain-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chain-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

.chain-row:hover { background: var(--bg-surface-hover); }

.chain-row.active { background: rgba(124, 92, 252, 0.15); }

.chain-row-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-elevated);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chain-row-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chain-row-placeholder {
  font-size: 11px;
  color: var(--text-secondary);
}

.chain-show-less {
  margin-top: var(--space-2);
  padding: var(--space-2);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.chain-show-less:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.chain-btn-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* ── Token List ───────────────────────────────────────────────────────────── */
.token-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
}

.token-list-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: var(--space-2) var(--space-2);
  margin-top: var(--space-2);
}

.token-list-loading,
.token-list-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  font-size: 14px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

.token-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: inherit;
}

.token-item:hover { background: var(--bg-surface-hover); }
.token-item.selected { background: rgba(124, 92, 252, 0.1); }

.token-item-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-elevated);
  flex-shrink: 0;
  position: relative;
}

.token-item-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.token-item-icon-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-surface));
  border-radius: 50%;
}

.token-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.token-item-symbol {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.token-item-name {
  font-size: 12px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.token-item-price {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ── Wallet Modal ─────────────────────────────────────────────────────────── */
.wallet-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.wallet-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 100%;
  text-align: left;
  color: inherit;
}

.wallet-item:hover {
  border-color: var(--border-primary);
  background: rgba(124, 92, 252, 0.08);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.wallet-item-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.wallet-item-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wallet-item-icon-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-surface));
}

.wallet-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.wallet-item-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.wallet-item-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wallet-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-tertiary);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.wallet-badge-qr {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(59, 153, 252, 0.12);
  color: #3B99FC;
  border-color: rgba(59, 153, 252, 0.3);
}

.wallet-item-arrow {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* ── Toast Notifications ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-modal);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 400px;
  pointer-events: all;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s, transform 0.3s;
}

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

.toast.toast-hiding {
  opacity: 0;
  transform: translateX(20px);
}

.toast-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  min-width: 0;
}

.toast-close {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
  transition: color var(--transition-fast);
  border: none;
}

.toast-close:hover { color: var(--text-primary); }

/* Toast type colors */
.toast-success { border-color: rgba(34, 197, 94, 0.3); }
.toast-success .toast-icon { background: rgba(34, 197, 94, 0.2); color: var(--color-success); }

.toast-error { border-color: rgba(239, 68, 68, 0.3); }
.toast-error .toast-icon { background: rgba(239, 68, 68, 0.2); color: var(--color-error); }

.toast-warning { border-color: rgba(245, 158, 11, 0.3); }
.toast-warning .toast-icon { background: rgba(245, 158, 11, 0.2); color: var(--color-warning); }

.toast-info { border-color: rgba(59, 130, 246, 0.3); }
.toast-info .toast-icon { background: rgba(59, 130, 246, 0.2); color: var(--color-info); }

/* ── Transaction Status ───────────────────────────────────────────────────── */
.tx-status-card {
  padding: var(--space-5);
  text-align: center;
}

.tx-status-message {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-input);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.tx-amount {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-success);
  margin: var(--space-3) 0;
}

.tx-links {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

.tx-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-primary-light);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
  text-decoration: none;
}

.tx-link:hover {
  background: rgba(124, 92, 252, 0.1);
  color: var(--color-primary);
}

/* ── Settings Panel ───────────────────────────────────────────────────────── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.settings-row:last-child { border-bottom: none; }

.settings-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.slippage-options {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

.slippage-btn {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.slippage-btn:hover,
.slippage-btn.active {
  background: rgba(124, 92, 252, 0.15);
  border-color: var(--color-primary);
  color: var(--color-primary-light);
}

.slippage-custom {
  width: 70px;
  padding: 4px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-primary);
  text-align: center;
  transition: border-color var(--transition-fast);
}

.slippage-custom:focus {
  border-color: var(--border-primary);
  outline: none;
}

/* ── Rotating animation for swap direction ────────────────────────────────── */
@keyframes rotate-once {
  from { transform: rotate(0deg); }
  to   { transform: rotate(180deg); }
}

.rotating {
  animation: rotate-once 0.3s ease-in-out forwards;
}

/* ── Tooltip ──────────────────────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: rgba(20, 20, 30, 0.95);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: var(--z-tooltip);
}

[data-tooltip]:hover::after { opacity: 1; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .toast-container {
    bottom: var(--space-4);
    right: var(--space-4);
    left: var(--space-4);
  }
  .toast { min-width: unset; }
  .chain-grid { grid-template-columns: repeat(4, 1fr); }
}
