/* ==========================================================================
   Bottom Sheets, Modal Dialogs, Search, Forms & Configuration
   ========================================================================== */

/* Android Native Bottom Sheet Modal */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  background: var(--bg-surface);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.sheet-backdrop.open .bottom-sheet {
  transform: translateY(0);
}

.sheet-drag-handle {
  width: 40px;
  height: 4px;
  background: var(--text-dim);
  border-radius: 2px;
  margin: 10px auto 4px auto;
  flex-shrink: 0;
}

.sheet-header {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sheet-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}

.sheet-close-btn {
  background: var(--bg-card);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sheet-close-btn:active {
  transform: scale(0.92);
  background: var(--bg-subtle);
}

/* Pair Input & Search inside Bottom Sheet */
.sheet-search-wrap {
  padding: 10px 16px 8px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pair-input-container {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.sheet-search-input {
  flex: 1;
  height: 42px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 0 12px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  outline: none;
  text-transform: uppercase;
}

.sheet-search-input:focus {
  border-color: var(--binance-gold);
}

.pair-go-btn {
  height: 42px;
  padding: 0 16px;
  background: var(--binance-gold);
  border: none;
  border-radius: 10px;
  color: #000;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.12s;
}

.pair-go-btn:active {
  transform: scale(0.92);
  background: var(--binance-gold-hover);
}

/* Filter Tabs in Sheet */
.sheet-filter-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sheet-tab-btn {
  flex: 1;
  height: 32px;
  border: none;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s;
}

.sheet-tab-btn.active {
  background: var(--binance-gold);
  color: #000;
}

/* Coins List inside Sheet */
.sheet-coin-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 52vh;
}

.coin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.coin-row:active {
  background: var(--bg-card);
}

.coin-row.active {
  background: rgba(240, 185, 11, 0.08);
  border-left: 3px solid var(--binance-gold);
}

.cr-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cr-symbol {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
}

.cr-vol {
  font-size: 11px;
  color: var(--text-dim);
}

.cr-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.cr-price {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.cr-change {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.cr-change.bull {
  color: var(--color-bull);
  background: var(--color-bull-bg);
}

.cr-change.bear {
  color: var(--color-bear);
  background: var(--color-bear-bg);
}

/* Indicator Settings Sheet Items */
.sheet-items-group {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.indicator-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  cursor: pointer;
}

.indicator-row:active {
  background: var(--bg-subtle);
}

.ind-label-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ind-color-badge {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.ind-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.ind-desc {
  font-size: 11px;
  color: var(--text-dim);
}


/* Timeframe Selector Bottom Sheet Styles */
.tf-bottom-sheet {
  max-height: 82vh;
  max-height: 82dvh;
}
.tf-sheet-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tf-current-badge {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: rgba(240, 185, 11, 0.15);
  color: var(--binance-gold);
  border: 1px solid rgba(240, 185, 11, 0.4);
  padding: 2px 8px;
  border-radius: 6px;
}
.tf-sheet-body {
  padding: 12px 16px 28px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.tf-section-title {
  font-size: 10px;
  font-weight: 800;
  font-family: var(--font-ui);
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 8px;
  padding-left: 2px;
}
.tf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  gap: 8px;
}
.tf-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.tf-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}
.tf-card:active {
  transform: scale(0.95);
  border-color: var(--binance-gold);
}
.tf-card.active {
  background: rgba(240, 185, 11, 0.14);
  border-color: var(--binance-gold);
  box-shadow: 0 0 12px rgba(240, 185, 11, 0.22);
}
.tf-card .tf-val {
  font-size: 16px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-main);
}
.tf-card.active .tf-val {
  color: var(--binance-gold);
}
.tf-card .tf-desc {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}
.tf-card.active .tf-desc {
  color: var(--binance-gold);
  opacity: 0.9;
}
.tf-card .tf-tag {
  position: absolute;
  top: -5px;
  right: -3px;
  background: var(--binance-gold);
  color: #0b0e11;
  font-size: 8px;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 4px;
  letter-spacing: 0.4px;
}


/* Position Settings Bottom Sheet Styles */
.pos-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px 16px 18px 16px;
}
.pos-type-toggle-row {
  display: flex;
  gap: 8px;
}
.pos-type-pill {
  flex: 1;
  height: 36px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  transition: all 0.2s ease;
}
.pos-type-pill.active.pos-type-long, .pos-type-pill.active#pos-pill-long {
  background: var(--color-bull-bg);
  border-color: var(--color-bull);
  color: var(--color-bull);
}
.pos-type-pill.active.pos-type-short, .pos-type-pill.active#pos-pill-short {
  background: var(--color-bear-bg);
  border-color: var(--color-bear);
  color: var(--color-bear);
}

