/**
 * Benefit Exchange - WebApp стили
 * Объединяет все стили веб-версии, адаптированные для Telegram MiniApp
 */

/* Animated Shader Background Container for MiniApp */
#shader-background {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
}

#shader-background canvas {
  display: block !important;
  width: 100vw !important;
  height: 100vh !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
}

/* Контент поверх шейдера */
.container {
  position: relative !important;
  z-index: 1 !important;
}

/* КРИТИЧЕСКАЯ ЗАЩИТА от стилей Telegram WebApp */
html {
  background: var(--gradient-background) !important;
  background-color: transparent !important;
  color: rgba(255, 255, 255, 0.95) !important;
}

html[style*="background"],
html[style*="background-color"] {
  background: var(--gradient-background) !important;
  background-color: transparent !important;
}

body {
  background: var(--gradient-background) !important;
  background-color: transparent !important;
  color: rgba(255, 255, 255, 0.95) !important;
}

/* Защита от любых inline стилей Telegram */
body[style*="background"],
body[style*="background-color"],
body[style*="color"] {
  background: var(--gradient-background) !important;
  background-color: transparent !important;
  color: rgba(255, 255, 255, 0.95) !important;
}

/* Защита всех элементов от темных цветов Telegram */
* {
  color: inherit;
}

/* Принудительно белый цвет для всех текстовых элементов */
p, span, div, label, h1, h2, h3, h4, h5, h6, a, button, input, textarea, select {
  color: rgba(255, 255, 255, 0.95) !important;
}

/* КРИТИЧЕСКОЕ: Гарантируем что все интерактивные элементы кликабельны */
button, input, textarea, select, a, .currency-selector-btn, .exchange-btn, .type-btn, .swap-btn {
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* Исключение для placeholder - они должны быть полупрозрачными */
input::placeholder, textarea::placeholder {
  color: rgba(255, 255, 255, 0.6) !important;
  opacity: 0.7 !important;
}

/* ===== БАЗОВЫЕ ПЕРЕМЕННЫЕ ===== */
:root {
  /* Основные цвета в стиле Liquid Glass */
  --primary-color: #007AFF;
  --primary-dark: #0051D5;
  --primary-light: #5AC8FA;
  --secondary-color: rgba(248, 249, 250, 0.8);
  --text-primary: #1D1D1F;
  --text-secondary: #6E6E73;
  --text-light: #86868B;
  --border-color: rgba(0, 0, 0, 0.1);
  --success-color: #34C759;
  --error-color: #FF3B30;
  --warning-color: #FF9500;
  
  /* Градиенты Dark Theme */
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  --gradient-light: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
  --gradient-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
  --gradient-background: linear-gradient(180deg, #1a1a2e 0%, #0d0d1a 50%, #050510 100%);
  
  /* Тени в стиле Liquid Glass */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.25);
  --shadow-glow: 0 0 20px rgba(102, 126, 234, 0.3);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  
  /* Радиусы */
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;
  
  /* Отступы */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  /* Шрифты */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-4xl: 2.5rem;
  
  /* Переходы */
  --transition-fast: 0.15s;
  --transition-base: 0.3s;
  --transition-slow: 0.5s;
}

/* ===== БАЗОВЫЕ СТИЛИ ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* КРИТИЧЕСКОЕ: Убираем любые блокировки событий на интерактивных элементах */
button, input, textarea, select, a {
  pointer-events: auto !important;
  touch-action: manipulation !important;
  user-select: auto !important;
  cursor: pointer !important;
}

.currency-selector-btn, .exchange-btn, .type-btn, .swap-btn {
  pointer-events: auto !important;
  touch-action: manipulation !important;
  cursor: pointer !important;
}

/* КРИТИЧЕСКОЕ: Все интерактивные элементы должны быть кликабельны */
button *, input *, .currency-selector-btn *, .exchange-btn *, .type-btn * {
  pointer-events: auto !important;
}

/* Исключение для псевдоэлементов и фона */
body::before,
body::after,
*::before,
*::after {
  pointer-events: none !important;
}

html {
  background: var(--gradient-background) !important;
  min-height: 100vh;
}

body {
  font-family: var(--font-family);
  color: rgba(255, 255, 255, 0.95) !important;
  /* Всегда используем градиентный фон */
  background: var(--gradient-background) !important;
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
  margin: 0;
  padding: 0;
}

/* Анимированный фон - тёмная тема */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 20%, rgba(102, 126, 234, 0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(118, 75, 162, 0.06) 0%, transparent 50%);
  animation: float 20s ease-in-out infinite;
  pointer-events: none !important;
  z-index: 0;
}

