/* =========================================================
   Custom Product Forms for WooCommerce
   Frontend Form Styles
   ========================================================= */


/* ---------------------------------------------------------
   Main form wrapper
   --------------------------------------------------------- */

.custom-form-wrap {
    width: 100% !important;
    box-sizing: border-box;
}


/* ---------------------------------------------------------
   Steps
   --------------------------------------------------------- */

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

.cpfwc-step {
    width: 80%;
    box-sizing: border-box;
}


/* ---------------------------------------------------------
   Step title
   --------------------------------------------------------- */

.cpfwc-step-title {
    display: block;
    width: 100%;

    margin: 0 0 22px;
    padding: 0 0 10px;

    border-bottom: 1px solid #e3e6eb;

    font-size: 18px;
    line-height: 1.4;
    font-weight: 700;

    box-sizing: border-box;
}


/* ---------------------------------------------------------
   Step fields grid
   --------------------------------------------------------- */

.cpfwc-step-content {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    column-gap: 18px;
    row-gap: 18px;

    width: 100%;

    box-sizing: border-box;
}


/* ---------------------------------------------------------
   Individual field
   --------------------------------------------------------- */

.cpfwc-step-content .cpfwc-field {
    display: flex;
    flex-direction: column;

    width: 100%;
    min-width: 0;

    margin: 0;

    box-sizing: border-box;
}


/* ---------------------------------------------------------
   Labels
   IMPORTANT:
   Same minimum height keeps both inputs aligned
   --------------------------------------------------------- */

.cpfwc-step-content .cpfwc-field label {
    display: flex;
    align-items: flex-start;

    width: 100%;
    min-height: 54px;

    margin: 0 0 7px;

    font-size: 14px;
    line-height: 1.35;
    font-weight: 600;

    box-sizing: border-box;
}


/*
 * Remove the <br> that comes from PHP.
 * Layout is controlled with CSS now.
 */
.cpfwc-step-content .cpfwc-field > br {
    display: none;
}


/* ---------------------------------------------------------
   Inputs
   --------------------------------------------------------- */

.cpfwc-step-content .cpfwc-field input[type="text"],
.cpfwc-step-content .cpfwc-field input[type="email"],
.cpfwc-step-content .cpfwc-field input[type="number"],
.cpfwc-step-content .cpfwc-field select,
.cpfwc-step-content .cpfwc-field textarea {
    display: block;

    width: 100% !important;
    max-width: 100%;

    min-height: 42px;

    margin: 0;
    padding: 8px 10px;

    box-sizing: border-box;

    border: 1px solid #d9dfe7;
    border-radius: 5px;

    background: #fff;

    font-size: 14px;
    line-height: 1.4;
}


/* ---------------------------------------------------------
   Input focus
   --------------------------------------------------------- */

.cpfwc-step-content .cpfwc-field input:focus,
.cpfwc-step-content .cpfwc-field select:focus,
.cpfwc-step-content .cpfwc-field textarea:focus {
    outline: none;
    border-color: #aeb7c4;
}


/* ---------------------------------------------------------
   Textarea
   --------------------------------------------------------- */

.cpfwc-step-content .cpfwc-field textarea {
    min-height: 76px;
    resize: vertical;
}


/* ---------------------------------------------------------
   Select
   --------------------------------------------------------- */

.cpfwc-step-content .cpfwc-field select {
    cursor: pointer;
}


/* ---------------------------------------------------------
   File upload
   --------------------------------------------------------- */

.cpfwc-step-content .cpfwc-field input[type="file"] {
    display: block;

    width: 100% !important;
    max-width: 100%;

    min-height: 42px;

    margin: 0;
    padding: 6px;

    box-sizing: border-box;

    font-size: 13px;
}


/* ---------------------------------------------------------
   Checkbox
   --------------------------------------------------------- */

.cpfwc-step-content .cpfwc-field input[type="checkbox"] {
    width: auto !important;
    min-height: auto;

    margin: 3px 7px 0 0;
}


/* ---------------------------------------------------------
   Textarea / image use complete row
   --------------------------------------------------------- */

.cpfwc-step-content .cpfwc-field:has(textarea),
.cpfwc-step-content .cpfwc-field:has(input[type="file"]) {
    grid-column: 1 / -1;
}


/*
 * Full-width fields do not need the large label spacer.
 */
.cpfwc-step-content .cpfwc-field:has(textarea) label,
.cpfwc-step-content .cpfwc-field:has(input[type="file"]) label {
    min-height: auto;
}


/* ---------------------------------------------------------
   Step navigation
   --------------------------------------------------------- */

.cpfwc-step-navigation {
    display: flex;
    align-items: center;

    gap: 10px;

    width: 100%;

    margin-top: 24px;

    box-sizing: border-box;
}


/* Previous / Next buttons */

.cpfwc-step-navigation .cpfwc-step-prev,
.cpfwc-step-navigation .cpfwc-step-next {
    min-height: 40px;

    margin: 0;
    padding: 8px 20px;

    border: 0;
    border-radius: 5px;

    cursor: pointer;

    font-size: 14px;
}


/* Counter */

.cpfwc-step-counter {
    display: inline-flex;
    align-items: center;

    min-height: 40px;

    font-size: 14px;
    line-height: 1.4;
}


/* ---------------------------------------------------------
   Old fields outside Steps
   --------------------------------------------------------- */

.cpfwc-outside-step-field {
    width: 80%;

    margin-bottom: 15px;

    box-sizing: border-box;
}

.cpfwc-outside-step-field .cpfwc-field {
    width: 100%;
}


/* ---------------------------------------------------------
   Mobile
   --------------------------------------------------------- */

