﻿/* ===== PROFESSIONAL CHART STYLES ===== */

/* ── Chart Container ── */
.chart-container-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #0d1117;
}

.tv-chart-container {
  width: 100%;
  height: 100%;
  position: relative;
}

.tv-chart-container table {
  border-collapse: collapse;
}

/* ── Toolbar Enhancements ── */
.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(0,0,0,0.4);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  z-index: 5;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border2);
  margin: 0 4px;
}

.tf-group {
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  padding: 2px;
}

.tf-btn {
  background: none;
  border: none;
  color: var(--text3);
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.3px;
}

.tf-btn:hover {
  background: rgba(0,200,83,0.1);
  color: var(--green);
}

.tf-btn.active {
  background: rgba(0,200,83,0.2);
  color: var(--green);
  box-shadow: 0 0 8px rgba(0,200,83,0.15);
}

/* ── Indicator Buttons ── */
.indicator-group {
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  padding: 2px;
}

.ind-btn {
  background: none;
  border: none;
  color: var(--text3);
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.ind-btn:hover {
  background: rgba(0,149,255,0.1);
  color: var(--blue);
}

.ind-btn.active {
  background: rgba(0,149,255,0.2);
  color: var(--blue);
  box-shadow: 0 0 6px rgba(0,149,255,0.15);
}

.ind-btn[data-indicator="ema"].active { color: #ffd600; background: rgba(255,214,0,0.15); }
.ind-btn[data-indicator="sma"].active { color: #00bcd4; background: rgba(0,188,212,0.15); }
.ind-btn[data-indicator="bb"].active  { color: #ce93d8; background: rgba(206,147,216,0.15); }

/* ── Live Indicator ── */
.chart-live-indicator {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,200,83,0.12);
  border: 1px solid rgba(0,200,83,0.25);
  border-radius: 20px;
  padding: 4px 12px 4px 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 1.2px;
  z-index: 3;
  backdrop-filter: blur(6px);
}

.live-pulse {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  animation: livePulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 6px rgba(0,200,83,0.6);
}

@keyframes livePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.6); opacity: 0.5; }
}

/* ── Price Tag ── */
.price-tag {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, #0095ff, #0077cc);
  border-radius: 6px 0 0 6px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  z-index: 4;
  font-family: 'Inter', monospace;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 12px rgba(0,149,255,0.3);
  display: none; /* Hidden — TradingView has its own price scale */
}

/* ── Chart Bottom Bar ── */
.chart-bottom-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  background: rgba(0,0,0,0.3);
  border-top: 1px solid var(--border);
  min-height: 28px;
}

.chart-bottom-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-bottom-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-market-badge {
  background: rgba(0,149,255,0.12);
  border: 1px solid rgba(0,149,255,0.2);
  color: var(--blue);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.chart-tf-badge {
  background: rgba(0,200,83,0.12);
  border: 1px solid rgba(0,200,83,0.2);
  color: var(--green);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
}

/* ── Crosshair Tooltip ── */
.chart-tooltip {
  display: none;
  position: absolute;
  z-index: 100;
  pointer-events: none;
  background: rgba(17,24,39,0.95);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  font-family: 'Inter', monospace;
  color: #e2e8f0;
  min-width: 150px;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.tt-header {
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  letter-spacing: 0.3px;
}

.tt-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  font-size: 11px;
}

.tt-label {
  color: var(--text3);
  font-weight: 600;
  margin-right: 12px;
}

/* ── Mobile Chart Styles ── */
.m-chart {
  flex: 1;
  position: relative;
  background: #0d1117;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.m-chart-time-info {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 5;
}

.m-live-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,200,83,0.12);
  border: 1px solid rgba(0,200,83,0.25);
  border-radius: 12px;
  padding: 3px 10px 3px 6px;
  font-size: 9px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 1px;
  backdrop-filter: blur(6px);
}