/* КРИТИЧЕСКОЕ: Гарантируем что body и html не блокируют клики */
body, html {
  pointer-events: auto !important;
}

/* КРИТИЧЕСКОЕ: Гарантируем что контейнеры не блокируют клики */
.container, main, .exchange-form {
  pointer-events: auto !important;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, 30px) scale(1.1); }
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--spacing-md);
  position: relative;
  z-index: 1;
  overflow: visible !important; /* Важно: не обрезаем dropdown */
  background: transparent !important;
  color: rgba(255, 255, 255, 0.95) !important;
  /* НЕ создаем новый stacking context - позволяем dropdown выходить за пределы */
}

/* ===== ЗАГОЛОВКИ ===== */
.container {
  padding-top: 24px;
}

header {
  text-align: center;
  color: white;
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}

.logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  margin-bottom: 8px;
}

.logo-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.logo-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
}

.logo-benefit {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.logo-exchange {
  font-size: 1.1rem;
  font-weight: 300;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

header h1 {
  font-size: var(--font-size-4xl);
  margin-bottom: var(--spacing-sm);
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: var(--font-size-lg);
  opacity: 0.95;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  font-weight: 400;
  color: rgba(255, 255, 255, 0.95);
}

/* ===== ФОРМА ОБМЕНА ===== */
main {
  background: transparent !important;
  color: rgba(255, 255, 255, 0.95) !important;
}

.exchange-form {
  padding: 0;
  position: relative;
  max-width: 100%;
  overflow: visible !important; /* Важно: не обрезаем dropdown */
  z-index: 1;
  background: transparent !important;
  /* НЕ создаем новый stacking context - позволяем dropdown выходить за пределы */
}

.exchange-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-bottom: 24px;
  max-width: 100%;
  overflow: visible !important; /* Важно: не обрезаем dropdown */
  /* Убрано: transition: padding-bottom - не меняем padding при открытии dropdown */
  padding-bottom: 0 !important; /* Фиксированный padding, не меняется */
}

.currency-input-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  max-width: 100%;
  width: 100%;
  min-width: 0;
  overflow: visible !important; /* Важно: не обрезаем dropdown */
  z-index: 1000; /* Увеличиваем z-index для обеспечения видимости dropdown */
}

.currency-input-row label {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  font-size: calc(var(--font-size-sm) * 1.2);
}

.input-currency-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative !important; /* Критично для позиционирования dropdown */
  overflow: visible !important; /* Важно: не обрезаем dropdown */
  z-index: 1000 !important; /* Увеличиваем z-index для обеспечения видимости dropdown */
  /* УБРАНО isolation: isolate - оно блокировало выход dropdown за пределы контекста */
}

.amount-currency-row {
  display: flex;
  gap: 0;
  align-items: stretch;
  background: rgba(15, 15, 25, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-md);
  border: 1px solid rgba(102, 126, 234, 0.25);
  overflow: visible !important; /* Важно: не обрезаем dropdown */
  transition: all var(--transition-base);
  height: 70px;
  position: relative;
  z-index: 1;
}

