/* Style input fields and buttons for better alignment */
.custom-meta-row input[type="text"],
.custom-meta-row textarea {
    width: 100%;
}

.custom-meta-row button {
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1.2em;
}

.custom-meta-row button:hover {
    color: #0073aa;
}

.custom-meta-row .upload_image_button,
.custom-meta-row .remove_image_button {
    display: block;
    margin: 5px 0;
}

/* Style for adding and removing rows buttons */
#add-row, #remove-all-row {
    margin-top: 20px; /* Space above buttons */
}

/* Hide empty row template and elements with empty-remove class */
.empty-row,
.empty-remove {
    display: none !important; /* Completely hide these elements */
}

.custom-mf-row-handle {
    width: 2% !important;
    text-align: center !important;
    vertical-align: middle !important;
    position: relative !important;
}

.custom-mf-row-handle.order {
    background: #f4f4f4 !important;
    cursor: move !important;
    color: #aaa !important;
    text-shadow: #fff 0 1px 0 !important;
}

/* Initialize the counter and style the table */
#custom-meta-box-wrapper {
    counter-reset: rowNumber; /* Initialize the counter */
    width: 100%;
    border-collapse: collapse;
}

#custom-meta-box-wrapper th {
    background-color: #f4f4f4;
    text-align: left;
}

.custom-mf-row-handle.order::before {
    counter-increment: rowNumber; /* Increment the counter */
    content: counter(rowNumber);  /* Display the counter value */
    display: block;
    text-align: center;
    font-weight: bold;
}

.button.upload_image_button,
.button.remove_image_button,
.button.add_row_before_button {
    margin-left: 5px;
}

/* Style table headers and cells */
#custom-meta-box-wrapper th,
#custom-meta-box-wrapper td {
    padding: 10px;
    border: 1px solid #ddd;
}

/* Style image wrapper and overlay icons */
#custom-meta-box-wrapper .image-wrapper {
    position: relative;
    display: inline-block;
}

#custom-meta-box-wrapper .image-wrapper img {
    max-width: 300px;
}

#custom-meta-box-wrapper .image-wrapper .wpse_image_upload_button {
    display: none;
    position: absolute;
    top: 0;
    right: 30px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 5px;
    cursor: pointer;
    font-size: 18px;
}

#custom-meta-box-wrapper .image-wrapper .wpse_image_remove_button {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 5px;
    cursor: pointer;
    font-size: 18px;
}

#custom-meta-box-wrapper .image-wrapper:hover .icon-overlay {
    display: block;
}

/* Hide buttons initially and show them on row hover */
#custom-meta-box-wrapper .remove_image_button {
    display: none;
}

#custom-meta-box-wrapper .custom-meta-row .button-placeholder,
#custom-meta-box-wrapper .custom-meta-row:hover .remove_image_button{
    display: inline-block;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    margin: 0 5px;
}

#custom-meta-box-wrapper .remove_image_button:hover{
    color: red;
}


.custom-mf-row-handle .remove_row_button{
    display: none;
    position: absolute;
    margin: -8px 0 0 -8px;
}
.custom-mf-row-handle .add_row_before_button{
    display: none;
    position: absolute;
    top: 0;
    margin: -8px 0 0 -8px;
}
.custom-meta-row:hover .remove_row_button{
    display: block;
    position: absolute;
    margin: -8px 0 0 -8px;

}
.custom-meta-row:hover .add_row_before_button{
    display: block;
    margin: -8px 0 0 -8px;
    position: absolute;
    top: 0;

}

