/**
 * MBH HubSpot Form - frontend styles.
 * Built to match the Figma "Modal" spec (Inter, 8px radii, #344054 primary button, #D0D5DD inputs).
 */

.mbh-form {
    --mbh-color-text: #101828;
    --mbh-color-muted: #475467;
    --mbh-color-label: #344054;
    --mbh-color-placeholder: #667085;
    --mbh-color-border: #D0D5DD;
    --mbh-color-border-soft: #E4E7EC;
    --mbh-color-bg: #FFFFFF;
    --mbh-color-primary: #344054;
    --mbh-color-primary-hover: #1D2939;
    --mbh-color-error: #D92D20;
    --mbh-color-success: #079455;
    --mbh-radius-input: 8px;
    --mbh-radius-card: 12px;
    --mbh-shadow-input: 0 1px 2px rgba(16, 24, 40, 0.05);
    --mbh-shadow-card: 0 20px 24px -4px rgba(16, 24, 40, 0.08), 0 8px 8px -4px rgba(16, 24, 40, 0.03);

    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    width: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--mbh-color-text);
}

/* Standalone "card" chrome: background, shadow, radius, max-width.
   Skipped in bare mode because the parent (e.g. modal) provides those. */
.mbh-form--card {
    max-width: 640px;
    margin-inline: auto;
    background: var(--mbh-color-bg);
    border-radius: var(--mbh-radius-card);
    box-shadow: var(--mbh-shadow-card);
    overflow: hidden;
}

/* Bare mode: form lives inside an existing card (modal, drawer, section).
   Inherit the parent's container; never duplicate visual chrome. */
.mbh-form--bare {
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
    max-width: none;
}

/* Decorative concentric rings (top-left like in Figma "background pattern") */
.mbh-form__decor {
    position: absolute;
    inset: -120px auto auto -120px;
    width: 336px;
    height: 336px;
    pointer-events: none;
    z-index: 0;
    -webkit-mask-image: radial-gradient(50% 50% at 50% 50%, #000 0%, transparent 100%);
            mask-image: radial-gradient(50% 50% at 50% 50%, #000 0%, transparent 100%);
}

.mbh-form__decor-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid var(--mbh-color-border-soft);
    border-radius: 0;
}

.mbh-form__decor-ring--1 { width: 96px;  height: 96px; }
.mbh-form__decor-ring--2 { width: 144px; height: 144px; }
.mbh-form__decor-ring--3 { width: 192px; height: 192px; }
.mbh-form__decor-ring--4 { width: 240px; height: 240px; }
.mbh-form__decor-ring--5 { width: 288px; height: 288px; }
.mbh-form__decor-ring--6 { width: 336px; height: 336px; }
.mbh-form__decor-ring--7 { display: none; }

/* Close button */
.mbh-form__close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: #98A2B3;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.mbh-form__close:hover,
.mbh-form__close:focus-visible {
    background: #F2F4F7;
    color: var(--mbh-color-text);
    outline: none;
}

/* Inner stack (z-index above decoration) */
.mbh-form__inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
.mbh-form__header {
    padding: 32px 24px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mbh-form__title {
    margin: 0;
    font-size: 30px;
    line-height: 1.27;
    font-weight: 600;
    color: var(--mbh-color-text);
    letter-spacing: -0.01em;
}

.mbh-form__subtitle {
    margin: 0;
    font-size: 14px;
    line-height: 1.43;
    font-weight: 400;
    color: var(--mbh-color-muted);
}

/* Form */
.mbh-form__form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px 24px 0;
}

.mbh-form__row {
    display: flex;
    flex-direction: row;
    gap: 16px;
}

.mbh-form__row > .mbh-form__field {
    flex: 1 1 0;
    min-width: 0;
}

/* Field wrapper */
.mbh-form__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Label */
.mbh-form__label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    line-height: 1.43;
    font-weight: 500;
    color: var(--mbh-color-label);
}

.mbh-form__required {
    color: var(--mbh-color-error);
    font-weight: 500;
}

.mbh-form__help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #98A2B3;
    cursor: help;
}

.mbh-form__help-icon:focus-visible {
    outline: 2px solid var(--mbh-color-primary);
    outline-offset: 2px;
    border-radius: 50%;
}

.mbh-form__help {
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--mbh-color-muted);
}

/* Inputs.
   Figma: full-width inputs are 44px tall (padding 10px 14px).
   Half-width inputs in a row are 40px tall (padding 8px 12px) - overridden below. */
.mbh-form__input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;
    color: var(--mbh-color-text);
    background: var(--mbh-color-bg);
    border: 1px solid var(--mbh-color-border);
    border-radius: var(--mbh-radius-input);
    box-shadow: var(--mbh-shadow-input);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.mbh-form__row .mbh-form__input {
    padding: 8px 12px;
}

.mbh-form__input::placeholder {
    color: var(--mbh-color-placeholder);
}

.mbh-form__input:focus,
.mbh-form__input:focus-visible {
    outline: none;
    border-color: var(--mbh-color-primary);
    box-shadow: 0 0 0 4px rgba(52, 64, 84, 0.12);
}

.mbh-form__input--textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

.mbh-form__input--select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'><path d='M5 7.5L10 12.5L15 7.5' stroke='%23667085' stroke-width='1.67' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.mbh-form__field--invalid .mbh-form__input,
.mbh-form__field--invalid .mbh-form__card {
    border-color: var(--mbh-color-error);
    box-shadow: 0 0 0 4px rgba(217, 45, 32, 0.12);
}

.mbh-form__field-error {
    margin: 0;
    font-size: 13px;
    color: var(--mbh-color-error);
}

