html, body {
  height: 100%;
}
body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  height: 100%;
  padding-top: 80px;    /* Height of header */
  padding-bottom: 40px; /* Height of footer */
  box-sizing: border-box;
  overflow: hidden;
}
header {
  background: #2c3e50;
  color: white;
  padding: 15px;
  text-align: center;
  position: fixed;      /* Make header fixed */
  top: 0;               /* Stick to top */
  left: 0;
  width: 100%;          /* Full width */
  height: 80px;
  min-height: 80px;
  box-sizing: border-box;
  z-index: 1000;        /* Stay above other content */
}
    header img {
      position: absolute;
      top: 15px;
      left: 15px;
      width: 200px;
      height: auto;
    }
    header nav {
      position: absolute;
      top: 15px;
      right: 15px;
      display: flex;
      gap: 10px;
      align-items: center;
    }
header nav a, header nav button {
  padding: 8px 16px;
  background: #3498db;
  color: white;
  text-decoration: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  height: 36px;
  line-height: 36px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  font-size: 1rem;
  margin: 0;
  white-space: nowrap; /* Prevents wrapping */
}
    header nav a:hover, header nav button:hover {
      background: #2980b9;
    }
    header nav button#resetButton {
      background: #e74c3c;
    }
    header nav button#resetButton:hover {
      background: #c0392b;
    }
    header nav button#logoutButton {
      background: #e74c3c;
    }
    header nav button#logoutButton:hover {
      background: #c0392b;
    }
#login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: #f9f9f9;
}
#loginLogo {
  width: 50%;
  max-width: 300px;
  height: auto;
  margin-bottom: 20px;
}
#login form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
#login input[type="password"] {
  padding: 8px;
  width: 200px;
  border: 1px solid #ccc;
  border-radius: 3px;
}
#login button {
  padding: 8px;
  width: 100px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}
#login button:hover {
  background-color: #0056b3;
}
#loginStatus {
  margin: 10px 0;
  color: #28a745;
}
#adminContent {
  display: none;
  flex: 1;
}
.container {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: calc(100vh - 120px); /* 80px header + 40px footer */
  min-height: 0;
  box-sizing: border-box;
  overflow-y: auto;
}
.left-panel, .center-panel, .right-panel {
  padding: 10px;
}
.left-panel {
  width: 25%;
  background: #f9f9f9;
  resize: horizontal;
  overflow: auto;
  min-width: 200px;
  max-width: 50%;
  position: relative;
}
#topLogo {
  width: 100%;
  height: auto;
  margin-bottom: 10px;
}
.center-panel {
  flex: 1;
  text-align: center;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.center-panel h2 {
  background: transparent; /* Make Assembly Drawing header transparent */
  position: relative;
  z-index: 1;
}
.top-content {
  height: 70%; /* Use height instead of flex for resizing */
  display: flex;
  flex-direction: column;
  padding-bottom: 0; /* Remove padding to use full height */
  overflow: hidden; /* Prevent content from overflowing into parts list area */
  position: relative; /* Enable z-index positioning */
}
.top-content > div {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Prevent content overflow */
}
.top-content > div > div {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* Ensure SVG doesn't overflow this container */
  padding: 10px; /* Add 10px padding on all sides */
  box-sizing: border-box;
}
svg, .drawing-placeholder {
  width: 100%;
  height: 100%;           /* Allow SVG to fill container height completely */
  min-height: 100px;      /* Minimum height for very small containers */
  border: none;           /* Remove border */
  display: block;         /* Change from flex to block for better scaling */
  background: transparent; /* Transparent background to avoid clipping */
  box-sizing: border-box;
  overflow: hidden;       /* Clip content that exceeds SVG bounds */
  margin: 0 auto;
  max-width: 100%;
}
.drawing-placeholder.dragover {
  border-color: #4a4a4a;
  background: #e0e0e0;
}
.drawing-placeholder .svg-image {
  width: auto;
  height: auto;
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.drawing-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}
.right-panel {
  width: 30%;
  background: #f0f0f0;
  resize: horizontal;
  overflow: auto;
  min-width: 200px;
  max-width: 50%;
}
.divider {
  width: 5px;
  background: #ccc;
  cursor: col-resize;
}
.horizontal-divider {
  height: 5px;
  background: #ccc;
  cursor: row-resize;
  margin: 0;
  width: 100%;
}
.accordion {
  text-align: left;
}
.accordion-item {
  display: flex;
  flex-direction: column;
  height: 100%; /* Take full height of accordion container */
}
.accordion-item h2 {
  margin: 0;
  padding: 10px;
  background: #ddd;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0; /* Prevent title from shrinking */
}
.accordion-item h2 .status-icon {
  font-size: 16px;
  width: 32px;
  text-align: center;
}
.accordion-item .status-icon::before {
  content: '+ ';
}
.accordion-item.active .status-icon::before {
  content: '- ';
}
.accordion-content {
  padding: 10px;
  display: none;
  overflow-y: auto; /* Add scroll to content area only */
  flex: 1; /* Take remaining space after title */
}
.accordion-item.active .accordion-content {
  display: block;
}
label {
  display: block;
  margin: 5px 0;
}
select {
  width: 100%;
  padding: 5px;
  font-size: 16px;
  border: 1px solid #ccc;
  background: #fff;
  height: auto;
  -webkit-appearance: menulist;
  -moz-appearance: menulist;
  appearance: menulist;
  line-height: 1.5;
}
button {
  margin-top: 10px;
  padding: 8px;
  width: 100%;
}
.center-panel .accordion {
  margin-top: 0;
  height: 30%; /* Use height instead of flex for resizing */
  overflow: hidden; /* Remove scroll from accordion container */
  display: flex;
  flex-direction: column;
}
    footer {
      background: #2c3e50;
  color: white;
  padding: 10px;
  text-align: center;
  font-size: 12px;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  z-index: 500;
    }
    footer a {
      color: #3498db;
      text-decoration: none;
      margin: 0 5px;
    }
    footer a:hover {
      text-decoration: underline;
    }
#logoutButton {
  background-color: #dc3545;
  color: white;
  border: none;
  cursor: pointer;
}
#logoutButton:hover {
  background-color: #c82333;
}
input[type="color"] {
  width: 60px;
  height: 30px;
  padding: 2px;
  border: 1px solid #ccc;
  border-radius: 4px;
}
canvas {
  margin-top: 10px;
}
.flash-message {
  position: fixed;
  top: 20px;
  right: 20px;
  background-color: #4CAF50;
  color: white;
  padding: 15px;
  border-radius: 5px;
  z-index: 1000;
  display: none;
}
.flash-message.error {
  background-color: #f44336;
}
.group-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
}
.settings-group {
  flex: 1;
  min-width: 300px;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 15px;
  background: #f9f9f9;
}
.settings-group legend {
  font-weight: bold;
  padding: 0 10px;
}
.center-panel {
  flex: 1;
  text-align: left;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-left: 0px;
  padding-right: 0px;
  padding-top: 20px;
  padding-bottom: 20px;
  overflow: hidden;
  background: #fff;
}
#drawingPlaceholder {
  overflow: visible !important;
}
#drawing {
  width: 100%;
  max-width: 100%;
  max-height: 100%; /* Prevent SVG from exceeding container height */
  background: #fff;
  border: none;
  display: block;
  margin: 0 auto;
  box-sizing: border-box;
  overflow: hidden; /* Clip any content that exceeds bounds */
}
.button-group {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.button-group button {
  padding: 8px;
  width: 100%;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}
#backToConfigurator {
  background-color: #007bff;
  color: white;
}
#backToConfigurator:hover {
  background-color: #0056b3;
}
#resetButton {
  background-color: #dc3545;
  color: white;
}
#resetButton:hover {
  background-color: #c82333;
}
/* Reset parent containers to prevent layout interference */
#adminContent .center-panel {
  display: block !important;
  width: 100% !important;
  padding: 20px;
  box-sizing: border-box;
  overflow-x: auto; /* Allow horizontal scrolling if columns overflow */
}

