/* ========================================
   Combo Chart Extension - Modern Styles
   ======================================== */

/* CSS Variables - Modern Theme */
:root {
  /* Primary Colors */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;

  /* Neutral Colors */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Semantic Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;

  /* Chart Colors - Tableau-inspired */
  --chart-blue: #4e79a7;
  --chart-orange: #f28e2c;
  --chart-red: #e15759;
  --chart-teal: #76b7b2;
  --chart-green: #59a14f;
  --chart-yellow: #edc949;
  --chart-purple: #af7aa1;
  --chart-pink: #ff9da7;
  --chart-brown: #9c755f;
  --chart-gray: #bab0ab;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Border Radius */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, Monaco, 'Cascadia Code', monospace;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: white;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Loading State */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 20px;
  background: linear-gradient(180deg, white 0%, var(--gray-50) 100%);
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-container p {
  color: var(--gray-500);
  font-size: 14px;
  font-weight: 500;
}

/* Config Required State */
.config-required {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 32px;
  background: linear-gradient(180deg, white 0%, var(--gray-50) 100%);
}

.config-message {
  text-align: center;
  max-width: 380px;
  padding: 32px;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-100);
}

.config-message svg {
  color: var(--primary-500);
  margin-bottom: 20px;
  opacity: 0.9;
}

.config-message h2 {
  margin: 0 0 10px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-900);
}

.config-message p {
  margin: 0 0 24px 0;
  color: var(--gray-500);
  font-size: 14px;
  line-height: 1.6;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  outline: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px white, 0 0 0 4px var(--primary-500);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(180deg, var(--primary-500) 0%, var(--primary-600) 100%);
  color: white;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.1);
}

.btn-primary:hover {
  background: linear-gradient(180deg, var(--primary-600) 0%, var(--primary-700) 100%);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.1);
}

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  color: var(--gray-500);
  box-shadow: var(--shadow-xs);
}

.btn-icon:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-700);
}

/* Chart Container */
.chart-container {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
  background: white;
  overflow: hidden;
  position: relative;
}

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

.chart-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  letter-spacing: -0.01em;
}

.chart-controls {
  display: flex;
  gap: 8px;
}

.chart-area {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  position: relative;
  padding: 12px 16px;
  background: white;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.chart-area svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  flex: 1 1 auto;
  display: block;
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 14px 20px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
  cursor: pointer;
}

.legend:hover {
  background: var(--gray-100);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
}

.legend-line {
  width: 20px;
  height: 3px;
  border-radius: var(--radius-full);
}

/* Legend positions */
.legend.legend-right,
.legend.legend-left {
  flex-direction: column;
  border-top: none;
  padding: 16px 14px;
  gap: 10px;
  flex-shrink: 0;
  width: auto;
  min-width: 100px;
  max-width: 150px;
}

.legend.legend-right {
  border-left: 1px solid var(--gray-200);
  order: 2;
}

.legend.legend-left {
  border-right: 1px solid var(--gray-200);
  order: 0;
}

.legend.legend-top {
  border-top: none;
  border-bottom: 1px solid var(--gray-200);
  order: 0;
}

/* Chart container layout adjustments for legend positions */
.chart-container {
  display: flex;
  flex-direction: column;
}

.chart-container .chart-area {
  flex: 1 1 auto;
  order: 1;
}

/* Error State */
.error-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 32px;
  background: linear-gradient(180deg, #fef2f2 0%, white 100%);
}

.error-message {
  text-align: center;
  max-width: 380px;
  padding: 32px;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid #fee2e2;
}

.error-message svg {
  color: var(--error);
  margin-bottom: 16px;
}

.error-message h2 {
  margin: 0 0 10px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--error);
}

.error-message p {
  margin: 0 0 20px 0;
  color: var(--gray-600);
  font-size: 14px;
  line-height: 1.6;
}

