/**
 * GXM Drawing Engine — Styles v1.0
 * Toolbar, style panel, and selection UI for the chart drawing engine.
 * These styles are isolated with gxm- prefix — zero conflict with existing styles.
 */

/* ============================================================
   DRAWING TOOLBAR
   ============================================================ */
#gxm-drawing-toolbar {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 2px !important;
  background: rgba(13, 17, 28, 0.94) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  border: 1px solid rgba(108, 0, 255, 0.28) !important;
  border-radius: 9px !important;
  padding: 0 5px !important;
  height: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  box-sizing: border-box !important;
  max-width: fit-content !important;
  overflow: visible !important;
  scrollbar-width: none !important;
  user-select: none !important;
  flex-wrap: nowrap !important;
  margin: 0 8px 0 36px !important;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45), 0 0 14px rgba(108, 0, 255, 0.15) !important;
  color: #94a3b8 !important;
  position: relative !important;
  z-index: 50 !important;
  vertical-align: middle !important;
}

#gxm-drawing-toolbar::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

@media (max-width: 767px) {
  #gxm-drawing-toolbar {
    display: none !important;
  }
}

body.light-theme #gxm-drawing-toolbar {
  background: rgba(255, 255, 255, 0.96) !important;
  border: 1px solid rgba(108, 0, 255, 0.2) !important;
  box-shadow: 0 6px 24px rgba(108, 0, 255, 0.1), 0 2px 6px rgba(0, 0, 0, 0.04) !important;
  color: #64748b !important;
}

/* Floating button contrast enhancements (Mobile and Desktop) */
.chart-float-btn {
  color: #f1f5f9 !important;
}
.chart-float-btn svg {
  stroke: currentColor;
}
body.light-theme .chart-float-btn {
  color: #0f172a !important;
  background: #ffffff !important;
  border: 1px solid rgba(108, 0, 255, 0.18) !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06) !important;
}
body.light-theme .chart-float-btn:hover {
  color: #6c00ff !important;
  background: rgba(108, 0, 255, 0.06) !important;
  border-color: rgba(108, 0, 255, 0.35) !important;
}
body.light-theme .chart-float-btn.active {
  background: rgba(108, 0, 255, 0.12) !important;
  color: #6c00ff !important;
  border-color: rgba(108, 0, 255, 0.45) !important;
}

.gxm-tb-label {
  display: none !important;
}

.gxm-tb-btn {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  border: 1px solid transparent !important;
  border-radius: 6px !important;
  background: transparent !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  vertical-align: middle !important;
  line-height: 1 !important;
  outline: none !important;
  flex-shrink: 0 !important;
  position: relative !important;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  color: #94a3b8 !important;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.gxm-tb-btn:hover {
  background: rgba(108, 0, 255, 0.14) !important;
  border: 1px solid rgba(108, 0, 255, 0.3) !important;
  color: #f1f5f9 !important;
}

body.light-theme .gxm-tb-btn {
  border: 1px solid transparent !important;
  background: transparent !important;
  color: #64748b !important;
}

body.light-theme .gxm-tb-btn:hover {
  background: rgba(108, 0, 255, 0.08) !important;
  border: 1px solid rgba(108, 0, 255, 0.22) !important;
  color: #6c00ff !important;
}

.gxm-tb-btn.gxm-tb-active {
  background: linear-gradient(135deg, rgba(108, 0, 255, 0.28) 0%, rgba(139, 92, 246, 0.28) 100%) !important;
  color: #c4b5fd !important;
  border: 1px solid rgba(108, 0, 255, 0.55) !important;
  box-shadow: 0 0 10px rgba(108, 0, 255, 0.35) !important;
}

body.light-theme .gxm-tb-btn.gxm-tb-active {
  background: linear-gradient(135deg, rgba(108, 0, 255, 0.12) 0%, rgba(139, 92, 246, 0.12) 100%) !important;
  color: #6c00ff !important;
  border: 1px solid rgba(108, 0, 255, 0.4) !important;
  box-shadow: 0 0 8px rgba(108, 0, 255, 0.2) !important;
}

