/* Verdeelkast Configurator Styles */
:root {
  --cabinet-bg: #f8fafc;
  --cabinet-border: #cbd5e1;
  --module-bg: #f1f5f9;
  --module-border: #cbd5e1;
  --module-hover: #e2e8f0;
  --module-active: #dbeafe;
  --rail-color: #94a3b8;
  --component-bg: #ffffff;
  --component-border: #cbd5e1;
  --component-text: #334155;
  --wire-l: #e53e3e;
  --wire-n: #3182ce;
  --wire-pe: #38a169;
  --wire-default: #94a3b8;
}

/* Main layout */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.configurator-sidebar {
  width: 280px;
  background-color: white;
  border-right: 1px solid var(--border-color);
  padding: 1.25rem;
  overflow-y: auto;
  z-index: 20;
}

.configurator-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.configurator-properties {
  width: 320px;
  background-color: white;
  border-left: 1px solid var(--border-color);
  padding: 1.25rem;
  overflow-y: auto;
  z-index: 20;
}

/* Component sections */
.component-section {
  margin-bottom: 1.5rem;
  background-color: var(--background-color);
  border-radius: 0.5rem;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.component-section h3 {
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  color: var(--text-color);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.component-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.component-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  background-color: white;
  cursor: grab;
  transition: all 0.2s;
  user-select: none;
}

.component-item:hover {
  background-color: var(--component-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.component-item:active {
  cursor: grabbing;
  transform: scale(0.98);
}

.component-preview {
  width: 40px;
  height: 40px;
  margin-bottom: 0.5rem;
  background-color: var(--background-color);
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
}

.component-item span {
  font-size: 0.75rem;
  text-align: center;
  color: var(--text-color);
}

/* Wire options */
.wire-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.wire-option {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  background-color: white;
  cursor: pointer;
  transition: all 0.2s;
}

.wire-option:hover {
  background-color: var(--component-hover);
  transform: translateX(2px);
}

.wire-option.active {
  border-color: var(--primary-color);
  background-color: var(--component-active);
}

.wire-preview {
  width: 24px;
  height: 4px;
  border-radius: 2px;
  margin-right: 0.75rem;
}

/* Cabinet options */
.cabinet-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cabinet-option {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  background-color: white;
  cursor: pointer;
  transition: all 0.2s;
}

.cabinet-option:hover {
  background-color: var(--component-hover);
  transform: translateX(2px);
}

.cabinet-option.active {
  border-color: var(--primary-color);
  background-color: var(--component-active);
}

.cabinet-preview {
  width: 40px;
  height: 40px;
  margin-right: 0.75rem;
  background-color: var(--background-color);
  border-radius: 0.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  border: 1px solid var(--border-color);
  padding: 4px;
}

.cabinet-small-preview::before,
.cabinet-medium-preview::before,
.cabinet-medium-preview::after,
.cabinet-large-preview::before,
.cabinet-large-preview::after {
  content: "";
  height: 4px;
  background-color: var(--rail-color);
  border-radius: 2px;
}

.cabinet-large-preview::after {
  content: "";
  height: 4px;
  background-color: var(--rail-color);
  border-radius: 2px;
  margin-top: 4px;
}

/* Configurator toolbar */
.configurator-toolbar {
  display: flex;
  padding: 0.75rem;
  background-color: white;
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
}

.tool-group {
  display: flex;
  gap: 0.375rem;
  border-right: 1px solid var(--border-color);
  padding-right: 1rem;
}

.tool-group:last-child {
  border-right: none;
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 0.375rem;
  background-color: white;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.2s;
}

.tool-btn:hover {
  background-color: var(--component-hover);
}

.tool-btn.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Cabinet container */
.cabinet-container {
  flex: 1;
  overflow: auto;
  padding: 2rem;
  background-color: var(--background-color);
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.cabinet-view {
  background-color: var(--cabinet-bg);
  border: 2px solid var(--cabinet-border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  transition: all 0.3s;
}

.cabinet-row {
  display: flex;
  margin-bottom: 1.5rem;
  background-color: var(--rail-color);
  border-radius: 0.25rem;
  padding: 0.5rem;
}

.cabinet-row:last-child {
  margin-bottom: 0;
}

.cabinet-small .cabinet-row:nth-child(n+2) {
  display: none;
}

.cabinet-large .cabinet-row:nth-child(3) {
  display: flex;
}

.module-slot {
  width: 36px;
  height: 80px;
  background-color: var(--module-bg);
  border: 1px solid var(--module-border);
  margin-right: 4px;
  border-radius: 0.25rem;
  transition: all 0.2s;
  position: relative;
}

.module-slot:last-child {
  margin-right: 0;
}

.module-slot:hover {
  background-color: var(--module-hover);
}

.module-slot.active {
  background-color: var(--module-active);
}

.module-slot.occupied {
  background-color: transparent;
  border-color: transparent;
}

/* Component in cabinet */
.cabinet-component {
  position: absolute;
  background-color: var(--component-bg);
  border: 1px solid var(--component-border);
  border-radius: 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.25rem;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s;
}

.cabinet-component:hover {
  box-shadow: 0 0 0 2px var(--primary-color);
}

.cabinet-component.selected {
  box-shadow: 0 0 0 2px var(--primary-color), 0 0 8px rgba(59, 130, 246, 0.5);
}

.component-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 0.25rem;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.component-label {
  font-size: 0.625rem;
  text-align: center;
  color: var(--component-text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Connection points */
.connection-point {
  position: absolute;
  width: 8px;
  height: 8px;
  background-color: white;
  border: 1px solid var(--component-border);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  cursor: pointer;
  transition: all 0.2s;
}

.connection-point:hover {
  transform: translate(-50%, -50%) scale(1.5);
  box-shadow: 0 0 0 2px white;
}

.connection-point.active {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  transform: translate(-50%, -50%) scale(1.5);
}

.connection-point.connected {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.connection-point[data-type="L"] {
  border-color: var(--wire-l);
}

.connection-point[data-type="N"] {
  border-color: var(--wire-n);
}

.connection-point[data-type="PE"] {
  border-color: var(--wire-pe);
}

/* Wiring canvas */
.wiring-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Properties panel */
.properties-content {
  background-color: var(--background-color);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.property-group {
  margin-bottom: 1rem;
}

.property-group:last-child {
  margin-bottom: 0;
}

.property-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--text-color);
}

.property-group input,
.property-group select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  background-color: white;
}

.property-group input:focus,
.property-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Info and validation sections */
.configurator-info,
.configurator-validation {
  background-color: var(--background-color);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.configurator-info h3,
.configurator-validation h3 {
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  color: var(--text-color);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.info-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.info-item:last-child {
  margin-bottom: 0;
}

.info-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.info-value {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-color);
}

.validation-results {
  font-size: 0.75rem;
  color: var(--text-color);
}

.validation-item {
  display: flex;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.375rem;
}

.validation-item:last-child {
  margin-bottom: 0;
}

.validation-item.error {
  background-color: rgba(239, 68, 68, 0.1);
}

.validation-item.warning {
  background-color: rgba(245, 158, 11, 0.1);
}

.validation-item.success {
  background-color: rgba(16, 185, 129, 0.1);
}

.validation-icon {
  margin-right: 0.5rem;
  font-size: 0.875rem;
}

.validation-icon.error {
  color: var(--danger-color);
}

.validation-icon.warning {
  color: var(--warning-color);
}

.validation-icon.success {
  color: var(--success-color);
}

/* Dialog */
.dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  backdrop-filter: blur(2px);
}

.dialog.active {
  opacity: 1;
  pointer-events: auto;
}

.dialog-content {
  background-color: white;
  border-radius: 0.75rem;
  padding: 2rem;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.3s;
}

.dialog.active .dialog-content {
  transform: scale(1);
}

.dialog-content h2 {
  color: var(--text-color);
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.schema-content,
.bill-content {
  margin-bottom: 1.5rem;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Component preview icons */
.hoofdschakelaar-preview {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="7" width="20" height="10" rx="2" /><line x1="6" y1="10" x2="6" y2="14" /><line x1="10" y1="10" x2="10" y2="14" /><line x1="14" y1="10" x2="14" y2="14" /><line x1="18" y1="10" x2="18" y2="14" /></svg>');
  background-size: 80%;
  background-repeat: no-repeat;
  background-position: center;
}

.aardlekschakelaar-preview {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="7" width="20" height="10" rx="2" /><path d="M7 12h4l2 -4l2 8l2 -4h4" /></svg>');
  background-size: 80%;
  background-repeat: no-repeat;
  background-position: center;
}

.automaat-preview {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="4" y="4" width="16" height="16" rx="2" /><line x1="12" y1="4" x2="12" y2="20" /></svg>');
  background-size: 80%;
  background-repeat: no-repeat;
  background-position: center;
}

.overspanning-preview {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" /></svg>');
  background-size: 80%;
  background-repeat: no-repeat;
  background-position: center;
}

.diff-30ma-preview,
.diff-300ma-preview {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="7" width="20" height="10" rx="2" /><path d="M7 12h2c2 0 4 -2 4 -2s2 2 4 2h2" /></svg>');
  background-size: 80%;
  background-repeat: no-repeat;
  background-position: center;
}

.automaat-6a-preview,
.automaat-10a-preview,
.automaat-16a-preview,
.automaat-20a-preview,
.automaat-25a-preview,
.automaat-32a-preview {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="4" y="4" width="16" height="16" rx="2" /><line x1="12" y1="4" x2="12" y2="20" /></svg>');
  background-size: 80%;
  background-repeat: no-repeat;
  background-position: center;
}

.relais-preview {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="4" y="4" width="16" height="16" rx="2" /><path d="M9 12h6" /><path d="M12 9v6" /></svg>');
  background-size: 80%;
  background-repeat: no-repeat;
  background-position: center;
}

.kwh-preview {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10" /><path d="M15 8h-4v8h4" /><path d="M11 12h3" /></svg>');
  background-size: 80%;
  background-repeat: no-repeat;
  background-position: center;
}

.timer-preview {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10" /><polyline points="12 6 12 12 16 14" /></svg>');
  background-size: 80%;
  background-repeat: no-repeat;
  background-position: center;
}

/* Schema styles */
.schema-content {
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 1.5rem;
}

.schema-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1.5rem;
}

.schema-component {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background-color: var(--background-color);
}

.schema-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 0.75rem;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.schema-label {
  font-size: 0.75rem;
  text-align: center;
  color: var(--text-color);
  font-weight: 500;
}

.schema-details {
  font-size: 0.625rem;
  text-align: center;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.schema-connection {
  display: flex;
  align-items: center;
  margin-top: 0.5rem;
}

.schema-wire {
  width: 20px;
  height: 3px;
  border-radius: 1.5px;
}

.schema-wire.L {
  background-color: var(--wire-l);
}

.schema-wire.N {
  background-color: var(--wire-n);
}

.schema-wire.PE {
  background-color: var(--wire-pe);
}

.schema-connection-label {
  font-size: 0.625rem;
  margin-left: 0.25rem;
  color: var(--text-muted);
}

/* Bill of materials styles */
.bill-content {
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 1.5rem;
}

.bill-table {
  width: 100%;
  border-collapse: collapse;
}

.bill-table th,
.bill-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.bill-table th {
  font-weight: 600;
  color: var(--text-color);
  background-color: var(--background-color);
}

.bill-table tr:last-child td {
  border-bottom: none;
}

.bill-table tr:hover td {
  background-color: var(--background-color);
}

.bill-component {
  display: flex;
  align-items: center;
}

.bill-icon {
  width: 24px;
  height: 24px;
  margin-right: 0.75rem;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.bill-total {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 2px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: var(--text-color);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .configurator-sidebar {
    width: 240px;
  }
  
  .configurator-properties {
    width: 280px;
  }
  
  .component-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .main-content {
    flex-direction: column;
  }
  
  .configurator-sidebar {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
  }
  
  .configurator-properties {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
    padding: 1rem;
  }
  
  .component-section {
    margin-bottom: 1rem;
    padding: 0.75rem;
  }
  
  .component-list {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .cabinet-container {
    padding: 1rem;
  }
}

@media (max-width: 768px) {
  .component-list {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .configurator-toolbar {
    flex-wrap: wrap;
  }
  
  .tool-group {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    width: 100%;
    justify-content: center;
  }
  
  .tool-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
  }
  
  .cabinet-view {
    transform: scale(0.9);
    transform-origin: top center;
  }
}

@media (max-width: 576px) {
  .component-list {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .cabinet-view {
    transform: scale(0.8);
  }
  
  .dialog-content {
    padding: 1.5rem;
  }
}