.pos-input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pos-input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pos-input-group label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.pos-num-input {
  height: 38px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
}
.pos-num-input:focus {
  border-color: var(--binance-gold);
}
.pos-num-input.input-bull:focus {
  border-color: var(--color-bull);
}
.pos-num-input.input-bear:focus {
  border-color: var(--color-bear);
}
.pos-rr-display {
  height: 38px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--binance-gold);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
}

.pos-presets-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.pos-presets-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  margin-right: 2px;
}
.pos-sheet-preset {
  height: 26px;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.pos-sheet-preset:hover, .pos-sheet-preset:active {
  background: var(--binance-gold);
  color: #0b0e11;
  border-color: var(--binance-gold);
}
.pos-sheet-preset.active {
  background: var(--binance-gold);
  color: #0b0e11;
  border-color: var(--binance-gold);
}

.pos-sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 8px));
}
.pos-btn-cancel {
  flex: 1;
  height: 40px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.pos-btn-cancel:hover, .pos-btn-cancel:active {
  background: var(--bg-subtle);
  color: var(--text-main);
}
.pos-btn-danger {
  flex: 1;
  height: 40px;
  border-radius: 8px;
  background: var(--color-bear-bg);
  border: 1px solid rgba(246, 70, 93, 0.4);
  color: var(--color-bear);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.pos-btn-apply {
  flex: 2;
  height: 40px;
  border-radius: 8px;
  background: var(--binance-gold);
  border: none;
  color: #0b0e11;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

/* Position Sheet Exchange Action Bar */
.pos-exchange-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.pos-btn-exchange {
  flex: 1;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f3ba2f, #d99c15);
  border: none;
  color: #0b0e11;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(240, 185, 11, 0.25);
  transition: all 0.2s ease;
}
.pos-btn-exchange:active {
  transform: scale(0.98);
  filter: brightness(0.95);
}
.pos-exchange-icon {
  font-size: 16px;
  margin-right: 6px;
}
.pos-exchange-title {
  font-size: 13px;
  letter-spacing: 0.2px;
  flex: 1;
  text-align: left;
}
.pos-exchange-tag {
  font-size: 10px;
  font-weight: 700;
  background: rgba(11, 14, 17, 0.3);
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}
.pos-btn-api-cfg {
  height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.pos-btn-api-cfg:hover, .pos-btn-api-cfg:active {
  border-color: var(--binance-gold);
  color: var(--binance-gold);
}
.pos-hud-trade {
  color: var(--binance-gold) !important;
  font-size: 13px !important;
}

/* Order Confirmation Sheet & Form */
#pos-confirm-sheet {
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pos-confirm-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 14px 14px 14px;
}
.pos-confirm-body::-webkit-scrollbar {
  width: 4px;
}
.pos-confirm-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
.confirm-env-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: rgba(240, 185, 11, 0.1);
  border: 1px solid rgba(240, 185, 11, 0.25);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--binance-gold);
}
.confirm-env-badge .env-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-bull);
  box-shadow: 0 0 6px var(--color-bull);
  flex-shrink: 0;
}
.confirm-env-badge .env-dot.testnet {
  background: #f0b90b;
  box-shadow: 0 0 6px #f0b90b;
}
.confirm-margin-mode-tag {
  margin-left: auto;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(240, 185, 11, 0.2);
  color: var(--binance-gold);
  border: 1px solid rgba(240, 185, 11, 0.4);
  letter-spacing: 0.3px;
}
.confirm-summary-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.confirm-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 6px;
}
.confirm-type-tag {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.confirm-type-tag.long {
  background: var(--color-bull-bg);
  color: var(--color-bull);
  border: 1px solid rgba(14, 203, 129, 0.4);
}
.confirm-type-tag.short {
  background: var(--color-bear-bg);
  color: var(--color-bear);
  border: 1px solid rgba(246, 70, 93, 0.4);
}
.confirm-sym {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  font-family: var(--font-mono);
}
.confirm-curr-price {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}
.confirm-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.confirm-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.confirm-field-lbl {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.confirm-avail-bal {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--binance-gold);
}
.confirm-toggle-group {
  display: flex;
  gap: 6px;
}
.confirm-type-btn {
  flex: 1;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.confirm-type-btn.active {
  background: var(--bg-card);
  border-color: var(--binance-gold);
  color: var(--binance-gold);
  box-shadow: 0 0 8px rgba(240, 185, 11, 0.15);
}
.confirm-size-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.size-prefix {
  position: absolute;
  left: 12px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
}
.size-input {
  width: 100%;
  padding-left: 26px !important;
  padding-right: 110px !important;
}
.size-equiv {
  position: absolute;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  pointer-events: none;
}
.confirm-risk-subtext {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--color-bear);
}
.confirm-risk-chips {
  display: flex;
  gap: 6px;
}
.confirm-risk-btn {
  flex: 1;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.confirm-risk-btn.active {
  border-color: var(--binance-gold);
  background: rgba(240, 185, 11, 0.15);
  color: var(--binance-gold);
  box-shadow: 0 0 6px rgba(240, 185, 11, 0.12);
}
.confirm-size-subline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 2px 2px 0;
}
.confirm-margin-cost-lbl {
  color: var(--binance-gold);
  font-weight: 700;
}
.confirm-sl-dist-lbl {
  color: var(--text-muted);
  font-weight: 600;
}
.quick-chip-lbl {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 600;
  display: flex;
  align-items: center;
  margin-right: 2px;
  white-space: nowrap;
}
.confirm-quick-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.confirm-chip {
  height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.confirm-chip:hover, .confirm-chip:active, .confirm-chip.active {
  border-color: var(--binance-gold);
  color: var(--binance-gold);
}
.confirm-leverage-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  color: var(--binance-gold);
}
.confirm-leverage-chips {
  display: flex;
  gap: 6px;
}
.confirm-lev-btn {
  flex: 1;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.confirm-lev-btn.active {
  border-color: var(--binance-gold);
  background: rgba(240, 185, 11, 0.15);
  color: var(--binance-gold);
}
.confirm-plan-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
}
.plan-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.plan-lbl {
  font-size: 8.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.2px;
}
.plan-val {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-main);
}
.plan-val.bull { color: var(--color-bull); }
.plan-val.bear { color: var(--color-bear); }
.plan-val.gold { color: var(--binance-gold); }

