/* ─── DATA INSPECTOR STYLES ───────────────────────────────────────────────────────── */

/* Modal Backdrop */
.inspector-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}

.inspector-modal.open {
  display: flex;
}

.inspector-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

/* Modal Container */
.inspector-container {
  position: relative;
  width: 90%;
  max-width: 1800px;
  height: 92vh;
  max-height: 1100px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: inspectorSlideIn 0.2s ease-out;
}

@keyframes inspectorSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header */
.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.inspector-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}

.inspector-icon {
  font-size: 20px;
}

.inspector-actions {
  display: flex;
  gap: 8px;
}

.inspector-actions .inspector-btn:last-child {
  padding: 6px 12px;
  font-size: 18px;
  line-height: 1;
}

/* Multi-Chart Tabs */
.inspector-charts-tabs {
  display: none;
  gap: 4px;
  padding: 8px 16px 0;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  overflow-x: auto;
}

.inspector-charts-tabs:not(:empty) {
  display: flex;
}

.inspector-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.inspector-tab:hover {
  color: #374151;
  background: #f3f4f6;
  border-radius: 6px 6px 0 0;
}

.inspector-tab.active {
  color: #059669;
  border-bottom-color: #059669;
  background: #fff;
}

/* Tab Delete Button */
.inspector-tab-delete {
  padding: 4px 8px;
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: 4px;
  margin-left: 2px;
}

.inspector-tab-delete:hover {
  color: #dc2626;
  background: #fee2e2;
}

/* Tab Edit Button */
.inspector-tab-action {
  padding: 4px 8px;
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: 4px;
  margin-left: 2px;
}

.inspector-tab-action:hover {
  color: #059669;
  background: #d1fae5;
}

/* Content Area */
.inspector-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Quality Panel */
.inspector-quality-panel {
  padding: 12px 16px;
  background: #fefce8;
  border-bottom: 1px solid #fef08a;
}

.quality-summary {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.quality-stat {
  display: flex;
  gap: 6px;
  font-size: 12px;
}

.quality-label {
  color: #78716c;
  font-weight: 500;
}

.quality-value {
  color: #1c1917;
  font-weight: 600;
}

.quality-error .quality-value {
  color: #dc2626;
}

.quality-warning .quality-value {
  color: #d97706;
}

/* Table Wrapper */
.inspector-table-wrapper {
  flex: 1;
  overflow: auto;
  border-top: 1px solid #e5e7eb;
}

/* Table */
.inspector-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.inspector-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f9fafb;
}

.inspector-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
  user-select: none;
}

.inspector-table th:hover {
  background: #f3f4f6;
}

.inspector-table td {
  padding: 8px 16px;
  border-bottom: 1px solid #f3f4f6;
}

.inspector-table tr:hover {
  background: #fefce8;
}

.inspector-table tr:focus-within {
  background: #eff6ff;
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
}

/* Editable Cells */
.inspector-table [contenteditable="true"] {
  cursor: text;
  transition: background 0.15s;
}

.inspector-table [contenteditable="true"]:hover {
  background: #fff;
  box-shadow: inset 0 0 0 1px #d1d5db;
}

.inspector-table [contenteditable="true"]:focus {
  outline: none;
  background: #fff;
  box-shadow: inset 0 0 0 2px #3b82f6;
}

/* Number Cells */
.inspector-number {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  text-align: right;
}

/* Status Column */
.inspector-status {
  text-align: center;
  padding: 8px 8px;
}

.status-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  line-height: 20px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
}

.status-valid {
  background: #dcfce7;
  color: #16a34a;
}

.status-warning {
  background: #fef3c7;
  color: #d97706;
}

.status-error {
  background: #fee2e2;
  color: #dc2626;
}

/* Actions Column */
.inspector-actions-col {
  width: 60px;
  text-align: center;
  padding: 8px 8px;
}

.inspector-btn-small {
  width: 24px;
  height: 24px;
  padding: 0;
  background: #fee2e2;
  border: none;
  border-radius: 4px;
  color: #dc2626;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
}

.inspector-btn-small:hover {
  background: #fecaca;
  transform: scale(1.1);
}

/* Footer */
.inspector-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

.inspector-footer-info {
  flex: 1;
  text-align: right;
  font-size: 12px;
  color: #6b7280;
}

/* Buttons */
.inspector-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s;
}

.inspector-btn:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.inspector-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.inspector-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.inspector-btn-primary {
  background: #059669;
  border-color: #059669;
  color: #fff;
}

.inspector-btn-primary:hover:not(:disabled) {
  background: #047857;
  border-color: #047857;
}

/* Responsive */
@media (max-width: 768px) {
  .inspector-container {
    width: 98%;
    height: 92vh;
  }

  .inspector-table {
    font-size: 12px;
  }

  .inspector-table th,
  .inspector-table td {
    padding: 8px 12px;
  }

  .quality-summary {
    flex-direction: column;
    gap: 8px;
  }

  .inspector-footer {
    flex-wrap: wrap;
  }
}

/* Scrollbar Styling */
.inspector-table-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.inspector-table-wrapper::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.inspector-table-wrapper::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.inspector-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}


/* ─── NEW CHART CREATION UI ───────────────────────────────────────────────────────── */

