/**
 * Power Up Forms -- Public form styles.
 *
 * Lightweight stylesheet loaded on pages where Forms::renderForm() is called.
 * Sits on top of the existing power-forms.css base. Override with higher
 * specificity or the pu/forms/form_classes filter.
 */

/* -- Form wrapper --------------------------------------------------------- */
.pf-form-wrap {
    max-width: 680px;
    margin: 0 auto;
}

.pf-form-title {
    margin: 0 0 1.25rem;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
}

/* -- Field rows ----------------------------------------------------------- */
.pf-l-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.pf-l-col-12 { flex: 0 0 100%; max-width: 100%; }
.pf-l-col-11 { flex: 0 0 calc(91.667% - 0.083rem); max-width: calc(91.667% - 0.083rem); }
.pf-l-col-10 { flex: 0 0 calc(83.333% - 0.167rem); max-width: calc(83.333% - 0.167rem); }
.pf-l-col-9  { flex: 0 0 calc(75% - 0.25rem); max-width: calc(75% - 0.25rem); }
.pf-l-col-8  { flex: 0 0 calc(66.667% - 0.333rem); max-width: calc(66.667% - 0.333rem); }
.pf-l-col-7  { flex: 0 0 calc(58.333% - 0.417rem); max-width: calc(58.333% - 0.417rem); }
.pf-l-col-6  { flex: 0 0 calc(50% - 0.5rem); max-width: calc(50% - 0.5rem); }
.pf-l-col-5  { flex: 0 0 calc(41.667% - 0.583rem); max-width: calc(41.667% - 0.583rem); }
.pf-l-col-4  { flex: 0 0 calc(33.333% - 0.667rem); max-width: calc(33.333% - 0.667rem); }
.pf-l-col-3  { flex: 0 0 calc(25% - 0.75rem); max-width: calc(25% - 0.75rem); }
.pf-l-col-2  { flex: 0 0 calc(16.667% - 0.833rem); max-width: calc(16.667% - 0.833rem); }
.pf-l-col-1  { flex: 0 0 calc(8.333% - 0.917rem); max-width: calc(8.333% - 0.917rem); }

@media (max-width: 640px) {
    [class*="pf-l-col-"]:not(.pf-l-col-12) {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* -- Field base ----------------------------------------------------------- */
.pf-field {
    margin-bottom: 0.25rem;
}

.pf-field__label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
}

.pf-field__required {
    color: #e53e3e;
}

.pf-field__input-wrap {
    position: relative;
}

.pf-field__input {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background: #fff;
    color: #111827;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.pf-field__input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.pf-field__input::placeholder {
    color: #9ca3af;
}

/* Textarea */
.pf-field--textarea .pf-field__input {
    min-height: 6rem;
    resize: vertical;
}

/* Select */
.pf-field--select .pf-field__input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8.825a.5.5 0 0 1-.354-.146l-4-4a.5.5 0 0 1 .708-.708L6 7.617l3.646-3.646a.5.5 0 0 1 .708.708l-4 4A.5.5 0 0 1 6 8.825z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

/* Checkbox / Radio */
.pf-field--checkbox .pf-field__input,
.pf-field--radio .pf-field__input {
    width: auto;
    display: inline-block;
}

/* -- Description ---------------------------------------------------------- */
.pf-field__description {
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: #6b7280;
    line-height: 1.4;
}

/* -- Errors --------------------------------------------------------------- */
.pf-field__errors {
    min-height: 0;
}

.pf-field__errors:not(:empty) {
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: #dc2626;
    line-height: 1.3;
}

.pf-is-invalid .pf-field__input {
    border-color: #dc2626;
}

.pf-is-invalid .pf-field__input:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

/* -- Submit --------------------------------------------------------------- */
.pf-field--submit {
    margin-top: 0.5rem;
}

/* .pf-btn kept for forms with a custom button_class; the default markup
   carries the theme atom classes plus the pf-btn--* hooks below. */
.pf-btn,
.pf-btn--submit,
.pf-btn--prev,
.pf-btn--next {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.15s, opacity 0.15s;
}

.pf-btn:disabled,
.pf-btn--submit:disabled,
.pf-btn--prev:disabled,
.pf-btn--next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pf-btn--submit {
    background: #3b82f6;
    color: #fff;
}

.pf-btn--submit:hover:not(:disabled) {
    background: #2563eb;
}

.pf-btn--prev,
.pf-btn--next {
    background: #e5e7eb;
    color: #374151;
}

.pf-btn--prev:hover:not(:disabled),
.pf-btn--next:hover:not(:disabled) {
    background: #d1d5db;
}

/* -- Success message ------------------------------------------------------ */
.pf-form-success:not(:empty) {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.375rem;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    font-size: 0.9375rem;
}

/* -- Multi-step progress -------------------------------------------------- */
.pf-progress {
    margin-bottom: 1.5rem;
}

.pf-progress__list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.5rem;
}

.pf-progress__step {
    flex: 1;
    text-align: center;
    font-size: 0.8125rem;
    color: #9ca3af;
}

.pf-progress__step--active {
    color: #3b82f6;
    font-weight: 600;
}

.pf-progress__indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    border: 2px solid currentColor;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.pf-progress__step--active .pf-progress__indicator {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.pf-progress__bar {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    margin-top: 0.75rem;
    overflow: hidden;
}

.pf-progress__fill {
    height: 100%;
    background: #3b82f6;
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* -- Step navigation ------------------------------------------------------ */
.pf-step__nav {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
    gap: 0.75rem;
}

/* -- Honeypot (keep hidden) ----------------------------------------------- */
.pf-hp {
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* -- Repeater ------------------------------------------------------------- */
.pf-repeater {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pf-repeater__row {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.75rem;
    background: #fafafa;
}

.pf-repeater__row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.pf-repeater__row-num {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
}

.pf-repeater__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    border-radius: 0.25rem;
    background: transparent;
    color: #9ca3af;
    font-size: 1.125rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

/* The button element is empty (icon comes from CSS) — draw the × here. */
.pf-repeater__remove::before {
    content: "\00d7";
}

.pf-repeater__remove:hover {
    background: #fef2f2;
    color: #dc2626;
}

.pf-repeater__row-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Summary field (review step) */
.pf-summary {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pf-summary__section {
    margin-top: 1rem;
    font-size: 1rem;
    font-weight: 600;
}

.pf-summary__section:first-child {
    margin-top: 0;
}

.pf-summary__item {
    display: flex;
    gap: 0.75rem;
}

.pf-summary__label {
    flex: 0 0 40%;
    color: #6b7280;
}

.pf-summary__value {
    white-space: pre-line;
}

.pf-summary__group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-left: 0.75rem;
    border-left: 2px solid #e5e7eb;
}

.pf-summary__group-title {
    font-weight: 600;
}

.pf-repeater__row-fields .pf-field {
    margin-bottom: 0;
}

/* Carries the theme's c-button atom classes, not .pf-btn — keep it
   self-sufficient for non-theme form skins. */
.pf-repeater__add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    padding: 0.625rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
    background: #f3f4f6;
    color: #374151;
    border: 1px dashed #d1d5db;
    border-radius: 0.375rem;
}

.pf-repeater__add:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

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