.gxm-tb-btn.gxm-tb-danger:hover {
  background: rgba(239, 68, 68, 0.14) !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  color: #ef4444 !important;
}

body.light-theme .gxm-tb-btn.gxm-tb-danger:hover {
  background: rgba(239, 68, 68, 0.08) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
  color: #dc2626 !important;
}

.gxm-tb-btn:disabled {
  opacity: 0.3 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

.gxm-tb-icon {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  min-height: 16px !important;
  line-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  pointer-events: none !important;
}

.gxm-tb-icon svg {
  display: block !important;
  width: 16px !important;
  height: 16px !important;
  max-width: 16px !important;
  max-height: 16px !important;
  margin: auto !important;
  pointer-events: none !important;
  flex-shrink: 0 !important;
}

.gxm-tb-divider {
  width: 1px !important;
  min-width: 1px !important;
  height: 18px !important;
  max-height: 18px !important;
  background: rgba(255, 255, 255, 0.1) !important;
  margin: 0 3px !important;
  flex-shrink: 0 !important;
  align-self: center !important;
  border: none !important;
  padding: 0 !important;
}

body.light-theme .gxm-tb-divider {
  background: rgba(108, 0, 255, 0.16) !important;
}

/* ============================================================
   ZENANCE THEMED PURPLE TOOLTIP (DESKTOP ONLY)
   ============================================================ */
.gxm-tb-btn[data-tooltip]::before {
  content: '';
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 6px;
  height: 6px;
  background: #140e26;
  border-left: 1px solid rgba(139, 92, 246, 0.45);
  border-top: 1px solid rgba(139, 92, 246, 0.45);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.16s cubic-bezier(0.4, 0, 0.2, 1), transform 0.16s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100001;
}

.gxm-tb-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(3px);
  background: linear-gradient(135deg, rgba(20, 14, 38, 0.98) 0%, rgba(13, 10, 26, 0.99) 100%);
  color: #f1f5f9;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid rgba(139, 92, 246, 0.45);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 14px rgba(108, 0, 255, 0.28);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.16s cubic-bezier(0.4, 0, 0.2, 1), transform 0.16s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100000;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body.light-theme .gxm-tb-btn[data-tooltip]::before {
  background: #241645;
  border-left-color: rgba(139, 92, 246, 0.5);
  border-top-color: rgba(139, 92, 246, 0.5);
}

body.light-theme .gxm-tb-btn[data-tooltip]::after {
  background: linear-gradient(135deg, #241645 0%, #170d30 100%);
  color: #ffffff;
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 8px 24px rgba(108, 0, 255, 0.25), 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Desktop hover activation */
@media (hover: hover) and (pointer: fine) and (min-width: 768px) {
  .gxm-tb-btn[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
  }
  
  .gxm-tb-btn[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
  }

  /* Keep left-most buttons' tooltips inside viewport */
  #gxm-draw-magnet[data-tooltip]::before {
    left: 14px;
  }
  #gxm-draw-magnet[data-tooltip]::after {
    left: 0;
    transform: translateX(0) translateY(3px);
  }
  #gxm-draw-magnet[data-tooltip]:hover::after {
    transform: translateX(0) translateY(0);
  }

  #gxm-draw-colorbucket[data-tooltip]::before {
    left: 14px;
  }
  #gxm-draw-colorbucket[data-tooltip]::after {
    left: -10px;
    transform: translateX(0) translateY(3px);
  }
  #gxm-draw-colorbucket[data-tooltip]:hover::after {
    transform: translateX(0) translateY(0);
  }

  /* Keep right-most buttons' tooltips inside viewport */
  #gxm-draw-clear-all[data-tooltip]::before {
    left: auto;
    right: 14px;
    transform: translateX(50%) rotate(45deg);
  }
  #gxm-draw-clear-all[data-tooltip]::after {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(3px);
  }
  #gxm-draw-clear-all[data-tooltip]:hover::after {
    transform: translateX(0) translateY(0);
  }

  #gxm-draw-delete[data-tooltip]::before {
    left: auto;
    right: 14px;
    transform: translateX(50%) rotate(45deg);
  }
  #gxm-draw-delete[data-tooltip]::after {
    left: auto;
    right: -10px;
    transform: translateX(0) translateY(3px);
  }
  #gxm-draw-delete[data-tooltip]:hover::after {
    transform: translateX(0) translateY(0);
  }
}

