/* ===== Advanced Pro Form Builder — Frontend Styles ===== */
/* Powered by Parija Digital Solutions | Author: Fisal Ijaz  */

/* ── Reset / Isolation ─────────────────────────────────────── */
.apfb-form-wrap,
.apfb-form-wrap * {
    box-sizing: border-box;
}

.apfb-form-wrap {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
    color: #1f2937;
    line-height: 1.5;
}

/* ── Astra / Elementor / theme resets ──────────────────────── */
.apfb-form-wrap .apfb-input,
.apfb-form-wrap .apfb-textarea,
.apfb-form-wrap .apfb-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    margin: 0;
    vertical-align: baseline;
    height: auto;
    box-shadow: none;
    outline: none;
}

.ast-separate-container .apfb-form-wrap .apfb-input,
.ast-plain-container .apfb-form-wrap .apfb-input,
.apfb-form-wrap input[type="text"],
.apfb-form-wrap input[type="email"],
.apfb-form-wrap input[type="date"] {
    border-radius: 6px;
    background-color: #fff;
}

/* Elementor widget placeholder */
.apfb-elementor-placeholder {
    padding: 30px;
    background: #f5f7fa;
    border: 2px dashed #c3c4c7;
    border-radius: 6px;
    text-align: center;
    color: #50575e;
    font-size: 14px;
}

/* ── Alerts ────────────────────────────────────────────────── */
.apfb-success-message {
    padding: 14px 18px;
    background-color: #ecfdf5;
    border: 1px solid #6ee7b7;
    border-left: 4px solid #059669;
    border-radius: 6px;
    color: #065f46;
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.apfb-error-message {
    padding: 14px 18px;
    background-color: #fef2f2;
    border: 1px solid #fca5a5;
    border-left: 4px solid #dc2626;
    border-radius: 6px;
    color: #991b1b;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.apfb-error-inline {
    color: #991b1b;
    font-size: 14px;
    font-style: italic;
}

/* ── Form grid ─────────────────────────────────────────────── */
.apfb-form {
    display: block;
}

/*
 * Flex row container. column-gap: 20px → each flex child loses 10px per
 * side via calc() in the width classes below.
 */
.apfb-fields-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 18px 20px;
    align-items: flex-start;
    width: 100%;
}

/* ── Field wrapper ─────────────────────────────────────────── */
.apfb-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 0 0 100%;       /* default full width */
    width: 100%;
    min-width: 0;         /* prevent overflow */
}

/*
 * Width variants — calc() subtracts half the column-gap (20px / 2 = 10px)
 * so rows with multiple fields don't overflow.
 */
.apfb-field-w-75  { flex: 0 0 calc(75%  - 10px); width: calc(75%  - 10px); }
.apfb-field-w-66  { flex: 0 0 calc(66.6% - 10px); width: calc(66.6% - 10px); }
.apfb-field-w-50  { flex: 0 0 calc(50%  - 10px); width: calc(50%  - 10px); }
.apfb-field-w-33  { flex: 0 0 calc(33.3% - 10px); width: calc(33.3% - 10px); }
.apfb-field-w-25  { flex: 0 0 calc(25%  - 10px); width: calc(25%  - 10px); }

/* Full-width always takes 100% regardless */
.apfb-field-w-100 { flex: 0 0 100%; width: 100%; }

/* ── Labels ────────────────────────────────────────────────── */
.apfb-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
    margin-bottom: 2px;
}

.apfb-required {
    color: #dc2626;
    margin-left: 2px;
}

/* ── Input / Textarea / Select ─────────────────────────────── */
.apfb-input,
.apfb-textarea,
.apfb-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 15px;
    color: #111827;
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

.apfb-input:focus,
.apfb-textarea:focus,
.apfb-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

.apfb-textarea {
    resize: vertical;
    min-height: 110px;
}

.apfb-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

/* ── Date Picker ───────────────────────────────────────────── */
.apfb-datepicker-wrap {
    position: relative;
}

.apfb-datepicker {
    cursor: pointer;
    padding-right: 36px;
}

.apfb-datepicker-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 16px;
    color: #6b7280;
}

.ui-datepicker {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
    z-index: 99999 !important;
}

.ui-datepicker .ui-datepicker-header {
    background: #2563eb;
    border: none;
    border-radius: 7px 7px 0 0;
    color: #fff;
}

