/**
 * VeryVariable.css
 *
 * Styles for the VeryVariable module backend UI
 */

/* Main container */
.VeryVariableBuilder {
    position: relative;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    display: block !important; /* Ensure visibility */
}

.VeryVariableBuilder *:focus-visible {
    outline: 0 
}

/* Instructions */
.VeryVariableInstructions {
    margin-bottom: 20px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background-color: #fefefe;
}

/* Attribute rows */
.VeryVariableRows {
    margin-bottom: 20px;
}

.VeryVariableRow {
    display: flex;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #ddd;
}

.VeryVariableAttribute {
    width: 200px;
    padding-right: 20px;
    && label {
        width: 100%;
        font-weight: 600;
        display: inline-block;
    }

    label.preselect {
        font-weight: normal;
        margin-bottom: 10px;
    }
}


.VeryVariableAttributeSelect {
    width: 100%;
    margin-top: 10px;
}

.vv_set_type {
    margin-top: 10px;
    width: 100% !important;
}

.vv_set_type.hidden {
    display: none !important
}

select {
    background-color: #f9f9f9 !important;
    border-color: #ddd !important;
}

span.select2-selection {
    height: 40px !important;
    padding: 4px 8px !important;
    border-radius: 0px !important;
    background-color: #f9f9f9 !important;
    border-color: #ddd !important;
    color: #354b60 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !important;
}

.select2-search__field:focus-visible {
    outline: 0;

}

.VeryVariableValues {
    flex: 1;
    display: none;
}

/* Value input */
.VeryVariableValueInput {
    display: flex;
    margin-bottom: 10px;
}

.VeryVariableValueInput input {
    flex: 1;
    margin-right: 10px;
}

/* Value buttons */
.VeryVariableValueBtn {
    display: inline-block;
    margin: 0 5px 5px 0;
    padding: 6px 12px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 3px;
    cursor: pointer;
    font-size: 16px;
    position: relative;
    &.active {
      z-index: 1;
    }
}

.VeryVariableAddValueBtn {
    margin-left: 10px !important;
    margin-right: 0px !important;
}

.VeryVariableValueBtn.blue {
    background: #e6f2ff;
    border-color: #99ccff;
    color: #0066cc;
}

.VeryVariableValueBtn.red {
    background: #ffe6e6;
    border-color: #ff9999;
    color: #cc0000;
}

.VeryVariableValueBtn.green {
    background: #e6ffe6;
    border-color: #99ff99;
    color: #006600;
}

.VeryVariableValueBtn.purple {
    background: #f2e6ff;
    border-color: #cc99ff;
    color: #6600cc;
}

.VeryVariableValueBtn.orange {
    background: #fff2e6;
    border-color: #ffcc99;
    color: #cc6600;
}

.VeryVariableValueBtn.vv-disabled,
.VeryVariableValueBtn[disabled] {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}


.VeryVariableAddComboLink {
    color: gray;
    border: 1px solid gray;
    padding: 4px 12px 4px;
    border-radius: 3px;
    font-size: 14px;
    margin-left: 0 !important;
    text-decoration: none;
    margin-top: -1px;
    position: absolute;
    font-family: -apple-system;
    &:hover {
        background-color: #fff;
        color: #333;
        text-decoration: none;
    }
}


/* Add layer button */
.VeryVariableAddLayer {
    margin-bottom: 20px;
}

/* Connections */
.VeryVariableConnections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.VeryVariableConnections svg {
    width: 100%;
    height: 100%;
}


.VeryVariableConnection {
    stroke-width: 2;
    stroke-dasharray: 5, 5;
}

.VeryVariableConnection.blue {
    stroke: #0066cc;
}

.VeryVariableConnection.red {
    stroke: #cc0000;
}

.VeryVariableConnection.green {
    stroke: #006600;
}

.VeryVariableConnection.purple {
    stroke: #6600cc;
}

.VeryVariableConnection.orange {
    stroke: #cc6600;
}

