/* ============================================================================
   Shield Swap - Production UI Styles
   Inspired by: Uniswap, Jupiter, 1inch
   ============================================================================ */

/* ============================================================================
   CSS Variables
   ============================================================================ */
:root {
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  --shadow-glow-accent: 0 0 40px rgba(240, 138, 60, 0.15);
  --shadow-glow-gold: 0 0 40px rgba(245, 158, 11, 0.1);
  --shadow-card: 0 25px 50px -12px rgba(0, 0, 0, 0.5);

  --border-subtle: 1px solid rgba(255, 255, 255, 0.06);
  --border-hover: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================================================
   Base Styles
   ============================================================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  background: #09090B;
  color: #FAFAFA;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================================================
   Background Grid
   ============================================================================ */
.grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 50% at 50% 0%, black 70%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 50% at 50% 0%, black 70%, transparent 100%);
}

/* ============================================================================
   Wallet Button
   ============================================================================ */
.wallet-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: linear-gradient(135deg, rgba(240, 138, 60, 0.15), rgba(240, 138, 60, 0.05));
  border: 1px solid rgba(240, 138, 60, 0.3);
  border-radius: 0.75rem;
  color: #FAFAFA;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.wallet-btn:hover {
  background: linear-gradient(135deg, rgba(240, 138, 60, 0.25), rgba(240, 138, 60, 0.1));
  border-color: rgba(240, 138, 60, 0.5);
  box-shadow: 0 0 20px rgba(240, 138, 60, 0.2);
}

.wallet-btn.connected {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.05));
  border-color: rgba(34, 197, 94, 0.3);
}

.wallet-btn.connected:hover {
  border-color: rgba(34, 197, 94, 0.5);
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.15);
}

/* ============================================================================
   Icon Button
   ============================================================================ */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  background: rgba(255, 255, 255, 0.05);
  border: var(--border-subtle);
  border-radius: 0.625rem;
  color: #A1A1AA;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FAFAFA;
  border-color: rgba(255, 255, 255, 0.15);
}

/* ============================================================================
   Swap Card
   ============================================================================ */
.swap-card {
  position: relative;
  background: linear-gradient(180deg, rgba(24, 24, 27, 0.95) 0%, rgba(24, 24, 27, 0.85) 100%);
  border: var(--border-subtle);
  border-radius: 1.25rem;
  padding: 1.25rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card), var(--shadow-glow-accent);
}

.swap-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 1.25rem;
  padding: 1px;
  background: linear-gradient(180deg, rgba(240, 138, 60, 0.2) 0%, transparent 50%, rgba(245, 158, 11, 0.1) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ============================================================================
   Settings Panel
   ============================================================================ */
.settings-panel {
  background: rgba(39, 39, 42, 0.5);
  border: var(--border-subtle);
  border-radius: 0.875rem;
  padding: 1rem;
  margin-bottom: 1rem;
  animation: slideUp var(--transition-normal);
}

.slippage-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: var(--border-subtle);
  border-radius: 0.5rem;
  color: #A1A1AA;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.slippage-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FAFAFA;
}

.slippage-btn.active {
  background: rgba(240, 138, 60, 0.2);
  border-color: rgba(240, 138, 60, 0.4);
  color: #f5a060;
}

.slippage-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: var(--border-subtle);
  border-radius: 0.5rem;
  padding: 0.5rem 1.75rem 0.5rem 0.75rem;
  color: #FAFAFA;
  font-size: 0.875rem;
  outline: none;
  transition: all var(--transition-fast);
}

.slippage-input:focus {
  border-color: rgba(240, 138, 60, 0.4);
  background: rgba(240, 138, 60, 0.1);
}

.slippage-input::placeholder {
  color: #52525B;
}

/* ============================================================================
   Token Input Container
   ============================================================================ */
.token-input-container {
  background: rgba(9, 9, 11, 0.6);
  border: var(--border-subtle);
  border-radius: 1rem;
  padding: 1rem;
  transition: all var(--transition-normal);
}

.token-input-container:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.token-input-container:focus-within {
  border-color: rgba(240, 138, 60, 0.3);
  box-shadow: 0 0 0 1px rgba(240, 138, 60, 0.1);
}

/* ============================================================================
   Amount Input
   ============================================================================ */
.amount-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: #FAFAFA;
  font-size: 1.75rem;
  font-weight: 500;
  outline: none;
  text-overflow: ellipsis;
}

.amount-input::placeholder {
  color: #3F3F46;
}

.amount-input:read-only {
  cursor: default;
}

/* ============================================================================
   Token Select Button
   ============================================================================ */
.token-select-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem 0.5rem 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border: var(--border-subtle);
  border-radius: 9999px;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.token-select-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.15);
}

.token-select-btn img {
  object-fit: cover;
}

/* Token icon fallback */
.token-icon-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  background: linear-gradient(135deg, #f08a3c, #F59E0B);
  border-radius: 50%;
  font-size: 0.625rem;
  font-weight: 700;
  color: white;
}

/* ============================================================================
   Swap Direction Button
   ============================================================================ */
.swap-direction-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: #18181B;
  border: 4px solid #09090B;
  border-radius: 0.75rem;
  color: #71717A;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.swap-direction-btn:hover {
  color: #f5a060;
  background: rgba(240, 138, 60, 0.15);
  border-color: rgba(240, 138, 60, 0.3);
}

.swap-direction-btn:active {
  transform: scale(0.95);
}

.swap-direction-btn.rotating svg {
  animation: rotate180 var(--transition-normal) ease-out;
}

