/* ═══════════════════════════════════════════════════════════════
   Exchange & P2P v3.0 — Order Book + On-chain UI
   ═══════════════════════════════════════════════════════════════ */

/* ═══ Статистика ═══ */
.exch-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.exch-stat-card {
  background: rgba(0, 26, 51, 0.9);
  border: 1px solid rgba(255, 215, 0, 0.15);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.exch-stat-val {
  color: #ffd700;
  font-size: 18px;
  font-weight: 700;
}
.exch-stat-label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
}

/* ═══ Табы ═══ */
.exch-mode-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.exch-mode-tabs::-webkit-scrollbar { display: none; }
.exch-tab {
  flex: 1;
  padding: 10px 8px;
  background: rgba(0, 26, 51, 0.8);
  border: 1px solid rgba(255, 215, 0, 0.15);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.2s;
}
.exch-tab:hover { border-color: rgba(255, 215, 0, 0.4); color: #fff; }
.exch-tab.active {
  background: rgba(255, 215, 0, 0.12);
  border-color: #ffd700;
  color: #ffd700;
  font-weight: 600;
}

/* ═══ Секции ═══ */
.exch-section {
  background: rgba(0, 26, 51, 0.92);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 14px;
  padding: 20px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ═══ Балансы ═══ */
.exch-balances {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.exch-balance-card {
  background: rgba(0, 20, 45, 0.8);
  border: 1px solid rgba(255, 215, 0, 0.1);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bal-label { color: rgba(255, 255, 255, 0.6); font-size: 12px; }
.bal-value { color: #fff; font-size: 20px; font-weight: 700; font-family: monospace; }
.bal-usd { color: rgba(255, 255, 255, 0.4); font-size: 11px; }

/* ═══ Swap форма ═══ */
.exch-swap-form { margin-top: 12px; }
.exch-swap-card {
  background: rgba(0, 15, 35, 0.7);
  border: 1px solid rgba(255, 215, 0, 0.1);
  border-radius: 14px;
  padding: 16px;
}
.swap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}
.swap-max {
  color: #ffd700;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}
.swap-max:hover { text-decoration: underline; }
.swap-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.swap-input {
  flex: 1;
  background: rgba(0, 10, 25, 0.9);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 10px;
  padding: 12px;
  color: #fff;
  font-size: 20px;
  font-family: monospace;
  outline: none;
}
.swap-input:focus { border-color: #ffd700; }
.swap-input::placeholder { color: rgba(255, 255, 255, 0.25); }
.swap-token-select {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 90px;
}
.token-icon { font-size: 18px; }
.token-name { color: #fff; font-weight: 600; font-size: 14px; }
.swap-balance-hint, .swap-rate-info {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  margin-top: 6px;
}
.swap-switch-btn {
  text-align: center;
  margin: 10px 0;
  cursor: pointer;
}
.swap-switch-btn span {
  display: inline-block;
  width: 36px;
  height: 36px;
  line-height: 36px;
  border-radius: 50%;
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
  color: #ffd700;
  font-size: 18px;
  transition: all 0.2s;
}
.swap-switch-btn:hover span {
  background: rgba(255, 215, 0, 0.2);
  transform: rotate(180deg);
}
.swap-details {
  margin-top: 12px;
  padding: 10px;
  background: rgba(0, 15, 35, 0.5);
  border-radius: 10px;
}
.swap-detail-row {
  display: flex;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  padding: 4px 0;
}
.exch-swap-btn {
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  background: linear-gradient(135deg, #ffd700, #f0c000);
  border: none;
  border-radius: 12px;
  color: #000;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.exch-swap-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3); }
.exch-swap-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.exch-swap-info {
  margin-top: 10px;
  padding: 10px;
  background: rgba(255, 215, 0, 0.05);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  line-height: 1.5;
}

/* ═══ ORDER BOOK ═══ */
.orderbook {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.orderbook-side { margin-bottom: 0; }
.orderbook-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  padding: 8px 0;
}
.sell-title { color: #ff4444; }
.buy-title { color: #00cc66; }
.orderbook-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 70px;
  gap: 4px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  margin-bottom: 4px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
}
.orderbook-list { max-height: 200px; overflow-y: auto; }
.orderbook-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 70px;
  gap: 4px;
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  font-family: monospace;
  align-items: center;
  transition: background 0.15s;
}
.orderbook-row:hover { background: rgba(255, 255, 255, 0.05); }
.sell-row .ob-price { color: #ff5555; }
.buy-row .ob-price { color: #00dd77; }
.ob-amount, .ob-total { color: rgba(255, 255, 255, 0.8); }
.ob-action { text-align: right; }
.ob-buy-btn, .ob-sell-btn, .ob-cancel-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
}
.ob-buy-btn { background: #00cc66; color: #000; }
.ob-sell-btn { background: #ff4444; color: #fff; }
.ob-cancel-btn { background: rgba(255, 255, 255, 0.1); color: #ff4444; }
.ob-buy-btn:hover { background: #00ee77; }
.ob-sell-btn:hover { background: #ff5555; }

.orderbook-spread {
  text-align: center;
  padding: 12px;
  margin: 4px 0;
  border-top: 1px solid rgba(255, 215, 0, 0.1);
  border-bottom: 1px solid rgba(255, 215, 0, 0.1);
}
.spread-price { color: #ffd700; font-size: 18px; font-weight: 700; font-family: monospace; }
.spread-label { display: block; color: rgba(255, 255, 255, 0.4); font-size: 11px; margin-top: 2px; }

.orderbook-empty {
  text-align: center;
  padding: 20px;
  color: rgba(255, 255, 255, 0.3);
  font-size: 13px;
}

.exch-refresh-btn {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 10px;
  color: #ffd700;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.exch-refresh-btn:hover { background: rgba(255, 215, 0, 0.15); }

/* ═══ CREATE ORDER ═══ */
.p2p-create h3 { color: #ffd700; margin-bottom: 8px; }
.exch-hint {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.p2p-form { display: flex; flex-direction: column; gap: 12px; }
.p2p-type-selector { display: flex; gap: 8px; }
.p2p-type-btn {
  flex: 1;
  padding: 10px;
  background: rgba(0, 20, 45, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}
.p2p-type-btn:hover { border-color: rgba(255, 215, 0, 0.3); }
.p2p-type-btn.active[data-type="sell"] {
  border-color: #ff4444;
  color: #ff4444;
  background: rgba(255, 68, 68, 0.08);
}
.p2p-type-btn.active[data-type="buy"] {
  border-color: #00cc66;
  color: #00cc66;
  background: rgba(0, 204, 102, 0.08);
}
.p2p-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.p2p-form-row label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}
.p2p-input {
  background: rgba(0, 10, 25, 0.9);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 10px;
  padding: 12px;
  padding-right: 80px;
  color: #fff;
  font-size: 16px;
  font-family: monospace;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.p2p-input:focus { border-color: #ffd700; }
.p2p-input::placeholder { color: rgba(255, 255, 255, 0.25); }
.p2p-max-btn, .p2p-cur-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 10px;
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 6px;
  color: #ffd700;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
}
.p2p-max-btn:hover, .p2p-cur-btn:hover { background: rgba(255, 215, 0, 0.2); }
.p2p-total-info {
  background: rgba(255, 215, 0, 0.05);
  padding: 10px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}
.p2p-total-info strong { color: #ffd700; font-size: 16px; }
.p2p-fee-hint { color: rgba(255, 255, 255, 0.35); font-size: 11px; }
.p2p-create-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #ffd700, #f0c000);
  border: none;
  border-radius: 12px;
  color: #000;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.p2p-create-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3); }

/* User rating */
.p2p-user-rating {
  margin-top: 16px;
  padding: 10px;
  background: rgba(0, 20, 45, 0.7);
  border-radius: 10px;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}
.rating-good { color: #00cc66; font-weight: 700; }
.rating-bad { color: #ff4444; font-weight: 700; }

/* ═══ MY ORDERS ═══ */
.my-orders-list { display: flex; flex-direction: column; gap: 8px; }
.my-order-card {
  background: rgba(0, 20, 45, 0.8);
  border: 1px solid rgba(255, 215, 0, 0.1);
  border-radius: 12px;
  padding: 12px;
}
.my-order-card.sell { border-left: 3px solid #ff4444; }
.my-order-card.buy { border-left: 3px solid #00cc66; }
.my-order-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.my-order-id { color: rgba(255, 255, 255, 0.4); font-size: 12px; }
.my-order-status { font-size: 12px; }
.my-order-body {
  display: grid;
  grid-template-columns: auto 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.my-order-type.sell { color: #ff4444; font-weight: 600; }
.my-order-type.buy { color: #00cc66; font-weight: 600; }
.my-order-amount { color: #fff; font-family: monospace; }
.my-order-price { color: rgba(255, 255, 255, 0.7); font-family: monospace; }
.my-order-date { color: rgba(255, 255, 255, 0.4); font-size: 11px; }
.my-order-cancel {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  background: rgba(255, 68, 68, 0.1);
  border: 1px solid rgba(255, 68, 68, 0.3);
  border-radius: 8px;
  color: #ff4444;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.my-order-cancel:hover { background: rgba(255, 68, 68, 0.2); }

/* ═══ Loading ═══ */
.exch-loading {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(5px);
}
.exch-loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255, 215, 0, 0.2);
  border-top-color: #ffd700;
  border-radius: 50%;
  animation: exchSpin 0.8s linear infinite;
}
@keyframes exchSpin { to { transform: rotate(360deg); } }
.exch-loading p { color: #ffd700; margin-top: 12px; font-size: 14px; }

/* ═══ Responsive ═══ */
@media (max-width: 600px) {
  .exch-stats { grid-template-columns: repeat(2, 1fr); }
  .exch-balances { grid-template-columns: 1fr; }
  .exch-mode-tabs { gap: 3px; }
  .exch-tab { font-size: 11px; padding: 8px 4px; }
  .orderbook-header, .orderbook-row { grid-template-columns: 1fr 1fr 1fr 60px; font-size: 11px; }
  .my-order-body { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   BUY WITH CARD — Fiat On-Ramp
   ═══════════════════════════════════════════════════════════════ */
.exch-buy-card-container {
  max-width: 480px;
  margin: 0 auto;
}

.exch-buy-header {
  text-align: center;
  margin-bottom: 20px;
}
.exch-buy-header h3 {
  color: #ffd700;
  font-size: 1.3em;
  margin: 0 0 8px;
}

.exch-buy-options {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.05), rgba(0, 212, 255, 0.03));
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 16px;
  padding: 20px;
}

.exch-buy-label {
  color: #aaa;
  font-size: 13px;
  display: block;
  margin-bottom: 10px;
}

.exch-buy-presets {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.exch-preset-btn {
  flex: 1;
  padding: 12px 8px;
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 10px;
  background: rgba(255, 215, 0, 0.08);
  color: #e0e0e0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  touch-action: manipulation;
}
.exch-preset-btn.active,
.exch-preset-btn:hover {
  background: linear-gradient(135deg, #ffd700, #ff9500);
  color: #000;
  border-color: #ffd700;
}

.exch-buy-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.exch-buy-input {
  flex: 1;
  padding: 14px 16px;
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  outline: none;
}
.exch-buy-input:focus {
  border-color: #ffd700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.15);
}
.exch-buy-currency {
  color: #ffd700;
  font-weight: 700;
  font-size: 16px;
}

.exch-buy-info {
  margin-bottom: 20px;
}
.exch-buy-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
}
.exch-buy-info-row span:first-child {
  color: #888;
}
.exch-buy-info-row strong {
  color: #e0e0e0;
}

.exch-buy-main-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffd700, #ff9500);
  color: #000;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 16px;
}
.exch-buy-main-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.35);
}
.exch-buy-main-btn:active {
  transform: translateY(0);
}
.buy-btn-icon {
  font-size: 22px;
}

.exch-buy-methods {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #666;
}
.pay-method {
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #aaa;
  font-size: 11px;
  font-weight: 500;
}

/* Widget container */
.exch-buy-widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  margin-top: 16px;
  border-top: 1px solid rgba(255, 215, 0, 0.2);
}
.exch-buy-widget-header span {
  color: #ffd700;
  font-weight: 600;
}
.exch-buy-close {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 14px;
}
.exch-buy-widget {
  border-radius: 12px;
  overflow: hidden;
  min-height: 600px;
}

.exch-buy-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: #555;
  line-height: 1.6;
}
.exch-buy-footer a {
  color: #00d4ff;
  text-decoration: none;
}

@media (max-width: 480px) {
  .exch-buy-presets { gap: 6px; }
  .exch-preset-btn { padding: 10px 4px; font-size: 13px; }
  .exch-buy-main-btn { font-size: 15px; padding: 14px; }
}
