/* ============================================================================
   KLH GRID LOADER - RUNTIME STYLES
   ============================================================================
   Portable CSS for klh-grid-loader.js runtime library.

   USAGE:
   - Standalone: Include this file, variables have sensible defaults
   - KLH Platform: Variables are set in klh-variables.css
   - Custom project: Override --klh-gl-* variables in your CSS

   PREFIX: .klh-gl-* (grid loader specific)

   SECTIONS:
   - CSS Variable Defaults (override these for theming)
   - Grid Shell (header, status bar, toast)
   - Buttons
   - Quick Filter
   - Status Indicators
   - Flex Utilities
   - Display States
   - Cell Renderers (badge, link, action buttons)
   - JSON Viewer
   - Form Modal
   - Bulk Edit Modal
   - Column Visibility Modal
   - Confirm Dialog
   - Child Grid Modal
   - Notes Popover
   - HTML Table Fallback
   - Audit Panel
   - Debug Panel
   - Context Menu Extensions
   ============================================================================ */

/* ==================== CSS VARIABLE DEFAULTS ==================== */
/* Override these in your project for custom theming */

:root {
  /* Colors - fallback to KLH Platform vars or sensible defaults */
  --klh-gl-bg-primary: var(--klh-bg-primary, #0f172a);
  --klh-gl-bg-secondary: var(--klh-bg-secondary, #1e293b);
  --klh-gl-bg-tertiary: var(--klh-bg-tertiary, #334155);
  --klh-gl-text-primary: var(--klh-text-primary, #f1f5f9);
  --klh-gl-text-secondary: var(--klh-text-secondary, #94a3b8);
  --klh-gl-text-muted: #9ca3af;
  --klh-gl-border: var(--klh-border-primary, #475569);
  --klh-gl-accent: var(--klh-accent, #3b82f6);
  --klh-gl-success: var(--klh-success, #22c55e);
  --klh-gl-warning: var(--klh-warning, #f59e0b);
  --klh-gl-error: var(--klh-error, #ef4444);

  /* Sizing */
  --klh-gl-font-size: 11px;
  --klh-gl-font-size-sm: 9px;
  --klh-gl-border-radius: 4px;
  --klh-gl-spacing-xs: 4px;
  --klh-gl-spacing-sm: 6px;
  --klh-gl-spacing-md: 10px;
  --klh-gl-spacing-lg: 16px;
}

/* ==================== GRID SHELL ==================== */

.klh-gl-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--klh-gl-spacing-sm) var(--klh-gl-spacing-md);
  background: var(--klh-gl-bg-secondary);
  border: 1px solid var(--klh-gl-border);
  border-radius: var(--klh-gl-border-radius);
  gap: 12px;
  opacity: 0;
  transition: opacity 0.1s;
}

.klh-gl-header.klh-gl-visible {
  opacity: 1;
}

.klh-gl-header-left {
  display: flex;
  align-items: center;
  gap: var(--klh-gl-spacing-sm);
}

.klh-gl-header-actions {
  display: flex;
  align-items: center;
  gap: var(--klh-gl-spacing-sm);
  flex-wrap: wrap;
}

.klh-gl-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--klh-gl-accent);
  white-space: nowrap;
}

.klh-gl-subtitle {
  font-size: var(--klh-gl-font-size);
  color: var(--klh-gl-text-secondary);
  margin-left: var(--klh-gl-spacing-sm);
}

.klh-gl-row-count {
  font-size: var(--klh-gl-font-size-sm);
  color: var(--klh-gl-text-muted);
  margin-left: var(--klh-gl-spacing-xs);
}

.klh-gl-row-count.klh-gl-loading {
  font-family: var(--klh-font-mono, monospace);
  color: var(--klh-gl-success);
  animation: klh-gl-pulse 1s infinite;
}

.klh-gl-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.klh-gl-grid-container {
  flex: 1;
  overflow: hidden;
}

.klh-gl-status-bar {
  display: none;
  align-items: center;
  gap: var(--klh-gl-spacing-md);
  padding: var(--klh-gl-spacing-xs) var(--klh-gl-spacing-md);
  background: var(--klh-gl-bg-tertiary);
  border: 1px solid var(--klh-gl-border);
  border-top: none;
  border-radius: 0 0 var(--klh-gl-border-radius) var(--klh-gl-border-radius);
  font-size: var(--klh-gl-font-size-sm);
  color: var(--klh-gl-text-secondary);
}

.klh-gl-status-bar.klh-gl-visible {
  display: flex;
}

.klh-gl-status-divider {
  color: var(--klh-gl-text-muted);
}

.klh-gl-collapse-toggle {
  display: none;
  cursor: pointer;
  margin-right: var(--klh-gl-spacing-sm);
  font-size: 10px;
  color: var(--klh-gl-text-secondary);
  user-select: none;
}

.klh-gl-collapse-toggle.klh-gl-visible {
  display: inline;
}

.klh-gl-error-message {
  padding: 20px;
  color: var(--klh-gl-error);
}

.klh-gl-loading-message {
  text-align: center;
  color: var(--klh-gl-text-muted);
  padding: 20px;
}

/* ==================== STATUS INDICATORS ==================== */

.klh-gl-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: var(--klh-gl-spacing-sm);
  background: var(--klh-gl-text-muted);
  transition: background 0.2s;
}

.klh-gl-status-dot.klh-gl-loading {
  background: var(--klh-gl-warning);
  animation: klh-gl-pulse 1s infinite;
}

.klh-gl-status-dot.klh-gl-connected {
  background: var(--klh-gl-success);
}

.klh-gl-status-dot.klh-gl-error {
  background: var(--klh-gl-error);
}

@keyframes klh-gl-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==================== TOAST ==================== */

.klh-gl-toast {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  padding: var(--klh-gl-spacing-md) var(--klh-gl-spacing-lg);
  background: var(--klh-gl-bg-secondary) !important;
  border: 1px solid var(--klh-gl-border);
  border-radius: var(--klh-gl-border-radius);
  font-size: var(--klh-gl-font-size);
  color: var(--klh-gl-text-primary) !important;
  z-index: 2147483647 !important;
  pointer-events: none;
  visibility: hidden;
  transform: translateZ(0);
}

.klh-gl-toast.klh-gl-show {
  visibility: visible !important;
  pointer-events: auto;
}

.klh-gl-toast.klh-gl-success {
  border-color: var(--klh-gl-success);
}

.klh-gl-toast.klh-gl-error {
  border-color: var(--klh-gl-error);
}

.klh-gl-toast.klh-gl-warning {
  border-color: var(--klh-gl-warning);
}

.klh-gl-toast-msg {
  flex: 1;
}

.klh-gl-toast-close {
  margin-left: 12px;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  opacity: 0.7;
  line-height: 1;
}

.klh-gl-toast-close:hover {
  opacity: 1;
}

/* Toast with close button needs flex layout */
.klh-gl-toast.klh-gl-warning,
.klh-gl-toast.klh-gl-error {
  display: flex;
  align-items: center;
}

/* ==================== BUTTONS ==================== */

.klh-gl-btn {
  padding: 3px 8px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  white-space: nowrap;
}

.klh-gl-btn:hover {
  background: var(--klh-gl-bg-tertiary);
  color: var(--klh-gl-text-primary);
}

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

.klh-gl-btn-sm {
  padding: 3px 6px;
  font-size: 8px;
}

.klh-gl-btn-primary {
  color: var(--klh-gl-accent);
  border: 1px solid var(--klh-gl-accent);
}

.klh-gl-btn-primary:hover {
  background: rgba(59, 130, 246, 0.15);
}

.klh-gl-btn-secondary {
  color: var(--klh-gl-text-secondary);
  border: 1px solid var(--klh-gl-border);
}

.klh-gl-btn-secondary:hover {
  background: var(--klh-gl-bg-tertiary);
  color: var(--klh-gl-text-primary);
}

.klh-gl-btn-success {
  color: var(--klh-gl-success);
  border: 1px solid var(--klh-gl-success);
}

.klh-gl-btn-success:hover {
  background: rgba(34, 197, 94, 0.15);
}

.klh-gl-btn-warning {
  color: var(--klh-gl-warning);
  border: 1px solid var(--klh-gl-warning);
}

.klh-gl-btn-warning:hover {
  background: rgba(245, 158, 11, 0.15);
}

.klh-gl-btn-danger {
  color: var(--klh-gl-error);
  border: 1px solid var(--klh-gl-error);
}

.klh-gl-btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* Tinted variants - colored background + border + text */
.klh-gl-btn-warning-tint {
  background: rgba(245, 158, 11, 0.25);
  color: #f59e0b;
  border: 1px solid #f59e0b;
}

.klh-gl-btn-warning-tint:hover {
  background: rgba(245, 158, 11, 0.35);
  color: #f59e0b;
}

.klh-gl-btn-danger-tint {
  background: rgba(239, 68, 68, 0.25);
  color: #ef4444;
  border: 1px solid #ef4444;
}

.klh-gl-btn-danger-tint:hover {
  background: rgba(239, 68, 68, 0.35);
  color: #ef4444;
}

.klh-gl-btn-muted {
  background: rgba(156, 163, 175, 0.25);
  color: #9ca3af;
  border: 1px solid #9ca3af;
}

.klh-gl-btn-muted:hover {
  background: rgba(156, 163, 175, 0.35);
  color: #9ca3af;
}

.klh-gl-btn-accent {
  background: rgba(59, 130, 246, 0.25);
  color: #3b82f6;
  border: 1px solid #3b82f6;
}

.klh-gl-btn-accent:hover {
  background: rgba(59, 130, 246, 0.35);
  color: #3b82f6;
}

.klh-gl-btn-audit {
  color: var(--klh-gl-text-secondary);
  border: 1px solid var(--klh-gl-border);
}

.klh-gl-audit-badge {
  display: inline-block;
  min-width: 16px;
  padding: 1px 4px;
  margin-left: 4px;
  font-size: 8px;
  font-weight: 700;
  text-align: center;
  background: var(--klh-gl-bg-tertiary);
  border-radius: 8px;
}

/* ==================== QUICK FILTER ==================== */

.klh-gl-quick-filter {
  display: flex;
  align-items: center;
  gap: var(--klh-gl-spacing-xs);
}

.klh-gl-quick-filter-input {
  padding: 4px 8px;
  font-size: var(--klh-gl-font-size-sm);
  background: var(--klh-gl-bg-primary);
  border: 1px solid var(--klh-gl-border);
  border-radius: var(--klh-gl-border-radius);
  color: var(--klh-gl-text-primary);
  min-width: 150px;
}

.klh-gl-quick-filter-input:focus {
  outline: none;
  border-color: var(--klh-gl-accent);
}

.klh-gl-quick-filter-input::placeholder {
  color: var(--klh-gl-text-muted);
}

.klh-gl-quick-filter-clear {
  padding: 2px 6px;
  font-size: 12px;
  background: transparent;
  border: none;
  color: var(--klh-gl-text-muted);
  cursor: pointer;
}

.klh-gl-quick-filter-clear:hover {
  color: var(--klh-gl-text-primary);
}

/* ==================== FLEX UTILITIES ==================== */

.klh-gl-flex {
  display: flex;
  align-items: center;
}

.klh-gl-flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.klh-gl-flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.klh-gl-flex-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.klh-gl-flex-col {
  display: flex;
  flex-direction: column;
}

.klh-gl-gap-4 { gap: 4px; }
.klh-gl-gap-8 { gap: 8px; }
.klh-gl-gap-12 { gap: 12px; }

/* ==================== DISPLAY STATES ==================== */

.klh-gl-hidden {
  display: none;
}

.klh-gl-visible {
  display: block;
}

.klh-gl-inline {
  display: inline;
}

/* ==================== CELL RENDERERS ==================== */

/* Badge Renderer */
.klh-gl-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 10px;
}

/* Link Renderer */
.klh-gl-link {
  color: var(--klh-accent-blue);
  text-decoration: underline;
}

/* Action Button Renderer */
.klh-gl-action-btn {
  padding: 2px 6px;
  cursor: pointer;
  border: 1px solid var(--klh-border);
  background: var(--klh-bg-tertiary);
  border-radius: 3px;
  margin-right: 2px;
  color: var(--klh-text-primary);
  font-size: 11px;
}

.klh-gl-action-btn:hover {
  background: var(--klh-bg-hover);
  border-color: var(--klh-border-light);
}

/* Number Renderer */
.klh-gl-number {
  font-family: var(--klh-font-mono);
  font-size: 11px;
  font-weight: 600;
}

/* Expand Icon (for master-detail) */
.klh-gl-expand-icon {
  font-family: var(--klh-font-mono);
  font-size: 11px;
  font-weight: 600;
}

/* Notes Cell with Tooltip */
.klh-gl-notes-cell {
  cursor: help;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

/* ==================== JSON VIEWER ==================== */

.klh-gl-json-viewer {
  background: var(--klh-bg-tertiary);
  padding: 16px;
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  font-size: 12px;
  line-height: 1.6;
  font-family: var(--klh-font-mono);
  color: var(--klh-text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
  border-radius: 0;
}

.klh-gl-json-table-view {
  background: var(--klh-bg-tertiary);
  padding: 16px;
  max-height: 60vh;
  overflow: auto;
  font-size: 12px;
  display: none;
}

.klh-gl-json-table-view.visible {
  display: block;
}

.klh-gl-json-null {
  color: #9ca3af;
}

.klh-gl-json-key {
  color: var(--klh-text-primary);
  font-weight: bold;
}

.klh-gl-json-value {
  color: var(--klh-text-secondary);
}

.klh-gl-json-toggle {
  cursor: pointer;
  user-select: none;
  color: #9ca3af;
  margin-right: 4px;
}

.klh-gl-json-section {
  display: block;
}

.klh-gl-json-section.collapsed {
  display: none;
}

.klh-gl-json-cell-trigger {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.klh-gl-json-ellipsis {
  color: #9ca3af;
  font-size: 9px;
}

/* ==================== FORM MODAL (Centered Overlay) ==================== */

.klh-gl-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.klh-gl-modal-overlay.klh-gl-show,
.klh-gl-modal-overlay.klh-gl-fade-in {
  display: flex;
}

.klh-gl-modal-box {
  background: var(--klh-bg-secondary, #1a1f2e);
  border: 1px solid #4a5568;
  border-radius: 8px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

.klh-gl-modal-sm { width: 300px; max-width: 90vw; }
.klh-gl-modal-md { width: 400px; max-width: 90vw; }
.klh-gl-modal-lg { width: 450px; max-width: 90vw; max-height: 80vh; }
.klh-gl-modal-xl { width: 800px; max-width: 90vw; }
.klh-gl-modal-full { width: 80%; max-width: 1400px; max-height: 90vh; }

.klh-gl-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--klh-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.klh-gl-modal-header-sm {
  padding: 12px 16px;
}

.klh-gl-modal-title {
  margin: 0;
  color: var(--klh-text-primary);
  font-size: 16px;
  font-weight: 600;
}

.klh-gl-modal-title-sm {
  font-size: 14px;
}

.klh-gl-modal-close {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.klh-gl-modal-close:hover {
  color: var(--klh-text-primary);
}

.klh-gl-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.klh-gl-modal-body-compact {
  padding: 16px;
}

.klh-gl-modal-body-none {
  padding: 0;
}

.klh-gl-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--klh-border);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.klh-gl-modal-footer-sm {
  padding: 12px 16px;
  border-top: 1px solid var(--klh-border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ==================== FORM FIELDS ==================== */

.klh-gl-field {
  margin-bottom: 16px;
}

.klh-gl-field-label {
  display: block;
  margin-bottom: 4px;
  color: var(--klh-text-primary);
  font-size: 13px;
}

.klh-gl-field-required {
  color: var(--klh-error);
}

.klh-gl-field-input {
  width: 100%;
  padding: 8px;
  background: #0d1117 !important;
  border: 1px solid #888 !important;
  color: #e4e4e7 !important;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}

.klh-gl-field-input:focus {
  outline: none;
  border-color: #fff !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3) !important;
}

.klh-gl-field-input:disabled,
.klh-gl-field-input[readonly] {
  background: var(--klh-bg-tertiary);
  color: #9ca3af;
}

.klh-gl-field-checkbox {
  width: auto;
  height: 18px;
}

/* ==================== BULK EDIT MODAL ==================== */

.klh-gl-bulk-edit-title {
  font-weight: 600;
  color: var(--klh-text-primary);
  font-size: 16px;
}

/* ==================== COLUMN VISIBILITY MODAL ==================== */

.klh-gl-columns-list {
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  max-height: 400px;
  color: var(--klh-text-primary);
  font-size: 13px;
}

.klh-gl-column-row {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 4px;
}

.klh-gl-column-row:hover {
  background: var(--klh-bg-hover);
}

.klh-gl-column-row.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.klh-gl-column-checkbox {
  margin-right: 8px;
}

.klh-gl-column-name {
  flex: 1;
}

.klh-gl-column-locked {
  color: #9ca3af;
  font-size: 10px;
}

/* ==================== CONFIRM DIALOG ==================== */

.klh-gl-confirm-title {
  margin: 0 0 12px;
  color: var(--klh-text-primary);
  font-size: 16px;
}

.klh-gl-confirm-message {
  margin: 0 0 20px;
  color: var(--klh-text-secondary);
  font-size: 14px;
}

.klh-gl-confirm-detail {
  margin-bottom: 12px;
}

.klh-gl-confirm-list {
  background: var(--klh-bg-secondary);
  border: 1px solid var(--klh-border);
  border-radius: 4px;
  padding: 8px 12px;
  font-family: var(--klh-font-mono);
  font-size: 12px;
  max-height: 150px;
  overflow-y: auto;
}

/* ==================== CHILD GRID MODAL ==================== */

.klh-gl-fade-in {
  opacity: 0;
  transition: opacity 0.15s;
}

.klh-gl-fade-in.visible {
  opacity: 1;
}

.klh-gl-child-grid-modal {
  background: var(--klh-bg-primary);
  width: 80%;
  max-width: 1400px;
  max-height: 90vh;
}

.klh-gl-child-grid-container {
  flex: 1;
  overflow: auto;
  padding: 0;
}

.klh-gl-child-header {
  background: var(--klh-bg-secondary);
  padding: 8px 16px;
  height: 32px;
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.1s;
}

.klh-gl-child-header.visible {
  opacity: 1;
}

.klh-gl-child-main {
  height: calc(100% - 32px);
}

.klh-gl-child-grid-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10002;
  opacity: 0;
  transition: opacity 0.15s;
}

.klh-gl-child-grid-overlay.visible {
  opacity: 1;
}

.klh-gl-child-grid-header {
  background: var(--klh-bg-secondary);
  padding: 8px 16px;
  height: 32px;
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.1s;
}

.klh-gl-child-grid-header.visible {
  opacity: 1;
}

.klh-gl-child-grid-main {
  height: calc(100% - 32px);
}

.klh-gl-child-grid-error {
  padding: 20px;
  text-align: center;
  color: var(--klh-error);
}

/* ==================== NOTES POPOVER ==================== */

.klh-gl-notes-popover {
  background: var(--klh-bg-secondary);
  border: 1px solid var(--klh-border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.klh-gl-note-row {
  padding: 3px 10px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--klh-bg-tertiary);
}

.klh-gl-note-row:last-child {
  border-bottom: none;
}

.klh-gl-note-code {
  font-family: var(--klh-font-mono);
  font-weight: 600;
  color: var(--klh-success);
  min-width: 60px;
}

.klh-gl-note-desc {
  color: var(--klh-text-secondary);
  flex: 1;
}

.klh-gl-note-detail {
  color: var(--klh-warning);
}

/* ==================== HTML TABLE FALLBACK ==================== */

.klh-gl-html-table-wrapper {
  width: 100%;
  overflow: auto;
  background: var(--klh-bg-primary);
  color: var(--klh-text-primary);
}

.klh-gl-html-table {
  table-layout: fixed;
  border-collapse: collapse;
}

.klh-gl-html-table th {
  padding: 0;
  border-bottom: 2px solid var(--klh-border);
  background: var(--klh-bg-primary);
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1;
}

.klh-gl-html-table th > div {
  padding: 0 8px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.klh-gl-html-table td {
  padding: 0;
  border-bottom: 1px solid var(--klh-border-light, #3a4458);
}

.klh-gl-html-table td > div {
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.klh-gl-html-table-empty {
  padding: 20px;
  text-align: center;
  color: #9ca3af;
}

/* ==================== CONTEXT MENU EXTENSIONS ==================== */

.klh-gl-context-separator {
  border-top: 1px solid var(--klh-border);
  margin: 4px 0;
}

/* ==================== AUDIT PANEL EXTENSIONS ==================== */

.klh-gl-audit-diff-field {
  font-size: 9px;
  color: var(--klh-text-secondary);
  margin-bottom: 2px;
}

.klh-gl-audit-diff-old {
  font-family: var(--klh-font-mono);
  font-size: 10px;
  color: var(--klh-error);
  background: rgba(248, 113, 113, 0.1);
  padding: 2px 6px;
  border-radius: 2px;
  margin-bottom: 2px;
}

.klh-gl-audit-diff-new {
  font-family: var(--klh-font-mono);
  font-size: 10px;
  color: var(--klh-success);
  background: rgba(74, 222, 128, 0.1);
  padding: 2px 6px;
  border-radius: 2px;
}

.klh-gl-audit-no-data {
  color: #9ca3af;
}

/* ==================== AUDIT PANEL ==================== */

/* Operation colors */
.klh-gl-op-add { color: var(--klh-gl-success); font-weight: 600; }
.klh-gl-op-update { color: var(--klh-gl-warning); font-weight: 600; }
.klh-gl-op-delete { color: var(--klh-gl-error); font-weight: 600; }

/* Main row (clickable header) */
.klh-gl-audit-main-row {
  cursor: pointer;
}

.klh-gl-audit-main-row:hover td {
  background: var(--klh-gl-bg-tertiary);
}

/* Detail row (expandable content) - hidden by default */
.klh-gl-audit-detail-row {
  display: none;
}

.klh-gl-audit-detail-row.visible {
  display: table-row;
}

.klh-gl-audit-detail-row td {
  padding: 0;
  background: var(--klh-gl-bg-primary);
}

/* Detail content container */
.klh-gl-audit-table .audit-detail-content {
  padding: var(--klh-gl-spacing-sm);
}

.klh-gl-audit-table .audit-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--klh-gl-spacing-sm);
}

/* Detail sections (Info, Changes, etc.) */
.klh-gl-audit-table .audit-detail-section {
  background: var(--klh-gl-bg-secondary);
  border: 1px solid var(--klh-gl-border);
  border-radius: var(--klh-gl-border-radius);
  padding: var(--klh-gl-spacing-sm);
}

.klh-gl-audit-table .audit-detail-section.full-width {
  grid-column: span 2;
}

.klh-gl-audit-table .audit-detail-title {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--klh-gl-accent);
  margin-bottom: var(--klh-gl-spacing-xs);
  letter-spacing: 0.5px;
}

.klh-gl-audit-table .audit-detail-item {
  display: flex;
  justify-content: space-between;
  font-size: var(--klh-gl-font-size-sm);
  margin-bottom: 2px;
}

.klh-gl-audit-table .audit-detail-item .label {
  color: var(--klh-gl-text-secondary);
}

.klh-gl-audit-table .audit-detail-item .value {
  color: var(--klh-gl-text-primary);
  font-weight: 500;
}

/* Diff styling for changes */
.klh-gl-audit-table .audit-diff-old {
  font-family: var(--klh-font-mono, monospace);
  font-size: 10px;
  color: var(--klh-gl-error);
  background: rgba(239, 68, 68, 0.1);
  padding: 2px 6px;
  border-radius: 2px;
  margin-bottom: 2px;
}

.klh-gl-audit-table .audit-diff-new {
  font-family: var(--klh-font-mono, monospace);
  font-size: 10px;
  color: var(--klh-gl-success);
  background: rgba(34, 197, 94, 0.1);
  padding: 2px 6px;
  border-radius: 2px;
}

/* Expand icon in first column */
.klh-gl-audit-table .klh-gl-expand-icon {
  transition: transform 0.15s;
  display: inline-block;
}

.klh-gl-audit-table .klh-gl-expand-icon.expanded {
  transform: rotate(90deg);
}

.klh-gl-audit-panel-overlay {
  position: fixed;
  top: 60px;
  right: 20px;
  left: auto;
  bottom: auto;
  background: transparent;
  display: none;
  z-index: 10001;
}

.klh-gl-audit-panel-overlay.klh-gl-show {
  display: block;
}

.klh-gl-audit-panel {
  background: var(--klh-gl-bg-secondary);
  border: 1px solid var(--klh-gl-border);
  border-radius: var(--klh-gl-border-radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  width: 800px;
  max-width: 95vw;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
}

.klh-gl-audit-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--klh-gl-spacing-md);
  border-bottom: 1px solid var(--klh-gl-border);
}

.klh-gl-audit-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--klh-gl-accent);
}

.klh-gl-audit-panel-controls {
  display: flex;
  align-items: center;
  gap: var(--klh-gl-spacing-sm);
}

.klh-gl-audit-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--klh-gl-spacing-sm);
}

.klh-gl-audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--klh-gl-font-size);
}

.klh-gl-audit-table th,
.klh-gl-audit-table td {
  padding: var(--klh-gl-spacing-xs) var(--klh-gl-spacing-sm);
  text-align: left;
  border-bottom: 1px solid var(--klh-gl-border);
}

.klh-gl-audit-table th {
  background: var(--klh-gl-bg-tertiary);
  color: var(--klh-gl-text-secondary);
  font-weight: 600;
  font-size: var(--klh-gl-font-size-sm);
  text-transform: uppercase;
}

.klh-gl-audit-table tr:hover td {
  background: var(--klh-gl-bg-tertiary);
}

.klh-gl-audit-panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--klh-gl-spacing-sm) var(--klh-gl-spacing-md);
  border-top: 1px solid var(--klh-gl-border);
  font-size: var(--klh-gl-font-size-sm);
  color: var(--klh-gl-text-muted);
}

/* ==================== DEBUG PANEL ==================== */

.klh-gl-debug-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200px;
  background: var(--klh-gl-bg-primary);
  border-top: 2px solid var(--klh-gl-warning);
  display: none;
  flex-direction: column;
  z-index: 1002;
}

.klh-gl-debug-panel.klh-gl-show {
  display: flex;
}

.klh-gl-debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--klh-gl-spacing-xs) var(--klh-gl-spacing-md);
  background: var(--klh-gl-bg-secondary);
  border-bottom: 1px solid var(--klh-gl-border);
  font-size: var(--klh-gl-font-size-sm);
  font-weight: 600;
  color: var(--klh-gl-warning);
}

.klh-gl-debug-versions {
  font-size: 9px;
  color: var(--klh-gl-text-muted);
}

.klh-gl-debug-log {
  flex: 1;
  overflow-y: auto;
  padding: var(--klh-gl-spacing-sm);
  font-family: monospace;
  font-size: 10px;
  color: var(--klh-gl-text-secondary);
}

/* ==================== AG GRID OVERLAY ==================== */

.klh-gl-no-rows {
  padding: 10px;
}