/* Choices (radio / checkbox) */
.mbh-form__choices {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
}

.mbh-form__choices--column {
    flex-direction: column;
    gap: 8px;
}

.mbh-form__choice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--mbh-color-label);
    cursor: pointer;
}

/* Checkbox cards (the 3 platform options in the screenshot) */
.mbh-form__cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mbh-form__card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: var(--mbh-color-bg);
    border: 1px solid var(--mbh-color-border-soft);
    border-radius: var(--mbh-radius-card);
    cursor: pointer;
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.mbh-form__card:hover {
    border-color: var(--mbh-color-label);
}

.mbh-form__card:has(.mbh-form__card-input:checked) {
    border-color: var(--mbh-color-text);
    border-width: 2px;
    padding: 15px; /* compensate +1px border to keep box stable */
}

.mbh-form__card:has(.mbh-form__card-input:focus-visible) {
    box-shadow: 0 0 0 4px rgba(52, 64, 84, 0.12);
}

.mbh-form__card-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mbh-form__card-checkbox {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    border: 1px solid var(--mbh-color-border);
    border-radius: 4px;
    background: var(--mbh-color-bg);
    color: var(--mbh-color-bg);
    transition: background-color 120ms ease, border-color 120ms ease;
}

.mbh-form__card:has(.mbh-form__card-input:checked) .mbh-form__card-checkbox,
.mbh-form__consent:has(input:checked) .mbh-form__card-checkbox {
    background: #0C111D;
    border-color: #0C111D;
}

.mbh-form__card-checkbox svg {
    opacity: 0;
}

.mbh-form__card:has(.mbh-form__card-input:checked) .mbh-form__card-checkbox svg,
.mbh-form__consent:has(input:checked) .mbh-form__card-checkbox svg {
    opacity: 1;
}

.mbh-form__card-body {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.mbh-form__card-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.43;
    color: var(--mbh-color-label);
}

.mbh-form__card-desc {
    font-size: 14px;
    line-height: 1.43;
    color: var(--mbh-color-muted);
}

/* Consent checkbox */
.mbh-form__consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--mbh-color-muted);
}

.mbh-form__consent input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Submit button.
   Figma: Modal-actions block adds padding-top: 32px above the button.
   The form has gap:16, so margin-top:16 brings the total spacing to 32px. */
.mbh-form__submit {
    margin-top: 16px;
    margin-bottom: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    width: 100%;
    background: var(--mbh-color-primary);
    color: #FFFFFF;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
    border: 0;
    border-radius: var(--mbh-radius-input);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05),
                inset 0 0 0 1px rgba(16, 24, 40, 0.18),
                inset 0 -2px 0 rgba(16, 24, 40, 0.05);
    cursor: pointer;
    transition: background-color 150ms ease, transform 100ms ease;
}

.mbh-form__submit:hover {
    background: var(--mbh-color-primary-hover);
}

.mbh-form__submit:active {
    transform: translateY(1px);
}

.mbh-form__submit:disabled,
.mbh-form__submit[aria-busy="true"] {
    opacity: 0.7;
    cursor: progress;
}

.mbh-form__submit-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: mbh-form-spin 0.8s linear infinite;
}

.mbh-form__submit[aria-busy="true"] .mbh-form__submit-spinner {
    display: inline-block;
}

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

/* Honeypot */
.mbh-form__honeypot {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Form-level error */
.mbh-form__error {
    display: none;
    padding: 12px 14px;
    background: #FEF3F2;
    border: 1px solid #FECDCA;
    border-radius: 8px;
    color: #B42318;
    font-size: 14px;
    line-height: 1.43;
}

.mbh-form__error[data-active] {
    display: block;
}

/* Success state */
.mbh-form__success {
    padding: 32px 24px;
    text-align: center;
}

.mbh-form__success[hidden] {
    display: none;
}

/* When success is shown, hide the now-redundant title/subtitle and
   give the success block a roomier vertical layout. */
.mbh-form--success .mbh-form__header,
.mbh-form--success .mbh-form__close {
    display: none;
}

.mbh-form--success .mbh-form__success {
    padding: 56px 24px 48px;
}

.mbh-form__success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    background: #DCFAE6;
    color: var(--mbh-color-success);
    border-radius: 50%;
}

.mbh-form-success__title {
    margin: 0 0 8px;
    font-size: 20px;
    line-height: 1.5;
    font-weight: 600;
    color: var(--mbh-color-text);
}

.mbh-form-success__body {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--mbh-color-muted);
}

.mbh-form__success-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    padding: 10px 16px;
    background: var(--mbh-color-primary);
    color: #FFFFFF;
    text-decoration: none;
    font-weight: 600;
    border-radius: 8px;
}

/* Empty state in builder */
.mbh-form--empty {
    padding: 24px;
    text-align: center;
    color: var(--mbh-color-muted);
    border: 1px dashed var(--mbh-color-border);
    border-radius: var(--mbh-radius-card);
    background: #F9FAFB;
}

/* Responsive */
@media (max-width: 640px) {
    .mbh-form--card {
        border-radius: 12px;
    }
    .mbh-form__header {
        padding: 24px 20px 0;
    }
    .mbh-form__form {
        padding: 16px 20px 0;
    }
    .mbh-form__title {
        font-size: 24px;
    }
    .mbh-form__row {
        flex-direction: column;
    }
    .mbh-form__decor {
        inset: -80px auto auto -80px;
        width: 240px;
        height: 240px;
    }
    .mbh-form__submit {
        margin-bottom: 20px;
    }
}
