/**
 * Power Forms — Frontend Styles
 * SMACSS architecture: layout (pf-l-*), module (pf-*), state (pf-is-*), theme (pf-t-*)
 */

/* ─── Custom Properties ─────────────────────────────────── */
:root {
    --pf-font-family: inherit;
    --pf-font-size: 15px;
    --pf-line-height: 1.5;
    --pf-color-text: #1f2937;
    --pf-color-text-light: #6b7280;
    --pf-color-label: #374151;
    --pf-color-border: #d1d5db;
    --pf-color-border-focus: #3b82f6;
    --pf-color-bg: #ffffff;
    --pf-color-bg-alt: #f9fafb;
    --pf-color-primary: #3b82f6;
    --pf-color-primary-hover: #2563eb;
    --pf-color-error: #dc2626;
    --pf-color-error-bg: #fef2f2;
    --pf-color-success: #16a34a;
    --pf-color-success-bg: #f0fdf4;
    --pf-radius: 6px;
    --pf-spacing: 16px;
    --pf-transition: 0.2s ease;
}

/* ─── Form Wrapper ──────────────────────────────────────── */
.pf-form-wrap {
    font-family: var(--pf-font-family);
    font-size: var(--pf-font-size);
    line-height: var(--pf-line-height);
    color: var(--pf-color-text);
    max-width: 100%;
}

.pf-form-title {
    font-size: 1.5em;
    font-weight: 600;
    margin: 0 0 var(--pf-spacing) 0;
    color: var(--pf-color-text);
}

.pf-form {
    position: relative;
}

/* ─── Success / Error Messages ──────────────────────────── */
.pf-form-success {
    padding: 14px 18px;
    border-radius: var(--pf-radius);
    background: var(--pf-color-success-bg);
    color: var(--pf-color-success);
    font-weight: 500;
    margin-bottom: var(--pf-spacing);
    border: 1px solid rgba(22, 163, 74, 0.2);
}

.pf-form-error {
    padding: 14px 18px;
    border-radius: var(--pf-radius);
    background: var(--pf-color-error-bg);
    color: var(--pf-color-error);
    font-weight: 500;
    margin-bottom: var(--pf-spacing);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

/* ─── Layout: Grid ──────────────────────────────────────── */
.pf-l-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 calc(var(--pf-spacing) / -2);
}

.pf-l-col-12 { width: 100%; }
.pf-l-col-11 { width: 91.6667%; }
.pf-l-col-10 { width: 83.3333%; }
.pf-l-col-9  { width: 75%; }
.pf-l-col-8  { width: 66.6667%; }
.pf-l-col-7  { width: 58.3333%; }
.pf-l-col-6  { width: 50%; }
.pf-l-col-5  { width: 41.6667%; }
.pf-l-col-4  { width: 33.3333%; }
.pf-l-col-3  { width: 25%; }
.pf-l-col-2  { width: 16.6667%; }
.pf-l-col-1  { width: 8.3333%; }

.pf-l-row > [class*="pf-l-col-"],
.pf-l-row > .pf-field {
    padding: 0 calc(var(--pf-spacing) / 2);
    box-sizing: border-box;
}

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

/* ─── Field Module ──────────────────────────────────────── */
.pf-field {
    margin-bottom: var(--pf-spacing);
}

.pf-field__label {
    display: block;
    font-size: 0.875em;
    font-weight: 500;
    color: var(--pf-color-label);
    margin-bottom: 4px;
}

.pf-field__required {
    color: var(--pf-color-error);
    font-weight: 400;
}

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

/* Input base */
.pf-field__input {
    display: block;
    width: 100%;
    padding: 10px 12px;
    font-family: inherit;
    font-size: inherit;
    line-height: var(--pf-line-height);
    color: var(--pf-color-text);
    background: var(--pf-color-bg);
    border: 1px solid var(--pf-color-border);
    border-radius: var(--pf-radius);
    outline: none;
    transition: border-color var(--pf-transition), box-shadow var(--pf-transition);
    box-sizing: border-box;
}

.pf-field__input::placeholder {
    color: var(--pf-color-text-light);
}

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

/* Textarea */
textarea.pf-field__input {
    resize: vertical;
    min-height: 80px;
}

/* Select */
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' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='2 4 6 8 10 4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

/* Checkbox / Radio items */
.pf-field--checkbox .pf-field__input-wrap,
.pf-field--radio .pf-field__input-wrap,
.pf-field--checkbox_list .pf-field__input-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pf-field__option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9375em;
    cursor: pointer;
}

.pf-field__option input[type="checkbox"],
.pf-field__option input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--pf-color-primary);
}

/* Single checkbox (e.g. "I agree") */
.pf-field--checkbox .pf-field__check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.pf-field--checkbox .pf-field__check-label input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--pf-color-primary);
}

/* Description */
.pf-field__description {
    font-size: 0.8125em;
    color: var(--pf-color-text-light);
    margin-top: 4px;
}

