/* ================================
   Generic Edit Dialog Styles
   ================================ */

.dialog-container {
  background: #fff;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Header */
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.caption-bar {
  font-size: 1.25rem;
  font-weight: bold;
}

.control-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Scrollable content */
.dialog-content {
  overflow-y: auto;
  flex-grow: 1;
  padding-right: 0.5rem;
}

.edit-content {
  padding: 1.5rem 1rem;
  flex: 1;
  overflow-y: auto;
}

/* ================================
   Form Fields
   ================================ */

.edit-field {
  display: flex;
  position: relative;
  justify-content: center;
  align-items: center;
}

/* Labels */
.edit-field label {
  flex: 0 0 150px;
  text-align: right;
  margin-right: 1rem;
  padding: 0.25rem 0.5rem;
  line-height: 2rem;
  white-space: nowrap;
}

.edit-field .search-wrapper {
  flex: 1;
  min-width: 0;
  /* padding: 0.25rem 0.5rem; */
  font-size: 1rem;
  line-height: 1.5rem;
  height: 2rem;
  box-sizing: border-box;
}

/* Inputs, textareas, selects, tags */
.edit-field input,
.edit-field textarea,
.edit-field select {
  flex: 1;
  min-width: 0;
  padding: 0.25rem 0.5rem;
  font-size: 1rem;
  line-height: 1.5rem;
  height: 2rem;
  box-sizing: border-box;
}

.edit-field input[type="number"] {
  text-align: center;
}

/* Checkboxes & radios */
.edit-field input[type="checkbox"],
.edit-field input[type="radio"] {
  width: auto;
  height: auto;
  margin: 0 0.25rem;
  align-self: center;
}

/* Wider labels in dialogs */
.dialog .edit-field label {
  flex: 0 0 150px;
  margin-right: 0.5rem;
  padding: 0.25rem;
}

/* ================================
   Buttons
   ================================ */

.save-btn {
  padding: 0.5rem 1rem;
  background-color: #007bff;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  width: 14rem;
  transition: background-color 0.2s;
}

.save-btn.right {
  align-self: flex-start;
  margin-left: auto;
}

.save-btn:hover {
  background-color: #0056b3;
}

.save-btn:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

/* ================================
   Password Field
   ================================ */

.password-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
}

.password-wrapper input {
  flex: 1;
  padding-right: 0.5rem;
}

.toggle-password {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  margin-left: 0.5rem;
  color: #007bff;
}

.input-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

.input-wrapper input {
  width: 100%;
  box-sizing: border-box;
}

.password-mismatch-indicator {
  color: red;
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  pointer-events: none;
}

/* ================================
   Toggle (Bootstrap-like)
   ================================ */

.edit-field .toggle {
  width: 50px;
  height: auto;
  align-self: center;
  display: flex;
  justify-content: center;
  padding: 0;
  margin: 0 auto;
}

.edit-field .toggle.btn {
  height: 1.5rem !important;
  line-height: 1.2rem !important;
  font-size: 0.875rem;
  padding: 0 0.5rem;
  width: 100%;
  box-sizing: border-box;
}

.edit-field .toggle-group .toggle-on,
.edit-field .toggle-group .toggle-off {
  padding: 0 0.5rem;
  line-height: 1.2 !important;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ================================
   Select2 Styling
   ================================ */

.edit-field .select2-container {
  flex: 1;
  min-width: 0;
  width: 100% !important;
  box-sizing: border-box;
}

.edit-field .select2-container .select2-selection--single {
  height: 2rem;
  line-height: 2rem;
  padding: 0 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.edit-field .select2-container .select2-selection--multiple {
  flex: 1;
  min-width: 0;
  width: 100% !important;
  box-sizing: border-box;
}

.edit-field .select2-container .select2-selection__rendered {
  padding: 0;
  line-height: 1.5rem;
}

.edit-field .select2-container .select2-selection__arrow {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ================================
   Tagify (Tag Input)
   ================================ */

.edit-field .tagify {
  flex: 1;
  min-width: 0;
  height: auto;
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.edit-field .tagify__tag {
  margin: 2px 4px 2px 0;
  padding: 0 0.25rem;
  font-size: 0.9rem;
  line-height: 1.2;
}

.edit-field .tagify__input {
  flex: 1;
  min-width: 50px;
  height: auto;
  box-sizing: border-box;
  line-height: 1.5rem;
  padding: 0;
}

/* ================================
   Sections / Fieldsets (Windows-style Groupbox)
   ================================ */

.edit-sections {
  display: grid;
  /* Maximum of 2 columns, but single fieldset will stretch full width */
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  width: 100%;
  margin-top: 0.5rem;
}

.edit-sections fieldset {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.75rem 1rem 1rem;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  width: 100%; /* ensure the fieldset takes all the column width */
}

/* When only one fieldset exists, make it full width explicitly */
.edit-sections:has(> fieldset:only-child) {
  grid-template-columns: 1fr;
}

.edit-sections fieldset legend {
  font-size: 1.2rem;
  font-weight: bold;
  color: #333;
  padding: 0 0.5rem;
  margin-left: 0.5rem;
}