#adminContent .center-panel #editSettingForm.edit-form {
  display: block !important;
  width: 100% !important;
  box-sizing: border-box;
}

/* Row-based two-column layout for settings form */
#adminContent .center-panel #editSettingForm .settings-row {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 20px !important; /* Space between columns in the row */
  width: 100% !important;
  margin-bottom: 20px !important; /* Space between rows */
  box-sizing: border-box !important;
  background: rgba(240, 240, 240, 0.5) !important; /* Light background for debugging */
  border: 2px dashed blue !important; /* Thicker border for debugging */
}

/* Full-width row for Motor Settings */
#adminContent .center-panel #editSettingForm .settings-row-full {
  display: block !important;
  width: 100% !important;
  margin-bottom: 20px !important; /* Space below the full-width row */
  box-sizing: border-box !important;
  background: rgba(220, 220, 220, 0.5) !important; /* Light background for debugging */
  border: 2px dashed green !important; /* Thicker border for debugging */
}

/* Columns within a row */
#adminContent .center-panel #editSettingForm .settings-column {
  flex: 1 !important; /* Each column takes equal width within the row */
  min-width: 300px !important; /* Ensure columns don’t collapse too small */
  box-sizing: border-box !important;
  background: rgba(200, 200, 200, 0.2) !important; /* Light background for debugging */
  border: 2px dashed red !important; /* Thicker border for debugging */
}

/* Ensure fieldsets and their contents fit nicely */
#adminContent .center-panel #editSettingForm .settings-group {
  margin: 0 !important;
  padding: 15px !important;
  border: 1px solid #ccc !important;
  border-radius: 4px !important;
  background: #fff !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Ensure inputs and sample boxes don’t overflow */
#adminContent .center-panel #editSettingForm .settings-group label,
#adminContent .center-panel #editSettingForm .settings-group input,
#adminContent .center-panel #editSettingForm .settings-group select,
#adminContent .center-panel #editSettingForm #pump_spigot_sample_box,
#adminContent .center-panel #editSettingForm #bellhousing_sample_box,
#adminContent .center-panel #editSettingForm #coupling_sample_box,
#adminContent .center-panel #editSettingForm #coupling_elements_sample_box {
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Adjust sample box container to fit within column */
#adminContent .center-panel #editSettingForm #pump_spigot_sample_box,
#adminContent .center-panel #editSettingForm #bellhousing_sample_box,
#adminContent .center-panel #editSettingForm #coupling_sample_box,
#adminContent .center-panel #editSettingForm #coupling_elements_sample_box {
  max-width: 100px !important; /* Keep sample box size consistent */
  margin-top: 10px !important;
}

/* Add gap between Motor Settings and Save button */
#adminContent .center-panel #editSettingForm .save-button-wrapper {
  margin-top: 40px !important; /* Increased gap for visibility */
  text-align: center !important; /* Center the button */
  background: rgba(255, 245, 220, 0.5) !important; /* Light background for debugging */
  border: 2px dashed purple !important; /* Thicker border for debugging */
}

#adminContent .center-panel #editSettingForm .save-button-wrapper button {
  padding: 10px 20px !important;
  font-size: 16px !important;
}