/* Errors */
.pf-field__errors {
    font-size: 0.8125em;
    color: var(--pf-color-error);
    margin-top: 4px;
    min-height: 0;
}

.pf-field__errors:empty {
    display: none;
}

/* ─── Field States ──────────────────────────────────────── */
.pf-is-invalid .pf-field__input {
    border-color: var(--pf-color-error);
}

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

.pf-is-hidden {
    display: none !important;
}

/* ─── Form-Level Error Summary ──────────────────────────── */
.pf-form-error-summary {
    margin-top: var(--pf-spacing);
    padding: 10px 14px;
    border: 1px solid var(--pf-color-error);
    border-radius: var(--pf-radius);
    background: var(--pf-color-error-bg);
    color: var(--pf-color-error);
    font-size: 0.875em;
}

.pf-form-error-summary:empty {
    display: none;
}

.pf-is-disabled .pf-field__input {
    opacity: 0.9;
    cursor: not-allowed;
    background: var(--pf-color-bg-alt);
}

/* ─── Heading / HTML fields ─────────────────────────────── */
.pf-field--heading .pf-field__heading {
    font-size: 1.25em;
    font-weight: 600;
    color: var(--pf-color-text);
    margin: 0;
    padding: 4px 0;
}

.pf-field--html .pf-field__html {
    font-size: 0.9375em;
    line-height: 1.6;
    color: var(--pf-color-text);
}

/* ─── Submit Button ─────────────────────────────────────── */
.pf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    font-family: inherit;
    font-size: 0.9375em;
    font-weight: 500;
    line-height: 1.5;
    color: #fff;
    background: var(--pf-color-primary);
    border: none;
    border-radius: var(--pf-radius);
    cursor: pointer;
    transition: background var(--pf-transition), opacity var(--pf-transition);
    text-decoration: none;
}

.pf-btn:hover {
    background: var(--pf-color-primary-hover);
}

.pf-btn:disabled,
.pf-btn.pf-is-loading {
    opacity: 0.6;
    cursor: not-allowed;
}

.pf-btn--prev {
    background: transparent;
    color: var(--pf-color-text);
    border: 1px solid var(--pf-color-border);
}

.pf-btn--prev:hover {
    background: var(--pf-color-bg-alt);
}

.pf-btn--next {
    background: var(--pf-color-primary);
}

/* Loading spinner */
.pf-btn .pf-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pf-spin 0.6s linear infinite;
}

@keyframes pf-spin {
    to { transform: rotate(360deg); }
}

/* ─── Multi-step Progress ───────────────────────────────── */
.pf-progress {
    margin-bottom: 24px;
}

.pf-progress__list {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0 0 12px 0;
    gap: 4px;
}

.pf-progress__step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
}

.pf-progress__indicator {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125em;
    font-weight: 600;
    background: var(--pf-color-bg-alt);
    color: var(--pf-color-text-light);
    border: 2px solid var(--pf-color-border);
    transition: all var(--pf-transition);
}

.pf-progress__step--active .pf-progress__indicator {
    background: var(--pf-color-primary);
    color: #fff;
    border-color: var(--pf-color-primary);
}

.pf-progress__step--complete .pf-progress__indicator {
    background: var(--pf-color-success);
    color: #fff;
    border-color: var(--pf-color-success);
}

.pf-progress__label {
    font-size: 0.75em;
    color: var(--pf-color-text-light);
    text-align: center;
}

.pf-progress__step--active .pf-progress__label {
    color: var(--pf-color-primary);
    font-weight: 500;
}

.pf-progress__bar {
    height: 4px;
    background: var(--pf-color-bg-alt);
    border-radius: 2px;
    overflow: hidden;
}

.pf-progress__fill {
    height: 100%;
    background: var(--pf-color-primary);
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* ─── Step Container ────────────────────────────────────── */
.pf-step__nav {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: var(--pf-spacing);
    padding-top: var(--pf-spacing);
    border-top: 1px solid var(--pf-color-border);
}

/* ─── Honeypot ──────────────────────────────────────────── */
.pf-hp {
    position: absolute;
    left: -9999px;
    opacity: 0;
    height: 0;
    overflow: hidden;
}

/* ─── Theme: Flat ───────────────────────────────────────── */
.pf-t-flat .pf-field__input {
    border-radius: 0;
    border-width: 0 0 2px 0;
    padding-left: 0;
    padding-right: 0;
    background: transparent;
}

.pf-t-flat .pf-field__input:focus {
    box-shadow: none;
    border-bottom-color: var(--pf-color-border-focus);
}

.pf-t-flat select.pf-field__input {
    background-position: right 0 center;
    padding-right: 20px;
}

/* ─── Theme: Minimal ────────────────────────────────────── */
.pf-t-minimal .pf-field__input {
    border-color: transparent;
    background: var(--pf-color-bg-alt);
}

.pf-t-minimal .pf-field__input:focus {
    border-color: var(--pf-color-border-focus);
    background: var(--pf-color-bg);
}