.m-price-tag {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, #0095ff, #0077cc);
  border-radius: 5px 0 0 5px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  z-index: 4;
  font-family: 'Inter', monospace;
  box-shadow: 0 2px 8px rgba(0,149,255,0.3);
  display: none; /* Hidden — TradingView has its own price scale */
}

/* ── Mobile Timeframe & Indicator Bar ── */
.m-tf-bar {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(13,17,23,0.85);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 4px 6px;
  z-index: 5;
  backdrop-filter: blur(12px);
  justify-content: center;
}

.m-tf-btn {
  background: none;
  border: none;
  color: var(--text3);
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
}

.m-tf-btn:hover,
.m-tf-btn.active {
  background: rgba(0,200,83,0.2);
  color: var(--green);
}

.m-tf-divider {
  width: 1px;
  height: 16px;
  background: var(--border2);
  margin: 0 4px;
}

.m-ind-btn {
  background: none;
  border: none;
  color: var(--text3);
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.5px;
}

.m-ind-btn:hover,
.m-ind-btn.active {
  background: rgba(0,149,255,0.15);
  color: var(--blue);
}

.m-ind-btn[data-indicator="ema"].active { color: #ffd600; background: rgba(255,214,0,0.12); }
.m-ind-btn[data-indicator="sma"].active { color: #00bcd4; background: rgba(0,188,212,0.12); }
.m-ind-btn[data-indicator="bb"].active  { color: #ce93d8; background: rgba(206,147,216,0.12); }

/* ── Candle Countdown Timer ── */
.candle-countdown {
  position: absolute;
  top: 12px;
  left: 130px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(13, 17, 23, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 5px 14px 5px 6px;
  z-index: 3;
  backdrop-filter: blur(12px);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.candle-countdown:hover {
  border-color: rgba(0, 200, 83, 0.3);
  box-shadow: 0 0 20px rgba(0, 200, 83, 0.08);
}

.candle-countdown.mobile {
  position: relative;
  top: auto;
  left: auto;
  margin-top: 6px;
  padding: 4px 10px 4px 4px;
  gap: 7px;
  border-radius: 12px;
}

/* Ring Wrapper */
.countdown-ring-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.candle-countdown.mobile .countdown-ring-wrap {
  width: 30px;
  height: 30px;
}

.countdown-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.countdown-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 3;
}

.countdown-ring-progress {
  fill: none;
  stroke: var(--green, #00c853);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 97.39;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.5s ease, stroke 0.5s ease;
  filter: drop-shadow(0 0 4px rgba(0, 200, 83, 0.4));
}

/* Color States */
.countdown-ring-progress.warning {
  stroke: #ffab00;
  filter: drop-shadow(0 0 4px rgba(255, 171, 0, 0.5));
}

.countdown-ring-progress.urgent {
  stroke: #ff1744;
  filter: drop-shadow(0 0 6px rgba(255, 23, 68, 0.6));
  animation: urgentPulseRing 0.6s ease-in-out infinite;
}

@keyframes urgentPulseRing {
  0%, 100% { stroke-width: 3; }
  50% { stroke-width: 4; }
}

/* Ring Center Text */
.countdown-ring-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 800;
  font-family: 'Inter', monospace;
  color: #ffffff;
  letter-spacing: -0.3px;
  line-height: 1;
}

.candle-countdown.mobile .countdown-ring-text {
  font-size: 9px;
}

/* Info Section */
.countdown-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.countdown-label {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  line-height: 1.2;
}

.countdown-time {
  font-size: 14px;
  font-weight: 800;
  font-family: 'Inter', monospace;
  color: var(--green, #00c853);
  letter-spacing: 0.5px;
  line-height: 1.2;
  transition: color 0.4s ease;
}

.candle-countdown.mobile .countdown-label {
  font-size: 8px;
}

.candle-countdown.mobile .countdown-time {
  font-size: 12px;
}

/* Warning/Urgent Color States for text */
.countdown-time.warning {
  color: #ffab00;
}

.countdown-time.urgent {
  color: #ff1744;
  animation: urgentBlink 0.6s ease-in-out infinite;
}

@keyframes urgentBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Candle Complete Flash */
.candle-countdown.flash {
  animation: candleFlash 0.5s ease;
}

@keyframes candleFlash {
  0% { border-color: rgba(0, 200, 83, 0.6); box-shadow: 0 0 20px rgba(0, 200, 83, 0.3); }
  50% { border-color: rgba(0, 200, 83, 0.8); box-shadow: 0 0 30px rgba(0, 200, 83, 0.5); }
  100% { border-color: rgba(255, 255, 255, 0.08); box-shadow: none; }
}

/* ── Light Mode Overrides ── */
body.light-mode {
  --bg: #f5f7fa;
  --bg2: #ffffff;
  --bg3: #f0f2f5;
  --bg4: #e8ebef;
  --text: #1a1a2e;
  --text2: #5a6577;
  --text3: #8b95a5;
  --border: #e0e4ea;
  --border2: #d0d4da;
}

body.light-mode .chart-container-wrap {
  background: #ffffff;
}

body.light-mode .chart-toolbar {
  background: rgba(240,242,245,0.95);
  border-bottom-color: #e0e4ea;
}

body.light-mode .chart-live-indicator {
  background: rgba(0,180,83,0.08);
  border-color: rgba(0,180,83,0.2);
}

body.light-mode .chart-tooltip {
  background: rgba(255,255,255,0.96);
  border-color: rgba(0,0,0,0.1);
  color: #333;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

body.light-mode .tt-header {
  color: #1a1a2e;
  border-bottom-color: rgba(0,0,0,0.08);
}

body.light-mode .m-tf-bar {
  background: rgba(255,255,255,0.9);
  border-color: rgba(0,0,0,0.08);
}

body.light-mode .m-live-indicator {
  background: rgba(0,180,83,0.08);
  border-color: rgba(0,180,83,0.2);
}

body.light-mode .candle-countdown {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

body.light-mode .candle-countdown:hover {
  border-color: rgba(0, 180, 83, 0.3);
  box-shadow: 0 4px 20px rgba(0, 180, 83, 0.1);
}

body.light-mode .countdown-ring-bg {
  stroke: rgba(0, 0, 0, 0.08);
}

body.light-mode .countdown-ring-text {
  color: #1a1a2e;
}

body.light-mode .countdown-label {
  color: rgba(0, 0, 0, 0.4);
}

/* ── Tool Buttons (refined) ── */
.tool-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text3);
  font-size: 13px;
  transition: all 0.25s ease;
}

.tool-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}

/* ── Responsive Chart Adjustments ── */
@media (max-width: 767px) {
  .chart-toolbar {
    display: none; /* Mobile uses the bottom TF bar instead */
  }
  
  .chart-bottom-tools {
    display: none;
  }
}

@media (max-width: 1100px) and (min-width: 768px) {
  .indicator-group {
    display: none; /* Hide on small desktop to save space */
  }
}

/* Override the old canvas style */
canvas#mainChart,
canvas#mobileChart {
  display: none !important;
}

/* ══════════════════════════════════════════════════════
   ── Professional Trade Marking System ──
   ══════════════════════════════════════════════════════ */

.tm-wrapper {
  position: absolute;
  display: flex;
  align-items: center;
  z-index: 10;
  pointer-events: none;
  transform: translateX(-100%) translateY(-50%);
  animation: tmAppear 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.25));
}

@keyframes tmAppear {
  0%   { opacity: 0; transform: translateX(-100%) translateY(-50%) scale(0.5); }
  60%  { opacity: 1; transform: translateX(-100%) translateY(-50%) scale(1.05); }
  100% { opacity: 1; transform: translateX(-100%) translateY(-50%) scale(1); }
}

/* ── Badge (pill) ── */
.tm-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 3px;
  border-radius: 16px;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.18);
}