.confirm-error-banner {
  background: rgba(246, 70, 93, 0.15);
  border: 1px solid var(--color-bear);
  color: #ff6b7e;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.35;
  font-weight: 600;
  word-break: break-word;
}
.pos-confirm-actions {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 8px)) 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
  z-index: 10;
}
.pos-btn-submit {
  flex: 2;
  height: 42px;
  border-radius: 8px;
  background: var(--binance-gold);
  border: none;
  color: #0b0e11;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(240, 185, 11, 0.25);
  transition: all 0.2s ease;
}
.pos-btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.5);
}
.submit-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: #000000;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* API & Gateway Configuration Modal */
.api-config-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  margin-bottom: 2px;
}

.api-config-tab-btn {
  flex: 1;
  height: 34px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.api-config-tab-btn:hover {
  color: var(--text-main);
}

.api-config-tab-btn.active {
  background: var(--bg-surface);
  border-color: var(--border-light);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.api-config-tab-btn.active[data-tab="binance"] {
  border-color: rgba(240, 185, 11, 0.4);
  color: var(--binance-gold);
}

.api-config-tab-btn.active[data-tab="huggingface"] {
  border-color: rgba(168, 85, 247, 0.45);
  color: #c084fc;
}

.api-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.api-tab-panel.hidden {
  display: none !important;
}

#api-sheet {
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
}

.api-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom, 16px)) 16px;
}

