/* Main diagram editor styling */
.dnd-flow {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-gap: 16px;
  height: calc(80vh - 250px);
  min-height: 700px;
  position: relative;
}

/* Sidebar styling - updated for collapsible functionality */
/* Main sidebar styles */
.sidebar-wrapper {
  position: relative;
  height: 100%;
  transition: width 0.3s ease-in-out;
  z-index: 20;
  min-width: 58px;
  flex-shrink: 0;
  overflow: visible;
  background-color: #ffffff;
}

.sidebar-wrapper.expanded {
  width: 220px;
}

.sidebar-wrapper.collapsed {
  width: 58px;
  min-width: 58px;
  max-width: 58px;
  flex: 0 0 58px;
  flex-shrink: 0;
  flex-grow: 0;
}

.sidebar {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  background-color: #ffffff;
  border-radius: 0;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  visibility: visible;
  opacity: 1;
  z-index: 10;
  overflow: visible;
}

.sidebar.expanded {
  width: 220px;
}

.sidebar.collapsed {
  width: 58px;
  min-width: 58px;
  max-width: 58px;
  height: 100%;
  overflow: visible;
  visibility: visible;
  opacity: 1;
  z-index: 30;
  display: block;
  background-color: #ffffff;
}

/* Content containers */
.sidebar-container {
  display: flex;
  flex-direction: column;
  height: calc(100% - 60px);
  width: 100%;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  transition: opacity 0.2s ease-in-out;
  opacity: 1;
  visibility: visible;
}

/* Collapsed sidebar content */
.sidebar-collapsed-content {
  display: flex;
  flex-direction: column;
  opacity: 1;
  visibility: visible;
  width: 100%;
  height: calc(100% - 60px);
  overflow-y: auto;
  padding: 10px 0;
  position: relative;
  z-index: 30;
  background-color: #ffffff;
}

/* Category icons in collapsed state */
.category-icon-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 8px 0;
  cursor: grab;
}

.category-icon-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  position: relative;
  background-color: transparent;
}

.category-icon-item:hover {
  background-color: #f0f5fa;
}

.category-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
  visibility: visible;
  opacity: 1;
}

.category-tooltip {
  position: absolute;
  left: 45px;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
}

.category-icon-item:hover .category-tooltip {
  opacity: 1;
}

/* Footer and toggle button */
.navbar-vertical-footer {
  height: 60px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background-color: #f9fafd;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 30;
}

.navbar-vertical-toggle {
  height: 40px;
  width: 100%;
  background-color: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  font-size: 13px;
  padding: 0 15px;
  color: #5e6e82;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar.collapsed .navbar-vertical-toggle {
  width: 40px;
  padding: 0;
  justify-content: center;
  display: flex;
  align-items: center;
}

.navbar-vertical-toggle:hover {
  background-color: #f1f4f8;
  color: #2c7be5;
}

/* Main content adjustments */

.main-content-wrapper.sidebar-collapsed {
  margin-left: 0;
}

.sidebar-toggle {
  position: absolute;
  right: -16px;
  width: 28px;
  height: 28px;
  background-color: #f8f9fa;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #6c757d;
  z-index: 100; 
  transition: all 0.2s ease;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
  
  /* Position at the right edge of the sidebar */
  top: 12px;
  right: -12px; /* Place half outside the sidebar */
}

.sidebar-toggle:hover {
  color: #0d6efd;
  background-color: #e9ecef;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}

.sidebar-header {
  padding: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: #f8f9fa;
  flex-shrink: 0;
}

.sidebar-header h5 {
  font-size: 14px !important;
  margin-bottom: 4px !important;
}

.sidebar-header p {
  font-size: 11px !important;
  margin-bottom: 8px !important;
}

/* Make the search box more compact */
.sidebar-header .form-control {
  font-size: 11px;
  height: 28px;
  padding: 4px 6px 4px 26px;
  width: calc(100% - 2px);
}
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  width: 100%;
}

.product-list {
  overflow-y: auto;
  padding: 6px;
  flex-grow: 1;
  height: calc(100% - 90px);
  width: 100%;
}

.category-group {
  margin-bottom: 8px;
  width: 100%;
  max-width: 100%;
}

.category-header {
  padding: 6px 8px !important;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
}

.category-header h6 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px; /* Ensure text doesn't overflow */
  margin-bottom: 0 !important;
  font-size: 12px !important;
}