@keyframes rotate180 {
  from { transform: rotate(0deg); }
  to { transform: rotate(180deg); }
}

/* ============================================================================
   Swap Details
   ============================================================================ */
.swap-details {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: var(--border-subtle);
  border-radius: 0.75rem;
  animation: fadeIn var(--transition-normal);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================================================
   Swap Button
   ============================================================================ */
.swap-btn {
  position: relative;
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, #f08a3c, #e85c4a);
  border: none;
  border-radius: 1rem;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  transition: all var(--transition-normal);
}

.swap-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.swap-btn:not(:disabled):hover {
  box-shadow: 0 8px 30px rgba(240, 138, 60, 0.4);
  transform: translateY(-1px);
}

.swap-btn:not(:disabled):hover::before {
  transform: translateX(100%);
}

.swap-btn:not(:disabled):active {
  transform: translateY(0);
}

.swap-btn:disabled {
  background: #27272A;
  color: #52525B;
  cursor: not-allowed;
}

/* ============================================================================
   Modal
   ============================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 1;
  transition: opacity var(--transition-normal);
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal {
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  background: #18181B;
  border: var(--border-subtle);
  border-radius: 1.25rem;
  overflow: hidden;
  animation: scaleIn var(--transition-normal);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-overlay.hidden .modal {
  animation: none;
}

/* ============================================================================
   Token List
   ============================================================================ */
.token-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.token-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.token-item-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  object-fit: cover;
}

.token-item-icon-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  background: linear-gradient(135deg, #f08a3c, #F59E0B);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

/* Popular token chips */
.popular-token {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  background: rgba(255, 255, 255, 0.05);
  border: var(--border-subtle);
  border-radius: 9999px;
  color: #FAFAFA;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.popular-token:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.popular-token img {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
}

/* ============================================================================
   Status Modal
   ============================================================================ */
.status-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.status-icon.loading {
  background: rgba(240, 138, 60, 0.1);
  border: 2px solid rgba(240, 138, 60, 0.3);
}

.status-icon.success {
  background: rgba(34, 197, 94, 0.1);
  border: 2px solid rgba(34, 197, 94, 0.3);
}

.status-icon.error {
  background: rgba(239, 68, 68, 0.1);
  border: 2px solid rgba(239, 68, 68, 0.3);
}

.spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid transparent;
  border-top-color: #f08a3c;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.checkmark {
  width: 1.5rem;
  height: 1.5rem;
  color: #22C55E;
}

.checkmark path {
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  animation: drawCheck 0.4s ease-out forwards;
}

@keyframes drawCheck {
  to { stroke-dashoffset: 0; }
}

.error-x {
  width: 1.5rem;
  height: 1.5rem;
  color: #EF4444;
}

.status-btn {
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.status-btn.primary {
  background: #f08a3c;
  border: none;
  color: white;
}

.status-btn.primary:hover {
  background: #f5a060;
}

.status-btn.secondary {
  background: transparent;
  border: var(--border-subtle);
  color: #A1A1AA;
}

.status-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #FAFAFA;
}

/* ============================================================================
   Swap Step Indicators
   ============================================================================ */
.swap-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
}

.step-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: #3F3F46;
  border: 1.5px solid #52525B;
  transition: all var(--transition-normal);
}

.swap-step.active .step-dot {
  background: #f08a3c;
  border-color: #f08a3c;
  box-shadow: 0 0 8px rgba(240, 138, 60, 0.5);
}

.swap-step.done .step-dot {
  background: #22C55E;
  border-color: #22C55E;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.step-label {
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #52525B;
  transition: color var(--transition-normal);
}

.swap-step.active .step-label {
  color: #f08a3c;
}

.swap-step.done .step-label {
  color: #22C55E;
}

.step-line {
  width: 2.5rem;
  height: 1.5px;
  background: #3F3F46;
  margin-bottom: 1.125rem;
  transition: background var(--transition-normal);
}

.step-line.active {
  background: linear-gradient(90deg, #22C55E, #f08a3c);
}

.step-line.done {
  background: #22C55E;
}

/* ============================================================================
   Encryption Proof Display
   ============================================================================ */
.encryption-proof {
  text-align: left;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.625rem;
  padding: 0.625rem 0.75rem;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.6875rem;
  line-height: 1.6;
}

.proof-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
}

.proof-row + .proof-row {
  margin-top: 0.25rem;
}

.proof-label {
  color: #71717A;
  flex-shrink: 0;
  width: 4.5rem;
}

.proof-plain {
  color: #EF4444;
  text-decoration: line-through;
  flex-shrink: 0;
  opacity: 0.7;
}

.proof-arrow {
  color: #52525B;
  flex-shrink: 0;
}

.proof-cipher {
  color: #22C55E;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ============================================================================
   FHE Status Badge
   ============================================================================ */
.fhe-badge {
  font-weight: 500;
  transition: color var(--transition-normal);
}

.fhe-badge.loading {
  color: #F59E0B;
  animation: pulse 2s ease-in-out infinite;
}

.fhe-badge.ready {
  color: #22C55E;
}

.fhe-badge.error {
  color: #EF4444;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================================================
   Scrollbar
   ============================================================================ */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #3F3F46;
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: #52525B;
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 480px) {
  .swap-card {
    padding: 1rem;
    border-radius: 1rem;
  }

  .amount-input {
    font-size: 1.5rem;
  }

  .modal {
    max-height: 90vh;
    border-radius: 1rem 1rem 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 100%;
  }
}

/* ============================================================================
   Reduced Motion
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