/* Когда dropdown открыт, изменяем скругление только сверху для визуального соединения */
.amount-currency-row.dropdown-open {
  border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
  border-bottom: none !important;
  /* Усиливаем эффект стекла для визуального соединения */
  box-shadow: 
    0 -4px 16px rgba(0, 0, 0, 0.2),
    0 4px 16px rgba(102, 126, 234, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(255, 255, 255, 0.1) !important;
}

.amount-currency-row:focus-within {
  border-color: rgba(102, 126, 234, 0.5);
  box-shadow: 0 0 15px rgba(102, 126, 234, 0.15);
}

.amount-currency-row .amount-input,
.amount-currency-row .amount-input-search {
  flex: 1;
  padding: 20px 20px;
  border: none;
  background: transparent;
  font-size: calc(var(--font-size-lg) * 1.2);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  outline: none;
  box-sizing: border-box;
  transition: all var(--transition-base);
  min-width: 150px;
  display: flex;
  align-items: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.amount-currency-row .amount-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.amount-currency-row .amount-input-search::placeholder {
  color: rgba(255, 255, 255, 0.6);
  opacity: 0.7;
  font-size: calc(var(--font-size-base) * 1.1);
}

.amount-currency-row .amount-input-search {
  display: none;
}

.amount-currency-row .amount-input-search.active {
  display: block;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

.amount-input[readonly] {
  opacity: 0.8;
  cursor: default;
}

/* ===== СЕЛЕКТОР ВАЛЮТЫ ===== */
.input-currency-wrapper .currency-selector-wrapper {
  position: absolute !important;
  top: calc(100% - 1px) !important; /* Точное соединение без зазора (минус 1px для перекрытия границы) */
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 99999 !important; /* Максимально высокий z-index для гарантированного отображения поверх всего */
  overflow: visible !important;
  display: none !important;
  visibility: hidden !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-bottom: 0 !important;
  pointer-events: none !important;
  transform: translateY(-10px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  /* Критично: не влияет на поток документа */
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
}

.input-currency-wrapper .currency-selector-wrapper.active {
  display: block !important;
  visibility: visible !important;
  transform: translateY(0) !important;
  pointer-events: auto !important;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  z-index: 99999 !important; /* Базовый z-index для активного dropdown */
}

/* КРИТИЧЕСКОЕ: Класс для последнего открытого dropdown - будет устанавливаться через JS */
.input-currency-wrapper .currency-selector-wrapper.active.last-opened {
  z-index: 100000 !important; /* Максимальный z-index для последнего открытого */
}

.currency-input-row.has-active-dropdown {
  z-index: 100000 !important;
  pointer-events: auto !important; /* Гарантируем кликабельность */
}

.input-currency-wrapper.has-active-dropdown {
  z-index: 100000 !important;
  pointer-events: auto !important; /* Гарантируем кликабельность */
}

.input-currency-wrapper.has-active-dropdown button,
.input-currency-wrapper.has-active-dropdown input {
  pointer-events: auto !important; /* Гарантируем кликабельность кнопок и инпутов */
}

.input-currency-wrapper .currency-selector-wrapper .currency-dropdown {
  pointer-events: auto !important; /* Включаем клики для самого dropdown */
}

.amount-currency-row .currency-selector-btn {
  flex-shrink: 0;
  width: 150px;
  min-width: 155px;
  max-width: 150px;
  padding: 20px 40px 20px 20px;
  border: none;
  background: transparent;
  font-size: calc(var(--font-size-base) * 1.2);
  transition: all var(--transition-base);
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer !important;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  text-align: right;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  z-index: 100 !important;
  pointer-events: auto !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(102, 126, 234, 0.3);
}

.amount-currency-row .currency-selector-btn:hover {
  background: transparent;
  opacity: 0.8;
}

.amount-currency-row .currency-selector-btn.active {
  background: transparent;
  opacity: 1;
}

.currency-selector-placeholder {
  color: rgba(255, 255, 255, 0.6);
  font-size: var(--font-size-sm);
}

.currency-selector-selected {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

.currency-logo-wrapper {
  position: relative;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.currency-selector-logo {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.currency-network-logo {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(30, 30, 40, 0.98);
  background: rgba(30, 30, 40, 0.98);
  z-index: 10;
}

.currency-selector-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
  align-items: flex-end;
  justify-content: center;
}

.currency-selector-name {
  font-weight: 600;
  font-size: calc(var(--font-size-sm) * 1.3);
  color: rgba(255, 255, 255, 0.95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: block;
  line-height: 1.2;
  text-align: right;
}

.currency-network-badge {
  display: none;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  white-space: nowrap;
  line-height: 1.2;
  text-align: right;
}

.currency-selector-arrow {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  transition: transform var(--transition-base);
  flex-shrink: 0;
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.currency-selector-btn.active .currency-selector-arrow {
  transform: translateY(-50%) rotate(180deg);
}

/* ===== DROPDOWN ВАЛЮТ - тёмная тема ===== */
.currency-dropdown {
  position: relative !important;
  width: 100% !important;
  max-height: 500px !important;
  min-height: 100px !important;
  /* Тёмный фон */
  background: rgba(15, 15, 25, 0.95) !important;
  backdrop-filter: blur(50px) !important;
  -webkit-backdrop-filter: blur(50px) !important;
  /* Скругление только снизу - продолжение окна суммы */
  border-radius: 0 0 var(--radius-md) var(--radius-md) !important;
  /* Тени */
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 8px 24px rgba(0, 0, 0, 0.3) !important;
  /* Границы */
  border: none !important;
  border-left: 1px solid rgba(102, 126, 234, 0.25) !important;
  border-right: 1px solid rgba(102, 126, 234, 0.25) !important;
  border-bottom: 1px solid rgba(102, 126, 234, 0.25) !important;
  /* Убираем верхнюю границу для полного соединения */
  border-top: none !important;
  display: none !important;
  flex-direction: column;
  overflow: hidden;
  z-index: 10001 !important;
  visibility: hidden !important;
  transform: translateY(-10px) scale(0.98);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  margin-top: 0 !important;
  padding-top: 0 !important;
  opacity: 1 !important;
}

.currency-dropdown.active {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: 100% !important;
  min-height: 100px !important;
  z-index: 10001 !important;
  transform: translateY(0) scale(1) !important;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  /* Тёмные тени */
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 8px 24px rgba(0, 0, 0, 0.3),
    0 0 30px rgba(102, 126, 234, 0.1) !important;
}

/* ДОПОЛНИТЕЛЬНАЯ ЗАЩИТА: Гарантируем что active класс всегда видим */
.currency-dropdown.active[style*="opacity: 0"],
.currency-dropdown.active[style*="opacity:0"] {
  opacity: 1 !important;
}

/* Еще одна защита - если есть inline style с opacity, переопределяем */
.currency-dropdown.active {
  opacity: 1 !important;
}

/* КРИТИЧЕСКАЯ ЗАЩИТА: Предотвращаем скрытие активного dropdown */
.currency-dropdown.active[style*="display: none"],
.currency-dropdown.active[style*="display:none"] {
  display: flex !important;
}

.currency-dropdown-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 12px 12px;
  max-height: 400px;
  /* Улучшенная стилизация скроллбара */
  scrollbar-width: thin;
  scrollbar-color: rgba(102, 126, 234, 0.5) rgba(255, 255, 255, 0.05);
}

.currency-dropdown-list::-webkit-scrollbar {
  width: 8px;
}

.currency-dropdown-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  margin: 8px 0;
}

.currency-dropdown-list::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.6), rgba(118, 75, 162, 0.6));
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.currency-dropdown-list::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.8), rgba(118, 75, 162, 0.8));
  box-shadow: 0 0 8px rgba(102, 126, 234, 0.4);
}

.currency-section {
  margin-bottom: 16px;
}

.currency-section-title {
  padding: 8px 14px;
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
  text-transform: uppercase;
  letter-spacing: 1px;
  background: rgba(102, 126, 234, 0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 10px;
  margin-bottom: 10px;
  border: 1px solid rgba(102, 126, 234, 0.2);
  box-shadow: none;
}

.currency-dropdown-item {
  padding: 10px 14px;
  /* Тёмный фон */
  background: rgba(25, 25, 40, 0.8) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  border: 1px solid rgba(102, 126, 234, 0.15);
  box-shadow: none;
  position: relative;
  overflow: hidden;
}

/* Эффект свечения при наведении */
.currency-dropdown-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(102, 126, 234, 0.2),
    transparent
  );
  transition: left 0.5s ease;
}