/* Make badge smaller */
.category-header .badge {
  font-size: 9px !important;
  padding: 3px 6px !important;
  min-width: 18px;
}

.category-products {
  display: flex;
  flex-wrap: wrap;
  gap: 4px; /* Reduced from 8px */
  padding-top: 4px;
  padding-left: 4px;
  padding-right: 4px;
}

.dndnode {
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
  transition: all 0.2s ease;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background-color: white;
  box-shadow: none;
}

.dndnode:hover {
  transform: translateY(-2px);
  box-shadow: none;
  border-color: rgba(85, 146, 237, 0.5);
}
.dndnode.product-node {
   width: 70px;
  padding: 3px;
  margin-bottom: 3px;
  font-size: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* Flow container */
.reactflow-wrapper {
  flex-grow: 1;
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.react-flow-container {
  flex-grow: 1;
  position: relative;
}


@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.panel-header {
  padding: 12px 16px 36px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: #f8f9fa;
  flex-shrink: 0; /* Prevent header from shrinking */
  min-height: 120px; /* Fixed height to ensure tabs don't overlap content */
  position: relative;
  min-height: 100px;
  margin-bottom: 8px;
}

.panel-content {
  padding: 8px 16px 16px 16px;
  overflow-y: auto;
  flex-grow: 1;
  height: calc(100% - 120px); /* Match with header height */
  position: relative;
}
.tab-content-details,
.tab-content-properties {
  width: 100%;
  position: relative;
}
.node-id-text {
  margin: 4px 0 10px 0 !important;
  display: block;
  font-size: 12px !important;
  color: #6c757d !important;
}
.panel-tabs {
   display: flex;
  margin-top: 16px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.1);
  position: absolute;
  bottom: -1px;
  left: 16px;
  right: 16px;
  z-index: 5;
  background-color: #fff;
  margin-top: 8px;
}

.panel-tab-btn {
 flex: 1;
  border: none !important;
  border-radius: 0 !important;
  text-align: center;
  font-weight: 500;
  font-size: 14px;
  padding: 8px 0;
  background-color: #f8f9fa;
  transition: all 0.2s;
  color: #495057;
  margin: 0 !important;
  position: relative;
}

.panel-tab-btn:first-child {
  border-right: 1px solid rgba(0, 0, 0, 0.1) !important;
}

.panel-tab-btn.active {
   background-color: #0d6efd;
  color: white;
  box-shadow: none;
  z-index: 6;
}
/* Clear separation between tabs */
.panel-tab-btn:first-child {
  border-right: 1px solid rgba(0, 0, 0, 0.1) !important;
}
/* Close button in panel header */
.panel-close-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background-color: #f8f9fa;
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #6c757d;
  transition: all 0.2s;
}

.panel-close-btn:hover {
  background-color: #e9ecef;
  color: #dc3545;
}

/* Section headers */
.panel-section-header {
  font-size: 14px;
  color: #0d6efd;
  margin-bottom: 12px;
  font-weight: 500;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding-bottom: 8px;
  display: flex;
  align-items: center;
}

.panel-section-header svg {
  margin-right: 8px;
}

/* Property values */
.property-value {
  border-radius: 6px;
  padding: 8px 12px;
  background: #f8f9fa;
  border: 1px solid rgba(0, 0, 0, 0.1);
  margin-top: 4px;
  margin-bottom: 12px;
  font-family: monospace;
  font-size: 13px;
  word-break: break-word;
}

/* Property item styling */
.property-item {
  display: flex;
  margin-bottom: 16px;
  align-items: flex-start;
}

.property-item .form-control {
  flex-grow: 1;
  margin-right: 8px;
}

.property-item .btn-icon {
  margin-bottom: 8px;
}

/* Additional PropertyPanel styling */
.properties-panel {
  position: relative !important; 
  width: 300px !important;
  min-width: 300px !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1) !important;
  background-color: #ffffff !important;
  z-index: 5 !important;
  border-radius: 0.5rem !important;
  overflow: hidden !important;
  visibility: visible !important;
  opacity: 1 !important;
  transform: none !important;
  margin-left: 0.25rem;
  border: 1px solid var(--phoenix-border-color, rgba(0, 0, 0, 0.125));
  border-left: none;
}