.api-sheet-body::-webkit-scrollbar {
  width: 4px;
}

.api-sheet-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
.api-security-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(56, 97, 251, 0.12);
  border: 1px solid rgba(56, 97, 251, 0.3);
  border-radius: 6px;
  padding: 10px;
  font-size: 11px;
  line-height: 1.4;
  color: #7090ff;
}
.api-security-notice .security-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.api-input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.api-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.api-text-input {
  width: 100%;
  height: 38px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0 36px 0 10px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}
.api-text-input:focus {
  border-color: var(--binance-gold);
}
.api-toggle-vis {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
}
.api-input-hint {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.3;
}
.api-env-btn {
  flex: 1;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.api-env-btn.active {
  border-color: var(--binance-gold);
  background: rgba(240, 185, 11, 0.12);
  color: var(--binance-gold);
}
.api-test-result {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  line-height: 1.4;
}
.api-test-result.success {
  background: rgba(14, 203, 129, 0.15);
  border: 1px solid var(--color-bull);
  color: var(--color-bull);
}
.api-test-result.error,
.api-test-result.fail {
  background: rgba(246, 70, 93, 0.15);
  border: 1px solid var(--color-bear);
  color: #ff6b7e;
}
.api-sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

@media (max-width: 480px) {
  .api-sheet-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .api-sheet-actions #btn-huggingface-modal-save,
  .api-sheet-actions #btn-api-save {
    grid-column: span 2;
    order: -1;
    height: 42px;
    font-size: 13px;
    width: 100%;
  }
  .api-sheet-actions #btn-huggingface-modal-test,
  .api-sheet-actions #btn-api-test {
    grid-column: span 1;
    height: 38px;
    width: 100%;
    padding: 0 6px;
    font-size: 11.5px;
  }
  .api-sheet-actions #btn-huggingface-modal-clear,
  .api-sheet-actions #btn-api-clear {
    grid-column: span 1;
    height: 38px;
    width: 100%;
    padding: 0 6px;
    font-size: 11.5px;
  }
}

@media (max-width: 768px) {
  .api-text-input {
    /* 16px prevents iOS Safari's focus auto-zoom, which otherwise pushes the
       key field and the Save button out of view behind the on-screen keyboard. */
    font-size: 16px;
    height: 42px;
    touch-action: manipulation;
  }
  .api-toggle-vis {
    width: 36px;
    height: 36px;
  }
}

/* Binance Positions & Balance Bottom Sheet Styles */
.dock-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.dock-btn svg.stroke-icon {
  fill: none;
  stroke: currentColor;
}
.dock-pos-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  background: var(--binance-gold);
  color: #000;
  font-size: 8.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 2;
}
.pos-list-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pos-env-tag {
  font-size: 10px;
  font-weight: 800;
  font-family: var(--font-mono);
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1.2;
}
.pos-env-tag.live {
  background: rgba(14, 203, 129, 0.12);
  color: var(--color-bull);
  border: 1px solid rgba(14, 203, 129, 0.3);
}
.pos-env-tag.testnet {
  background: rgba(240, 185, 11, 0.12);
  color: var(--binance-gold);
  border: 1px solid rgba(240, 185, 11, 0.3);
}
.pos-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-bull);
  box-shadow: 0 0 6px rgba(14, 203, 129, 0.85);
  animation: posPulse 1.8s ease-in-out infinite;
  display: inline-block;
  flex-shrink: 0;
}
.pos-env-tag.testnet .pos-live-dot {
  background: var(--binance-gold);
  box-shadow: 0 0 6px rgba(240, 185, 11, 0.85);
}
@keyframes posPulse {
  0% { transform: scale(0.85); opacity: 0.55; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0.55; }
}
.pos-realtime-badge {
  font-size: 9px;
  font-weight: 800;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(14, 203, 129, 0.08);
  color: var(--color-bull);
  border: 1px solid rgba(14, 203, 129, 0.22);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  line-height: 1.2;
}
.pos-list-head-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pos-icon-btn {
  width: 32px;
  height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}
