/**
 * Shared form feedback styles.
 *
 * Success/error messages, field validation, anonymous explainer,
 * and success transition — shared across all shelter form blocks.
 *
 * @package Starter_Shelter
 * @since 2.1.0
 */

/* ── Collapsed utility ─────────────────────────────────────────────── */
.sd-collapsed {
    display: none;
}

/* ── Success message ───────────────────────────────────────────────── */
.sd-form-success {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 1.25rem;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    text-align: center;
    animation: sd-fade-in 0.3s ease;
}

.sd-form-success-visible {
    display: flex;
}

.sd-success-icon {
    color: #059669;
}

.sd-form-success p {
    margin: 0;
    font-weight: 500;
    color: #065f46;
}

.sd-checkout-link {
    margin-top: 0.25rem;
}

@keyframes sd-fade-in {
    from { opacity: 0; transform: translateY( 8px ); }
    to   { opacity: 1; transform: translateY( 0 ); }
}

/* ── Error message ─────────────────────────────────────────────────── */
.sd-form-error {
    display: none;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 4px;
    animation: sd-fade-in 0.2s ease;
}

.sd-form-error-visible {
    display: block;
}

.sd-form-error p {
    margin: 0;
    font-size: 0.9rem;
    color: #991b1b;
}

/* ── Field-level error highlighting ────────────────────────────────── */
.sd-field-error .sd-text-input,
.sd-field-error .sd-textarea,
.sd-field-error .sd-custom-input,
.sd-field-error .sd-select {
    border-color: #ef4444;
}

.sd-field-error-message {
    font-size: 0.8125rem;
    color: #dc2626;
    margin-top: 0.25rem;
}

/* ── Required / optional indicators ────────────────────────────────── */
.sd-required {
    color: #dc2626;
    font-weight: normal;
}

.sd-optional {
    color: var(--wp--preset--color--contrast-3, #999);
    font-size: 0.85em;
    font-weight: normal;
}

/* ── Anonymous explainer ───────────────────────────────────────────── */
.sd-anonymous-explainer {
    font-size: 0.8125rem;
    color: var(--wp--preset--color--contrast-3, #666);
    font-style: italic;
    margin: 0.5rem 0 0;
    padding-left: 2.75rem; /* align with checkbox text */
    animation: sd-fade-in 0.2s ease;
}

/* ── Field help text ───────────────────────────────────────────────── */
.sd-field-help {
    font-size: 0.8125rem;
    color: var(--wp--preset--color--contrast-3, #999);
    margin: 0.25rem 0 0;
}

/* ── Success state: fade form inner ────────────────────────────────── */
.sd-form-success-visible ~ .sd-form-inner-fade {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* ── Secure badge ──────────────────────────────────────────────────── */
.sd-form-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.sd-secure-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--wp--preset--color--contrast-3, #666);
    margin: 0;
}

/* ── Submit button shared styles ───────────────────────────────────── */
.sd-submit-button {
    width: 100%;
    padding: 1rem 2rem;
    background: var(--wp--preset--color--primary, #28a745);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.sd-submit-button:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}

.sd-submit-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sd-button-loading {
    align-items: center;
    gap: 0.5rem;
}

.sd-button-loading:not([hidden]) {
    display: inline-flex;
}

.sd-spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sd-spin 0.8s linear infinite;
}

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

/* ── Form header ───────────────────────────────────────────────────── */
.sd-form-header {
    text-align: center;
    margin-bottom: 2rem;
}

.sd-form-title {
    font-size: 1.5rem;
    margin: 0 0 0.5rem;
    color: var(--wp--preset--color--contrast, #1e1e1e);
}

.sd-form-subtitle {
    color: var(--wp--preset--color--contrast-2, #666);
    margin: 0 0 1rem;
}

.sd-config-warning {
    padding: 0.75rem 1rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 4px;
    color: #92400e;
    font-size: 0.875rem;
}

/* ── Section spacing ───────────────────────────────────────────────── */
.sd-form-section {
    margin-bottom: 1.5rem;
}

.sd-section-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--wp--preset--color--contrast, #1e1e1e);
}

/* ── Checkbox shared styles ────────────────────────────────────────── */
.sd-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.sd-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}
