/* Frontend Styles for Category Product Fields */

.cpf-field-group {
    margin: 20px 0;
}

.cpf-field-group {
  margin-top:0;
  grid-column: 1 / -1;
  padding:20px 30px;
  background:#efefef;
  & select,
  & input {
    background:#fff;
  }
  display:flex;
  flex-direction:column;
  row-gap:20px;
  border:1px solid #c1c1c1;
}

.cpf-field {
    margin-bottom: 0px;
}

.cpf-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    display:grid;
    justify-content: center;
}

.cpf-field .required {
    color: #e2401c;
    font-weight: bold;
    margin-left: 3px;
}

.cpf-field.hidden {
    display: none;
}

/* Label position: left */
.cpf-field.cpf-label-left {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 15px;
    align-items: start;
}

.cpf-field.cpf-label-left > label {
    margin-bottom: 0;
    padding-top: 10px;
    text-align: left;
    justify-content:start;
}

.cpf-field.cpf-label-left .cpf-field-description {
    grid-column: 2;
}

/* Adjust for different field types with left labels */
.cpf-field.cpf-label-left .cpf-radio-group,
.cpf-field.cpf-label-left .cpf-checkbox-group,
.cpf-field.cpf-label-left .cpf-image-swatch-group,
.cpf-field.cpf-label-left .cpf-multi-image-swatch-group {
    grid-column: 2;
}

/* Label position: above (default) */
.cpf-field.cpf-label-above > label {
    display: block;
    margin-bottom: 8px;
}

/* Input fields */
.cpf-input,
.cpf-textarea,
.cpf-select,
.cpf-file-input {
    width: 100%;
    padding: 0px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.cpf-textarea {
    min-height: 100px;
    resize: vertical;
}

.cpf-input:focus,
.cpf-textarea:focus,
.cpf-select:focus {
    outline: none;
    border-color: #999;
}

/* Radio and Checkbox groups */
.cpf-radio-group,
.cpf-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cpf-radio-label,
.cpf-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.2s;
}

.cpf-radio-label:hover,
.cpf-checkbox-label:hover {
    background: #f5f5f5;
    border-color: #999;
}

.cpf-radio-label input,
.cpf-checkbox-label input {
    margin-right: 10px;
}

/* Image Swatches */
.cpf-image-swatch-group,
.cpf-multi-image-swatch-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
}

.cpf-image-swatch {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
    text-align:center;
}

.cpf-image-swatch:hover {
    border-color: #999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.cpf-image-swatch input[type="radio"],
.cpf-image-swatch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.cpf-image-swatch input:checked + img,
.cpf-image-swatch input:checked ~ img {
    border-color: #2271b1;
}

.cpf-image-swatch input:checked ~ .cpf-swatch-label {
    color: #2271b1;
    font-weight: 600;
}

.cpf-image-swatch img {
    width: 70px;
    height: auto;
    max-width: 100px;
    margin-bottom: 8px;
    border: 0px solid transparent;
    border-radius: 4px;
    transition: border-color 0.2s;
}

.cpf-swatch-label {
    text-align: center;
    font-size: 13px;
    line-height: 1.3;
}

.cpf-image-swatch:has(input:checked) {
    border-color: #2271b1;
    background: #f0f6fc;
}

/* Field description */
.cpf-field-description {
    margin-top: 5px;
    font-size: 13px;
    color: #666;
    font-style: italic;
}

/* Validation errors */
.cpf-field.error input,
.cpf-field.error select,
.cpf-field.error textarea {
    border-color: #e2401c;
}

.cpf-error-message {
    color: #e2401c;
    font-size: 13px;
    margin-top: 5px;
}

/* File upload preview */
.cpf-file-preview {
    margin-top: 10px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 4px;
}

.cpf-file-preview img {
    max-width: 200px;
    height: auto;
    display: block;
}

/* Loading state */
.cpf-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
    .cpf-image-swatch-group,
    .cpf-multi-image-swatch-group {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .cpf-image-swatch img {
        max-width: 60px;
    }
    
    /* Stack labels on mobile */
    .cpf-field.cpf-label-left {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .cpf-field.cpf-label-left > label {
        text-align: left;
        padding-top: 0;
        margin-bottom: 8px;
    }
    
    .cpf-field.cpf-label-left .cpf-field-description {
        grid-column: 1;
    }
}

@media (max-width: 480px) {
    .cpf-image-swatch-group,
    .cpf-multi-image-swatch-group {
        grid-template-columns: repeat(2, 1fr);
    }
}