.currency-dropdown-item:hover::before {
  left: 100%;
}

.currency-dropdown-item:hover {
  background: rgba(102, 126, 234, 0.2) !important;
  backdrop-filter: blur(25px) !important;
  -webkit-backdrop-filter: blur(25px) !important;
  transform: translateX(6px) scale(1.02);
  border-color: rgba(102, 126, 234, 0.4);
  box-shadow: 0 0 15px rgba(102, 126, 234, 0.2);
}

.currency-dropdown-item:active {
  background: rgba(102, 126, 234, 0.3) !important;
  transform: translateX(4px) scale(0.99);
  box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.currency-item-logo {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.currency-item-logo::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.3), rgba(118, 75, 162, 0.3));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.currency-dropdown-item:hover .currency-item-logo::before {
  opacity: 1;
}

.currency-item-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  background: rgba(30, 30, 50, 0.8);
  padding: 3px;
  border: 2px solid rgba(102, 126, 234, 0.2);
  position: relative;
  z-index: 1;
  box-shadow: none;
  transition: all 0.3s ease;
}

.currency-dropdown-item:hover .currency-item-logo img {
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
  border-color: rgba(102, 126, 234, 0.5);
}

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

.currency-item-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.98);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: color 0.3s ease;
}

.currency-dropdown-item:hover .currency-item-name {
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 0 8px rgba(102, 126, 234, 0.5);
}