/* Up = Blue */
.tm-wrapper.up .tm-badge {
  background: linear-gradient(135deg, rgba(33,150,243,0.92), rgba(21,101,192,0.96));
  box-shadow: 0 4px 18px rgba(33,150,243,0.45),
              inset 0 1px 0 rgba(255,255,255,0.18);
}

/* Down = Red */
.tm-wrapper.down .tm-badge {
  background: linear-gradient(135deg, rgba(244,67,54,0.92), rgba(183,28,28,0.96));
  box-shadow: 0 4px 18px rgba(244,67,54,0.45),
              inset 0 1px 0 rgba(255,255,255,0.18);
}

/* ── Direction icon circle ── */
.tm-icon-circle {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 900;
  flex-shrink: 0;
  background: rgba(255,255,255,0.22);
  color: #fff;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.2);
}

/* ── Text ── */
.tm-amount {
  font-weight: 800;
  letter-spacing: 0.3px;
  font-size: 10px;
}

.tm-timer {
  opacity: 0.8;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3px;
  font-family: 'Inter', monospace;
}

/* ── Connector line ── */
.tm-connector {
  height: 1.5px;
  width: 12px;
  flex-shrink: 0;
  position: relative;
}

.tm-wrapper.up .tm-connector {
  background: linear-gradient(90deg, rgba(33,150,243,0.7), rgba(33,150,243,0.35));
}
.tm-wrapper.down .tm-connector {
  background: linear-gradient(90deg, rgba(244,67,54,0.7), rgba(244,67,54,0.35));
}

