/**
 * System-wide flash messages and inline form validation feedback.
 */

.pmts-messages-wrap {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 0.5rem var(--pmts-page-padding-x, 1rem) 0;
    background: linear-gradient(to bottom, rgb(249 250 251 / 0.98) 70%, transparent);
}

.pmts-toast-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 42rem;
    margin: 0 auto;
}

.pmts-toast-stack--detailed {
    width: 100%;
    max-width: none;
    margin: 0;
}

.pmts-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.625rem;
    border: 1px solid transparent;
    box-shadow: 0 4px 14px rgb(15 23 42 / 0.08);
    animation: pmts-alert-in 0.28s ease-out;
}

@keyframes pmts-alert-in {
    from {
        opacity: 0;
        transform: translateY(-0.35rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pmts-alert__icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.1rem;
}

.pmts-alert__body {
    flex: 1;
    min-width: 0;
}

.pmts-alert__title {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.35;
    margin: 0;
}

.pmts-alert__text,
.pmts-alert__summary {
    font-size: 0.875rem;
    line-height: 1.45;
    margin: 0;
}

.pmts-alert__summary {
    margin-top: 0.25rem;
    color: inherit;
    opacity: 0.92;
}

.pmts-alert__list {
    margin: 0.45rem 0 0;
    padding: 0.45rem 0.5rem 0.45rem 1rem;
    max-height: min(11rem, 34vh);
    overflow-y: auto;
    border-radius: 0.375rem;
    background: rgb(255 255 255 / 0.55);
    border: 1px solid rgb(0 0 0 / 0.06);
    font-size: 0.6875rem;
    line-height: 1.4;
    list-style: disc;
}

.pmts-alert__list li + li {
    margin-top: 0.3rem;
}

.pmts-alert__list li {
    word-break: break-word;
}

.pmts-alert--detailed {
    padding: 0.625rem 0.75rem;
    gap: 0.5rem;
}

.pmts-alert--detailed .pmts-alert__icon {
    width: 1rem;
    height: 1rem;
    margin-top: 0.05rem;
}

.pmts-alert--detailed .pmts-alert__title {
    font-size: 0.8125rem;
}

.pmts-alert--detailed .pmts-alert__summary,
.pmts-alert--detailed .pmts-alert__text {
    font-size: 0.75rem;
    line-height: 1.4;
}

.pmts-alert--detailed .pmts-alert__list {
    margin-top: 0.4rem;
}

.pmts-alert--error .pmts-alert__list {
    background: rgb(254 242 242 / 0.85);
    border-color: rgb(252 165 165 / 0.55);
}

.pmts-alert--warning .pmts-alert__list {
    background: rgb(255 251 235 / 0.9);
    border-color: rgb(252 211 77 / 0.55);
}

.pmts-alert__dismiss {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    border-radius: 0.375rem;
    background: transparent;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.15s, background-color 0.15s;
}

.pmts-alert__dismiss:hover {
    opacity: 1;
}

.pmts-alert--success {
    background: #ecfdf5;
    border-color: #6ee7b7;
    color: #065f46;
}

.pmts-alert--success .pmts-alert__dismiss:hover {
    background: rgb(16 185 129 / 0.12);
}

.pmts-alert--info {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1e40af;
}

.pmts-alert--info .pmts-alert__dismiss:hover {
    background: rgb(59 130 246 / 0.12);
}

.pmts-alert--warning {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #92400e;
}

.pmts-alert--warning .pmts-alert__dismiss:hover {
    background: rgb(245 158 11 / 0.12);
}

.pmts-alert--error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}

.pmts-alert--error .pmts-alert__dismiss:hover {
    background: rgb(239 68 68 / 0.12);
}

.pmts-alert--debug,
.pmts-alert--default {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #374151;
}

/* Inline form validation banner */
.pmts-form-errors {
    border-radius: 0.625rem;
    border: 1px solid #fca5a5;
    background: #fef2f2;
    padding: 1rem 1.125rem;
    margin-bottom: 1.25rem;
}

.pmts-form-errors__header {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    margin-bottom: 0.625rem;
}

.pmts-form-errors__title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #991b1b;
    margin: 0;
}

.pmts-form-errors__hint {
    font-size: 0.8125rem;
    color: #b91c1c;
    margin: 0.125rem 0 0;
}

.pmts-form-errors__list {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.875rem;
    color: #b91c1c;
}

.pmts-form-errors__list li + li {
    margin-top: 0.35rem;
}

.pmts-form-errors__link {
    color: #b91c1c;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.pmts-form-errors__link:hover {
    color: #7f1d1d;
}

/* Per-field states */
.pmts-form-field--invalid label {
    color: #b91c1c;
}

.pmts-form-field--invalid .pmts-field-control,
.pmts-form-field--invalid select,
.pmts-form-field--invalid textarea,
.pmts-form-field--invalid input[type="text"],
.pmts-form-field--invalid input[type="email"],
.pmts-form-field--invalid input[type="number"],
.pmts-form-field--invalid input[type="date"],
.pmts-form-field--invalid input[type="url"] {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 1px rgb(239 68 68 / 0.15);
}

.pmts-field-error {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: #dc2626;
}

.pmts-field-error__icon {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    margin-top: 0.1rem;
}

.pmts-form-field--valid .pmts-field-control:not(:focus) {
    border-color: #86efac;
}

.field-focus-highlight {
    box-shadow: 0 0 0 3px rgb(239 68 68 / 0.22) !important;
    border-color: #ef4444 !important;
}