.currency-item-code {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
  letter-spacing: 0.5px;
  transition: color 0.3s ease;
}

.currency-dropdown-item:hover .currency-item-code {
  color: rgba(102, 126, 234, 0.9);
}

.no-results {
  text-align: center;
  padding: 48px 24px;
  color: rgba(255, 255, 255, 0.6);
}

.currency-dropdown-list::-webkit-scrollbar {
  width: 8px;
}

.currency-dropdown-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.currency-dropdown-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.currency-dropdown-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===== КНОПКА ОБМЕНА ===== */
.swap-btn {
  width: auto;
  height: auto;
  min-width: 32px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-size: var(--font-size-xl);
  cursor: pointer;
  transition: transform 0.3s ease, color 0.3s ease;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-top: 18px;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.swap-btn:hover {
  color: rgba(102, 126, 234, 1);
  background: transparent;
}

/* Анимация через JS-класс */
.swap-btn.swapping {
  transform: rotate(180deg) !important;
  color: rgba(102, 126, 234, 1);
}

/* ===== ПОЛЕ АДРЕСА ===== */
/* Фиксируем позицию элементов ниже, чтобы они не двигались при открытии dropdown */
.address-input,
.order-type {
  position: relative !important;
  z-index: 1 !important;
  /* Не меняем позицию при открытии dropdown */
  margin-top: 0 !important;
  padding-top: 0 !important;
  transition: none !important;
}

.exchange-btn {
  position: relative !important;
  z-index: 1 !important;
  /* Не меняем позицию при открытии dropdown */
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  /* Сохраняем transition для hover эффектов */
}

.address-input {
  margin-bottom: 20px;
  position: relative;
  z-index: 1; /* Низкий z-index - ниже dropdown */
  transition: margin-top 0.3s ease; /* Плавный переход при сдвиге */
}

.address-input label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  font-size: calc(var(--font-size-sm) * 1.2);
}