/* ── Entry dot ── */
.tm-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  box-sizing: border-box;
  border: 1.5px solid rgba(255,255,255,0.6);
  position: relative;
}

.tm-wrapper.up .tm-dot {
  background: #2196F3;
  box-shadow: 0 0 8px rgba(33,150,243,0.7), 0 0 20px rgba(33,150,243,0.3);
}
.tm-wrapper.down .tm-dot {
  background: #F44336;
  box-shadow: 0 0 8px rgba(244,67,54,0.7), 0 0 20px rgba(244,67,54,0.3);
}

/* Pulse ring on dot */
.tm-dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid;
  transform: translate(-50%, -50%) scale(1);
  animation: tmDotPulse 2s ease-in-out infinite;
}
.tm-wrapper.up .tm-dot::after {
  border-color: rgba(33,150,243,0.5);
}
.tm-wrapper.down .tm-dot::after {
  border-color: rgba(244,67,54,0.5);
}

@keyframes tmDotPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  50%      { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

/* ── Expired / exit animation ── */
.tm-wrapper.tm-expired {
  animation: tmDisappear 0.6s ease forwards !important;
  pointer-events: none;
}

@keyframes tmDisappear {
  0%   { opacity: 1; transform: translateX(-100%) translateY(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-100%) translateY(-70%) scale(0.6); }
}

/* ── Light Mode ── */
body.light-mode .tm-wrapper {
  filter: drop-shadow(0 2px 10px rgba(0,0,0,0.12));
}

body.light-mode .tm-wrapper.up .tm-badge {
  background: linear-gradient(135deg, rgba(33,150,243,0.95), rgba(21,101,192,0.98));
}
body.light-mode .tm-wrapper.down .tm-badge {
  background: linear-gradient(135deg, rgba(244,67,54,0.95), rgba(183,28,28,0.98));
}

body.light-mode .tm-dot {
  border-color: rgba(255,255,255,0.8);
}

/* ── Mobile adjustments ── */
.m-chart .tm-wrapper .tm-badge {
  padding: 5px 10px 5px 5px;
  gap: 6px;
  font-size: 11px;
  border-radius: 18px;
}

.m-chart .tm-wrapper .tm-icon-circle {
  width: 20px;
  height: 20px;
  font-size: 11px;
}

.m-chart .tm-wrapper .tm-amount {
  font-size: 11px;
}

.m-chart .tm-wrapper .tm-timer {
  font-size: 10px;
}

.m-chart .tm-wrapper .tm-connector {
  width: 18px;
}

.m-chart .tm-wrapper .tm-dot {
  width: 10px;
  height: 10px;
}