/* Strictly disable on touch / mobile */
@media (hover: none), (pointer: coarse), (max-width: 767px) {
  .gxm-tb-btn[data-tooltip]::before,
  .gxm-tb-btn[data-tooltip]::after,
  .chart-float-btn[data-tooltip]::before,
  .chart-float-btn[data-tooltip]::after,
  .tf-dropdown-btn[data-tooltip]::before,
  .tf-dropdown-btn[data-tooltip]::after {
    display: none !important;
    content: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }
}

/* Floating Sidebar Button Tooltips (Desktop Only) */
.chart-float-btn[data-tooltip],
.tf-dropdown-btn[data-tooltip] {
  position: relative !important;
}

.chart-float-btn[data-tooltip]::before,
.tf-dropdown-btn[data-tooltip]::before {
  content: '';
  position: absolute;
  left: calc(100% + 4px);
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 6px;
  height: 6px;
  background: #1a0f35;
  border-left: 1px solid rgba(139, 92, 246, 0.5);
  border-bottom: 1px solid rgba(139, 92, 246, 0.5);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.16s cubic-bezier(0.4, 0, 0.2, 1), transform 0.16s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100001;
}

.chart-float-btn[data-tooltip]::after,
.tf-dropdown-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 7px);
  top: 50%;
  transform: translateY(-50%) translateX(3px);
  background: linear-gradient(135deg, #1f123c 0%, #120926 100%);
  color: #ffffff;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(139, 92, 246, 0.5);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 12px rgba(108, 0, 255, 0.25);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.16s cubic-bezier(0.4, 0, 0.2, 1), transform 0.16s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100000;
}

@media (hover: hover) and (pointer: fine) and (min-width: 768px) {
  .chart-float-btn[data-tooltip]:hover::before,
  .tf-dropdown-btn[data-tooltip]:hover::before {
    opacity: 1 !important;
    visibility: visible !important;
  }
  .chart-float-btn[data-tooltip]:hover::after,
  .tf-dropdown-btn[data-tooltip]:hover::after {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(-50%) translateX(0) !important;
  }
}

/* ============================================================
   STYLE PANEL
   ============================================================ */
#gxm-style-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100000;
  background: #0e111a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.7);
  padding: 0;
  width: 240px;
  display: none;
  flex-direction: column;
  gap: 0;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

body.light-theme #gxm-style-panel {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.15);
}

.gxm-sp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
}

body.light-theme .gxm-sp-header {
  color: #0f172a;
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

.gxm-sp-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s;
}

.gxm-sp-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

body.light-theme .gxm-sp-close {
  color: rgba(0, 0, 0, 0.4);
}

body.light-theme .gxm-sp-close:hover {
  color: #0f172a;
  background: rgba(0, 0, 0, 0.06);
}

.gxm-sp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  gap: 10px;
}

body.light-theme .gxm-sp-row {
  border-bottom-color: rgba(0, 0, 0, 0.04);
}

.gxm-sp-row label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  flex-shrink: 0;
}

body.light-theme .gxm-sp-row label {
  color: rgba(15, 23, 42, 0.6);
}

.gxm-sp-row input[type="color"] {
  width: 40px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  cursor: pointer;
  background: none;
  padding: 2px;
}

.gxm-sp-row input[type="range"] {
  flex: 1;
  accent-color: #8b5cf6;
  cursor: pointer;
}

.gxm-sp-row select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #ffffff;
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}

body.light-theme .gxm-sp-row select {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.08);
  color: #0f172a;
}

.gxm-sp-row select option {
  background-color: #0e111a !important;
  color: #ffffff !important;
}

body.light-theme .gxm-sp-row select option {
  background-color: #ffffff !important;
  color: #0f172a !important;
}

.gxm-sp-actions {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
}