/* Tooltip */
.tooltip {
  position: fixed;
  pointer-events: none;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  max-width: 280px;
  backdrop-filter: blur(8px);
  animation: tooltipFadeIn 0.15s ease;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tooltip-title {
  font-weight: 600;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 2px 0;
}

.tooltip-label {
  opacity: 0.75;
}

.tooltip-value {
  font-weight: 600;
  font-feature-settings: 'tnum';
}

/* Chart Elements */
.bar {
  transition: opacity var(--transition-fast), filter var(--transition-fast);
}

.bar:hover {
  opacity: 0.85;
  filter: brightness(1.05);
}

.line-path {
  fill: none;
  transition: opacity var(--transition-fast);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.data-point {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

.data-point circle,
.data-point rect,
.data-point polygon {
  transition: transform var(--transition-fast), filter var(--transition-fast);
  transform-origin: center;
  transform-box: fill-box;
}

.data-point:hover circle,
.data-point:hover rect,
.data-point:hover polygon {
  transform: scale(1.3);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
}

/* Axes */
.x-axis path,
.y-axis-left path,
.y-axis-right path {
  stroke: var(--gray-300);
}

.x-axis line,
.y-axis-left line,
.y-axis-right line {
  stroke: var(--gray-200);
}

.x-axis text,
.y-axis-left text,
.y-axis-right text {
  font-size: 11px;
  fill: var(--gray-500);
  font-weight: 500;
}

.axis-title {
  font-size: 12px;
  font-weight: 600;
  fill: var(--gray-700);
}

/* Grid */
.grid-group line {
  stroke: var(--gray-200);
  stroke-dasharray: 2 2;
}

.grid-group path {
  display: none;
}

/* Labels */
.bar-label, .line-label {
  font-size: 11px;
  font-weight: 600;
  fill: var(--gray-700);
  pointer-events: none;
  font-feature-settings: 'tnum';
}

/* Responsive */
@media (max-width: 600px) {
  .chart-header {
    padding: 12px 16px;
  }

  .chart-header h3 {
    font-size: 14px;
  }

  .chart-area {
    padding: 12px 16px;
  }

  .legend {
    gap: 16px;
    padding: 12px 16px;
  }

  .legend-item {
    font-size: 12px;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.2s ease;
}

.animate-slide-up {
  animation: slideUp 0.25s ease;
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  min-width: 200px;
  z-index: 2000;
  animation: contextMenuIn 0.15s ease;
  overflow: hidden;
}

@keyframes contextMenuIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.context-menu-header {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.context-menu-items {
  padding: 6px 0;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--gray-700);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.context-menu-item:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.context-menu-item svg {
  width: 16px;
  height: 16px;
  color: var(--gray-400);
  flex-shrink: 0;
}

.context-menu-item:hover svg {
  color: var(--gray-600);
}

.context-menu-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 6px 0;
}

.context-menu-item.has-submenu::after {
  content: '';
  margin-left: auto;
  border: 4px solid transparent;
  border-left-color: var(--gray-400);
}

.context-menu-item input[type="color"] {
  width: 24px;
  height: 24px;
  border: none;
  padding: 0;
  cursor: pointer;
  margin-left: auto;
}

.context-menu-item input[type="number"] {
  width: 60px;
  padding: 4px 8px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-left: auto;
}

.context-menu-item .toggle-switch {
  margin-left: auto;
  width: 36px;
  height: 20px;
  background: var(--gray-300);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.context-menu-item .toggle-switch.active {
  background: var(--primary-500);
}

.context-menu-item .toggle-switch::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.context-menu-item .toggle-switch.active::after {
  transform: translateX(16px);
}

/* ========================================
   Debug Console Panel
   ======================================== */
.debug-toggle {
  position: fixed;
  bottom: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  background: var(--gray-800);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 9998;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  opacity: 0.7;
  transition: opacity 0.2s, transform 0.2s;
}

.debug-toggle:hover {
  opacity: 1;
  transform: scale(1.1);
}

.debug-panel {
  position: fixed;
  bottom: 55px;
  right: 10px;
  width: 450px;
  max-width: calc(100vw - 20px);
  height: 350px;
  max-height: calc(100vh - 70px);
  background: #1e1e1e;
  border-radius: 8px;
  box-shadow: var(--shadow-xl);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 11px;
  overflow: hidden;
}

.debug-panel.hidden {
  display: none;
}

.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #2d2d2d;
  color: #e0e0e0;
  font-weight: 600;
  font-size: 12px;
  border-bottom: 1px solid #3d3d3d;
}

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

.debug-btn {
  background: #3d3d3d;
  border: none;
  color: #e0e0e0;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
}

.debug-btn:hover {
  background: #4d4d4d;
}

.debug-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  color: #d4d4d4;
}

.debug-log {
  padding: 4px 6px;
  margin-bottom: 2px;
  border-radius: 3px;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.4;
}

.debug-log:hover {
  background: rgba(255, 255, 255, 0.05);
}

.debug-time {
  color: #888;
  font-size: 10px;
}

.debug-type {
  font-weight: 600;
  margin-right: 4px;
}

.debug-log {
  color: #d4d4d4;
}

.debug-info .debug-type {
  color: #569cd6;
}

.debug-warn {
  background: rgba(255, 193, 7, 0.1);
}

.debug-warn .debug-type {
  color: #ffc107;
}

.debug-error {
  background: rgba(244, 67, 54, 0.1);
}

.debug-error .debug-type {
  color: #f44336;
}

/* Scrollbar styling for debug panel */
.debug-content::-webkit-scrollbar {
  width: 8px;
}

.debug-content::-webkit-scrollbar-track {
  background: #1e1e1e;
}

.debug-content::-webkit-scrollbar-thumb {
  background: #4d4d4d;
  border-radius: 4px;
}

.debug-content::-webkit-scrollbar-thumb:hover {
  background: #5d5d5d;
}
