/* GP Custom Customer Fields - Front Office controls */
textarea.gp-ccf-textarea {
    display: block;
    width: 100% !important;
    min-height: 180px !important;
    height: 180px;
    resize: vertical;
    box-sizing: border-box;
    white-space: pre-wrap;
}

.gp-ccf-choice-group {
    display: block;
}

.gp-ccf-choice-group label {
    display: block;
    margin: 0 0 8px;
    font-weight: normal;
    cursor: pointer;
}

.gp-ccf-choice-group input[type="radio"],
.gp-ccf-choice-group input[type="checkbox"] {
    margin-right: 6px;
}

select.gp-ccf-multiselect {
    min-height: 120px;
}

.gp-ccf-file-error { margin-top: 6px; color: #b94a48; font-size: 13px; }

.gp-ccf-existing-file {
    margin-top: 8px;
    display: block;
}

.gp-ccf-existing-file-preview {
    width: 80px !important;
    height: 80px !important;
    object-fit: cover;
    display: block;
}


/* -------------------------------------------------------------------------
 * Front-office field layout
 * Keep all custom fields visually consistent with the PrestaShop form grid.
 * ------------------------------------------------------------------------- */

.gp-ccf-choice-group {
    width: 100%;
    margin: 0;
    padding: 0;
}

.gp-ccf-choice-group label {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin: 0 18px 10px 0;
    padding: 0;
    line-height: 1.5;
    font-weight: normal;
    cursor: pointer;
}

.gp-ccf-choice-group input[type="radio"],
.gp-ccf-choice-group input[type="checkbox"] {
    position: static;
    width: auto;
    height: auto;
    margin: 0 6px 0 0;
    vertical-align: middle;
}

/* Checkbox groups are easier to read when each option occupies its own row. */
.gp-ccf-checkbox_group label {
    display: flex;
    width: 100%;
    margin-right: 0;
    margin-bottom: 9px;
}

/* Radio buttons can flow naturally across the available field width. */
.gp-ccf-radio label {
    display: inline-flex;
    width: auto;
}

/* Keep normal controls inside their Bootstrap field column. */
input[name^="gp_ccf_"],
textarea[name^="gp_ccf_"],
select[name^="gp_ccf_"] {
    box-sizing: border-box;
    max-width: 100%;
}

input[name^="gp_ccf_"].form-control,
textarea[name^="gp_ccf_"].form-control,
select[name^="gp_ccf_"].form-control {
    width: 100%;
}

/* Date input: don't stretch beyond the normal form-control width. */
input[type="date"][name^="gp_ccf_"] {
    width: 100%;
    min-height: 38px;
}

/* File upload and existing-file preview. */
input[type="file"][name^="gp_ccf_"] {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.gp-ccf-existing-file {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin: 0 0 10px;
}

.gp-ccf-existing-file-preview {
    width: 80px !important;
    height: 80px !important;
    max-width: 80px !important;
    object-fit: cover;
    display: block;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.gp-ccf-existing-file-link {
    align-self: center;
    word-break: break-word;
}

/* Multiselect: give it a useful height without overflowing its column. */
select.gp-ccf-multiselect,
select[name^="gp_ccf_"][multiple] {
    width: 100%;
    min-height: 120px;
    max-width: 100%;
}

/* Textarea: comfortable editing area and predictable sizing. */
textarea.gp-ccf-textarea,
textarea[name^="gp_ccf_"] {
    width: 100% !important;
    min-height: 180px;
    height: 180px;
    box-sizing: border-box;
    resize: vertical;
    line-height: 1.5;
}

/* Description/help text should stay below the control and wrap normally. */
[name^="gp_ccf_"] + .form-control-comment,
.gp-ccf-existing-file + input[name^="gp_ccf_"] + .form-control-comment {
    display: block;
    margin-top: 6px;
    line-height: 1.45;
}

/* Give each custom field a little breathing room on themes with tight rows. */
.gp-ccf-wrap .form-group,
.gp-ccf-existing-file {
    margin-bottom: 12px;
}

/* Prevent very long option labels from breaking the form layout. */
.gp-ccf-choice-group label,
.gp-ccf-choice-group label * {
    max-width: 100%;
}


/* Dedicated custom-field descriptions.
 * Kept inside the input column so choice fields (radio/checkbox/select)
 * do not lose their description when the theme places "Optionnel" elsewhere.
 */
.gp-ccf-description {
    display: block;
    width: 100%;
    margin-top: 6px;
    margin-bottom: 8px;
    line-height: 1.45;
    clear: both;
}

.gp-ccf-description p {
    margin: 0 0 6px;
}

.gp-ccf-description:last-child {
    margin-bottom: 0;
}

/* -------------------------------------------------------------------------
 * PrestaShop 1.7.8+ classic-theme alignment
 * -------------------------------------------------------------------------
 * The legacy customer form uses a 3/6/3 Bootstrap grid. Keep the custom
 * description inside the same control column as its field instead of letting
 * it become a full-width child of .form-group.
 */
.gp-ccf-description {
    display: block !important;
    width: 100%;
    max-width: 100%;
    margin: 6px 0 8px !important;
    padding: 0;
    clear: both;
    box-sizing: border-box;
    line-height: 1.45;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Legacy PS 1.7 radio/checkbox labels should not inherit the theme's
 * floating/positioned input rules in a way that makes options jump. */
.gp-ccf-choice-group {
    display: block !important;
    width: 100%;
    margin: 0;
    padding: 0;
}

.gp-ccf-choice-group label,
.gp-ccf-radio label,
.gp-ccf-checkbox_group label {
    position: static !important;
    float: none !important;
    box-sizing: border-box;
}

.gp-ccf-choice-group input[type="radio"],
.gp-ccf-choice-group input[type="checkbox"] {
    position: static !important;
    float: none !important;
    display: inline-block;
    width: auto !important;
    height: auto !important;
    margin: 0 6px 0 0 !important;
    vertical-align: middle;
}

/* Native PS 1.7 single checkbox. */
input[type="checkbox"][name^="gp_ccf_"] {
    width: 16px !important;
    max-width: none !important;
    vertical-align: middle;
}

/* The custom field control column must remain a normal block so the
 * description sits below the complete radio/checkbox group. */
.gp-ccf-choice-group + .gp-ccf-description,
.gp-ccf-choice-group ~ .gp-ccf-description {
    clear: both;
}

@media (max-width: 767px) {
    .gp-ccf-description {
        width: 100%;
    }
}


/*
 * Required Checkbox Group message.
 * Checkbox Groups use module-level group validation rather than native
 * `required` on one checkbox, so the message is shown below the group.
 */
.gp-ccf-required-error {
    display: block;
    margin-top: 6px;
    color: #dc3545;
    font-size: 0.875rem;
}


span.gp-ccf-required-marker {
    color: #dc3545;
    display: none;
}

