/**
 * PostBox - Frontend Form Styles
 * @package PostBox
 *
 * Clean default styling. Override in your template with:
 * templates/{template}/html/com_postboxpro/form/default.php  (layout)
 * templates/{template}/css/postbox-override.css            (styles)
 */

/* ── Wrapper ─────────────────────────────────────────── */
.postbox-form-wrapper {
    max-width: 640px;
    margin: 0 auto;
    padding: 0;
}

/* ── Form header ─────────────────────────────────────── */
.postbox-form-header {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 1.5rem 2rem;
}

.postbox-form-header + .postbox-form {
    border-radius: 0 0 8px 8px;
}

.postbox-form-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.3;
}

.postbox-form-description {
    margin: 0.375rem 0 0;
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.5;
}

.postbox-form {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 2rem;
}

/* ── No-border variant ───────────────────────────────── */
.postbox-form-wrapper--no-border .postbox-form-header {
    border: none;
    border-radius: 0;
    padding-left: 0;
    padding-right: 0;
}

.postbox-form-wrapper--no-border .postbox-form {
    border: none;
    border-radius: 0;
    padding-left: 0;
    padding-right: 0;
}

/* ── Fields ──────────────────────────────────────────── */
.postbox-field {
    margin-bottom: 1.5rem;
}

.postbox-field label,
.postbox-field > fieldset > legend {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.375rem;
}

.postbox-field > fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.postbox-field > fieldset > legend {
    padding: 0;
    font-size: 0.875rem;
    float: none;
    width: auto;
}

/* ── Text inputs, email, date, textarea, select ─────── */
.postbox-field input[type="text"],
.postbox-field input[type="email"],
.postbox-field input[type="date"],
.postbox-field textarea,
.postbox-field select {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    font-family: inherit;
    line-height: 1.5;
    color: #1f2937;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.postbox-field input[type="text"]:focus,
.postbox-field input[type="email"]:focus,
.postbox-field input[type="date"]:focus,
.postbox-field textarea:focus,
.postbox-field select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.postbox-field textarea {
    resize: vertical;
    min-height: 120px;
}

.postbox-field select {
    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 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
    padding-right: 2.25rem;
}

/* ── Placeholder ─────────────────────────────────────── */
.postbox-field input::placeholder,
.postbox-field textarea::placeholder {
    color: #9ca3af;
}

/* ── Checkbox & radio options ────────────────────────── */
.postbox-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 400;
    color: #374151;
    padding: 0.25rem 0;
    cursor: pointer;
}

.postbox-option input[type="checkbox"],
.postbox-option input[type="radio"] {
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    flex-shrink: 0;
    accent-color: #3b82f6;
}

/* ── Required asterisk ───────────────────────────────── */
.postbox-required {
    color: #dc2626;
    font-weight: 700;
    margin-left: 0.125rem;
}

