/**
 * Frontend styles for MBN Custom Woo
 */

.mbn-configuration-container .required {
    color: #cc0000;
}

#mbn-price-bar {
  position: fixed;
  top: 80px;
  height: 42px !important;
  transform: translateY(-42px);
  opacity: 0;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

body.mbn-price-bar-visible #mbn-price-bar {
  transform: translateY(0);
  opacity: 1;
}

.woocommerce-notices-wrapper {
  transition: transform 0.3s ease;
}

body.mbn-price-bar-visible .woocommerce-notices-wrapper {
  transform: translateY(42px);
}

.mbn-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.mbn-swatch {
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease;
}

.mbn-swatch:hover {
  transform: translateY(-2px);
}

.mbn-swatch img {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: cover;
  border: 2px solid #e6e6e6 !important;
  border-radius: 16px !important;
}

.mbn-swatch-label {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  text-align: center;
  max-width: 120px;
  word-wrap: break-word;
}

.mbn-swatch.selected img {
  border-color: #43a0f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.mbn-swatch.selected::after {
  content: "✓";
  position: absolute;
  top: 8px;
  right: 8px;
  background: #43a0f0;
  color: #fff;
  width: 28px;
  height: 28px;
  border: 2px solid white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  z-index: 10;
}

/* Hide color select dropdown - keep swatches only */
.mbn-swatches ~ select[name^="attribute_"],
select[name^="attribute_pa_"] {
  display: none !important;
}

/* Style WooCommerce variation table to match meta fields */
.variations_form .variations {
  border: 1px solid #f3f3f3 !important;
  border-radius: 16px;
  padding: 24px;
  background-color: #fafafa;
  border-collapse: separate;
  border-spacing: 0;
}

.variations_form .variations tr {
  display: block;
  margin-bottom: 0;
}

.variations_form .variations tr td,
.variations_form .variations tr th {
  background-color: unset;
}

.variations_form .variations .label {
  display: block;
  margin: 0 0 15px 0;
  padding: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  text-align: left;
  color: var(--e-global-color-secondary) !important;
}

.variations_form .variations .label label {
  /* font-family: var(--e-global-typography-d3dae9a-font-family), Sans-serif; */
  font-size: var(--e-global-typography-d3dae9a-font-size) !important;
  font-weight: var(--e-global-typography-d3dae9a-font-weight) !important;
  font-style: var(--e-global-typography-d3dae9a-font-style) !important;
  line-height: var(--e-global-typography-d3dae9a-line-height) !important;
}

.variations_form .variations .value {
  display: block;
  padding: 0;
}

.variations_form .reset_variations {
  display: none;
}

/* Configuration Container */
.mbn-configuration-container {
  padding: 24px;
  border: 1px solid #f3f3f3;
  border-radius: 16px;
  margin: 24px 0;
  background-color: #fafafa;
}

.mbn-configuration-heading {
  margin: 0 0 24px 0;
  padding-bottom: 16px;
  border-bottom: 2px solid #ececec;
  font-size: 20px;
  font-weight: 700;
  color: #333;
  text-align: left;
}

/* Unified Meta Fields */
.mbn-meta-field {
  margin-top: 20px;
  /*
  padding: 20px;
  background-color: #f8f8f8;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  */
}