.gxm-sp-btn {
  flex: 1;
  padding: 8px 0;
  border: none;
  border-radius: 7px;
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.gxm-sp-apply {
  background: linear-gradient(135deg, #6c00ff 0%, #8b5cf6 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(108, 0, 255, 0.3);
}

.gxm-sp-apply:hover {
  background: linear-gradient(135deg, #7c14ff 0%, #9d6fff 100%);
  box-shadow: 0 4px 16px rgba(108, 0, 255, 0.45);
}

.gxm-sp-delete {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.gxm-sp-delete:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* ============================================================
   MOBILE — Hide toolbar on very small screens, show toggle
   ============================================================ */
@media (max-width: 767px) {
  #gxm-drawing-toolbar {
    display: none !important;
  }

  #gxm-style-panel {
    width: 90vw;
    max-width: 280px;
  }
}

/* ============================================================
   INDICATOR PANEL — Picker popup
   ============================================================ */
.gxm-indicator-wrap {
  position: relative;
}

.gxm-indicator-panel {
  position: absolute;
  top: auto !important;
  bottom: -10px !important;
  left: calc(100% + 8px) !important;
  z-index: 1200;
  width: 270px;
  max-height: calc(100vh - 120px) !important;
  background: rgba(10, 14, 26, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(139, 92, 246, 0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  animation: gxm-ip-in 0.18s ease;
}

body.light-theme .gxm-indicator-panel {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.14);
}

@keyframes gxm-ip-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.gxm-ip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

body.light-theme .gxm-ip-header {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

.gxm-ip-title {
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.3px;
}

body.light-theme .gxm-ip-title {
  color: #0f172a;
}

.gxm-ip-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.gxm-ip-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

body.light-theme .gxm-ip-close {
  color: rgba(15, 23, 42, 0.4);
}

body.light-theme .gxm-ip-close:hover {
  color: #0f172a;
  background: rgba(0, 0, 0, 0.06);
}

.gxm-ip-list {
  display: flex !important;
  flex-direction: column !important;
  padding: 6px 0 !important;
  max-height: 200px !important;
  overflow-y: auto !important;
  scrollbar-width: thin !important;
  scrollbar-color: rgba(255,255,255,0.12) transparent !important;
}

.gxm-ip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  position: relative;
}

.gxm-ip-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

body.light-theme .gxm-ip-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.gxm-ip-item.gxm-ip-active {
  background: rgba(139, 92, 246, 0.12);
}

.gxm-ip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gxm-ip-name {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.3;
}

.gxm-ip-name em {
  font-style: normal;
  font-weight: 500;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
}

body.light-theme .gxm-ip-name {
  color: #1e293b;
}

body.light-theme .gxm-ip-name em {
  color: rgba(15, 23, 42, 0.4);
}

.gxm-ip-check {
  font-size: 12px;
  font-weight: 800;
  color: #8b5cf6;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.gxm-ip-item.gxm-ip-active .gxm-ip-check {
  opacity: 1;
}

.gxm-ip-footer {
  padding: 8px 14px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: flex-end;
}

body.light-theme .gxm-ip-footer {
  border-top-color: rgba(0, 0, 0, 0.06);
}

.gxm-ip-clear-btn {
  background: none;
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ef4444;
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.gxm-ip-clear-btn:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Active state of the trigger button */
.btn-indicators.active, .btn-drawing-toggle.active {
  background: rgba(108, 0, 255, 0.16) !important;
  box-shadow: 0 0 0 1px rgba(108, 0, 255, 0.4) inset !important;
}

.gxm-sp-row input[type="text"] {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #ffffff;
  font-family: inherit;
  font-size: 12px;
  padding: 4px 8px;
  width: 120px;
  outline: none;
}

body.light-theme .gxm-sp-row input[type="text"] {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.08);
  color: #0f172a;
}

/* =========================================================
   COLLAPSIBLE TRADES PANEL (QUOTEX STYLE COLLAPSE)
   ========================================================= */
.tc-trades-toggle-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 0;
  cursor: pointer;
  border-bottom: 1.5px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.2s;
  user-select: none;
  z-index: 10;
}

.tc-trades-toggle-bar:hover {
  background: rgba(255, 255, 255, 0.05);
}

.tc-trades-toggle-arrow {
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.25s ease, color 0.2s;
  display: inline-block;
}

.tc-trades-toggle-bar:hover .tc-trades-toggle-arrow {
  color: var(--text-primary);
}

body.light-theme .tc-trades-toggle-bar {
  background: rgba(0, 0, 0, 0.02);
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

body.light-theme .tc-trades-toggle-bar:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* Transitions for rolling up content */
.tc-trades-content {
  max-height: 400px;
  opacity: 1;
  overflow-y: auto;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, padding 0.3s ease;
}

/* Minimized States */
.tc-trades-panel-mobile-container.minimized .tc-trades-content {
  max-height: 0px !important;
  min-height: 0px !important;
  flex: none !important;
  opacity: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.tc-trades-panel-mobile-container.minimized .tc-trades-toggle-arrow {
  transform: rotate(180deg);
}

@media (max-width: 767px) {
  .tc-trades-toggle-bar {
    display: none !important;
  }

  /* Mobile Centered Premium Popup Overlay Styles */
  .gxm-mobile-overlay {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(5, 8, 16, 0.65) !important; /* darkened transparent backdrop */
    backdrop-filter: blur(10px) !important; /* premium glass blur */
    -webkit-backdrop-filter: blur(10px) !important;
    z-index: 2100000000 !important;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    padding: 20px !important;
    animation: gxm-fade-in 0.25s ease-out;
  }

  @keyframes gxm-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  .gxm-mo-container {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 360px !important;
    max-height: 82vh !important;
    background: #0f141c !important; /* deep slate dark background */
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 20px !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8) !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    animation: gxm-slide-up 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  @keyframes gxm-slide-up {
    from { transform: translateY(20px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
  }

  body.light-theme .gxm-mo-container {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.06) !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15) !important;
  }

  .gxm-mo-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 18px 20px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
  }

  body.light-theme .gxm-mo-header {
    border-bottom-color: rgba(0, 0, 0, 0.05) !important;
  }

  #gxm-mo-title {
    font-size: 17px !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    letter-spacing: -0.3px !important;
  }

  body.light-theme #gxm-mo-title {
    color: #0f172a !important;
  }

  .gxm-mo-close {
    background: rgba(255, 255, 255, 0.04) !important;
    border: none !important;
    color: rgba(255, 255, 255, 0.6) !important;
    font-size: 14px !important;
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
  }

  .gxm-mo-close:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
  }

  body.light-theme .gxm-mo-close {
    background: rgba(0, 0, 0, 0.03) !important;
    color: rgba(0, 0, 0, 0.6) !important;
  }

  body.light-theme .gxm-mo-close:hover {
    background: rgba(0, 0, 0, 0.06) !important;
    color: #0f172a !important;
  }

  .gxm-mo-body {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 16px 20px 24px 20px !important;
  }

  /* Grid layout for drawing options on mobile */
  .gxm-mo-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
  }

  .gxm-mo-grid-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(255, 255, 255, 0.015) !important;
    border: 1px solid rgba(255, 255, 255, 0.04) !important;
    border-radius: 14px !important;
    padding: 12px 6px !important;
    min-height: 82px !important;
    cursor: pointer !important;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1) !important;
    opacity: 0;
    animation: gxm-scale-in 0.3s forwards;
    box-sizing: border-box !important;
  }

  @keyframes gxm-scale-in {
    from { opacity: 0; transform: scale(0.92) translateY(5px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
  }

  body.light-theme .gxm-mo-grid-item {
    background: #f8fafc !important;
    border-color: rgba(0, 0, 0, 0.03) !important;
  }

  .gxm-mo-grid-item:active, .gxm-mo-grid-item:hover {
    background: var(--accent-bg, rgba(255, 255, 255, 0.05)) !important;
    border-color: var(--accent-color, #8b5cf6) !important;
    box-shadow: 0 4px 15px var(--accent-bg) !important;
    transform: translateY(-3px) !important;
  }

  body.light-theme .gxm-mo-grid-item:active, body.light-theme .gxm-mo-grid-item:hover {
    background: var(--accent-bg, rgba(139, 92, 246, 0.08)) !important;
    border-color: var(--accent-color, #8b5cf6) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04) !important;
  }

  .gxm-mo-grid-icon {
    font-size: 22px !important;
    font-weight: 700 !important;
    margin-bottom: 6px !important;
    transition: transform 0.2s ease !important;
    display: inline-block !important;
  }

  .gxm-mo-grid-item:hover .gxm-mo-grid-icon, .gxm-mo-grid-item:active .gxm-mo-grid-icon {
    transform: scale(1.18) !important;
  }

  .gxm-mo-grid-label {
    font-size: 9.5px !important;
    color: rgba(255, 255, 255, 0.6) !important;
    font-weight: 600 !important;
    text-align: center !important;
    width: 100% !important;
    white-space: normal !important; /* wrap text instead of truncating */
    line-height: 1.25 !important;
    word-break: break-word !important;
  }

  body.light-theme .gxm-mo-grid-label {
    color: #475569 !important;
  }

  /* List layout for indicator options on mobile */
  .gxm-mo-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  .gxm-mo-list-item {
    display: flex !important;
    align-items: center !important;
    padding: 12px 16px !important;
    background: rgba(255, 255, 255, 0.02) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
  }

  body.light-theme .gxm-mo-list-item {
    background: #f8fafc !important;
    border-color: rgba(0, 0, 0, 0.05) !important;
  }

  .gxm-mo-list-item:hover, .gxm-mo-list-item:active {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    transform: translateX(2px) !important;
  }

  body.light-theme .gxm-mo-list-item:hover, body.light-theme .gxm-mo-list-item:active {
    background: #f1f5f9 !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
  }

  .gxm-mo-list-item.selected {
    background: rgba(22, 199, 132, 0.06) !important;
    border-color: rgba(22, 199, 132, 0.25) !important;
  }

  body.light-theme .gxm-mo-list-item.selected {
    background: rgba(22, 199, 132, 0.05) !important;
    border-color: rgba(22, 199, 132, 0.35) !important;
  }

  .gxm-mo-list-dot {
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    margin-right: 12px !important;
  }

  .gxm-mo-list-name {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: rgba(255, 255, 255, 0.9) !important;
    flex: 1 !important;
  }

  body.light-theme .gxm-mo-list-name {
    color: #0f172a !important;
  }

  .gxm-mo-list-check {
    font-size: 14px !important;
    color: #16c784 !important;
    display: none;
    font-weight: 800 !important;
  }

  .gxm-mo-list-item.selected .gxm-mo-list-check {
    display: block !important;
  }

  /* Premium Outlined Clear All Button */
  .gxm-ip-clear-btn {
    width: 100% !important;
    margin-top: 14px !important;
    padding: 12px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    border-radius: 12px !important;
    background: rgba(239, 68, 68, 0.08) !important;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
    color: #ef4444 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .gxm-ip-clear-btn:hover, .gxm-ip-clear-btn:active {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.35) !important;
    transform: scale(0.98) !important;
  }
}

/* Trade row stacking layout */
.tc-trade-row {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  width: 100% !important;
  min-height: 52px !important;
  height: auto !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}

.tc-trade-row-new, .tc-trade-details {
  width: 100% !important;
  box-sizing: border-box !important;
}

/* ============================================================
   NEXTER TEXT ANNOTATION MODAL
   ============================================================ */
#nexter-text-modal-backdrop,
#zenance-text-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1000010;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ztm-fade-in 0.16s ease;
}

@keyframes ztm-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

#nexter-text-modal-card,
#zenance-text-modal-card {
  background: #ffffff;
  border: 1px solid rgba(108, 0, 255, 0.28);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25), 0 0 24px rgba(108, 0, 255, 0.18);
  width: 90vw;
  max-width: 380px;
  padding: 22px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: ztm-card-in 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

@keyframes ztm-card-in {
  from { transform: scale(0.93) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.ztm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ztm-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.ztm-title svg {
  stroke: #6c00ff;
}

.ztm-close-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.ztm-close-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.ztm-input-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ztm-textarea {
  width: 100%;
  min-height: 85px;
  max-height: 180px;
  padding: 12px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: #0f172a;
  background: #f8fafc;
  resize: vertical;
  box-sizing: border-box;
  outline: none;
  transition: all 0.15s ease;
}

.ztm-textarea:focus {
  border-color: #6c00ff;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(108, 0, 255, 0.12);
}

.ztm-actions {
  display: flex !important;
  gap: 10px !important;
  justify-content: flex-end !important;
  margin-top: 4px !important;
}

.ztm-btn,
#nexter-text-modal-backdrop .ztm-btn,
#zenance-text-modal-backdrop .ztm-btn {
  padding: 9px 18px !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  border: none !important;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif !important;
  transition: all 0.15s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1.4 !important;
  letter-spacing: 0.2px !important;
}

.ztm-btn-cancel,
#nexter-text-modal-backdrop .ztm-btn-cancel,
#zenance-text-modal-backdrop .ztm-btn-cancel {
  background: #f1f5f9 !important;
  color: #475569 !important;
  border: 1px solid #cbd5e1 !important;
}

.ztm-btn-cancel:hover,
#nexter-text-modal-backdrop .ztm-btn-cancel:hover,
#zenance-text-modal-backdrop .ztm-btn-cancel:hover {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

.ztm-btn-submit,
#nexter-text-modal-backdrop .ztm-btn-submit,
#zenance-text-modal-backdrop .ztm-btn-submit {
  background: linear-gradient(135deg, #6c00ff 0%, #8b5cf6 100%) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  box-shadow: 0 4px 14px rgba(108, 0, 255, 0.35) !important;
}

.ztm-btn-submit:hover,
#nexter-text-modal-backdrop .ztm-btn-submit:hover,
#zenance-text-modal-backdrop .ztm-btn-submit:hover {
  background: linear-gradient(135deg, #7c14ff 0%, #9d6fff 100%) !important;
  box-shadow: 0 6px 20px rgba(108, 0, 255, 0.45) !important;
  color: #ffffff !important;
  transform: translateY(-1px) !important;
}

/* Chart Canvas Mobile / Desktop Performance Optimization */
@media (min-width: 768px) {
  #nexter-chart canvas,
  #zenance-chart canvas {
    filter: drop-shadow(0 2px 5px rgba(108, 0, 255, 0.08));
  }
}