/* ── Consent field ───────────────────────────────────── */
.postbox-field--consent {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.postbox-field--consent .postbox-option {
    font-size: 0.8125rem;
    color: #6b7280;
}

/* ── Captcha ─────────────────────────────────────────── */
.postbox-captcha {
    margin-bottom: 1.5rem;
}

/* ── Error states ────────────────────────────────────── */
.postbox-field--error > label,
.postbox-field--error > fieldset > legend {
    color: #dc2626;
}

.postbox-field--error input[type="text"],
.postbox-field--error input[type="email"],
.postbox-field--error input[type="date"],
.postbox-field--error textarea,
.postbox-field--error select {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.postbox-field--error > fieldset {
    border-left: 3px solid #dc2626;
    padding-left: 0.75rem;
}

.postbox-field-error {
    font-size: 0.8125rem;
    color: #dc2626;
    margin-top: 0.25rem;
    min-height: 0;
}

.postbox-field-error:empty {
    display: none;
}

/* ── Submit button ───────────────────────────────────── */
.postbox-submit {
    margin-top: 2rem;
}

.postbox-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 2rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1;
    color: #fff;
    background-color: #1d4ed8;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    min-width: 140px;
}

.postbox-button:hover {
    background-color: #1e40af;
}

.postbox-button:active {
    background-color: #1e3a8a;
}

.postbox-button:disabled {
    background-color: #93c5fd;
    cursor: not-allowed;
}

/* ── Messages (success / error) ──────────────────────── */
.postbox-message {
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    border-radius: 6px;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.postbox-message--success {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.postbox-message--error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* ── Pro: Progress bar ───────────────────────────────── */
.postboxpro-progress {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    padding: 0 0.25rem;
}

.postboxpro-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    flex-shrink: 0;
}

.postboxpro-step-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    font-size: 0.8125rem;
    font-weight: 700;
    background-color: #e5e7eb;
    color: #6b7280;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.postboxpro-step--active .postboxpro-step-dot {
    background-color: #1d4ed8;
    color: #fff;
}

.postboxpro-step--done .postboxpro-step-dot {
    background-color: #16a34a;
    color: #fff;
}

.postboxpro-step--done .postboxpro-step-dot::before {
    content: '✓';
    font-size: 0.875rem;
}

.postboxpro-step--done .postboxpro-step-dot {
    font-size: 0; /* hide number, show checkmark via ::before */
}

.postboxpro-step-label {
    font-size: 0.75rem;
    color: #6b7280;
    white-space: nowrap;
    text-align: center;
}

.postboxpro-step--active .postboxpro-step-label {
    color: #1d4ed8;
    font-weight: 600;
}

.postboxpro-step--done .postboxpro-step-label {
    color: #16a34a;
}

.postboxpro-step-line {
    flex: 1;
    height: 2px;
    background-color: #e5e7eb;
    margin: 0 0.5rem;
    margin-bottom: 1.125rem; /* align with dot centres */
    transition: background-color 0.2s ease;
}

/* ── Pro: Page navigation buttons ────────────────────── */
.postboxpro-page-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 2rem;
}

/* Submit button sits naturally in the nav row on the last page */
.postboxpro-page-nav > .postbox-submit {
    margin-top: 0;
}

.postboxpro-next,
.postboxpro-prev {
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border: none;
}

.postboxpro-next {
    background-color: #1d4ed8;
    color: #fff;
}

.postboxpro-next:hover { background-color: #1e40af; }

.postboxpro-prev {
    background-color: transparent;
    color: #374151;
    border: 1px solid #d1d5db;
}

.postboxpro-prev:hover { background-color: #f3f4f6; }

/* ── Pro: Restore progress banner ────────────────────── */
.postboxpro-restore-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 0.875rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    color: #1e40af;
}

.postboxpro-restore-banner span {
    flex: 1;
    min-width: 0;
}

.postboxpro-restore-yes,
.postboxpro-restore-no {
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 5px;
    cursor: pointer;
    border: none;
    white-space: nowrap;
}

.postboxpro-restore-yes {
    background-color: #1d4ed8;
    color: #fff;
}

.postboxpro-restore-no {
    background-color: transparent;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

/* ── Pro: Summary step ───────────────────────────────── */
.postboxpro-summary {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}

.postboxpro-summary-title {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
}

.postboxpro-summary-list {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1.5rem;
}

.postboxpro-summary-list dt {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #6b7280;
    align-self: start;
    padding-top: 0.125rem;
}

.postboxpro-summary-list dd {
    margin: 0;
    font-size: 0.9375rem;
    color: #1f2937;
    word-break: break-word;
}

.postboxpro-summary-actions {
    margin-top: 1.25rem;
}

.postboxpro-summary-edit {
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    color: #1d4ed8;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
}

/* ── Pro: HTML content block ─────────────────────────── */
.postbox-field--html {
    margin-bottom: 1.5rem;
}

.postbox-html-content {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: #374151;
}

.postbox-html-content > *:first-child { margin-top: 0; }
.postbox-html-content > *:last-child  { margin-bottom: 0; }

/* ── Pro: File field ─────────────────────────────────── */
.postbox-field--file input[type="file"] {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    font-family: inherit;
    line-height: 1.5;
    color: #374151;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-sizing: border-box;
    cursor: pointer;
}

.postbox-field--file .postboxpro-file-hint {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.25rem;
}

/* ── Pro: Auto-save notice ───────────────────────────── */
.postboxpro-autosave-notice {
    display: none;
    font-size: 0.8125rem;
    color: #16a34a;
    margin-top: 0.5rem;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 640px) {
    .postbox-form-header {
        padding: 1.25rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .postbox-form {
        padding: 1.25rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .postbox-form-header + .postbox-form {
        border-radius: 0;
    }
}