.properties-panel .panel-header {
  padding: 15px;
  border-bottom: 1px solid #e9ecef;
  min-height: unset;
  margin-bottom: 0;
  background-color: #f8f9fa;
  flex-shrink: 0;
}

.properties-panel .panel-content {
  padding: 15px;
  flex: 1;
  overflow-y: auto;
  height: auto;
}

.property-label {
  font-size: 0.8rem;
  color: #6c757d;
  margin-bottom: 2px;
}

.property-sublabel {
  font-size: 12px;
  color: #6c757d;
  margin-bottom: 2px;
}

/* Add new property form */
.add-property-form {
  background-color: #f8f9fa;
  border-radius: 8px;
  padding: 12px;
  margin-top: 16px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.add-property-form .form-label {
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
}

.add-property-form .form-label svg {
  margin-right: 6px;
}

/* Toolbar */
.toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: #f8f9fa;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
}
/* Edge label font styling */
.react-flow__edge-text {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 12px;
}

/* Node label specific styling */
.react-flow__node-default .react-flow__node-default__label {
  font-weight: normal;
  line-height: 1.4;
}

/* Form controls consistent font */
.form-control, .form-select, .btn {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

.react-flow__node:hover {
  box-shadow: none;
}

.react-flow__node.selected {
  box-shadow: 0 0 0 2px #3182ce;
}

.react-flow__edge-path {
  stroke-width: 2;
  stroke:  #555;
}

.react-flow__edge.selected .react-flow__edge-path {
  stroke: #555555;
  stroke-width: 3;
}

.react-flow__controls {
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

.react-flow__controls-button {
  border: none !important;
  background: white !important;
  color: #555 !important;
}

.react-flow__controls-button:hover {
  background: #f8f9fa !important;
}

.react-flow__minimap {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* Custom form styles */
.form-control-slim {
  border-radius: 6px;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: none;
  transition: all 0.2s;
}

.form-control-slim:focus {
  border-color: #3182ce;
  box-shadow: 0 0 0 1px rgba(49, 130, 206, 0.2);
}

/* Button styles */
.btn-action {
  border-radius: 6px;
  padding: 0.375rem 0.75rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-action:hover {
  transform: translateY(-1px);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

/* Card customization */
.custom-card {
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.05);
  overflow: hidden;
}
.custom-card.mb-3 {
  width: 100%;
  display: block;
  z-index: 1;
}
/* Toast customization */
.custom-toast {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Loader styling */
.diagram-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  flex-direction: column;
  padding: 2rem;
}
/* Make sure the main content area takes remaining height */
.diagram-content-area {
  display: flex !important;
  width: 100% !important;
  height: calc(100% - 60px); /* Adjust based on header height */
  position: relative;
  overflow: hidden;
}

/* No company selected state */
.no-selection-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  background: #f9fcff;
  border-radius: 8px;
}

.info-icon {
  font-size: 3rem;
  color: #3182ce;
  margin-bottom: 1.5rem;
}

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

.animate-fade-in {
  animation: fadeIn 0.3s ease-in-out;
}
/* Product node styling */
.product-node {
   padding: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: transparent;
  position: relative;
}
.product-icon-container {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  border-radius: 0;
  box-shadow: none;
  transition: transform 0.2s;
  position: relative;
  border: none;
}
.product-name,
.product-sku {
  display: none;
  position: absolute;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  margin-top: 4px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 1000;
  pointer-events: none;
}
.product-node.selected .product-icon-container {
  border: 1px solid #3182ce;
  box-shadow: none;
}

.react-flow__node .product-icon-container {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  border-radius: 6px;
  box-shadow: none;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.react-flow__node {
  transition: none !important;
}

.react-flow__viewport {
  transition: none !important;
}
.react-flow__handle {
        transition: none !important;
      }
.product-node-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.product-node-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 48px;
  height: 48px;
  background: #f8f9fa;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #e0e0e0;
}
.product-node:hover .product-name {
  display: block;
  top: -25px;
  left: 50%;
  transform: translateX(-50%);
}

.product-node:hover .product-icon-container {
  transform: translateY(-2px);
  box-shadow: none;
}
.product-icon {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  width: 36px;
  height: 36px;
}

.fallback-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background-color: #f8f9fa;
  border-radius: 4px;
}

.product-flow-node.selected {
  transform: scale(1.02);
}

.node-label {
  font-weight: 500;
  margin-top: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.react-flow__renderer {
  z-index: 0 !important;
}

.react-flow__pane {
  z-index: 0 !important;
}

.react-flow__viewport {
  transform-origin: 0 0 !important;
}
.react-flow__handle {
    width: 8px;
  height: 8px;
  background-color: #3182ce;
  border: 2px solid white;
  border-radius: 50%;
  z-index: 10;
}

.react-flow__handle-left {
  left: -4px;
}

.react-flow__handle-right {
  right: -4px;
}

.react-flow__handle-top {
  top: -4px;
}

.react-flow__handle-bottom {
  bottom: -4px;
}

.react-flow-container, .reactflow-wrapper, .react-flow {
  overflow: hidden;
}
.react-flow__node {
    background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
  z-index: 5;
  pointer-events: all;
  padding: 0;
  min-width: auto;
  min-height: auto;
}

/* Adjust the React Flow Container to properly fit */
.react-flow {
  width: 100%;
  height: 100%;
}

/* Improve minimap positioning */
.react-flow__minimap {
  bottom: 20px !important;
  right: 20px !important;
}

/* Improve controls positioning */
.react-flow__controls {
  bottom: 10px !important;
  left: 10px !important;
  right: auto !important; /* Override default right positioning */
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

/* Make sure the viewport fits correctly */
.react-flow__viewport {
  width: 100% !important;
  height: 100% !important;
}

/* Main diagram editor styling */
.diagram-editor-container {
  height: calc(100vh - 160px); /* Adjust this value based on your header height */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 15px;
  margin-bottom: 0;
}

.d-flex {
  display: flex;
  height: 100% !important;
  width: 100% !important;
}

.diagram-tools {
  display: block !important;
  margin: 10px;
  z-index: 10;
}
.diagram-header-section {
  min-height: 32px;
  margin-bottom: 4px !important;
  padding-top: 4px !important;
  overflow: visible;
  flex-shrink: 0;
}

.diagram-header-section button {
  white-space: nowrap;
  min-width: auto;
}

/* For smaller screens, ensure proper responsiveness */
@media (max-width: 576px) {
  .diagram-header-section .d-flex {
    flex-wrap: nowrap !important;
  }
}

@media (max-height: 800px) {
  .diagram-editor-container {
    height: calc(100vh - 150px); /* Slightly smaller offset for smaller screens */
  }
  
  .diagram-header-section {
    min-height: 35px;
    margin-bottom: 5px;
  }
  
  .diagram-content-area {
    height: calc(100% - 40px);
  }
}

@media (max-height: 700px) {
  .diagram-editor-container {
    height: calc(100vh - 140px);
  }
}
/* Add these styles to make the sidebar appear as a separate container */
.phoenix-offcanvas {
  border-radius: 0.5rem 0 0 0.5rem;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  background-color: var(--phoenix-card-bg, #fff);
  margin-right: 0.25rem;
  margin-left: 0;
  overflow: hidden;
}

.phoenix-offcanvas.phoenix-offcanvas-start {
  border: 1px solid var(--phoenix-border-color, rgba(0, 0, 0, 0.125));
}

.sidebar-header {
  padding: 0.75rem 1rem;
  background-color: var(--phoenix-bg-100, #f8f9fa);
  border-bottom: 1px solid var(--phoenix-border-color, rgba(0, 0, 0, 0.125));
}

.diagram-content-area {
  display: flex;
  gap: 0.25rem;
  padding: 0; 
  border-radius: 0.5rem;
  height: calc(100% - 48px);
  min-height: 200px;
}

.main-content-wrapper {
  flex: 1;
  position: relative;
  transition: margin-left 0.3s ease;
  overflow: hidden;
  width: calc(100% - 300px); /* Subtract the width of the property panel */
  border: 1px solid var(--phoenix-border-color, rgba(0, 0, 0, 0.125));
  border-radius: 0.5rem;
  height: 100%;
}
.phoenix-offcanvas {
  border-radius: 0.5rem 0 0 0.5rem;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  background-color: var(--phoenix-card-bg, #fff);
  margin-right: 0.25rem; /* Reduced from 1rem to 0.25rem */
  margin-left: 0; /* Ensure no left margin */
  overflow: hidden;
}
.phoenix-offcanvas.phoenix-offcanvas-start {
  border: 1px solid var(--phoenix-border-color, rgba(0, 0, 0, 0.125));
}

.flow-canvas-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