@media (max-width: 767px) {
  #nexter-chart canvas,
  #zenance-chart canvas {
    filter: none !important;
    -webkit-filter: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* ============================================================
   NEXTER CHART CONTEXT MENU (TRADE PAGE ONLY)
   Dark Purple glassmorphism default, light theme support
   ============================================================ */
#nexter-chart-context-menu,
#zenance-chart-context-menu {
  position: fixed;
  z-index: 1000000;
  background: rgba(15, 12, 28, 0.97) !important;
  border: 1px solid rgba(139, 92, 246, 0.35) !important;
  border-radius: 12px !important;
  padding: 6px !important;
  min-width: 220px !important;
  max-width: 290px !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.65), 0 0 18px rgba(108, 0, 255, 0.25) !important;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif !important;
  user-select: none !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 2px !important;
  animation: zcm-fade-in 0.14s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
}

body.light-theme #nexter-chart-context-menu,
body.light-theme #zenance-chart-context-menu {
  background: #ffffff !important;
  border: 1px solid rgba(108, 0, 255, 0.2) !important;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(108, 0, 255, 0.1) !important;
}

@keyframes zcm-fade-in {
  from { opacity: 0; transform: scale(0.96) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.zcm-item {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  color: #f1f5f9 !important;
  cursor: pointer !important;
  background: transparent !important;
  border: none !important;
  width: 100% !important;
  text-align: left !important;
  box-sizing: border-box !important;
  transition: all 0.12s ease !important;
  line-height: 1.3 !important;
}

body.light-theme .zcm-item {
  color: #1e293b !important;
}

.zcm-item:hover {
  background: rgba(108, 0, 255, 0.16) !important;
  color: #c4b5fd !important;
}

body.light-theme .zcm-item:hover {
  background: rgba(108, 0, 255, 0.08) !important;
  color: #6c00ff !important;
}

.zcm-item:active {
  background: rgba(108, 0, 255, 0.22) !important;
}

body.light-theme .zcm-item:active {
  background: rgba(108, 0, 255, 0.14) !important;
}

.zcm-item-icon {
  width: 16px !important;
  height: 16px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  color: #a78bfa !important;
}

body.light-theme .zcm-item-icon {
  color: #8b5cf6 !important;
}

.zcm-item:hover .zcm-item-icon {
  color: #c4b5fd !important;
}

body.light-theme .zcm-item:hover .zcm-item-icon {
  color: #6c00ff !important;
}

.zcm-divider {
  height: 1px !important;
  background: rgba(139, 92, 246, 0.2) !important;
  margin: 4px 6px !important;
}

body.light-theme .zcm-divider {
  background: rgba(108, 0, 255, 0.1) !important;
}

.zcm-section-title {
  font-size: 10px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  color: #a78bfa !important;
  padding: 5px 10px 3px !important;
}

body.light-theme .zcm-section-title {
  color: #8b5cf6 !important;
}

.zcm-empty-tools {
  padding: 6px 12px !important;
  font-size: 11.5px !important;
  color: rgba(255, 255, 255, 0.45) !important;
  font-style: italic !important;
}

body.light-theme .zcm-empty-tools {
  color: #94a3b8 !important;
}

.zcm-tools-list {
  max-height: 190px !important;
  overflow-y: auto !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 3px !important;
  padding: 0 2px !important;
}

.zcm-tool-item {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 6px 10px !important;
  border-radius: 7px !important;
  font-size: 11.5px !important;
  font-weight: 500 !important;
  color: #e2e8f0 !important;
  cursor: pointer !important;
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(139, 92, 246, 0.15) !important;
  transition: all 0.12s ease !important;
  box-sizing: border-box !important;
}

body.light-theme .zcm-tool-item {
  color: #334155 !important;
  background: rgba(248, 250, 252, 0.9) !important;
  border: 1px solid rgba(108, 0, 255, 0.08) !important;
}

.zcm-tool-item:hover {
  background: rgba(108, 0, 255, 0.18) !important;
  color: #c4b5fd !important;
  border-color: rgba(139, 92, 246, 0.35) !important;
}

body.light-theme .zcm-tool-item:hover {
  background: rgba(108, 0, 255, 0.1) !important;
  color: #6c00ff !important;
  border-color: rgba(108, 0, 255, 0.25) !important;
}

.zcm-tool-item.zcm-selected {
  background: linear-gradient(135deg, rgba(108, 0, 255, 0.28) 0%, rgba(139, 92, 246, 0.32) 100%) !important;
  color: #ffffff !important;
  border-color: rgba(139, 92, 246, 0.55) !important;
  font-weight: 600 !important;
}

body.light-theme .zcm-tool-item.zcm-selected {
  background: linear-gradient(135deg, rgba(108, 0, 255, 0.12) 0%, rgba(139, 92, 246, 0.16) 100%) !important;
  color: #6c00ff !important;
  border-color: rgba(108, 0, 255, 0.4) !important;
}

.zcm-tool-name {
  display: flex !important;
  align-items: center !important;
  gap: 7px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  flex: 1 !important;
}

.zcm-tool-name svg {
  flex-shrink: 0 !important;
}

.zcm-tool-delete {
  background: none !important;
  border: none !important;
  padding: 2px 5px !important;
  color: #94a3b8 !important;
  cursor: pointer !important;
  border-radius: 4px !important;
  font-size: 11px !important;
  line-height: 1 !important;
  opacity: 0.65 !important;
  transition: all 0.12s !important;
  flex-shrink: 0 !important;
}

.zcm-tool-delete:hover {
  color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.12) !important;
  opacity: 1 !important;
}