/* Mode Badge */
.inspector-mode-badge {
  display: inline-block;
  padding: 2px 8px;
  background: #8b5cf6;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  border-radius: 12px;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Metadata Bar */
.inspector-metadata-bar {
  display: none;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  align-items: flex-end;
}

.meta-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-field label {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.meta-field input,
.meta-field select {
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 12px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.meta-field input:focus,
.meta-field select:focus {
  outline: none;
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.meta-field input::placeholder {
  color: #94a3b8;
}

.meta-compact {
  flex: 0 0 auto;
}

.meta-compact input,
.meta-compact select {
  width: 100px;
}

/* Save Button */
.inspector-btn-save {
  background: #8b5cf6;
  border-color: #8b5cf6;
  color: #fff;
}

.inspector-btn-save:hover:not(:disabled) {
  background: #7c3aed;
  border-color: #7c3aed;
}

/* Smart Suggestions Panel */
.inspector-suggestions {
  padding: 12px 16px;
  background: linear-gradient(135deg, #fef3c7 0%, #fef9c3 100%);
  border-bottom: 1px solid #fde68a;
}

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

.suggestions-header span {
  font-size: 12px;
  font-weight: 600;
  color: #92400e;
}

.suggestions-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.suggestion-item {
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.suggestion-item:hover {
  background: #fef3c7;
  border-color: #fcd34d;
  transform: translateX(2px);
}

.suggestion-item strong {
  color: #92400e;
  font-weight: 600;
}

/* Small button variant */
.inspector-btn-small {
  padding: 4px 8px;
  font-size: 11px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.inspector-btn-small:hover {
  background: #e2e8f0;
}

/* Empty state improvements */
.inspector-table tbody:empty::after {
  content: "No flows yet. Click '+ Add Row' or select a template above to get started.";
  display: block;
  padding: 60px 40px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
  font-style: normal;
}

.inspector-table tbody:empty::before {
  content: "✨";
  display: block;
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Responsive adjustments for metadata bar */
@media (max-width: 1024px) {
  .inspector-metadata-bar {
    max-height: 120px;
    overflow-y: auto;
  }

  .meta-compact {
    flex: 1 1 45%;
  }

  .meta-compact input,
  .meta-compact select {
    width: 100%;
  }
}

/* Animation for mode badge */
.inspector-mode-badge {
  animation: badgePop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes badgePop {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* Focus states for accessibility */
.meta-field input:focus-visible,
.meta-field select:focus-visible {
  outline: 2px solid #8b5cf6;
  outline-offset: 2px;
}

/* ─── STATUS TOOLTIPS ──────────────────────────────────────────────────────────────── */

.inspector-status {
  position: relative;
  cursor: help;
}

.status-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  line-height: 20px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  position: relative;
}

/* Custom tooltip on hover */
.status-icon:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  padding: 8px 12px;
  background: #1e293b;
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  white-space: pre-line;
  text-align: left;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  min-width: 200px;
  max-width: 300px;
  pointer-events: none;
  opacity: 0;
  animation: tooltipFadeIn 0.2s ease-out forwards;
}

/* Tooltip arrow */
.status-icon:hover::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: -2px;
  border: 6px solid transparent;
  border-top-color: #1e293b;
  opacity: 0;
  animation: tooltipFadeIn 0.2s ease-out forwards;
}

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

/* Ensure tooltips work on all status types */
.status-valid:hover::after,
.status-warning:hover::after,
.status-error:hover::after {
  content: attr(title);
}

.status-valid:hover::before,
.status-warning:hover::before,
.status-error:hover::before {
  border-top-color: #1e293b;
}

/* Adjust tooltip position for rows near top */
.inspector-table tr:first-child .status-icon:hover::after {
  bottom: auto;
  top: 100%;
  margin-bottom: 0;
  margin-top: 8px;
}

.inspector-table tr:first-child .status-icon:hover::before {
  bottom: auto;
  top: 100%;
  margin-bottom: 0;
  margin-top: -2px;
  border-top-color: transparent;
  border-bottom-color: #1e293b;
}

/* ─── FLOW CANVAS STYLES ───────────────────────────────────────────────────────────── */

.flow-canvas-svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.flow-canvas-svg:active {
  cursor: grabbing;
}

.flow-canvas-node {
  transition: opacity 0.15s ease;
}

.flow-canvas-node-rect {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  transition: filter 0.15s ease;
}

.flow-canvas-node:hover .flow-canvas-node-rect {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.flow-canvas-connection {
  transition: opacity 0.15s ease, stroke-width 0.15s ease;
}

.flow-canvas-label text {
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* ─── CONTEXT MENU STYLES ───────────────────────────────────────────────────────────── */

.flow-canvas-context-menu .context-menu-item {
  transition: background 0.15s ease;
}

.flow-canvas-context-menu .context-menu-item:hover {
  background: #fef2f2;
}

/* ─── ADD BUTTON STYLES ─────────────────────────────────────────────────────────────── */

.flow-canvas-add-button {
  transition: transform 0.15s ease;
}

.flow-canvas-add-button:hover circle {
  fill: #047857;
  stroke-width: 3;
}

.flow-canvas-add-button:active {
  transform: scale(0.95);
}

.flow-canvas-add-button:hover {
  transform: scale(1.1);
}

/* ─── TABLE SEARCH INPUT ───────────────────────────────────────────────────────────── */
#inspectorTableSearch:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}
