/**
 * R2R FinTech Components CSS
 * Cards, Buttons, Gauges, Tables, Chart Overlays, Modals
 * Ultra-Responsive for Desktop, Tablet, and Mobile
 */

/* --- GLASS CARDS --- */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  padding: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--glow-subtle);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.glass-card:hover {
  border-color: rgba(0, 240, 255, 0.2);
}

.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-r2r);
  opacity: 0.7;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 7px;
}

.card-title i {
  color: var(--r2r-cyan);
}

/* --- MARKET TOOLBAR --- */
.market-toolbar {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  padding: 8px 12px;
  gap: 8px;
}

.symbol-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.symbol-selector::-webkit-scrollbar {
  display: none;
}

.pair-pill {
  padding: 5px 11px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.pair-pill:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.pair-pill.active {
  color: var(--r2r-cyan);
  background: rgba(0, 240, 255, 0.12);
  border-color: rgba(0, 240, 255, 0.4);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.25);
}

.market-sub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.timeframe-group {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.tf-pill {
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.tf-pill:hover {
  color: var(--text-primary);
}

.tf-pill.active {
  color: #fff;
  background: var(--r2r-blue);
  box-shadow: 0 0 8px rgba(41, 121, 255, 0.4);
}

.ticker-metrics {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
}

.metric-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 10px;
}

.metric-item .val {
  font-weight: 700;
  color: var(--text-primary);
}

/* --- CANVAS CHART CONTAINER --- */
.chart-container {
  height: 420px;
  position: relative;
  background: rgba(5, 7, 13, 0.95);
  border-radius: var(--card-radius);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chart-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(10, 15, 26, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  z-index: 10;
  gap: 8px;
}

.chart-price-box {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.hud-symbol-price {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
}

.hud-indicators {
  display: flex;
  gap: 8px;
  font-size: 10px;
  font-family: var(--font-mono);
}

.ind-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.ind-tag i {
  font-size: 5px;
}

.ind-tag.ema9 { color: var(--r2r-cyan); }
.ind-tag.ema21 { color: var(--r2r-blue); }
.ind-tag.ema50 { color: var(--r2r-violet); }

.chart-controls {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.chart-ctrl-btn {
  background: rgba(14, 20, 34, 0.8);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 10px;
  padding: 3px 6px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s;
}

.chart-ctrl-btn:hover, .chart-ctrl-btn.active {
  color: var(--r2r-cyan);
  border-color: rgba(0, 240, 255, 0.4);
}

.chart-ohlc-bar {
  padding: 2px 12px;
  font-size: 9.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: rgba(5, 8, 15, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#candlestickCanvas {
  width: 100%;
  flex: 1;
  display: block;
}

/* --- SEMI-AUTO SETUP BANNER --- */
.setup-alert-banner {
  background: linear-gradient(90deg, rgba(0, 240, 255, 0.15) 0%, rgba(138, 63, 252, 0.15) 100%);
  border: 1px solid var(--r2r-cyan);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: pulseGlow 3s infinite;
}

.setup-info-text {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.setup-info-sub {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-top: 2px;
}

.setup-actions {
  display: flex;
  gap: 6px;
}

.btn-confirm-setup {
  background: var(--gradient-r2r);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 7px;
  font-weight: 700;
  font-size: 11.5px;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.35);
  white-space: nowrap;
}

.btn-dismiss-setup {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 11.5px;
  cursor: pointer;
}

/* --- ORDER DESK CONTROLS --- */
.order-desk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.order-input-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.order-input-label {
  font-size: 9.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.order-input {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 7px 9px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.order-input:focus {
  border-color: var(--r2r-cyan);
}

.order-buttons-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-trade-long {
  flex: 1;
  background: linear-gradient(135deg, #00f0ff 0%, #00b4d8 100%);
  color: #05070d;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
  padding: 10px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-trade-long:hover {
  transform: translateY(-1px);
}

.btn-trade-short {
  flex: 1;
  background: linear-gradient(135deg, #f72585 0%, #b5179e 100%);
  color: #fff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
  padding: 10px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 12px rgba(247, 37, 133, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-trade-short:hover {
  transform: translateY(-1px);
}

/* --- AI MARKET ANALYSIS CARD --- */
.ai-signal-badge {
  padding: 4px 10px;
  border-radius: var(--pill-radius);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ai-signal-badge.buy, .ai-signal-badge.strong-buy {
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid var(--r2r-cyan);
  color: var(--r2r-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.25);
}

.ai-signal-badge.sell, .ai-signal-badge.strong-sell {
  background: rgba(247, 37, 133, 0.15);
  border: 1px solid var(--r2r-magenta);
  color: var(--r2r-magenta);
  box-shadow: 0 0 12px rgba(247, 37, 133, 0.25);
}

.ai-signal-badge.hold {
  background: rgba(148, 163, 184, 0.15);
  border: 1px solid #94a3b8;
  color: #94a3b8;
}

/* Confidence Meter Bar */
.confidence-container {
  margin: 10px 0;
}

.confidence-header {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 600;
  margin-bottom: 5px;
}

.confidence-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.confidence-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--gradient-r2r);
  transition: width 0.5s ease;
  box-shadow: 0 0 10px var(--r2r-cyan);
}

/* Indicator Matrix Grid */
.indicator-matrix {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 10px 0;
}

.ind-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
}

.ind-name {
  font-size: 9.5px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.ind-val {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  margin-top: 1px;
}

.ai-reasoning-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--r2r-cyan);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-secondary);
}

/* --- TABBED SECTION --- */
.tab-headers {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
  margin-bottom: 10px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tab-headers::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--r2r-cyan);
  background: rgba(0, 240, 255, 0.1);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Position Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.data-table th {
  text-align: left;
  padding: 6px;
  color: var(--text-muted);
  font-size: 9.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-family: var(--font-mono);
}

.badge-pos {
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
}

.badge-pos.buy {
  background: var(--trade-profit-subtle);
  color: var(--trade-profit);
}

.badge-pos.sell {
  background: var(--trade-loss-subtle);
  color: var(--trade-loss);
}

.btn-close-pos {
  background: linear-gradient(135deg, rgba(0, 230, 118, 0.25) 0%, rgba(0, 240, 255, 0.25) 100%);
  border: 1px solid var(--r2r-cyan);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
  transition: all 0.2s ease;
}

.btn-close-pos:hover {
  background: var(--gradient-r2r);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.6);
  transform: scale(1.04);
}

.btn-quick-tp {
  background: linear-gradient(135deg, rgba(0, 230, 118, 0.2) 0%, rgba(0, 240, 255, 0.2) 100%);
  border: 1px solid rgba(0, 230, 118, 0.5);
  color: var(--trade-profit);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-quick-tp:hover {
  background: var(--trade-profit);
  color: #05070d;
  box-shadow: 0 0 15px rgba(0, 230, 118, 0.5);
}

/* --- TERMINAL STREAM --- */
.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: rgba(14, 20, 34, 0.7);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 10.5px;
}

.terminal-logs {
  height: 100px;
  overflow-y: auto;
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.log-line {
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.log-time {
  color: var(--text-muted);
}

.log-msg.INFO { color: var(--text-secondary); }
.log-msg.SUCCESS { color: var(--trade-profit); }
.log-msg.WARN { color: #f59e0b; }
.log-msg.ERROR { color: var(--trade-loss); }

/* --- MODAL DIALOG --- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

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

.modal-box {
  background: #0d121f;
  border: 1px solid rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.2);
  border-radius: 14px;
  width: 92%;
  max-width: 480px;
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
}

/* =========================================
   MOBILE RESPONSIVENESS OVERRIDES
   ========================================= */

@media (max-width: 768px) {
  .chart-container {
    height: 310px; /* Perfect height for phones: visible chart + room for controls */
  }

  .chart-top-bar {
    padding: 6px 10px;
  }

  .hud-symbol-price {
    font-size: 16px;
  }

  .hud-indicators {
    font-size: 9px;
    gap: 6px;
  }

  .chart-controls {
    gap: 3px;
  }

  .chart-ctrl-btn {
    font-size: 9.5px;
    padding: 2px 5px;
  }

  .setup-alert-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 10px;
  }

  .setup-actions {
    width: 100%;
  }

  .setup-actions button {
    flex: 1;
    text-align: center;
  }

  .order-desk-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .order-buttons-row {
    gap: 6px;
  }

  .btn-trade-long, .btn-trade-short {
    padding: 9px 6px;
    font-size: 11.5px;
  }

  .modal-box {
    padding: 14px;
  }

  .terminal-logs {
    height: 80px;
    font-size: 9.5px;
  }
}

@media (max-width: 420px) {
  .chart-container {
    height: 290px;
  }

  .hud-symbol-price {
    font-size: 15px;
  }

  .chart-ohlc-bar {
    display: none; /* Hide detailed OHLC sub-bar on very small screens to avoid clutter */
  }

  .metric-item {
    font-size: 9px;
  }
}

/* =========================================
   USER AUTH & PRO SUBSCRIPTION BADGES
   ========================================= */

.user-plan-badge {
  padding: 3px 8px;
  border-radius: var(--pill-radius);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.user-plan-badge.admin {
  background: linear-gradient(135deg, rgba(247, 37, 133, 0.25) 0%, rgba(138, 63, 252, 0.25) 100%);
  border: 1px solid var(--r2r-magenta);
  color: var(--r2r-magenta);
  box-shadow: 0 0 10px rgba(247, 37, 133, 0.4);
}

.user-plan-badge.pro {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2) 0%, rgba(41, 121, 255, 0.2) 100%);
  border: 1px solid var(--r2r-cyan);
  color: var(--r2r-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.user-plan-badge.free {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
}

.user-plan-badge.free:hover {
  border-color: var(--r2r-cyan);
  color: #fff;
}

/* =========================================
   PRICING & SUBSCRIPTION CARDS ($9.99 / $19.99)
   ========================================= */

.pricing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 16px 0;
}

@media (max-width: 600px) {
  .pricing-grid {
    grid-template-columns: 1fr;
  }
}

.plan-card {
  background: rgba(14, 20, 34, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  position: relative;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
}

.plan-card:hover {
  border-color: rgba(0, 240, 255, 0.3);
  transform: translateY(-2px);
}

.plan-card.selected {
  border-color: var(--r2r-cyan);
  background: linear-gradient(180deg, rgba(0, 240, 255, 0.08) 0%, rgba(14, 20, 34, 0.9) 100%);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.25);
}

.plan-badge-tag {
  position: absolute;
  top: -10px;
  right: 12px;
  background: var(--gradient-button-auto);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--pill-radius);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.plan-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  color: #fff;
}

.plan-price-wrap {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 8px 0 12px 0;
}

.plan-price {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 900;
  color: var(--r2r-cyan);
}

.plan-period {
  font-size: 11px;
  color: var(--text-muted);
}

.plan-features {
  list-style: none;
  font-size: 11.5px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.plan-features li i {
  color: var(--trade-profit);
  margin-right: 6px;
}

/* =========================================
   ADMIN PANEL DASHBOARD
   ========================================= */

.admin-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.admin-stat-card {
  background: rgba(14, 20, 34, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
}

.admin-stat-num {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
  color: var(--r2r-cyan);
  margin-top: 4px;
}

.btn-admin-act {
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.btn-admin-act.upgrade-1m {
  background: rgba(0, 240, 255, 0.15);
  border-color: rgba(0, 240, 255, 0.4);
  color: var(--r2r-cyan);
}

.btn-admin-act.upgrade-3m {
  background: rgba(138, 63, 252, 0.2);
  border-color: rgba(138, 63, 252, 0.5);
  color: #c084fc;
}

.btn-admin-act.downgrade {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #f59e0b;
}

.btn-admin-act.delete {
  background: rgba(255, 51, 102, 0.15);
  border-color: rgba(255, 51, 102, 0.4);
  color: var(--trade-loss);
}

#adminModal .modal-box {
  max-width: 780px;
}

#pricingModal .modal-box {
  max-width: 640px;
}

.admin-users-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(10, 14, 26, 0.6);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.admin-table th, .admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-table th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}