@media (max-width: 600px) {

    .cpfwc-step-title {
        margin-bottom: 18px;
        padding-bottom: 9px;

        font-size: 17px;
    }


    .cpfwc-step-content {
        grid-template-columns: 1fr;

        column-gap: 0;
        row-gap: 15px;
    }


    /*
     * We don't need equal label heights
     * when fields are in one column.
     */
    .cpfwc-step-content .cpfwc-field label {
        min-height: auto;

        margin-bottom: 7px;
    }


    .cpfwc-step-content .cpfwc-field:has(textarea),
    .cpfwc-step-content .cpfwc-field:has(input[type="file"]) {
        grid-column: auto;
    }


    .cpfwc-step-navigation {
        margin-top: 20px;
    }


    .cpfwc-step-navigation .cpfwc-step-prev,
    .cpfwc-step-navigation .cpfwc-step-next {
        padding: 8px 16px;
    }
}

/* =========================
   Repeater frontend
========================= */

.cpfwc-repeater {
    width: 100%;
    margin: 0 0 24px;
    box-sizing: border-box;
}

.cpfwc-repeater-title {
    margin: 0 0 18px;
    font-size: 18px;
    line-height: 1.4;
    font-weight: 700;
}

.cpfwc-repeater-items {
    width: 100%;
}

.cpfwc-repeater-item {
    width: 100%;
    margin: 0 0 18px;
    padding: 0 0 18px;
    border-bottom: 1px solid #e3e6eb;
    box-sizing: border-box;
}

/* Header: title left, delete right */
.cpfwc-repeater-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin: 0 0 16px;
}

.cpfwc-repeater-item-title {
    margin: 0;
    font-size: 17px;
    line-height: 1.4;
    font-weight: 700;
}

/* Repeater fields - same 2-column layout as normal Step fields */
.cpfwc-repeater-item-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 18px;
    row-gap: 18px;
    width: 100%;
    box-sizing: border-box;
}

.cpfwc-repeater-item-fields .cpfwc-field {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    margin: 0;
    box-sizing: border-box;
}

.cpfwc-repeater-item-fields .cpfwc-field label {
    display: flex;
    align-items: flex-start;
    width: 100%;
    min-height: 54px;
    margin: 0 0 7px;
    font-size: 14px;
    line-height: 1.35;
    font-weight: 600;
    box-sizing: border-box;
}

.cpfwc-repeater-item-fields .cpfwc-field > br {
    display: none;
}

.cpfwc-repeater-item-fields .cpfwc-field input[type="text"],
.cpfwc-repeater-item-fields .cpfwc-field input[type="email"],
.cpfwc-repeater-item-fields .cpfwc-field input[type="number"],
.cpfwc-repeater-item-fields .cpfwc-field select,
.cpfwc-repeater-item-fields .cpfwc-field textarea {
    display: block;
    width: 100% !important;
    max-width: 100%;
    min-height: 42px;
    margin: 0;
    padding: 8px 10px;
    box-sizing: border-box;
    border: 1px solid #d9dfe7;
    border-radius: 5px;
    background: #fff;
    font-size: 14px;
    line-height: 1.4;
}

.cpfwc-repeater-item-fields .cpfwc-field textarea {
    min-height: 76px;
    resize: vertical;
}

.cpfwc-repeater-item-fields .cpfwc-field input[type="file"] {
    width: 100% !important;
    min-height: 42px;
    box-sizing: border-box;
}

/* checkbox */
.cpfwc-repeater-item-fields .cpfwc-field:has(input[type="checkbox"]) {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.cpfwc-repeater-item-fields .cpfwc-field:has(input[type="checkbox"]) label {
    min-height: auto;
    margin: 0;
    order: 2;
}

.cpfwc-repeater-item-fields .cpfwc-field input[type="checkbox"] {
    width: auto !important;
    margin: 0;
    order: 1;
}

/* Full-width fields */
.cpfwc-repeater-item-fields .cpfwc-field:has(textarea),
.cpfwc-repeater-item-fields .cpfwc-field:has(input[type="file"]) {
    grid-column: 1 / -1;
}

.cpfwc-repeater-item-fields .cpfwc-field:has(textarea) label,
.cpfwc-repeater-item-fields .cpfwc-field:has(input[type="file"]) label {
    min-height: auto;
}


/* =========================
   Repeater buttons
========================= */

/* Add button - smaller */
.cpfwc-add-repeater-item {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;

    width: auto !important;
    min-height: 34px !important;

    margin: 0 !important;
    padding: 6px 14px !important;

    border-radius: 5px !important;

    font-size: 14px !important;
    line-height: 20px !important;
    font-weight: 500 !important;
}

/* Delete button - right side */
.cpfwc-remove-repeater-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: auto !important;
    min-height: 30px !important;

    margin: 0 !important;
    padding: 4px 10px !important;

    border: 0 !important;
    border-radius: 0 !important;

    background: #ff4d4f !important;
    color: #fff !important;

    font-size: 13px !important;
    line-height: 20px !important;
    font-weight: 400 !important;

    cursor: pointer;
    box-shadow: none !important;
}

.cpfwc-remove-repeater-item:hover,
.cpfwc-remove-repeater-item:focus {
    background: #e94345 !important;
    color: #fff !important;
    box-shadow: none !important;
}


/* =========================
   Mobile
========================= */

@media (max-width: 600px) {

    .cpfwc-repeater-item-fields {
        grid-template-columns: 1fr;
        column-gap: 0;
    }

    .cpfwc-repeater-item-fields .cpfwc-field label {
        min-height: auto;
    }

    .cpfwc-repeater-item-header {
        align-items: center;
    }
}