.ui-datepicker .ui-datepicker-title { color: #fff; font-weight: 600; }
.ui-datepicker .ui-datepicker-prev,
.ui-datepicker .ui-datepicker-next { cursor: pointer; top: 6px; }
.ui-datepicker .ui-datepicker-prev:hover,
.ui-datepicker .ui-datepicker-next:hover { background: rgba(255,255,255,0.15); border: none; }
.ui-datepicker td .ui-state-default { border-radius: 4px; text-align: center; }
.ui-datepicker td .ui-state-active,
.ui-datepicker td .ui-state-highlight { background: #2563eb; color: #fff; border-color: #2563eb; }

/* ── Geolocation ───────────────────────────────────────────── */
.apfb-geo-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.apfb-geo-address {
    background-color: #f9fafb;
    color: #374151;
    cursor: default;
}

.apfb-geo-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    background-color: #f1f5f9;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    align-self: flex-start;
}

.apfb-geo-button:hover  { background-color: #dbeafe; border-color: #93c5fd; }
.apfb-geo-button:disabled { opacity: 0.6; cursor: not-allowed; }

.apfb-geo-status         { font-size: 13px; color: #6b7280; font-style: italic; }
.apfb-geo-status.apfb-geo-error   { color: #dc2626; }
.apfb-geo-status.apfb-geo-success { color: #059669; }

/* ── Header field ──────────────────────────────────────────── */
.apfb-field-type-header {
    flex: 0 0 100% !important;
    width: 100% !important;
    margin-top: 8px;
}

.apfb-header-field {
    margin: 0 0 4px;
    padding: 0;
    color: inherit;
    font-family: inherit;
    line-height: 1.3;
    border: none;
    background: none;
}

/* ── Section Divider ───────────────────────────────────────── */
.apfb-field-type-divider {
    flex: 0 0 100% !important;
    width: 100% !important;
    align-items: center;
}

.apfb-divider-field { width: 100%; position: relative; }

.apfb-divider-field hr {
    margin: 6px 0;
    border: none;
    border-top-width: 1px;
    border-top-color: #d1d5db;
    background: none;
    height: 0;
}

.apfb-divider-solid  hr { border-top-style: solid; }
.apfb-divider-dashed hr { border-top-style: dashed; }
.apfb-divider-dotted hr { border-top-style: dotted; }
.apfb-divider-double hr { border-top-style: double; border-top-width: 3px; }

.apfb-divider-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

/* ── Checkboxes ────────────────────────────────────────────── */
.apfb-checkbox-group {
    border: none;
    padding: 0;
    margin: 0;
}

.apfb-checkbox-group legend {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
    margin-bottom: 8px;
    float: none;
    width: 100%;
    padding: 0;
}

/*
 * Checkbox options wrap: items flow horizontally, wrapping to the
 * next row when there is no space left — like a tag/chip cloud.
 * min-width keeps each item readable; they are NOT forced to equal
 * column widths so short labels don't leave huge gaps.
 */
.apfb-checkbox-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    width: 100%;
}

.apfb-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #374151;
    padding: 5px 10px 5px 6px;
    cursor: pointer;
    font-weight: normal;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    min-width: 140px;
    flex: 0 1 auto;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.apfb-checkbox-label:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}

.apfb-checkbox-label:has(.apfb-checkbox:checked) {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1e40af;
    font-weight: 500;
}

.apfb-checkbox {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    accent-color: #2563eb;
    cursor: pointer;
    margin: 0;
}

/* ── File upload ───────────────────────────────────────────── */
.apfb-file-input {
    width: 100%;
    padding: 8px 0;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
}

.apfb-file-hint {
    font-size: 12px;
    color: #6b7280;
    margin: 0;
}

/* ── Submit ────────────────────────────────────────────────── */
.apfb-submit-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
}

.apfb-submit-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 28px;
    background-color: #2563eb;
    color: #fff;
    border: 2px solid transparent;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    font-family: inherit;
    text-decoration: none;
    line-height: 1.4;
}

.apfb-submit-button:hover   { background-color: #1d4ed8; color: #fff; text-decoration: none; }
.apfb-submit-button:active  { transform: scale(0.98); }
.apfb-submit-button:disabled { background-color: #93c5fd; cursor: not-allowed; transform: none; }

/* Spinner */
.apfb-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #bfdbfe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: apfb-spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* ── Powered-by footer ─────────────────────────────────────── */
.apfb-powered-by {
    margin-top: 12px;
    font-size: 11px;
    color: #9ca3af;
    text-align: right;
}

.apfb-powered-by a {
    color: #6b7280;
    text-decoration: none;
}

.apfb-powered-by a:hover { text-decoration: underline; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
    .apfb-form-wrap { padding: 0 4px; }

    .apfb-field,
    .apfb-field-w-75,
    .apfb-field-w-66,
    .apfb-field-w-50,
    .apfb-field-w-33,
    .apfb-field-w-25 {
        flex: 0 0 100% !important;
        width: 100% !important;
    }

    .apfb-submit-button { width: 100%; }
    .apfb-submit-wrap   { flex-direction: column; align-items: stretch; }
}
