/* Schema Diagram Styles */
.schema-diagram-container {
  height: 100%;
  position: relative;
  background: #f8fafc;
  border-radius: 8px;
  overflow: hidden;
}

/* Zoom Controls */
.diagram-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.95);
  padding: 8px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(4px);
}

.zoom-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.2s ease;
}

.zoom-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  transform: scale(1.05);
}

.zoom-btn:active {
  transform: scale(0.95);
}

.search-input {
  width: 150px;
  height: 28px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  transition: border-color 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

/* SVG Elements */
.relationship-link {
  cursor: pointer;
  transition: all 0.3s ease;
}

.relationship-link:hover {
  stroke-width: 3 !important;
  stroke-opacity: 0.9 !important;
}

.table-node {
  cursor: pointer;
  transition: all 0.3s ease;
}

.table-node:hover .node-rect {
  stroke-width: 3;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.node-rect {
  transition: all 0.3s ease;
}

.node-label {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  user-select: none;
  pointer-events: none;
}

.node-icon {
  user-select: none;
  pointer-events: none;
}

.column-indicator {
  transition: all 0.3s ease;
}

.column-count {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  user-select: none;
  pointer-events: none;
}

.link-label {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  user-select: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Table Information Panel */
.table-info-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 280px;
  max-height: 400px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10;
  overflow: hidden;
}

.table-info-header {
  background: #f9fafb;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-info-content {
  padding: 16px;
}

.table-stats {
  margin-top: 12px;
}

.table-stats div {
  padding: 4px 0;
  border-bottom: 1px solid #f3f4f6;
}

.table-stats div:last-child {
  border-bottom: none;
}

/* Zoom Info */
.zoom-info {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  z-index: 10;
}

/* Loading State */
.diagram-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
}

.loading-spinner {
  margin-bottom: 1rem;
}

.spinner {
  width: 3rem;
  height: 3rem;
  border: 3px solid #e5e7eb;
  border-top: 3px solid #6366f1;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  color: #6b7280;
  font-size: 0.875rem;
  text-align: center;
}

/* Error State */
.diagram-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  text-align: center;
  padding: 2rem;
}

.error-icon {
  width: 4rem;
  height: 4rem;
  color: #ef4444;
  margin-bottom: 1rem;
}

.error-icon svg {
  width: 100%;
  height: 100%;
}

.diagram-error h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 0.5rem;
}

.diagram-error p {
  color: #6b7280;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.retry-button {
  background: #6366f1;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s;
}

.retry-button:hover {
  background: #4f46e5;
}

/* No Data State */
.diagram-no-data {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  text-align: center;
  padding: 2rem;
}

.no-data-icon {
  width: 3rem;
  height: 3rem;
  color: #9ca3af;
  margin-bottom: 1rem;
}

.no-data-icon svg {
  width: 100%;
  height: 100%;
}

.diagram-no-data h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 0.5rem;
}

.diagram-no-data p {
  color: #6b7280;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Tooltip */
.schema-tooltip {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.4;
  max-width: 200px;
}

/* Legend */
.diagram-legend {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px;
  z-index: 10;
  backdrop-filter: blur(4px);
}

.legend-title {
  font-size: 12px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 8px;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #6b7280;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Node Groups Colors */
.legend-color.users { background-color: #10b981; }
.legend-color.commerce { background-color: #f59e0b; }
.legend-color.catalog { background-color: #8b5cf6; }
.legend-color.logging { background-color: #64748b; }
.legend-color.configuration { background-color: #06b6d4; }
.legend-color.communication { background-color: #ec4899; }
.legend-color.views { background-color: #6b7280; }
.legend-color.tables { background-color: #3b82f6; }

/* Statistics Panel */
.diagram-statistics {
  position: absolute;
  top: 60px;
  right: 10px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px;
  z-index: 10;
  backdrop-filter: blur(4px);
  min-width: 180px;
}

.statistics-title {
  font-size: 12px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 8px;
}

.statistics-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.statistics-item {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #6b7280;
}

.statistics-value {
  font-weight: 500;
  color: #1f2937;
}

/* Responsive Design */
@media (max-width: 768px) {
  .diagram-controls {
    flex-wrap: wrap;
    gap: 3px;
  }
  
  .search-input {
    width: 120px;
  }
  
  .table-info-panel {
    width: 250px;
    max-height: 300px;
  }
  
  .diagram-legend,
  .diagram-statistics {
    position: static;
    margin-bottom: 10px;
  }
}

/* Dark Mode Support */
.dark .schema-diagram-container {
  background: #111827;
}

.dark .diagram-controls {
  background: rgba(31, 41, 55, 0.95);
}

.dark .zoom-btn {
  background: #374151;
  border-color: #4b5563;
  color: #f3f4f6;
}

.dark .zoom-btn:hover {
  background: #4b5563;
  border-color: #6b7280;
}

.dark .search-input {
  background: #374151;
  border-color: #4b5563;
  color: #f3f4f6;
}

.dark .search-input::placeholder {
  color: #9ca3af;
}

.dark .table-info-panel {
  background: #1f2937;
  border-color: #374151;
}

.dark .table-info-header {
  background: #111827;
  border-bottom-color: #374151;
}

.dark .table-info-content {
  color: #f3f4f6;
}

.dark .zoom-info {
  background: rgba(0, 0, 0, 0.8);
}

.dark .diagram-legend,
.dark .diagram-statistics {
  background: rgba(31, 41, 55, 0.95);
  border-color: #374151;
}

.dark .legend-title,
.dark .statistics-title {
  color: #f3f4f6;
}

.dark .legend-item,
.dark .statistics-item {
  color: #d1d5db;
}

.dark .statistics-value {
  color: #f3f4f6;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.table-info-panel,
.diagram-legend,
.diagram-statistics {
  animation: fadeIn 0.3s ease-out;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Focus styles for keyboard navigation */
.zoom-btn:focus,
.search-input:focus,
.retry-button:focus {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}