.mbn-field-title {
  margin: 0 0 15px 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

/* Included Text (for disabled treatment options) */
.mbn-included-text {
  font-size: 16px;
  color: #666;
}

/* Image Select Field (Mount Type) */
.mbn-image-select-wrapper {
  display: flex;
  gap: 30px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.mbn-image-select-options {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  flex-shrink: 0;
  max-width: 100%;
}

.mbn-mount-instruction,
.mbn-lifting-instruction,
.mbn-remote-instruction,
.mbn-hub-instruction {
  flex: 1 1 190px;
  min-width: 190px;
  padding: 15px;
  background-color: #f0f7ff;
  border: 1px solid #d0e4ff;
  border-radius: 6px;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
}

.mbn-instruction-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-direction: column;
}

.mbn-instruction-link {
  flex-shrink: 0;
  font-size: 14px;
  color: #0073aa;
  text-decoration: none;
  white-space: nowrap;
  align-self: end;
}

.mbn-instruction-link:hover {
  text-decoration: underline;
}

.mbn-text-divider {
  display: block;
  height: 1px;
  background-color: #ccc;
  margin: 15px 0;
  border: none;
}

.mbn-image-select-option {
  cursor: pointer;
  text-align: center;
  transition: transform 0.2s ease;
}

.mbn-image-select-option:hover {
  transform: translateY(-2px);
}

.mbn-option-image {
  position: relative;
  width: 120px;
  height: 120px;
  border: 2px solid #e6e6e6;
  border-radius: 16px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #666;
}

.mbn-image-select-option.selected .mbn-option-image {
  border-color: #43a0f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.mbn-option-outside {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.mbn-option-checkmark {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background-color: #43a0f0;
  color: #fff;
  border: 2px solid white;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
}

.mbn-image-select-option.selected .mbn-option-checkmark {
  display: flex;
}

.mbn-option-label {
  margin-top: 10px;
  max-width: 120px;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

/* Treatment Options Styling */
.mbn-field-optional {
  font-size: 12px;
  font-weight: 400;
  color: #666;
  margin-left: 8px;
}

.mbn-field-top_treatment .mbn-option-image,
.mbn-field-bottom_treatment .mbn-option-image,
.mbn-field-treatment_color .mbn-option-image,
.mbn-conditional-option .mbn-option-image {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #f5f5f5;
}

.mbn-option-price {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #4caf50;
  margin-top: 4px;
}

/* Hierarchical Select (Lifting Options) */
.mbn-hierarchical-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.mbn-lifting-suboptions {
  padding: 20px;
  background-color: #f3f3f3;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  margin-top: 10px;
}

.mbn-suboption-title {
  margin: 0 0 15px 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

/* Composite Fields (Location) */
.mbn-composite-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.mbn-composite-field {
  display: flex;
  flex-direction: column;
}

.mbn-composite-field label {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 14px;
  color: #333;
}

.mbn-field-select,
.mbn-field-input {
  width: 100%;
  height: 40px;
  padding: 10px 12px;
  border: 1px solid #ccc !important;
  border-radius: 4px;
  font-size: 14px;
  background-color: #fff;
  transition: border-color 0.3s ease;
}

.mbn-field-select:focus,
.mbn-field-input:focus {
  outline: none;
  border-color: #666 !important;
}

.mbn-field-input::placeholder {
  color: #999;
  font-style: italic;
}

/* Full-width composite field (spans both columns) */
.mbn-composite-field--full {
  grid-column: 1 / -1;
}

/* Room number and custom name: hidden by default, shown via JS */
.mbn-room-number-wrapper,
.mbn-room-other-wrapper {
  display: none;
}

.mbn-room-number-wrapper.mbn-visible {
  display: flex;
  flex-direction: column;
}

.mbn-room-other-wrapper.mbn-visible {
  display: flex;
  flex-direction: column;
}

.mbn-field-number {
  width: 70px;
  height: 40px;
  padding: 10px 8px;
  border: 1px solid #ccc !important;
  border-radius: 4px;
  font-size: 14px;
  background-color: #fff;
  text-align: center;
  transition: border-color 0.3s ease;
}

.mbn-field-number:focus {
  outline: none;
  border-color: #666 !important;
}

.mbn-field-number:invalid {
  border-color: #c0392b !important;
}

/* Field validation error state */
.mbn-field-error {
  border-color: #c0392b !important;
}

.mbn-field-error-msg {
  display: block;
  color: #c0392b;
  font-size: 12px;
  margin-top: 4px;
}

/* Measurement Fields (Size) */
.mbn-measurement-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.mbn-measurement-fields-group {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1 1 auto;
  min-width: 0;
}

.mbn-measurement-field {
  display: flex;
  gap: 20px;
  align-items: center;
  min-width: 0;
}

.mbn-measurement-instruction {
  flex: 1 1 175px;
  min-width: 175px;
  padding: 15px;
  background-color: #f0f7ff;
  border: 1px solid #d0e4ff;
  border-radius: 6px;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
}

.mbn-measurement-diagram {
  flex-shrink: 0;
  width: 120px;
}

.mbn-diagram-image {
  width: 120px;
  height: 120px;
  background-color: #f5f5f5;
  border: 2px solid #e6e6e6;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.mbn-diagram-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mbn-diagram-placeholder {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #666;
}

.mbn-measurement-row {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-width: 0;
}

.mbn-measurement-controls {
  width: 100%;
}

.mbn-measurement-controls label {
  font-weight: 600;
  font-size: 14px;
  color: #333;
  display: block;
  margin-bottom: 8px;
}

.mbn-ruler-visualization {
  width: 100%;
  max-width: 300px;
  min-height: 80px;
  border: 2px solid #ddd;
  border-radius: 6px;
  padding: 0;
  background-color: #fafafa;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow-x: auto;
  position: relative;
  overflow: hidden;
}

.mbn-ruler-display {
  width: auto;
  max-width: 100%;
  display: block;
  flex-grow: 1;
}

.mbn-ruler-track {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  position: relative;
  padding-top: 10px;
  min-height: 50px;
}

.mbn-ruler-tick {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 10px;
  position: relative;
  flex-shrink: 0;
}

.mbn-ruler-mark {
  width: 1px;
  background-color: #666;
  height: 18px;
  margin-bottom: 4px;
  display: block;
}

.mbn-ruler-tick-major .mbn-ruler-mark {
  height: 30px;
  width: 2px;
  background-color: #000;
}

.mbn-ruler-tick-half .mbn-ruler-mark {
  height: 24px;
  width: 1.5px;
  background-color: #333;
}

.mbn-ruler-tick-selected {
  z-index: 10;
}

.mbn-ruler-tick-selected .mbn-ruler-mark {
  height: 60px;
  width: 2px;
  background-color: #4f9edb;
  margin-top: -10px;
  box-shadow: 0 2px 4px rgba(79, 158, 219, 0.3);
}

.mbn-ruler-label {
  font-size: 11px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  margin-top: 2px;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: block;
}

.mbn-ruler-tick-selected .mbn-ruler-label {
  color: #4f9edb;
  font-weight: 700;
  font-size: 12px;
}

.mbn-ruler-label-small {
  font-size: 10px;
  font-weight: 500;
  color: #666;
  display: block;
}

.mbn-measurement-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mbn-measurement-inches,
.mbn-measurement-eighths {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  background-color: #fff;
  transition: border-color 0.3s ease;
}

.mbn-measurement-inches {
  width: 70px;
}

.mbn-measurement-eighths {
  width: 70px;
}

.mbn-measurement-inches:focus,
.mbn-measurement-eighths:focus {
  outline: none;
  border-color: #666;
}

/* Conditional Fields (Remote, Smart Hub) - styled as subsections */
.mbn-conditional-field {
  display: none;
  padding: 20px;
  margin-top: 10px;
  background-color: #f3f3f3;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
}

/* Loading/Transition States */
.mbn-dynamic-price-wrapper {
  transition: opacity 0.3s ease;
}

.mbn-dynamic-price-wrapper.mbn-updating {
  opacity: 0.6;
}

.mbn-price-transitioning {
  animation: priceFlash 0.5s ease;
}

@keyframes priceFlash {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.mbn-conditional-option {
  cursor: pointer;
  text-align: center;
  transition: transform 0.2s ease;
}

.mbn-conditional-option:hover {
  transform: translateY(-2px);
}

/* Gradient placeholders for conditional fields */
.mbn-option-none {
  background: linear-gradient(135deg, #e0e0e0 0%, #bdbdbd 100%);
  color: white;
}

.mbn-option-6-channel {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.mbn-option-12-channel {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.mbn-option-yes {
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  color: white;
}

.mbn-option-no {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
  color: white;
}

/* Checkbox Field (Adjacency) */
.mbn-adjacency-container {
  /* Container already has proper styling from .mbn-configuration-container */
}

.mbn-checkbox-wrapper {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.mbn-checkbox-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  user-select: none;
}

/* Hide native checkbox */
.mbn-checkbox-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Custom checkbox icon */
.mbn-checkbox-custom {
  display: block;
  position: relative;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  background-image: url("../icons/uncheck.svg");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transition: transform 0.2s ease;
}

/* Preload both icons to prevent delay on first interaction */
.mbn-checkbox-custom::before,
.mbn-checkbox-custom::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  z-index: -1;
}

.mbn-checkbox-custom::before {
  background-image: url("../icons/uncheck.svg");
}

.mbn-checkbox-custom::after {
  background-image: url("../icons/checked.svg");
}

/* Checked state */
.mbn-checkbox-input:checked + .mbn-checkbox-custom {
  background-image: url("../icons/checked.svg");
}

/* Hover effect */
.mbn-checkbox-label:hover .mbn-checkbox-custom {
  transform: translateY(-2px);
}

.mbn-checkbox-text {
  /* Text styling inherits from label */
}

.mbn-checkbox-price {
  font-size: 12px;
  font-weight: 500;
  color: #4caf50;
}

.mbn-checkbox-instruction {
  padding: 15px;
  background-color: #f0f7ff;
  border: 1px solid #d0e4ff;
  border-radius: 6px;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Responsive layout */


/* Tablet: 768px - 1024px */
@media (max-width: 1024px) {
  #mbn-price-bar {
    top: 75px;
  }

  .mbn-composite-fields {
    grid-template-columns: 1fr;
  }

  /* Display width and height as two columns side by side */
  .mbn-measurement-fields {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 20px;
  }

  .mbn-measurement-fields-group {
    flex-direction: row;
  }

  .mbn-measurement-field {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    gap: 15px;
    align-items: center;
  }

  .mbn-measurement-row {
    width: 100%;
    flex-direction: column;
    gap: 15px;
    align-items: center;
  }

  .mbn-measurement-controls {
    text-align: center;
  }

  .mbn-measurement-inputs {
    justify-content: center;
  }

  .mbn-ruler-visualization {
    width: 100%;
  }
}

/* Mobile: up to 767px */
@media (max-width: 767px) {
  #mbn-price-bar {
    top: 70px;
  }

  .mbn-field-number {
    padding: 0;
  }

  .mbn-option-image {
    width: 80px;
    height: 80px;
  }

  .mbn-image-select-options {
    gap: 10px;
  }

  .mbn-option-label {
    font-size: 12px;
    margin-top: 6px;
  }

  .mbn-option-price {
    font-size: 11px;
  }

  /* .mbn-measurement-fields-group {
    flex-direction: column;
  } */

  .mbn-measurement-field {
    flex-direction: column;
    gap: 12px;
  }

  .mbn-measurement-instruction {
    padding: 12px;
  }

  .mbn-measurement-row {
    flex-direction: column;
    gap: 12px;
  }

  .mbn-ruler-visualization {
    min-height: 60px;
    max-width: 150px;
  }

  .mbn-ruler-tick {
    width: 7px;
  }

  .mbn-ruler-label {
    font-size: 10px;
  }

  .mbn-swatches {
    gap: 8px;
  }

  .mbn-composite-fields {
    gap: 12px;
  }

  .mbn-mount-instruction,
  .mbn-lifting-instruction,
  .mbn-remote-instruction,
  .mbn-hub-instruction {
    padding: 12px;
  }

  .mbn-instruction-text {
    font-size: 13px;
    line-height: 1.5;
  }

  .mbn-measurement-inputs {
    gap: 6px;
  }

  .mbn-measurement-inches,
  .mbn-measurement-eighths {
    font-size: 14px;
    padding: 6px 8px;
  }

  .mbn-configuration-container {
    border-width: 1px;
    margin: 16px 0;
  }

  .mbn-configuration-heading {
    font-size: 18px;
    padding-bottom: 12px;
    margin-bottom: 16px;
  }

  .mbn-meta-field {
    margin-top: 15px;
  }

  .mbn-field-title {
    font-size: 16px;
    margin-bottom: 12px;
  }
}