.address-input input {
  width: 100%;
  height: 70px;
  padding: 20px 30px;
  font-size: calc(var(--font-size-base) * 1.3);
  border: 1px solid rgba(102, 126, 234, 0.25);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  background: rgba(15, 15, 25, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: rgba(255, 255, 255, 0.95);
  box-shadow: none;
  box-sizing: border-box;
}

.address-input input:focus {
  outline: none;
  border-color: rgba(102, 126, 234, 0.5);
  background: rgba(20, 20, 35, 0.9);
  box-shadow: 0 0 15px rgba(102, 126, 234, 0.15);
}

.address-input input::placeholder {
  color: rgba(255, 255, 255, 0.6);
  opacity: 0.7;
}

/* ===== ТИП ЗАКАЗА ===== */
.order-type {
  margin-bottom: 30px;
  position: relative;
  z-index: 1; /* Низкий z-index - ниже dropdown */
  transition: margin-top 0.3s ease; /* Плавный переход при сдвиге */
}

.order-type label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.type-buttons {
  display: flex;
  gap: var(--spacing-sm);
}

.type-btn {
  flex: 1;
  padding: 14px 20px;
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: var(--radius-md);
  background: rgba(15, 15, 25, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  cursor: pointer;
  transition: all var(--transition-base);
  font-size: var(--font-size-base);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  box-shadow: none;
}

.type-btn:hover {
  background: rgba(25, 25, 40, 0.9);
  border-color: rgba(102, 126, 234, 0.4);
  transform: translateY(-1px);
}

.type-btn.active {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
  color: rgba(255, 255, 255, 0.95);
  border-color: rgba(102, 126, 234, 0.6);
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

/* ===== КНОПКА ОБМЕНА ===== */
.exchange-btn {
  width: 100%;
  padding: 20px 24px;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  background: rgba(40, 40, 60, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: var(--radius-md);
  font-size: var(--font-size-lg);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: none;
  position: relative;
  overflow: hidden;
  z-index: 1; /* Низкий z-index - ниже dropdown */
  /* Фиксируем позицию - не двигается при открытии dropdown */
  top: auto;
  left: auto;
  right: auto;
  transform: none;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exchange-btn.active {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
  color: rgba(255, 255, 255, 0.95);
  border-color: rgba(102, 126, 234, 0.5);
  box-shadow: 0 0 25px rgba(102, 126, 234, 0.3);
}

.exchange-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.exchange-btn:hover:not(:disabled)::before {
  left: 100%;
}

.exchange-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(102, 126, 234, 1) 0%, rgba(118, 75, 162, 1) 100%);
  color: rgba(255, 255, 255, 0.95);
  transform: translateY(-1px) scale(1.005);
  box-shadow: 0 0 30px rgba(102, 126, 234, 0.4);
}

.exchange-btn:disabled {
  background: rgba(40, 40, 60, 0.6);
  color: rgba(255, 255, 255, 0.4);
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

/* ===== РЕЗУЛЬТАТ ЗАКАЗА ===== */
.order-result {
  margin-top: var(--spacing-xl);
  padding: var(--spacing-lg);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-glass);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.order-result::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 768px) {
  .container {
    padding: var(--spacing-sm);
  }
  
  .exchange-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .swap-btn {
    transform: rotate(90deg);
    align-self: center;
    margin-top: 0;
    margin-bottom: 0;
  }
  
  /* Анимация через JS-класс на мобильных */
  .swap-btn.swapping {
    transform: rotate(270deg) !important;
  }

  header h1 {
    font-size: 2rem;
  }
  
  .currency-dropdown {
    max-height: 400px;
  }
  
  .currency-dropdown-list {
    max-height: 380px;
    padding: 10px;
  }
}

/* ===== ORDER TYPE HELP BUTTON ===== */
.type-buttons {
    display: flex;
    align-items: center;
}

.type-help-btn {
    position: relative;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.3));
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: #a5b4fc;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.type-help-btn:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.5), rgba(139, 92, 246, 0.5));
    border-color: rgba(99, 102, 241, 0.6);
    color: #c4b5fd;
}

.type-help-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%) translateY(5px);
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.98), rgba(20, 20, 40, 0.98));
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 8px;
    padding: 8px 14px;
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 100;
    pointer-events: none;
}

.type-help-btn:hover .type-help-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.type-help-tooltip::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -6px;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(99, 102, 241, 0.4);
}

.type-help-tooltip::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -4px;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(30, 30, 50, 0.98);
}

/* ===== MODAL STYLES ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: linear-gradient(145deg, rgba(25, 25, 45, 0.98), rgba(15, 15, 30, 0.98));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 20px;
    padding: 24px;
    max-width: 100%;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-30px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 22px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.modal-title {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 20px;
    padding-right: 36px;
    text-align: center;
}

.modal-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-section-last {
    border-bottom: none !important;
    margin-bottom: 16px !important;
    padding-bottom: 0 !important;
}

.modal-section h3 {
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
}

.modal-section p {
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.6;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.modal-section ul {
    list-style: none;
    padding: 0;
    margin: 0 0 10px 0;
}

.modal-section li {
    color: rgba(255, 255, 255, 0.7);
    padding: 5px 0 5px 20px;
    position: relative;
    line-height: 1.5;
    font-size: 0.9rem;
}

.modal-section li::before {
    content: "•";
    position: absolute;
    left: 6px;
    color: #a5b4fc;
}

.modal-highlight {
    padding: 12px 14px;
    border-radius: 10px;
    margin-top: 10px;
}

.modal-highlight.warning {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.1));
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.modal-highlight.warning strong {
    color: #fcd34d;
}

.modal-highlight {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.88rem;
    line-height: 1.5;
}

.modal-ok-btn {
    display: block;
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-ok-btn:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

/* Currency unavailable warning */
.currency-dropdown-item.currency-item-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.currency-dropdown-item.currency-item-disabled:hover {
    background: rgba(255, 255, 255, 0.03);
}

.currency-item-warning {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding: 4px 8px;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 6px;
    font-size: 0.7rem;
    color: #fcd34d;
}

.currency-item-warning .warning-icon {
    font-size: 0.8rem;
}

.currency-item-warning .warning-text {
    line-height: 1.3;
}