/* Combinations */
.VeryVariableCombinations {
    margin-top: 20px;
    padding: 15px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.VeryVariableCombinationsList {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-x: scroll;
    display: grid;
}

.VeryVariableCombinationsList li {
    padding: 0.5em 1em;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    margin-bottom: 2px;
    font-size: 15px;
    color: #333;
    list-style: none;
}

.VeryVariableRemoveCombo {
    color: #333;
    cursor: pointer;
    font-weight: bold;
    font-size: 18px;
    text-decoration: none;
    float: right;
    font-weight: bold;
    font-size: 18px;
    width: 30px;
    height: 30px;
    text-align: center;
    margin-top: 5px;
    border: 2px solid #333;
    border-radius: 100%;
    aspect-ratio: 1 / 1 !important;
    padding: 0;
    line-height: 24px;
    margin: 5px auto 0 auto;
    &:hover {
        color: #cc0000;
        border-color: #cc0000;
        text-decoration: none;
    }
}



/* Override any ProcessWire styles that might hide our UI */
.InputfieldVeryVariable .InputfieldContent {
    display: block !important;
}

/* Make sure our UI is visible */
.InputfieldVeryVariable {
    display: block !important;
}

.VeryVariableRemoveRow {
    color: #333;
    text-decoration: none;
    font-size: 12px;
    display: block;
    margin-top: 10px;
}

.VeryVariableRemoveRow:hover {
    color: #e83561 !important;
    text-decoration: none;
}

.vv-combo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background-color: #f9f9f9;
    border-bottom: 1px solid #eee;
  }
  
  .vv-combo-label {
    font-size: 13px;
  }
  
  .vv-combo-label strong {
    color: #333;
  }
  
  .vv-combo-header-row, .vv-combo-row {
    display: flex;
    flex-wrap: nowrap;
    align-content: flex-start;
    justify-content: space-around;
  }

  .vv-combo-row span, .vv-combo-row input, .vv-combo-row a, .vv-combo-header-row span, .vv-combo-header-row input, .vv-combo-header-row a {
    width: auto;
  }
  
  .vv-combo-actions a {
    text-decoration: none;
    margin-left: 10px;
    font-size: 16px;
    color: #888;
  }
  
  .vv-combo-details {
    padding: 15px;
    background-color: #fff;
    border-bottom: 1px solid #eee;
  }
  
  .vv-detail-field {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
  }
  
  .vv-detail-field label {
    font-weight: bold;
    color: #555;
    width: 80px;
    margin-right: 10px;
    font-size: 12px;
  }
  
  .vv-detail-field input {
    width: calc(100% - 90px);
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
  }
  
  .VeryVariableCombinationsList li {
    background-color: #fff;
    border: 1px solid #ddd;
    margin-bottom: 5px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  }

/* Image selector styles */
.vv-image-selector {
  display: flex;
  align-items: center;
}

.vv-image-selector .ui-button {
  padding: 0 15px;
  margin-right: 5px;
}

.vv-image-selector .ui-state-default {
  background-color: transparent;
  color: #333;
  border: 1px solid #e5e5e5;
}

/* Dynamic Image Grid */
.vv-image-modal-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 400px;
}

.vv-image-grid {
  display: grid;
  gap: 12px;
  padding: 20px;
  flex: 1;
  place-content: center;
  place-items: center;
  overflow: hidden;
  
  /* Smart auto-layout - automatically finds most compact grid */
  grid-template-columns: repeat(auto-fill, 120px);
  width: fit-content;
  max-width: 90vw; /* Fill available modal width, up to ~12 images per row */
  align-items: stretch;
}

/* Image item styling */
.vv-image-item {
  position: relative;
  width: 100%;
  max-width: 120px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  text-align: center;
  border: 2px solid transparent;
  border-radius: 6px;
}

.vv-image-item:hover {
  border-color: #3eb998;
  /* box-shadow: 0 2px 8px rgba(0,115,170,0.2); */
}
.vv-image-item:hover .vv-image-remove:hover,
.vv-image-item .vv-image-remove:hover {
  border-color: transparent;
}
.vv-image-item:hover:has(.vv-image-remove:hover) {
  border-color: transparent;
}

.vv-image-item.selected {
  border-color: #3eb99896;
  /* box-shadow: 0 2px 8px rgba(0,115,170,0.3); */
  /* background-color: #f0f8ff; */
}

.vv-image-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 3px 3px 0 0;
  margin-bottom: 8px;
}

.vv-image-item .vv-image-filename {
  font-size: 11px;
  color: #666;
  word-break: break-word;
  text-align: center;
  line-height: 1.2;
  margin-bottom: 7px;
  padding: 0 5px;
}


/* darkgray flat border button */
.vv-image-remove {
  position: absolute;
  top: -10px;
  right: -9px;
  width: 23px;
  height: 23px;
  background: white;
  color: #878787;
  border-radius: 50%;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10;
  display: block;
  transition: 
    background-color 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    opacity 0.2s ease;
  border: 2px solid #9e9e9e;
  text-align-last: center;
  opacity: 0;
  /* Center content using flex */
  display: flex;
  align-items: center;
  justify-content: center;
  outline: 3px solid white;
  padding:0 0 2px .5px;  
}

.vv-image-remove:hover {
  background-color: #a02622;
  color: white;
  border-color: #a02622;
  opacity: 1;
}


.vv-image-item:hover .vv-image-remove {
  opacity: 1;
}

/* .vv-image-remove:hover {
  background: #a02622;
  transform: scale(1.1);
} */

/* Empty state */
.vv-image-grid-empty {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  border: 2px dashed #ddd;
  border-radius: 8px;
  margin: 20px;
}

.vv-modal {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: calc(100% - 80px); /* Allow wider modal */
  max-height: 90vh; /* Allow taller modal */
  height: fit-content;
  width: fit-content;
  min-width: 400px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Modal body with scroll support */
.vv-modal-body {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  max-height: calc(90vh - 120px); /* Account for header/footer */
}

/* Modal drag & drop styling */
.vv-modal.vv-drag-active {
  background-color: #e6f2ff;
  position: relative;
}

.vv-modal.vv-drag-active::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 3px;
  border: 2px dashed #6997ad;
  border-radius: 5px;
}

.vv-modal.vv-drag-active .vv-modal-header,
.vv-modal.vv-drag-active .vv-modal-body,
.vv-modal.vv-drag-active .vv-modal-footer {
  background-color: transparent !important;
}