.pos-icon-btn:active {
  transform: scale(0.92);
  background: var(--bg-subtle);
}
.pos-icon-btn.rotating {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  100% { transform: rotate(360deg); }
}
.pos-list-body {
  display: flex;
  flex-direction: column;
  padding: 10px 14px 24px 14px;
  max-height: calc(85vh - 65px);
  overflow-y: auto;
}
.account-balance-card {
  background: linear-gradient(135deg, rgba(240, 185, 11, 0.09) 0%, rgba(20, 26, 34, 0.95) 100%);
  border: 1px solid rgba(240, 185, 11, 0.3);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.bal-card-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.bal-val-wrap {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-top: 2px;
}
.bal-val {
  font-size: 20px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: #fff;
  letter-spacing: -0.3px;
}
.bal-unit {
  font-size: 11px;
  font-weight: 700;
  color: var(--binance-gold);
}
.bal-pnl-val {
  font-size: 15px;
  font-weight: 800;
  font-family: var(--font-mono);
  margin-top: 4px;
}
.bal-pnl-val.bull { color: var(--color-bull); }
.bal-pnl-val.bear { color: var(--color-bear); }
.bal-card-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 10px 0;
}
.bal-mini-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}
.bal-sub-lbl {
  color: var(--text-dim);
}
.bal-sub-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-muted);
}
.bal-sub-val.highlight {
  color: var(--binance-gold);
}
.pos-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.pos-sec-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pos-sec-count {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--binance-gold);
  background: rgba(240, 185, 11, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
}
.open-positions-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pos-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  transition: border-color 0.15s;
}
.pos-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.pos-card-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pos-card-sym {
  font-size: 14px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-main);
}
.pos-card-side {
  font-size: 10px;
  font-weight: 800;
  font-family: var(--font-mono);
  padding: 1px 5px;
  border-radius: 4px;
}
.pos-card-side.long {
  background: rgba(14, 203, 129, 0.15);
  color: var(--color-bull);
}
.pos-card-side.short {
  background: rgba(246, 70, 93, 0.15);
  color: var(--color-bear);
}
.pos-card-lev {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 1px 4px;
  border-radius: 3px;
}
.pos-card-pnl {
  font-size: 13.5px;
  font-weight: 800;
  font-family: var(--font-mono);
  text-align: right;
  transition: color 0.15s ease;
}
.pos-card-pnl.bull { color: var(--color-bull); }
.pos-card-pnl.bear { color: var(--color-bear); }
.pos-card-pnl-pct {
  font-size: 11px;
  font-weight: 700;
  margin-left: 2px;
}
.pos-val-mark {
  transition: color 0.15s ease;
}
.pos-val-mark.tick-up {
  color: var(--color-bull) !important;
}
.pos-val-mark.tick-down {
  color: var(--color-bear) !important;
}
.pos-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 8px;
  padding: 8px 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 8px;
}
.pos-grid-cell {
  display: flex;
  flex-direction: column;
}
.pos-grid-lbl {
  font-size: 9.5px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
}
.pos-grid-val {
  font-size: 11.5px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-main);
  margin-top: 1px;
}
.pos-card-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.pos-card-btn {
  height: 26px;
  padding: 0 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.pos-btn-chart {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-main);
}
.pos-btn-chart:active {
  background: var(--bg-card);
  transform: scale(0.95);
}
.pos-btn-close-market {
  background: rgba(246, 70, 93, 0.12);
  border: 1px solid rgba(246, 70, 93, 0.35);
  color: var(--color-bear);
}
.pos-btn-close-market:active {
  background: var(--color-bear);
  color: #fff;
  transform: scale(0.95);
}
.pos-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: 10px;
  text-align: center;
}

